Find icons in Script

Everything about mods can be found here.

Moderator: Morax

Find icons in Script

Postby Jip » 14 Jul 2016, 15:30

Hello everyone,

I need the icons found in game for a mod that I am making.
I couldn't find a reference anywhere to them myself, and searching these forums didn't help me a lot either.

So, my question is: How do you get the icons of units? For example: An interceptor.
And could you get the generic background they use somehow? (All air units have the same 'airish' background)

It'd really appreciate some help on this, it's the last part of the mod.
The rest already works.

Lots of love,
Jip

PS: The mod is about filtering the current selected units.
For example: filter out all the hover when moving your navy.
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip

Re: Find icons in Script

Postby Myxir » 14 Jul 2016, 18:14

you want to have the unit ID
(if you don't have it, you can get it by u:GetBlueprint().BlueprintId)

then your icon is named:
Code: Select all
unitId..'_icon.dds'

and you can get it via something like:
Code: Select all
   for _, file in DiskFindFiles('/textures/', iconname) do
      return file
   end   


not sure about all the generic backgrouns, but at least some are amph_up.dds, sea_up.dds and land_up.dds
(the 'up' part refers to the state of the curser not beeing over it - when it's over, it's 'over', pressed down is 'down' afaik)
Unhappy with balance http://i.imgur.com/q5G2BlM.png
User avatar
Myxir
Evaluator
 
Posts: 791
Joined: 09 Apr 2012, 14:01
Has liked: 94 times
Been liked: 306 times
FAF User Name: Washy (irc)

Re: Find icons in Script

Postby Jip » 14 Jul 2016, 18:59

Dear Myxir,

Thanks for your reply!

Today, you're my hero Myxir.
I didn't know the unitID's were managed like that, now I can continue working again. Thanks!

I do have something else: perhaps another way of retrieving these icons: GameCommon.GetUnitIconFileNames(BLUEPRINT)
However, this requires a blueprint. Is there a way to get a blueprint in a UI Mod when all you have is the name of the blueprint?

The C function GetUnitBlueprintByName(STRING) does not appear to work, it does work when I use it though a map script.

Lots of love,
Jip
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip

Re: Find icons in Script

Postby Uveso » 15 Jul 2016, 06:36

you can acces the blueprint directly over the global variable __blueprints

Code: Select all
    local FatboyBlueprint = __blueprints['uel0401']
    LOG('***', repr(FatboyBlueprint),'***')


Or you can loop over all blueprints like this :

Code: Select all
    for unitID, unitBLUEPRINT in __blueprints do
        if unitID == 'uel0401' then
            LOG('Unit ID='..unitID)
            LOG('Unit Background='..(unitBLUEPRINT.General.Icon or 'no General.Icon found'))
            IconName = unitID..'_icon.dds'
            Filepath = '/textures/ui/common/icons/units/'
            if DiskFindFiles(Filepath, IconName) then
                LOG('Found Iconfile: '..IconName..' inside directory: '..Filepath)
            else
                LOG('Iconfile not found!')
            end
        end
    end
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: Find icons in Script

Postby Jip » 15 Jul 2016, 13:34

Dear Uveso,

Thank you very much!
I didn't find that global variable myself, it's quite a good one to know about.

Lots of love,
Jip
Jip
Avatar-of-War
 
Posts: 51
Joined: 12 Jul 2015, 22:25
Has liked: 3 times
Been liked: 11 times
FAF User Name: Jip


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest