RenaissanceFan
Warlord
- Joined
- Mar 15, 2011
- Messages
- 125
Hello again. I got the backbone for one of my mods almost done, but I'm having trouble to make it work. Please tell me what am I doing wrong. Two things:
1) I created a button at the Domestic Advisor for calling a popup, but the handleInput function doesn't seem to be working:
- Button declaration:
- handleInput part of code:
2) Here's the function that the popup calls. Also, where should I place it?
1) I created a button at the Domestic Advisor for calling a popup, but the handleInput function doesn't seem to be working:
- Button declaration:
Code:
screen.setImageButton( "CreateProvince", "", self.nScreenWidth - 165, self.nScreenHeight - 45, 28, 28, WidgetTypes.WIDGET_ACTION, -1, -1 )
screen.setStyle( "CreateProvince", "Button_HUDLog_Style" )
- handleInput part of code:
Code:
if (inputClass.getFunctionName() == "CreateProvince"):
if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
pPlayer = gc.getActivePlayer()
CityChoice = CyPopupInfo()
CityChoice.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
CityChoice.setText("Choose your new province's capital:")
CityChoice.setOnClickedPythonCallback("makeProvince")
(pLoopCity, iter) = pPlayer.firstCity(false)
while(pLoopCity):
if (pLoopCity.isCapital() != True):
CityChoice.addPythonButton(pLoopCity.getName())
i += 1
(pLoopCity, iter) = player.nextCity(iter, false)
CityChoice.addPopup(pPlayer)
2) Here's the function that the popup calls. Also, where should I place it?
Code:
def makeProvince (self, argsList):
ButtonID = argsList[0]
pPlayer = gc.getActivePlayer()
tPlayer = gc.getActivePlayer().getTeam()
for i in range(0, gc.getMAX_CIV_PLAYERS()) :
if( not gc.getPlayer(i).isEverAlive() and not gc.getPlayer(i).isAlive() ) :
newPlayerId = i
break
game.addPlayer(i, gc.getInfoTypeForString("LEADER_GOVERNOR", gc.getInfoTypeForString("CIVILIZATION_PROVINCE"))
iVassal = gc.getPlayer(i)
tVassal = gc.getPlayer(iVassal).getTeam()
gc.getPlayer(iVassal).acquireCity(pPlayer.getCity(ButtonID+1), False, True)
for iTech in range(gc.getNumTechInfos()):
if (tPlayer.isHasTech(iTech)):
iVassal.setHasTech(iTech, True, iVassal, False, False)
pPlayer.assignVassal(gc.getPlayer(iVassal).getTeam(), True)