Custom icon for city-states?

DataNalle

Chieftain
Joined
Jul 30, 2014
Messages
5
Location
Finland
I'm working on a scenario/mod and I would like for my new city-states to use a custom icon next to their names. I noticed that city-states do not have any texture atlases so I guess the icons are hard coded? Is there a way to change them?
 
The icon is based on the trait (mercantile, militaristic, etc.). Unfortunately, because of the hard-coding the DLL, [if I recall correctly] you couldn't just add a new fake trait, so you have to edit the CityBannerManager.lua file.

First, you'd want to add a couple new columns to the MinorCivilizations table, and add the appropriate entries to your city state SQL or XML, and add your atlases:
SQL:
Code:
ALTER TABLE MinorCivilizations ADD PortraitIndex INTEGER DEFAULT -1;
ALTER TABLE MinorCivilizations ADD AlphaIconAtlas TEXT DEFAULT NULL;

UPDATE MinorCivilizations SET PortraitIndex = 0, AlphaIconAtlas = 'MINOR_CIV_ALPHA_ATLAS'
    WHERE Type = 'MINOR_CIV_BRATISLAVA';

INSERT INTO IconTextureAtlases (Atlas, IconSize, Filename, IconsPerRow, IconsPerColumn)
    SELECT
    'MINOR_CIV_ALPHA_ATLAS', 16, 'CivSymbolAtlas16.dds', 1, 1    UNION ALL
    'MINOR_CIV_ALPHA_ATLAS', 24, 'CivSymbolAtlas24.dds', 1, 1    UNION ALL
    'MINOR_CIV_ALPHA_ATLAS', 32, 'CivSymbolAtlas32.dds', 1, 1    UNION ALL
    'MINOR_CIV_ALPHA_ATLAS', 48, 'CivSymbolAtlas48.dds', 1, 1    UNION ALL
    'MINOR_CIV_ALPHA_ATLAS', 64, 'CivSymbolAtlas64.dds', 1, 1    UNION ALL
    'MINOR_CIV_ALPHA_ATLAS', 128, 'CivSymbolAtlas128.dds', 1, 1;

Then replace this line in CityBannerManager.lua:
Code:
-- minor trait icon
controls.StatusIcon:SetTexture( GameInfo.MinorCivTraits[ GameInfo.MinorCivilizations[ player:GetMinorCivType() ].MinorCivTrait ].TraitIcon );

with this:
Code:
local minorCivType = player:GetMinorCivType();
local minorCivInfo = GameInfo.MinorCivilizations[minorCivType];

if minorCivInfo.AlphaIconAtlas then
    IconHookup( minorCivInfo.PortraitIndex, 32, minorCivInfo.AlphaIconAtlas, controls.StatusIcon );
else
    -- minor trait icon
    controls.StatusIcon:SetTexture( GameInfo.MinorCivTraits[minorCivInfo].MinorCivTrait ].TraitIcon );
end

EDIT: Note you would add this changed Lua file to the mod, VFS=true. No Entry Point is required.
[I haven't tested this, but it should get you close.]
 
Top Bottom