How to replace a popup

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,699
Location
Near Portsmouth, UK
This tutorial shows how to replace a standard popup with a custom one

Locate your popup pair of files (one .xml and one .lua)
  • For BNW, start your search in C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\UI\InGame\Popups
  • For G&K, start your search in C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion\UI\InGame\Popups
  • If you can't find one or other of them, look in C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\UI\InGame\Popups

We are going to mod the GoodyHutPopup.lua/xml pair

Copy the pair to your mod, rename them (eg MyGoodyHutPopup.lua/xml) and add them as an InGameUIAddin - do NOT set VFS=true

Open the C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\UI\InGame\InGame.xml file (or whichever one is appropriate for the version of the game you're playing) and locate the <LuaContext> line of your donor popup and make a note of its ID value (GoodyHutPopup in this case) - this is usually the same as the filename but NOT always!

Make any changes needed to the XML file, eg changing the top icon. We'll just change AncientRuinsPopupTop300.dds to GoldenAgePopupTop300.dds - it doesn't line up correctly but it'll prove the point!

Open the Lua file, locate the SerialEventGameMessagePopup event handler, and note the ButtonPopupTypes referenced (BUTTONPOPUP_GOODY_HUT_REWARD in this case)

Replace the SerialEventGameMessagePopup event handler with

Code:
function SuppressPopup(popupInfo)
    if (popupInfo.Type == ButtonPopupTypes.BUTTONPOPUP_XYZ) then
        m_PopupInfo = popupInfo
	
        UIManager:DequeuePopup(ContextPtr:LookUpControl("/InGame/ABC"))
        ContextPtr:SetHide(false)
    end
end
Events.SerialEventGameMessagePopup.Add(SuppressPopup)

where XYZ and ABC are the values noted above, eg, for the GoodyHutPopup it would be

Code:
function SuppressPopup(popupInfo)
    if (popupInfo.Type == ButtonPopupTypes.BUTTONPOPUP_GOODY_HUT_REWARD) then
        m_PopupInfo = popupInfo
	
        UIManager:DequeuePopup(ContextPtr:LookUpControl("/InGame/GoodyHutPopup"))
        ContextPtr:SetHide(false)
    end
end
Events.SerialEventGameMessagePopup.Add(SuppressPopup)


Replace the SetShowHideHandler handler with

Code:
function ShowHideHandler(bIsHide, bInitState)
    if (not bInitState) then
        if (not bIsHide) then
            -- Update any controls here, eg new text strings
            -- If more than a handful of lines, add them to a function and call the function here
        end
    end
end
ContextPtr:SetShowHideHandler(ShowHideHandler)

eg, for the GoodyHutPopup

Code:
function ShowHideHandler(bIsHide, bInitState)
    if (not bInitState) then
        if (not bIsHide) then
            -- Update any controls here, eg new text strings
            Controls.DescriptionLabel:SetText("Woo hoo!!! We found something!");
        end
    end
end
ContextPtr:SetShowHideHandler(ShowHideHandler)


Finally, replace any occurances of
Code:
    UIManager:DequeuePopup( ContextPtr );

with
Code:
    ContextPtr:SetHide(true)

there should be at least one attached to the Close/OK button.


The attached "My - Changes" mod replaces both the Goody Hut and Barbie Camp popups

[END]
 

Attachments

  • My - Changes (v 1).zip
    8.9 KB · Views: 175
How would one block a popup entirely? I'm interested in blocking the whoswinning popups and the announcements about golden ages. Any advice?
 
How would one block a popup entirely?

Quick way - omit the ContextPtr:SetHide(false) line from the SuppressPopup() function

Longer way - do the quick way and then strip the MyXyz.xml/lua files right back to bare bones
 
Quick way - omit the ContextPtr:SetHide(false) line from the SuppressPopup() function

Longer way - do the quick way and then strip the MyXyz.xml/lua files right back to bare bones

Perfect. Works for me. Thx so much.
 
The golden age popup is in the GoldenAgePopup.xml/lua pair.

The .lua file is common to all versions of the game (vanilla, G&K and BNW) the .xml file is specific to the version you're playing, so make sure you get the correct one

Those are your starting point, copy and edit them as described above.
 
I can't find the "ContextPtr:SetHide(false) line from the SuppressPopup() function" in the GoldenAgePopup.xml/lua pair. Where is it?
 
Ummm .... from the very first post of this tutorial

"Replace the SerialEventGameMessagePopup event handler with function SuppressPopup(popupInfo) ..."

You'll need to follow all the tutorial, not just grasp at parts of it
 
Top Bottom