renegadechicken
Warlord
Preamble: I'm adding events to the Final Frontier mod, and they're coming along nicely, and actually nearing completion. However, I had a thought: how cool would it be to add visuals to these events? This led me to...
My Goal: I would like to add a PopUp that appears when an event is triggered just before the actual event box and options come up. For example, I have an event where your colonists can discover the ruins of an advanced alien civilization on one of the worlds in one of your systems (in Final Frontier, a system is a city). Wouldn't it be cool to have a PopUp appear with a picture of some alien ruins? It would be titled as such, and you would click "Ok", and then make your choices on what to do (like any normal event), like plunder any wealth, or study the ruins for beakers, etc.
The Problem: Try as I might, I can't get ANY custom PopUps to work. The event triggers perfectly and I can make whatever choice I want with no problems, but the PopUp simply does not...well, pop up!
The Technical Stuff: Here is what I have, so you can see what I've done and point out what I've done wrong.
First off, since I want the PopUp to appear before the event choices come up, I went into the Civ4EventTriggerInfos.xml file and added a Python tag to the correct section:
<EventTriggerInfo>
This event has been edited to be non-random for testing purposes. Basically I've set it up to trigger once ANY city reaches size 4 so that I can easily test it. Once any city reaches size 4, the PopUp is supposed to trigger, the player will press ok, and then they are presented with 3 choices (EVENT_ALIEN_RUINS_1, 2, and 3). However, the event fires, skips the PopUp, and goes right to the choices. In other words, it works perfectly and just like any normal BTS event, but the PopUp never shows up!
Now let's move on to the Python code I've added that should create the custom PopUp. Since I'm dealing with a random event, I went into the CvRandomEventInterface.py file and added the following code to the end of the document:
######## Alien Ruins ########
def doAlienRuinsPopUp(argsList):
Now, I'm no expert at Python, but I do know enough to get me by. This PopUp code is basically copied and pasted from Kael's "HOW TO: Add Popups" article here on CivFanatics, so it should work, right? Basically, I want the PopUp to appear only if the triggered player is human (I don't want to push PopUps onto the AIs, because they probably wouldn't know what to do), I want it to be a simple "press OK to continue" deal, I want it to display a picture, and I want it to have a bit of descriptive text. And, as stated previously, I want it to occur right before the actual event options appear. Once again, however, the PopUp fails to appear, though the event triggers and executes perfectly.
To sum up, I'm wondering why the PopUp isn't appearing. Is it because I have the Python code in the wrong place? Have I screwed up the Python? Is what I want, simple though it may be, impossible?
Thank you in advance for any help or insights you can share!
My Goal: I would like to add a PopUp that appears when an event is triggered just before the actual event box and options come up. For example, I have an event where your colonists can discover the ruins of an advanced alien civilization on one of the worlds in one of your systems (in Final Frontier, a system is a city). Wouldn't it be cool to have a PopUp appear with a picture of some alien ruins? It would be titled as such, and you would click "Ok", and then make your choices on what to do (like any normal event), like plunder any wealth, or study the ruins for beakers, etc.
The Problem: Try as I might, I can't get ANY custom PopUps to work. The event triggers perfectly and I can make whatever choice I want with no problems, but the PopUp simply does not...well, pop up!
The Technical Stuff: Here is what I have, so you can see what I've done and point out what I've done wrong.
First off, since I want the PopUp to appear before the event choices come up, I went into the Civ4EventTriggerInfos.xml file and added a Python tag to the correct section:
Spoiler :
<EventTriggerInfo>
<Type>EVENTTRIGGER_ALIEN_RUINS</Type>
<WorldNewsTexts>
<Text>TXT_KEY_EVENTTRIGGER_ALIEN_RUINS</Text>
</WorldNewsTexts>
<TriggerTexts>
<TriggerText>
<Text>TXT_KEY_EVENT_TRIGGER_ALIEN_RUINS</Text>
<Era>NONE</Era>
</TriggerText>
</TriggerTexts>
<bSinglePlayer>0</bSinglePlayer>
<iPercentGamesActive>100</iPercentGamesActive>
<iWeight>-1</iWeight>
...
<iMinPopulation>4</iMinPopulation>
...
<Events>
<Event>EVENT_ALIEN_RUINS_1</Event>
<Event>EVENT_ALIEN_RUINS_2</Event>
<Event>EVENT_ALIEN_RUINS_3</Event>
</Events>
...
<bPickCity>1</bPickCity>
...
<PythonCallback>doAlienRuinsPopUp</PythonCallback>
</EventTriggerInfo>This event has been edited to be non-random for testing purposes. Basically I've set it up to trigger once ANY city reaches size 4 so that I can easily test it. Once any city reaches size 4, the PopUp is supposed to trigger, the player will press ok, and then they are presented with 3 choices (EVENT_ALIEN_RUINS_1, 2, and 3). However, the event fires, skips the PopUp, and goes right to the choices. In other words, it works perfectly and just like any normal BTS event, but the PopUp never shows up!
Now let's move on to the Python code I've added that should create the custom PopUp. Since I'm dealing with a random event, I went into the CvRandomEventInterface.py file and added the following code to the end of the document:
Spoiler :
######## Alien Ruins ########
def doAlienRuinsPopUp(argsList):
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
if player.isHuman():
popup = PyPopup.PyPopup(-1)
popup.addDDS('art/interface/popups/alienruins.dds', 0, 0, 256, 512)
popup.addSeparator()
popup.setHeaderString('Alien Ruins')
popup.setBodyString('The ruins of an ancient alien civilization have been discovered on one of our worlds!')
popup.setPosition(256,128)
popup.setSize(512,512)
popup.launch(true, PopupStates.POPUPSTATE_QUEUED)
Now, I'm no expert at Python, but I do know enough to get me by. This PopUp code is basically copied and pasted from Kael's "HOW TO: Add Popups" article here on CivFanatics, so it should work, right? Basically, I want the PopUp to appear only if the triggered player is human (I don't want to push PopUps onto the AIs, because they probably wouldn't know what to do), I want it to be a simple "press OK to continue" deal, I want it to display a picture, and I want it to have a bit of descriptive text. And, as stated previously, I want it to occur right before the actual event options appear. Once again, however, the PopUp fails to appear, though the event triggers and executes perfectly.
To sum up, I'm wondering why the PopUp isn't appearing. Is it because I have the Python code in the wrong place? Have I screwed up the Python? Is what I want, simple though it may be, impossible?
Thank you in advance for any help or insights you can share!