Problems adding a page to sevopedia

j_mie6

Deity
Joined
Dec 20, 2009
Messages
2,963
Location
Bristol (uni)/Swindon (home)
Hello,

This is literally driving me insane (:twitch:), how can I add a new page into the sevopedia? I have a new class called SevoPediaPromotionTier and that just is the page. but several things are happening when I try to add it (I will explain what I have done in a second)

1) the exit button on the pedia doesn't work (I literally have to Alt + F4 out of the pedia! :mad:) (Fixed)
2) the page won't display, if I click promotion tiers in the contents I can see a list of all the tiers but I can't click on any of them (Fixed)
3) the trait page displays a python exception when it is opened (ditto for the index page)
Spoiler :

Code:
Traceback (most recent call last):

  File "CvScreensInterface", line 933, in handleInput

  File "SevoPediaMain", line 888, in handleInput

  File "SevoPediaMain", line 332, in showIndex

  File "SevoPediaIndex", line 37, in interfaceScreen

  File "SevoPediaIndex", line 64, in buildIndex

  File "SevoPediaMain", line 606, in getTraitList

  File "SevoPediaMain", line 924, in getSortedList

  File "SevoPediaMain", line 620, in getDescription

AttributeError: 'NoneType' object has no attribute 'getDescription'
ERR: Python function handleInput failed, module CvScreensInterface

4)if I click a link in to the tiers page it just doesn't respond to me. (Fixed)

so, what have I done:

C++
  • created some enum types in CvEnums.h (the screen and the widget for jumping)
  • added some functions into CvGameTextMgr (not important I don't think)
  • defined two new behaviors for the page in CvDLLWidgetData, namely a doPediaJump for the tier and a parseHelp() (note the parse help is actually working!)

Python
  • added the new screen into the CvScreenEnums and SevoScreenEnums
  • added the appropriate function in the ScreensInterface (for doPediaJump)
  • went through SevoPediaMain and SevoPediaIndex, where ever there was reference to promotions I added in simillar code for the tiers.

Can anybody help me with this? I can't just keep scrolling through the same files again and again looking for answers :lol:

Thanks,
Jamie
 
Generally, if you are adding a new page to Sevo without the need of new widgets, such as adding World Units using jump to unit widget or Natural Wonders using jump to feature widget.

It only requires:
1) Adding a new page to SevoScreenEnums
2) Some adjustments to SevoPediaMain

As for pages that require new widgets, such as routes, traits, processes etc because there is no jump to trait widget
Both Sevopedia and Platypedia use dummy concepts to achieve it via pure python.
You can of course make yourself troublesome and devise new widgets to achieve the same thing.

Thus, depending on whatever is promotion tier, it is either easy or hard :D
 
well promotion tiers are an independent C++ type, where they govern the availability of promotions. so one can only acquire tier 2 promotions when all the promotions that belong in tier 1 have been acquired.

it does need a new widget I believe, as they are a separate page and type, and I thought the widget was fine, maybe I should take a look in the DLL again :twitch: unless someone around here knows why I have managed to break the entire sevopedia :p
 
I believe whether tier 1 promo or tier 2 promo are after all just promotions.
So why do you need a new jump widget when you can use the jump to promo widget.

Just make new promo pages:
1) Tier 1 Promos
2) Tier 2 Promos

And probability just write a short concept section to describe whatever is promotion tiers.

Buildings is a good example.
Whether it is normal building, national wonder or world wonder, they are all just buildings.
Thus, they are all using jump to building widget, and one CvPediaBuilding is enough.
 
it isn't a promotion though :p

Spoiler :

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Made by J_mie6 for the Babylon 5 Mods promotion tier system -->
<!-- Promotion Tier Infos -->
<Civ4PromotionTierInfos xmlns="x-schema:CIV4UnitSchema.xml">
	<PromotionTierInfos>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_TRAINED</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_TRAINED_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>NONE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierI_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_EXPERIENCED</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_EXPERIENCED_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_TRAINED</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierII_Button.dds</Button>
	    </PromotionTierInfo>
	   	<PromotionTierInfo>
	        <Type>PROMOTION_TIER_VETERAN</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_VETERAN_DESC</Description>
	      	<PrereqTech>TECH_B5_SPACE_EXPLORATION</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_EXPERIENCED</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIII_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_ELITE</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_ELITE_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_VETERAN</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_LEGENDARY</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_LEGENDARY_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_ELITE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_TRAINED_PILOTS</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_TRAINED_PILOTS_DESC</Description>
		<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>NONE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierI_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_EXPERIENCED_PILOTS</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_EXPERIENCED_PILOTS_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_TRAINED_PILOTS</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierII_Button.dds</Button>
	    </PromotionTierInfo>
	   	<PromotionTierInfo>
	        <Type>PROMOTION_TIER_VETERAN_PILOTS</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_VETERAN_PILOTS_DESC</Description>
	      	<PrereqTech>TECH_B5_SPACE_EXPLORATION</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_EXPERIENCED_PILOTS</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIII_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_ELITE_PILOTS</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_ELITE_PILOTS_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_VETERAN_PILOTS</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_LEGENDARY_PILOTS</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_LEGENDARY_PILOTS_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_ELITE_PILOTS</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_TRAINED_STARBASE_CREW</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_TRAINED_STARBASE_CREW_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>NONE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierI_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_EXPERIENCED_STARBASE_CREW</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_EXPERIENCED_STARBASE_CREW_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_TRAINED_STARBASE_CREW</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierII_Button.dds</Button>
	    </PromotionTierInfo>
	   	<PromotionTierInfo>
	        <Type>PROMOTION_TIER_VETERAN_STARBASE_CREW</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_VETERAN_STARBASE_CREW_DESC</Description>
	      	<PrereqTech>TECH_B5_SPACE_EXPLORATION</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_EXPERIENCED_STARBASE_CREW</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIII_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_ELITE_STARBASE_CREW</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_ELITE_STARBASE_CREW_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_VETERAN_STARBASE_CREW</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_LEGENDARY_STARBASE_CREW</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_LEGENDARY_STARBASE_CREW_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_ELITE_STARBASE_CREW</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_TRAINED_PLANETARY_DEFENSE</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_TRAINED_PLANETARY_DEFENSE_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>NONE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierI_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_EXPERIENCED_PLANETARY_DEFENSE</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_EXPERIENCED_PLANETARY_DEFENSE_DESC</Description>
	      	<PrereqTech>NONE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_TRAINED_PLANETARY_DEFENSE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierII_Button.dds</Button>
	    </PromotionTierInfo>
	   	<PromotionTierInfo>
	        <Type>PROMOTION_TIER_VETERAN_PLANETARY_DEFENSE</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_VETERAN_PLANETARY_DEFENSE_DESC</Description>
	      	<PrereqTech>TECH_B5_SPACE_EXPLORATION</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_EXPERIENCED_PLANETARY_DEFENSE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIII_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_ELITE_PLANETARY_DEFENSE</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_ELITE_PLANETARY_DEFENSE_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_VETERAN_PLANETARY_DEFENSE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierIV_Button.dds</Button>
	    </PromotionTierInfo>
	    <PromotionTierInfo>
	        <Type>PROMOTION_TIER_LEGENDARY_PLANETARY_DEFENSE</Type>
	        <Description>TXT_KEY_PROMOTION_TIER_LEGENDARY_PLANETARY_DEFENSE_DESC</Description>
	      	<PrereqTech>TECH_B5_MILITARY_ELITE</PrereqTech>
	      	<PrereqTier>PROMOTION_TIER_ELITE_PLANETARY_DEFENSE</PrereqTier>
		<Button>Art/Interface/Buttons/Promotions/TierV_Button.dds</Button>
	    </PromotionTierInfo>
	</PromotionTierInfos>
</Civ4PromotionTierInfos>


the page is to show what tier is required for a given tier, what tech is required and the promotions owning it unlocks, we are talking gc.getPromotionTierInfo(PromtionTierTypes) and everything here :p completely self dependant.

in any case I still need to know how I broke the pedia :lol: I need it fixed and it requires the widget afaict
 
Then just use dummy concepts to display it just like how traits are done.
Of course making a new widget will do the same job, but unless you are 100% sure your widget is working, use the tried and tested method...
 
well, the thing is the help scroll over text generated by the widgets setPromotionTierHelpText() method in the DLL is working fine, and the only other thing is this:

Code:
//ExtendedPromotions - Start
void CvDLLWidgetData::doPediaPromotionTierJump(CvWidgetDataStruct &widgetDataStruct)
{
	CyArgsList argsList;
	argsList.add(widgetDataStruct.m_iData1);
	gDLL->getPythonIFace()->callFunction(PYScreensModule, "pediaJumpToPromotionTier", argsList.makeFunctionArgs());
}
//ExtendedPromotions - End

void CvDLLWidgetData::doPediaPromotionJump(CvWidgetDataStruct &widgetDataStruct)
{
	CyArgsList argsList;
	argsList.add(widgetDataStruct.m_iData1);
	gDLL->getPythonIFace()->callFunction(PYScreensModule, "pediaJumpToPromotion", argsList.makeFunctionArgs());
}

which as you can see should be exactly the same, and the python functions follow the same pattern too. it looks the same as everything else around it. unless there is a sneaky reference to widgets elsewhere in the DLL everything looks solid...

at least I know what is going on with the concepts in the traits info, any idea why it is returning that error?
 
hmm I think I might have found it, instead of a gc.getPromotionTierInfo I used a gc.getPromotionInfo. let's see

edit: no joy....
 
The times I have tried to mod the sevopedia and had a new page not respond were when I got the iCategory wrong for the elements in that screen so there was nothing to display.
 
plus this is the screen itself:

Spoiler :

Code:
# Sid Meier's Civilization 4
# Copyright Firaxis Games 2005

#
# J_mie6 work for EnhancedPromotions for Sevopedia tier page
#

from CvPythonExtensions import *
import CvUtil
import ScreenInput
import SevoScreenEnums

gc = CyGlobalContext()
ArtFileMgr = CyArtFileMgr()
localText = CyTranslator()

class SevoPediaPromotionTier:

	def __init__(self, main):
		self.iPromotion = -1
		self.top = main
	
		self.BUTTON_SIZE = 46
		
		self.X_ICON_PANE = self.top.X_PEDIA_PAGE
		self.Y_ICON_PANE = self.top.Y_PEDIA_PAGE
		self.W_ICON_PANE = 250
		self.H_ICON_PANE = 116

		self.W_ICON = 100
		self.H_ICON = 100
		self.X_ICON = self.X_ICON_PANE + (self.H_ICON_PANE - self.H_ICON) / 2
		self.Y_ICON = self.Y_ICON_PANE + (self.H_ICON_PANE - self.H_ICON) / 2
		self.ICON_SIZE = 64

		self.X_PREREQ_PANE = self.X_ICON_PANE + self.W_ICON_PANE + 10
		self.Y_PREREQ_PANE = self.Y_ICON_PANE
		self.W_PREREQ_PANE = self.top.R_PEDIA_PAGE - self.X_PREREQ_PANE
		self.H_PREREQ_PANE = 116

		self.X_ALLOWS_PANE = self.X_ICON_PANE
		self.Y_ALLOWS_PANE = self.Y_ICON_PANE + self.H_ICON_PANE + 10
		self.W_ALLOWS_PANE = self.top.R_PEDIA_PAGE - self.X_ALLOWS_PANE
		self.H_ALLOWS_PANE = self.top.B_PEDIA_PAGE - self.Y_ALLOWS_PANE

	def interfaceScreen(self, iTier):
		self.iTier = iTier
		screen = self.top.getScreen()

		screen.addPanel(self.top.getNextWidgetName(), "", "", False, False, self.X_ICON_PANE, self.Y_ICON_PANE, self.W_ICON_PANE, self.H_ICON_PANE, PanelStyles.PANEL_STYLE_BLUE50)
		screen.addPanel(self.top.getNextWidgetName(), "", "", False, False, self.X_ICON, self.Y_ICON, self.W_ICON, self.H_ICON, PanelStyles.PANEL_STYLE_MAIN)
		screen.addDDSGFC(self.top.getNextWidgetName(), gc.getPromotionTierInfo(self.iTier).getButton(), self.X_ICON + self.W_ICON/2 - self.ICON_SIZE/2, self.Y_ICON + self.H_ICON/2 - self.ICON_SIZE/2, self.ICON_SIZE, self.ICON_SIZE, WidgetTypes.WIDGET_GENERAL, -1, -1)

		self.placePrereqs()
		self.placeAllows()

	def placeAllows(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_PEDIA_ALLOWS", ()), "", False, True, self.X_ALLOWS_PANE, self.Y_ALLOWS_PANE, self.W_ALLOWS_PANE, self.H_ALLOWS_PANE, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		for j in range(gc.getNumPromotionInfos()):
			if gc.getPromotionInfo(j).getTierType() == self.iTier:
				screen.attachImageButton(panelName, "", gc.getPromotionInfo(j).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROMOTION, j, 1, False)


	def placePrereqs(self):
		screen = self.top.getScreen()
		panelName = self.top.getNextWidgetName()
		screen.addPanel(panelName, localText.getText("TXT_KEY_PEDIA_REQUIRES", ()), "", False, True, self.X_PREREQ_PANE, self.Y_PREREQ_PANE, self.W_PREREQ_PANE, self.H_PREREQ_PANE, PanelStyles.PANEL_STYLE_BLUE50)
		screen.attachLabel(panelName, "", "  ")
		pTierInfo = gc.getPromotionTierInfo(self.iTier)
		eTier = pTierInfo.getPrereqTier()
		if (eTier > -1):
                        screen.attachImageButton(panelName, "", gc.getPromotionTierInfo(eTier).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_JUMP_TO_TIER, eTier, 1, False)
		eTech = pTierInfo.getPrereqTech()
		if (eTech > -1):
			screen.attachImageButton(panelName, "", gc.getTechInfo(eTech).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, eTech, 1, False)

	def handleInput (self, inputClass):
		return 0
 
Attaching it might be more useful, because going through the code like this is a bit tedious.

You should also first make sure, if the error is in the C++ or the Python. Testing the latter should be easy, I guess.

Did you add a page before? Because finding all the necessary parts to adjust (must be 10 or so) can be quite hard the first time.
 
This is the frustrating thing: there are no errors, according to the game everything is perfectly normal! (Apart from that seemingly unrelated error)

I will attach when I am at my computer
 
ok here we are

all changes marked with

//EnhancedPromotions - Start
#EnhancedPromotions - Start
or possibly
#Enhanced Promotions - Start

and no, I have never added a page to the pedia before
 

Attachments

Then I suggest you start with a simple practice.
Just add a simple page, using existing widget, such as a new building page that displays only buildings with happiness bonus.

When you know how to do this simple task, then you can go ahead and implement your new widget with totally new pedia screen and totally new concepts.

You are pretty much trying to fly directly without never walking before :D
 
If I can not get any answers here or can't figure out the problem myself I will do just that :)
 
something else I am not understanding is why that error is appearing? the code (and I even modified it aswell when I found the error) check that the value is valid (I added and not None just in case) yet None values are still getting through. I am so confused. and why doesn't the exit button work :lol:
 
nope, all I've done is what I listed, haven't worked with traits at all, might ask psi to test later whether he gets the error without my modifications, then it's his fault :p I'm tempted to (once I fix this) to actually make the traits work normally with some DLL modifications :p
 
If dummy trait concepts are not present, then it is not surprising that self.traitInfo is simply None?
 
Back
Top Bottom