Popups in the SDK

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
How do popups work in the SDK? For example, this code here, what is happening?

Code:
void CvPlayer::acquireCity(...)
                   CvPopupInfo* pInfo = new CvPopupInfo(BUTTONPOPUP_RAZECITY);
                    pInfo->setData1(pNewCity->getID());
                    pInfo->setData2(eHighestCulturePlayer);
                    pInfo->setData3(iCaptureGold);
                    gDLL->getInterfaceIFace()->addPopup(pInfo, getID());
....

If I wanted to create a new popup with 4 choices or selections for the player, how would I go about doing that?
 
You'd have to define a new popup type to handle 4 options and code them in. Just follow BUTTONPOPUP_RAZECITY through the DLL and you should see most every location where you need something. When it is doing checks for 0,1,2 or 3 within that popup, that is the button pressed (first/second/third/fourth). How the info is used varies per popup, typically it is used for setting the text or properly linking the buttons to their appropriate action afterward.
 
You'd have to define a new popup type to handle 4 options and code them in. Just follow BUTTONPOPUP_RAZECITY through the DLL and you should see most every location where you need something. When it is doing checks for 0,1,2 or 3 within that popup, that is the button pressed (first/second/third/fourth). How the info is used varies per popup, typically it is used for setting the text or properly linking the buttons to their appropriate action afterward.

Okay, but I don't understand two things.

1.) Where is the text for that popup displayed? I don't see any TXT_KEY's anywhere...
2.)How does the game know what to do when the button is pressed... I don't see any following actions. The SetData functions are pretty much useless for understanding what's happening.
 
The text keys are set up in CvDLLButtonPopup::launchRazeCityPopup, which is called from CvDLLButtonPopup::launchButtonPopup.

The actions after clicking a button are handled in CvDLLButtonPopup::OnOkClicked.

Also, you'll find a reference in CvDLLButtonPopup::OnFocus if you are searching with this popup type, you can ignore that unless your new popup is allowed to be minimized as I recall.
 
The text keys are set up in CvDLLButtonPopup::launchRazeCityPopup, which is called from CvDLLButtonPopup::launchButtonPopup.

The actions after clicking a button are handled in CvDLLButtonPopup::OnOkClicked.

Also, you'll find a reference in CvDLLButtonPopup::OnFocus if you are searching with this popup type, you can ignore that unless your new popup is allowed to be minimized as I recall.

Thanks! That's exactly what I needed to know. :)
 
Find in Files and Find References are very useful features of Visual Studio. Using those for BUTTONPOPUP_RAZECITY would have led you to exactly the functions xienwolf laid out. Those and Go to Definition are the only features not found in a normal editor that I used in VS. Well, those and Build Solution. ;)
 
Find in Files and Find References are very useful features of Visual Studio. Using those for BUTTONPOPUP_RAZECITY would have led you to exactly the functions xienwolf laid out. Those and Go to Definition are the only features not found in a normal editor that I used in VS. Well, those and Build Solution. ;)

Yeah, I didn't realize that BUTTONPOPUPS were enumerated elsewhere. Once Xienwolf pointed that out, I figured everything else out okay. My popups work perfectly. :p
 
Top Bottom