1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

How do you hide Civlopedia entries?

Discussion in 'Civ4 - Creation & Customization' started by Chuggi, Jan 28, 2007.

  1. Kael

    Kael Deity

    Joined:
    May 6, 2002
    Messages:
    17,401
    Location:
    Ohio
    Yeah, but I can link the relevant parts here:

    in CIV4UnitSchema.xml (additions in bold):

    Code:
    	<ElementType name="bCtrlDown" content="textOnly" dt:type="boolean"/>
    [b]	<ElementType name="bGraphicalOnly" content="textOnly" dt:type="boolean"/>[/b]
    	<ElementType name="iHotKeyPriority" content="textOnly" dt:type="int"/>
    
    Code:
    		<element type="bCtrlDown"/>
    [b]		<element type="bGraphicalOnly"/>[/b]
    		<element type="iHotKeyPriority"/>
    
    And in CvPediaUnit.py:

    Code:
    	def getUnitSortedList(self, bHero):
    		listUnits = []
    		iCount = 0
    		for iUnit in range(gc.getNumUnitInfos()):
    			if (self.getUnitType(iUnit) == bHero and not gc.getUnitInfo(iUnit).isGraphicalOnly()):
    				listUnits.append(iUnit)
    				iCount += 1
    		
    		listSorted = [(0,0)] * iCount
    		iI = 0
    		for iUnit in listUnits:
    			listSorted[iI] = (gc.getUnitInfo(iUnit).getDescription(), iUnit)
    			iI += 1
    		listSorted.sort()
    		return listSorted
    
    Note that the above code is also modified to allow the requester to pass in a bHero flag to tell if we want the returned list to be full of World Units or non-World units. Probably not a big deal for you so you wouldn't want to include that. Instead you probably just want the not gc.getUnitInfo(iUnit).isGraphicalOnly() check.

    The magic of this method is that bGraphicalOnly and isGraphicalOnly() are base definitions for all object types. Its not defined in schema for a unit or building, but once you set it up in schema everything works because its already inherited in the SDK. Makes it very simple.
     
  2. Gaurav

    Gaurav Prince

    Joined:
    May 14, 2006
    Messages:
    404
    If it is just checking the CvUnitInfo.isGraphicalOnly() method, then I already have it included! I'll only need to test it and provide the xml schema file and instructions with the Sevopedia.

    But for some reason I remember I had looked at the SDK source before and saw that the isGraphicalOnly() method was not actually looking at the XML. Instead it seemed to be just checking for certain entries directly. Maybe I read the source incorrectly or did not look at the base class version or something. I'll look again when I get home.
     
  3. Gaurav

    Gaurav Prince

    Joined:
    May 14, 2006
    Messages:
    404
    Well I'll be... :shake:

    The SDK looks for the nonexistent bGraphicalOnly tags and it hardcodes certain entries as graphical only. :wow:

    When I was reading it again I noticed I must have glossed over a particular &:
    Spoiler CvInfoBase::read(CvXMLLoadUtility* pXML) :
    Code:
    //
    // read from XML
    // TYPE, DESC, BUTTON
    //
    bool CvInfoBase::read(CvXMLLoadUtility* pXML)
    {
    	CvString szTextVal;
    
    	// Skip any comments and stop at the next value we might want
    	if (!pXML->SkipToNextVal())
    	{
    		return false;
    	}
    
    	if (pXML->GetXmlVal(szTextVal))
    	{
    		// GetXmlVal returns the XML tags for all children as well, separated by spaces
    		// Keep only the first value
    		CvString::size_type i = szTextVal.find(' ', 0);
    		if (CvString::npos != i)
    		{
    			szTextVal.resize(i);
    		}
    		setXmlVal(szTextVal);
    	}
    
    	pXML->MapChildren();	// try to hash children for fast lookup by name
    
    	// GRAPHICAL ONLY
    	[b]pXML->GetChildXmlValByName(&m_bGraphicalOnly, "bGraphicalOnly");[/b]
    
    	// TYPE
    	if (pXML->GetChildXmlValByName(szTextVal, "Type"))
    	{
    		setType(szTextVal);
    	}
    
    	// DESCRIPTION
    	if (pXML->GetChildXmlValByName(szTextVal, "Description"))
    	{
    		setTextKey(szTextVal);
    	}
    
    	// CIVILOPEDIA
    	if (pXML->GetChildXmlValByName(szTextVal, "Civilopedia"))
    	{
    		setCivilopediaKey(szTextVal);
    	}
    
    	// HELP
    	if (pXML->GetChildXmlValByName(szTextVal, "Help"))
    	{
    		setHelpKey(szTextVal);
    	}
    
    	// STRATEGY
    	if (pXML->GetChildXmlValByName(szTextVal, "Strategy"))
    	{
    		setStrategyKey(szTextVal);
    	}
    
    	// BUTTON
    	if (pXML->GetChildXmlValByName(szTextVal, "Button"))
    	{
    		setButton(szTextVal);
    	}
    
    	return true;
    }
    I thought it was not reading the bGraphicalOnly tag into m_bGraphicalOnly variable at all when I didn't see a call to a set method. :lol:

    Especially when I saw hardcoding like this:
    Code:
    	pXML->GetChildXmlValByName(&m_bLeader, "bLeader");
    	if (m_bLeader)
    	{
    		m_bGraphicalOnly = true;  // don't show in Civilopedia list of promotions
    	}
    Must never doubt Kael. :blush:

    Well, I tested it. The beta I've distributed already supports the bGraphicalOnly xml tags. :D Now I should write some minimal documentation.

    I will still recommend the way I wrote already since it shows your civ specific button and animation correctly, and requires no additional work. Not to mention you won't be forced to hide the hardcoded graphical only entries... you will still be able to see Lead by Warlord, for example.

    At some point I have to get back to fixing that bug where the special abilities text doesn't show unique unit for units that replace NONE. ;)

    P.S. Do you guys think I should include all the schemas or just the units schema as a sample?
     
  4. Gaurav

    Gaurav Prince

    Joined:
    May 14, 2006
    Messages:
    404
    Thanks for everyone's help.

    I posted the final version 2.2.
     
  5. Gaius Octavius

    Gaius Octavius Deity

    Joined:
    Jul 28, 2006
    Messages:
    4,016
    Chugginator, you will be pleased to know that this issue has finally been cleared up in the civ-specific great people mod, thanks to this thread. :goodjob:

    An updated version will be posted soon.
     
  6. Chuggi

    Chuggi Espada

    Joined:
    Jan 2, 2007
    Messages:
    2,369
    Location:
    Australia
    Yep, tis good. I'm actually working on combining the Civ-Specific Great Person Mod and the Great Person Mod (with the picture pop-ups), so I will be needing this.
     
  7. Grave

    Grave 1 Goat = 400 Horses

    Joined:
    May 5, 2002
    Messages:
    1,530
    Location:
    Louisiana


    That's bad ass! :goodjob:


    So just to re-verify... this requires no SDK work... it's straight up XML only?
     
  8. Gaius Octavius

    Gaius Octavius Deity

    Joined:
    Jul 28, 2006
    Messages:
    4,016
    Wow, that sounds like a lot of work! I should point out that it might be very hard to find pictures/quotes for some of the ancient names I used, especially those who are mentioned only in passing in ancient records. But I say go for it. I like the great person mod, too.

    As I said, I will be posting an updated version very soon that fixes the civilopedia issues and adds about 200 more names. I'm also doing a MASSIVE update for Civ-Specific GP 2.0, which when it is finished will have over 2,000 Great People. Should blow the competition out of the water. ;)
     
  9. Kael

    Kael Deity

    Joined:
    May 6, 2002
    Messages:
    17,401
    Location:
    Ohio
    And the included python change. It doesnt take any SDK work.
     
  10. Gaurav

    Gaurav Prince

    Joined:
    May 14, 2006
    Messages:
    404
    Of course, if you use Sevopedia 2.2, you won't need to make any additional python changes.
     
  11. Chuggi

    Chuggi Espada

    Joined:
    Jan 2, 2007
    Messages:
    2,369
    Location:
    Australia
    Over 2000 people?? Not sure if I'll be able to keep up with the art and quotes there, but I'll try.
     
  12. Grave

    Grave 1 Goat = 400 Horses

    Joined:
    May 5, 2002
    Messages:
    1,530
    Location:
    Louisiana
    How would you hide the flavor units under the Unique Units section of the Civilization's Pedia entry?
     
  13. Gaius Octavius

    Gaius Octavius Deity

    Joined:
    Jul 28, 2006
    Messages:
    4,016
    I believe you can do it the same way, using bGraphicalOnly.
     
  14. Grave

    Grave 1 Goat = 400 Horses

    Joined:
    May 5, 2002
    Messages:
    1,530
    Location:
    Louisiana

    I know that... I mean how would you code it in the CvPediaCivilization.py screen?
     
  15. Gaius Octavius

    Gaius Octavius Deity

    Joined:
    Jul 28, 2006
    Messages:
    4,016
    I don't think you even need to go that far, do you? Just set it in XML under the UU tag, although this might not work for that particular pedia section. I haven't tried, so I don't know.
     
  16. Grave

    Grave 1 Goat = 400 Horses

    Joined:
    May 5, 2002
    Messages:
    1,530
    Location:
    Louisiana
    I'm pretty sure you have to do some python, similar to what Kael did with the CvPediaUnit.py file. I wonder if a direct copy/paste to the CvPediaCivilization.py file would do the trick?
     
  17. Gaurav

    Gaurav Prince

    Joined:
    May 14, 2006
    Messages:
    404
    This was done in Sevopedia 2.2.
     

Share This Page