Iceco
Warlord
- Joined
- Oct 27, 2010
- Messages
- 188
For my Not Another City States Mod I am adding an image to the Greeting- and DiploPopups of city-states.
I got it working the easy way, by simply replacing those lua and xml files:
Now I'm trying to do it the proper way, that is with ContextPtr, without overwriting the core files, but it's not working.
The files are imported into the VFS and the lua is added as InGameUIAddin.
I assume the problem lies with the first few lines of the ShowCSIcon() function. I tried some different things, but nothing worked.
(The 'CSIcon' is just the round flag icon.)
The code is based on the original DiploPopup file, Onni's tutorial and Gedemon's Mercenary mod.
Any help would be appreciated.
I got it working the easy way, by simply replacing those lua and xml files:
Spoiler :

Now I'm trying to do it the proper way, that is with ContextPtr, without overwriting the core files, but it's not working.
Code:
<?xml version="1.0" encoding="utf-8"?>
<Context Font="TwCenMT20" ColorSet="Beige_Black_Alpha" FontStyle="Shadow" >
<Image ID="TitleCSIcon" Anchor="C,T" AnchorSide="I.O" Offset="0,-11" Texture="Assets/UI/Art/Controls/CityStatePopupTop100.dds" Size="86.86" Hidden="1"/>
</Context>
Code:
[COLOR="Green"]-------------------------------------------------
-- Changes to City State Diplo Popup
-------------------------------------------------[/COLOR]
[COLOR="Teal"]local[/COLOR] g_iMinorCivID = -1;
[COLOR="teal"]local [/COLOR]g_iMinorCivTeamID = -1;
[COLOR="teal"]local [/COLOR]m_PopupInfo = nil;
[COLOR="Green"]-------------------------------------------------
-- On Popup
-------------------------------------------------[/COLOR]
[COLOR="Blue"]function [/COLOR]OnEventReceived( popupInfo )
[COLOR="Teal"]if[/COLOR]( popupInfo.Type ~= ButtonPopupTypes.BUTTONPOPUP_CITY_STATE_DIPLO ) [COLOR="teal"]then[/COLOR]
[COLOR="teal"]return[/COLOR];
[COLOR="teal"]end[/COLOR]
m_PopupInfo = popupInfo;
[COLOR="teal"]local[/COLOR] iPlayer = popupInfo.Data1;
[COLOR="teal"]local [/COLOR]pPlayer = Players[iPlayer];
[COLOR="teal"]local [/COLOR]iTeam = pPlayer:GetTeam();
[COLOR="teal"]local [/COLOR]pTeam = Teams[iTeam];
g_iMinorCivID = iPlayer;
g_iMinorCivTeamID = iTeam;
[COLOR="teal"]local [/COLOR]bForcePeace = false;
ShowCSIcon()
[COLOR="teal"]end[/COLOR]
Events.SerialEventGameMessagePopup.Add( OnEventReceived );
[COLOR="Blue"]function [/COLOR]OnGameDataDirty()
[COLOR="Teal"]if [/COLOR](ContextPtr:LookUpControl("/InGame/CityStateDiploPopup"):IsHidden()) [COLOR="teal"]then[/COLOR]
[COLOR="teal"]return[/COLOR]
[COLOR="teal"]end [/COLOR]
ShowCSIcon()
[COLOR="teal"]end[/COLOR]
Events.SerialEventGameDataDirty.Add(OnGameDataDirty)
[COLOR="Green"]-------------------------------------------------
-- On Display
-------------------------------------------------[/COLOR]
[COLOR="Blue"]function [/COLOR]ShowCSIcon()
Controls.TitleCSIcon:ChangeParent(ContextPtr:LookUpControl("/InGame/CityStateDiploPopup"))
ContextPtr:LookUpControl("/InGame/CityStateDiploPopup"):ReprocessAnchoring()
[COLOR="Green"]-- The below code is copied over from the 'easy' version and works in that one[/COLOR]
[COLOR="Teal"]local[/COLOR] sMinorCivType = [COLOR="Red"]pPlayer[/COLOR]:GetMinorCivType();
[COLOR="teal"]local [/COLOR]trait = GameInfo.MinorCivilizations[sMinorCivType].MinorCivTrait;
[COLOR="teal"]local [/COLOR]CSIcon = nil;
[COLOR="teal"]if [/COLOR](sMinorCivType ~= nil) [COLOR="teal"]then[/COLOR]
[COLOR="teal"]local [/COLOR]realMinorCivType = GameInfo.MinorCivilizations[sMinorCivType].Type
[COLOR="teal"]if [/COLOR]realMinorCivType ~= nil [COLOR="teal"]then[/COLOR]
[COLOR="teal"]local [/COLOR]condition = "MinorCivType = '" .. realMinorCivType .. "'"
[COLOR="teal"]for [/COLOR]row in GameInfo.MinorCivIcons_Iceco(condition) [COLOR="teal"]do[/COLOR]
CSIcon = row.CSIcon;
[COLOR="teal"]end[/COLOR]
[COLOR="teal"]end[/COLOR]
[COLOR="teal"]end[/COLOR]
[COLOR="teal"]if [/COLOR]CSIcon ~= nil [COLOR="teal"]then[/COLOR]
Controls.TitleCSIcon:SetHide(false);
Controls.TitleCSIcon:SetTexture(CSIcon);
[COLOR="teal"]else[/COLOR]
Controls.TitleCSIcon:SetHide(true);
[COLOR="teal"]end[/COLOR]
[COLOR="teal"]end[/COLOR]
I assume the problem lies with the first few lines of the ShowCSIcon() function. I tried some different things, but nothing worked.
(The 'CSIcon' is just the round flag icon.)
The code is based on the original DiploPopup file, Onni's tutorial and Gedemon's Mercenary mod.
Any help would be appreciated.