Fabrysse
Charming-snake learner
Well... That's not a good new.
Thanks for your answer. I'll have a look in this screens files.
Thanks for your answer. I'll have a look in this screens files.
But there are already radio buttons and check boxes elsewhere in the game aren't there? How are those done?
def eventlist(event):
if event = 'WarUSSRvsFIN': #USSR demands land from Finland, Week 44, 1939
pPlayer = gc.getPlayer(13)
if pPlayer.isHuman():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
popupInfo.setText(CyTranslator().getText("The Soviet Union is demanding that you give them Viipuri.",()))
popupInfo.setData1('WarUSSRvsFIN1')
popupInfo.setData2('WarUSSRvsFIN2')
popupInfo.setData3('WarUSSRvsFIN3')
popupInfo.setOnClickedPythonCallback("popupthree")
popupInfo.addPythonButton(CyTranslator().getText("War is not an option, we must accept. (Viipuri is lost and all units east of it deleted)", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("Negotiate us to be vassalized. (Become Vassal of USSR, possibility of revolts)", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("Never! (War with USSR)", ()), "")
popupInfo.addPopup(pPlayer)
def popupmany(argsList):
iButtonId = argsList[0]
iData1 = argsList[1]
iData2 = argsList[2]
iData3 = argsList[3]
if iButtonId == 0:
send to wwii events def eventlist(iData1)
if iButtonId == 1:
send to wwii events def eventlist(iData2)
if iButtonId == 2:
send to wwii events def eventlist(iData3)
so how would you do something like in the American Revolution scenario, where a popup comes up on a certain turn and says "Reinforcements have arrived for the british!" and a bunch of unit spawn for the brits. Also, can you make one that despawns units?
How exactly do you do this? I figured the answer may involve using something like getData1, but I couldn't get it to work.
What would be the code to use to generate a popup box to select a unit from a stack, like is done when you want to add a warlord to a unit or to choose what ship to load a unit onto?
Thanks for the reply. I was afraid this thread had died and nobody would say anything.
I'm still a little unclear about what you said; wasn't a big point in Kael's guide that the function must necessarily be in the CvScreensInterface module? Not that I'm upset about it - if I can define my own, all the better!
I had thought about using global variables but didn't want to go that way, if I could avoid it, primarily because I wanted to incorporate the global script dictionary as well. (But since that's already global, I shouldn't have to do anything special with it, correct?) I'll look at this later and see what happens.
from CvPythonExtensions import *
import CvUtil
#######################################################################################
## Select my events
#######################################################################################
gc = CyGlobalContext()
def selectEventTrigger():
"""
Present the user with a list of event triggers and
launch the selected event
"""
iPlayer = 0
player = gc.getPlayer(iPlayer)
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT",()))
popupInfo.setData1(iPlayer)
# the following python routine must exist in the CvScreensInterface.py file.
popupInfo.setOnClickedPythonCallback("selectOneEvent")
# unless a different module is specified
popupInfo.setPythonModule("MyCvScreensInterface")
# The following keys must be defined in the Text\CIV4GameText_Events_BTS.xml file.
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_HORTICULTURE", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_SPICY", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_BLACK_PEARLS", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_SALTPETER", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_TRUFFLES", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_SEA_TURTLES", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_TIN", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_EVENT_GOLD_RUSH", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_SPORTS_LEAGUE", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_INSPIRED_MISSION", ()), "")
popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_SELECT_NEVER_MIND", ()), "")
popupInfo.addPopup(iPlayer)
# some standard event trigger names as they apperar in the
# Events\CIV4EventTriggerInfos.xml file.
eventTriggerKey = {
0 : 'EVENTTRIGGER_HORTICULTURE',
1 : 'EVENTTRIGGER_SPICY',
2 : 'EVENTTRIGGER_BLACK_PEARLS',
3 : 'EVENTTRIGGER_SALTPETER',
4 : 'EVENTTRIGGER_TRUFFLES',
5 : 'EVENTTRIGGER_SEA_TURTLES',
6 : 'EVENTTRIGGER_TIN',
7 : 'EVENTTRIGGER_GOLD_RUSH',
8 : 'EVENTTRIGGER_SPORTS_LEAGUE',
9 : 'EVENTTRIGGER_INSPIRED_MISSION'
}
def selectOneEvent(argsList):
iButtonId = argsList[0]
iData1 = argsList[1]
eventTriggerName = None
eventTriggerNumber = -1
if iButtonId in eventTriggerKey.keys():
eventTriggerName = eventTriggerKey[iButtonId]
if eventTriggerName == None:
return
eventTriggerNumber = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(), eventTriggerName)
if eventTriggerNumber == -1:
return
message = 'addImmediateMessage: You selected Event: %s[%d]' % (eventTriggerName, eventTriggerNumber)
CyInterface().addImmediateMessage(message, "")
message = 'pyPrint: You selected Event: %s[%d]' % (eventTriggerName, eventTriggerNumber)
CvUtil.pyPrint(message)
message = 'print: You selected Event: %s[%d]' % (eventTriggerName, eventTriggerNumber)
print message
pPlayer = gc.getPlayer(iData1)
pPlayer.trigger(eventTriggerNumber)
In a sense I did, but I used a work-around solution with the multiple choice popups. My original problem with creating pseudo-events was owing to my own clumsiness in Python more than anything else.
I still would really like to make a popup that looks like the random events one - the popup that has the "hover-over effects" display. I haven't checked out where that's explicitly used (probably in SDK, since I never saw it in any of the Python files) but if I find it I might write up a brief tutorial on how to use it.