How to import .png files for some art/icon

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
12,846
Location
France
A quick tutorial to get started into adding icons and images in the game, I've not been able to test it enough to get one working for a civ, but maybe it was because of my test image

test image :
1739482563033.png



.modinfo
Spoiler full ynamp.modinfo as example :


XML:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="ged-ynamp" version="1"
    xmlns="ModInfo">
    <Properties>
        <Name>LOC_MODULE_YNAMP_NAME</Name>
        <Description>LOC_MODULE_YNAMP_DESCRIPTION</Description>
        <Authors>Gedemon</Authors>
        <Package>MOD</Package>
    </Properties>
    <Dependencies>
        <Mod id="base-standard" title="LOC_MODULE_BASE_STANDARD_NAME"/>
    </Dependencies>
    <ActionCriteria>
        <Criteria id="always">
            <AlwaysMet></AlwaysMet>
        </Criteria>
    </ActionCriteria>
    <ActionGroups>
        <ActionGroup id="base-game-main-ynamp" scope="game" criteria="always">
            <Actions>
                <UpdateDatabase>
                    <Item>data/maps.xml</Item>
                </UpdateDatabase>
                <UpdateText>
                    <Item>text/en_us/MapText.xml</Item>
                </UpdateText>
                <ImportFiles>
                    <Item>maps/ynamp-utilities.js</Item>
                    <Item>icons/happy_cat.png</Item>
                </ImportFiles>
                <UpdateIcons>
                    <Item>icons/ynamp-icons.xml</Item>
                </UpdateIcons>
                <ScenarioScripts>
                    <Item>scenario/test.js</Item>
                </ScenarioScripts>
            </Actions>
        </ActionGroup>
        <ActionGroup id="shell-ynamp" scope="shell" criteria="always">
            <Actions>
                <UpdateDatabase>
                    <Item>config/config.xml</Item>
                </UpdateDatabase>
                <UpdateText>
                    <Item>text/en_us/MapText.xml</Item>
                </UpdateText>
                <ImportFiles>
                    <Item>icons/happy_cat.png</Item>
                </ImportFiles>
                <UpdateIcons>
                    <Item>icons/ynamp-icons.xml</Item>
                </UpdateIcons>
            </Actions>
        </ActionGroup>
    </ActionGroups>
    <LocalizedText>
        <File>text/en_us/ModuleText.xml</File>
    </LocalizedText>
</Mod>


The mod ID here will be used in the path creation
XML:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="ged-ynamp" version="1"
    xmlns="ModInfo">

The .png is imported in the file system, the Icons DB is updated with <UpdateIcons>
XML:
                <ImportFiles>
                    <Item>icons/happy_cat.png</Item>
                </ImportFiles>
                <UpdateIcons>
                    <Item>icons/ynamp-icons.xml</Item>
                </UpdateIcons>


XML example to replace an existing icon, note how the mod ID ("ged-ynamp") is used in the file path
XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Database>
    <IconDefinitions>
        <Replace>
            <ID>ADVISOR_CULTURE</ID>
            <Path>fs://game/ged-ynamp/icons/happy_cat.png</Path>
            <Context>CIRCLE_MASK</Context>
        </Replace>
    </IconDefinitions>
</Database>

Result:

1739482624242.png
 
Last edited:
So it seems there's an alpha channel missing for the graphics.
I guess you can get that info from any of the ingame icons.

if we could access them, yes, I suppose, problem is they are packed ATM.

but I've no doubt we'll find out, this is just the very first step, and the tools will come at some point anyway.
 
This is a fantastic help. Thank you for figuring this out.

but I've no doubt we'll find out, this is just the very first step, and the tools will come at some point anyway.

Instant gratification for the win :P
 
Any thoughts on the IconString="cult_whatever" or IconString="tech_whatever" for the civic and tech tree icons? As far as I can tell they are pulling directly from a .blp and aren't defined or given an ID in an .xml file / the database.

e.g. cult_mysticism or tech_sailing

Relevant files are:
progression-trees-culture-common.xml
progression-trees-culture-unique.xml
progression-trees-tech.xml

Located in:
Base\modules\age-antiquity\data\
Base\modules\age-exploration\data\
Base\modules\age-modern\data\
 
And some follow up, if I rename the cat to cult_qing (no file type) i get this in civilopedia yet the tree remains the same.

1739499240095.png


1739499643840.png


Using just this super basic .modinfo

XML:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="zinfinions-custom-unique-civics-colors" version="1"
    xmlns="ModInfo">
    <Properties>
        <Name>Custom Unique Civics Colors</Name>
        <Description>Customizes the unique civics colors.</Description>
        <Authors>zinfinion</Authors>
        <Package>Mod</Package>
        <AffectsSavedGames>0</AffectsSavedGames>
    </Properties>
    <Dependencies>
        <Mod id="base-standard" title="LOC_MODULE_BASE_STANDARD_NAME"/>
    </Dependencies>
    <ActionCriteria>
        <Criteria id="always">
            <AlwaysMet></AlwaysMet>
        </Criteria>
    </ActionCriteria>
    <ActionGroups>
        <ActionGroup id="base-game-main-zinfinions-custom-unique-civics-colors" scope="game" criteria="always">
            <Actions>
                <ImportFiles>
                    <Item>icons/cult_qing</Item>
                </ImportFiles>
            </Actions>
        </ActionGroup>
    </ActionGroups>
</Mod>
 
1739503394343.png

Quick update - it works with civilizations too. Once again, thank you for solving a major pain point for me. Really appreciated it!
 
Quick update - it works with civilizations too. Once again, thank you for solving a major pain point for me. Really appreciated it!
Can you share the details on how you made the png image? I've tried to make a civ icon and it's just white when unselected and black when selected.
 
Can you share the details on how you made the png image? I've tried to make a civ icon and it's just white when unselected and black when selected.
Did you make a png? The background needs to be transparent since the game checks for that. The grey parts around each icon are semi transparent parts. I can upload a sample pic later
 
Can you share the details on how you made the png image? I've tried to make a civ icon and it's just white when unselected and black when selected.
Sounds like you have a transparency issue. Make sure the background is transparent, and not white or some other solid color.
 
Can you share the details on how you made the png image? I've tried to make a civ icon and it's just white when unselected and black when selected.
I cannot share the .adesign file here, but here's the png

White symbol, and I added a semi transparent outline that's grey, with a transparent background. This is the closest I can get to the official civ icons with reasonable effort (which I'll revisit when they can get extracted).

civ_sym_philippines.png
 
I figured out how to import icon for new civics.

XML:
<IconDefinitions>
    <!-- civic -->
    <Row>
        <ID>cult_zhou_china</ID>
        <Path>fs://game/zhou-china/textures/cult_zhou_china.png</Path>
    </Row>  
</IconDefinitions>

The cult_zhou_china.png is imported in same ways in modinfo.

Code:
<ActionGroup id="shell-zhou" scope="shell" criteria="always">
    <Actions>
        <ImportFiles>
            <Item>textures/cult_zhou_china.png</Item>
        </ImportFiles>
       
        <UpdateIcons>
            <Item>icons/icons.xml</Item>
        </UpdateIcons>

    </Actions>
</ActionGroup>
20250221115125_1.jpg
 
Any ideas how to:
a) Change city banner (remove leader and add civilization sign/make it transparent)
b) Change resource icons
c) Change yield icons
 
Back
Top Bottom