HOW TO: Add Popups

I'm trying to run a yes/no popup at the start of a certain turn. I want it to ask the player if a zone flip can occur. Answering yes will lead to one flip scenario, and answering no will lead to another, more limited flip scenario and war with that civ. Is this going to get me there? I'm sure it needs work, and I'd appreciate any advice or suggestions you may have:


Spoiler :
Code:
def romePopup(self, argsList):
	iPlayerNum = 0
	for iPlayer in range(gc.getMAX_PLAYERS()):
		player = gc.getPlayer(iPlayer)
		if player.isAlive():
			iPlayerNum = iPlayerNum + 1
			if player.isHuman():
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
				popupInfo.setText(CyTranslator().setText("The Latin citizens of Rome have declared their independence. They lay claim to all of Italy. Will you recognize their sovereignty? Refusal will mean war.",()))
				popupInfo.setData1(iPlayer)
				popupInfo.setOnClickedPythonCallback("classicalButtons")
				popupInfo.addPythonButton(CyTranslator().setText("Yes", ()), "")
				popupInfo.addPythonButton(CyTranslator().setText("No", ()), "")
				popupInfo.addPopup(iPlayer)



#this goes in my custom CvScreensInterface.py 
def classicalButtons(argsList):
	iButtonId = argsList[0]
	iData1 = argsList[1]
	iData2 = argsList[2]
	iData3 = argsList[3]
	iData4 = argsList[4]
	szText = argsList[5]
	bOption1 = argsList[6]
	bOption2 = argsList[7]
	if iButtonId == 0:
		DawnOfTime.classicalSpawn()
	if iButtonId == 1:
		DawnOfTime.classicalWar()
 
I don't know, if you already got it to work (don't follow your thread, going on too fast), but it seems overall okay.
I don't understand why you assigned the parameters 3-7 in the second part, you should better remove it if you don't need it.
 
Do you guys know how to edit the width of a popup? Whenever I add some buttons to a HL layout in the popup, the extra elements simply disappear of the right edge of the popup. Of course I could add a seperator and adjust the layout, but I'd rather increase the popup width. Any link would be awesome too.

EDIT: ^It looks like there's no work around for the clipping.
Also, it appears that CyPopup is way more powerful than CyPopupInfo in terms of the input you can get. Supports text boxes, radio, checkboxes, the works.
 
Back
Top Bottom