pashaintel
Chieftain
- Joined
- Nov 22, 2008
- Messages
- 22
Guys, can anybody help me with popups? Can I launch my popup by right-clicking on building in building-list on the city screen? I want to add some options for each building, and i want to use a city screen for it.
I use CvDLLWidgetData::executeAction :
Then i write:
and
and
Then I compile dll without any mistakes.
But my code in phyton don't works. That's it:
and
and
This code doesn't destroy building. May be, problem with argsList? If i rewrite code to choose building after clicking building list,it works correctly. But I want to choose building to destroy by clicking on it in building list,but not after. Please help with dll, argslist...
I use CvDLLWidgetData::executeAction :
Code:
case WIDGET_HELP_BUILDING:
demolishBuilding(widgetDataStruct);
break;
Code:
void CvDLLWidgetData::demolishBuilding(CvWidgetDataStruct &widgetDataStruct)
{
BuildingTypes eBuilding;
eBuilding = ((BuildingTypes)(widgetDataStruct.m_iData1));
CvEventReporter::getInstance().demolishBuilding(eBuilding );
}
and
Code:
void CvDllPythonEvents::reportDemolishBuilding(BuildingTypes eBuilding )
{
if (preEvent())
{
CyArgsList eventData;
eventData.add("destroyBuilding"); // add key to lookup python handler fxn
eventData.add((int)eBuilding);
postEvent(eventData);
}
}
Code:
void CvEventReporter::demolishBuilding(BuildingTypes eBuilding)
{
m_kPythonEventMgr.reportDemolishBuilding(eBuilding);
}
Then I compile dll without any mistakes.
But my code in phyton don't works. That's it:
Code:
def onDestroyBuilding(self, argsList):
self.__eventDestroyBuildingBegin(argsList)
Code:
def __eventDestroyBuildingBegin(self, argsList):
iBuilding = argsList[0]
popup = PyPopup.PyPopup(CvUtil.EventDestroyBuilding, EventContextTypes.EVENTCONTEXT_ALL)
popup.setHeaderString(localText.getText("TXT_KEY_DESTROY_B", ()))
popup.setBodyString(localText.getText("TXT_KEY_DESTROY_DB", ()))
popup.setUserData((iBuilding.getID(),))
popup.addButton("OK")
popup.addButton(localText.getText("TXT_KEY_SCREEN_CANCEL", ()))
popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
return
Code:
def __eventDestroyBuildingApply(self, playerID, userData, popupReturn):
iBuilding = userData[0]
if (popupReturn.getButtonClicked() == 0):
CyInterface().getHeadSelectedCity().setNumRealBuilding(iBuilding, False)
CyAudioGame().Play2DSound("AS2D_PILLAGE")
return