Trying to modify CityView, no success

killmeplease

Mk Z on Steam
Joined
Nov 22, 2007
Messages
2,795
Location
Samara
Hello!
I'm trying to modify the CitiView xml and lua files. What i want is to add an another indicator in the upper-left corner
changes to CityView.xml:
Code:
			<!-- Faith Info -->
			<Box Offset="0,0" Anchor="L,T" Size="240,32" Color="255,255,255,0" ID="FaithBox">
				<Label Anchor="L,C" Offset="6,0" String="[ICON_PEACE]"/>
				<Label Anchor="L,C" Offset="32,0" String="TXT_KEY_CITYVIEW_FAITH_TEXT" Font="TwCenMT20" FontStyle="Shadow"/>
				<Label ID="FaithPerTurnLabel" Anchor="R,C" String="" Font="TwCenMT20" FontStyle="Shadow"/>
				<Box Anchor="L,B" Color="27.53.64.255" Offset="4,0" Size="240,1"/>
			</Box>
			<!-- EMIGRATION MOD: Prosperity Info -->
[COLOR="DarkGreen"]			<Box Offset="0,0" Anchor="L,T" Size="240,32" Color="255,255,255,0" ID="ProsperityBox">
				<Label Anchor="L,C" Offset="6,0" String="[ICON_FLOWER]"/>
				<Label Anchor="L,C" Offset="32,0" String="TXT_KEY_CITYVIEW_PROSPERITY_TEXT" Color0="128.128.128.255" Color1="0.0.0.128" Color2="255.255.200.255" Font="TwCenMT20" FontStyle="Shadow"/>
				<Label ID="ProsperityLabel" Anchor="R,C" String="" Font="TwCenMT20" FontStyle="Shadow"/>
				<Box Anchor="L,B" Color="27.53.64.255" Offset="4,0" Size="240,1"/>
			</Box>[/COLOR]

changes to CityView.lua:
Code:
		if (Game.IsOption(GameOptionTypes.GAMEOPTION_NO_RELIGION)) then
			Controls.FaithPerTurnLabel:SetText( Locale.ConvertTextKey("TXT_KEY_CITYVIEW_OFF") );
		else
			local iFaithPerTurn = pCity:GetFaithPerTurn();
			Controls.FaithPerTurnLabel:SetText( Locale.ConvertTextKey("TXT_KEY_CITYVIEW_PERTURN_TEXT", iFaithPerTurn) );
		end

[COLOR="darkgreen"]		-- EMIGRATION MOD --
		local prosp = 0;
		for i = 0, 3, 1 do
			prosp = prosp + pCity:GetYieldRateTimes100(i);
		end
		prosp = prosp / 100;							
		prosp = prosp + pCity:GetJONSCulturePerTurn();
		prosp = prosp + pCity:GetGreatPeopleRate();
		prosp = prosp / pCity:GetPopulation();	-- calc average per citizen
		prosp = prosp * GameInfo.EmigrationSettings["WealthFactor"].Value / 100;
		Controls.ProsperityLabel:SetText( Locale.ConvertTextKey("TXT_KEY_CITYVIEW_PERTURN_TEXT", prosp) );  -- line 1434
		--------------------
[/COLOR]

and its not working, my indicator isnt shown at the city screen.
i set improt to VFS to true for the both files
lua log says "attempt to index a nil field, line 1434". i assume that means ProsperityLabel is nil.
when i tried to add CityView.xml to the Content section as a CityViewUIAddin, the game crashed upon load.
what am i doing wrong?
thanks!
 
Looking at your XML, where is the control with ID 'ProsperityLabel'?

I see only 'ProsperityBox'.

EDIT: Never mind....found it...
 
Try this, for the XML set import to false... and add it in the OnModActivated section.

<Actions>
<OnModActivated>
<UpdateDatabase>CityView.xml</UpdateDatabase>
</OnModActivated>
</Actions>

This is wrong.

You ONLY do that for XML/SQL that updates the GameData database.

XML and LUA files that replace existing components in the UI only need VFS=true for both.

XML and LUA files that extend the UI need VFS=false and ONE of them adding as an InGameUIAddin

So the described settings for these files are correct

Now, the VFS is a weird place.

include "CityView" does not look for a file called CityView.lua but matches any files with CityView in them

This is intentional, but causes some weird "gotchas" and I think you've run into one of them.

The code to load the CityView screen in InGame.lua is

Code:
<LuaContext FileName="Assets/UI/InGame/CityView/CityView" ID="CityView" Hidden="True"/>

So it's looking for a file that matches that pattern in full. When it's found one (usually the xml file) it will do an "include CityView" to get the associated Lua file - so I *think* what is happeneing is the game is using the original XML file but your LUA file.

Try creating a series of sub-directories in your mod called

Code:
Assets
Assets/UI
Assets/UI/InGame
Assets/UI/InGame/CityView

(EXACT capitalisation)

and move your two CityView files into the last one and set VFS=true (as ModBuddy has an annoying habit of setting it back to false when you move files)

HTH

W
 
I have the same problem, and have followed your advice, but I still have no UI change to city view.

Do I need the files organized differently for GK expansion?

To recap:

Changes made to cityview.lua work. cityview.lua set to Import to VFS True
Changes made to cityview.xml don't work. cityview.xml set to Import to VFS True.

Both files are in Assest/UI/InGame/CityView.

CityView.xml set to update database.

Nothing is in Content.
 

Attachments

  • cityview.png
    cityview.png
    19.2 KB · Views: 148
The CityView comes in two flavours "normal" and "small" - there is also a CityView_Small.xml UI file

It's possible your machine is using the "small" UI settings but you're only editing the normal xml

Do NOT set CityView.xml to update the database, it has NOTHING to do with the game database
 
The CityView comes in two flavours "normal" and "small" - there is also a CityView_Small.xml UI file

It's possible your machine is using the "small" UI settings but you're only editing the normal xml

Do NOT set CityView.xml to update the database, it has NOTHING to do with the game database

this helped! thanks
there's also a tablet pc UI version btw
 
Back
Top Bottom