User Specified Icons

User Specified Icons

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

User Specified Icons

Post by trepan » 23 Nov 2006, 17:52

It is now possible for users to specify their own icons (for the minimap,
and when zoomed out). This will override the mod's icon settings. There
is also a new filename that can be used to load user icons, usericons.tdf.
This file is loaded before the usual icontypes.tdf, and the first icon entry
of a particular name is the one that is used.

The user specification can only be done through the LUA UI interface
(so far). It is also possible to create animated icons (you will have to
have the LUA calls change the icon names at the appropriate times).
The LUA callout is Spring.SetUnitDefIcon(number udid, string "icon").

Here is an example of the code that could be used:

Code: Select all

-- Setup the unitdef icons
for udid,ud in pairs(UnitDefs) do
  if ((udid ~= nil) and (ud ~= nil)) then
    if (ud.origIconType == nil) then
      -- save the original name, in case we want to revert
      ud.origIconType = ud.iconType
    end

    if (ud.isCommander) then
      Spring.SetUnitDefIcon(udid, "x.png")
    elseif (ud.canFly) then   
      Spring.SetUnitDefIcon(udid, "triangle-up.png")
    elseif ((ud.radarRadius > 1) and not ud.canMove) then
      Spring.SetUnitDefIcon(udid, "hourglass-side.png")
    elseif (ud.isBuilding or ud.isFactory) then
      Spring.SetUnitDefIcon(udid, "square.png")
    elseif (ud.isBuilder) then 
      Spring.SetUnitDefIcon(udid, "cross.png")
    end
  end
end
P.S. It looks like this (and other recent changes), will make it into 0.74b1.
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 23 Nov 2006, 17:58

Note that the mod is AA223 (which usually uses the default icon).
Also, the icons in this screenshot are not that good, they need better
outlines.

Image
0 x

Lippy
Posts: 327
Joined: 16 Jul 2006, 00:24

Post by Lippy » 23 Nov 2006, 19:05

Nice work! :-) :-) Will be very useful!
0 x

User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo » 23 Nov 2006, 19:13

Won't that allows us to "cheat" by allowing us to distinguish the enemy commander from the decoys?
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 23 Nov 2006, 19:59

Thanks for the reminder.
(... after having been so careful about it when doing the techLevel stuff)

It's been adjusted so that if an icon is being set for a unitDef that has
isCommand set, or TEDClass = COMMANDER, then ALL unitDefs
that match that description will have their icons set to the specified icon.

P.S. At least XTA and AA use "COMMANDER" as the TEDClass for
their decoy commanders.
0 x

User avatar
FoeOfTheBee
Posts: 557
Joined: 12 May 2005, 18:26

Post by FoeOfTheBee » 23 Nov 2006, 21:37

Will this be based on the iconType fbi tag?

I think I'd prefer that the icon used be determined by UnitName, with the ability to specify icon groups, like this:

Code: Select all

icons.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<icons>

<icon1 img='lvl1air.png'>
<unit>ARMACA</unit>
<unit>ARMBRAWL</unit>
<unit>ARMPNIX</unit>
<unit>ARMLANCE</unit>
<unit>ARMHAWK</unit>
<unit>ARMSEAP</unit>
<unit>ARMAWAC</unit>
<unit>ARMSEHAK</unit>
<unit>ARMCSA</unit>
</icon1>

<icon2 img='lvl1bot.png'>
<unit>ARMCK</unit>
<unit>ARMPW</unit>
<unit>ARMROCK</unit>
<unit>ARMHAM</unit>
<unit>ARMJETH</unit>
<unit>ARMFAST</unit>
</icon2>

</icons>
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 23 Nov 2006, 21:48

I think I prefer my way.

1. The same config can be used with multiple mods with no adjustments.
(and you wont have to categorize 300+ units for some mods)

2. It's much shorter to write out, and much more flexible. My way can even
be setup to look like your way (have the LUA parse an XML file that follows
your format).
0 x

User avatar
AF
AI Developer
Posts: 20667
Joined: 14 Sep 2004, 11:32

Post by AF » 23 Nov 2006, 21:51

Won't that allows us to "cheat" by allowing us to distinguish the enemy commander from the decoys?
Mouse over a true commander and itll say [tech level 0], but mouse over a decoy commander and it'll say [tech level 2]
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 23 Nov 2006, 21:54

AF: and under what conditions does it display the techLevel?
0 x

User avatar
FoeOfTheBee
Posts: 557
Joined: 12 May 2005, 18:26

Post by FoeOfTheBee » 23 Nov 2006, 21:57

trepan wrote:I think I prefer my way.

1. The same config can be used with multiple mods with no adjustments.
(and you wont have to categorize 300+ units for some mods)

2. It's much shorter to write out, and much more flexible. My way can even
be setup to look like your way (have the LUA parse an XML file that follows
your format).
Ok, with 2 you convinced me. Now I'll have to learn LUA...
0 x

User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo » 25 Nov 2006, 15:25

How does techLevel works? That is not specified by the unit definitions is it?

A Description2 must be added to the unit definitions, then. I really don't fancy the idea that the engine will try to figure out the tech level of my units when i know for sure it will get it wrong (for example, the Commander is, by tradition, technology lvl 10).
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 25 Nov 2006, 15:33

The techLevel value is determined from the build tree.
The commanders are techLevel 0, the units they can
build are techLevel 1, and so on. It searches for the
shortest path to build a particular unit. Units types that
are not in the build tree are techLevel -1.

The techLevel is not used by the game directly. I initially
added it to help with the bindbuildtype sorting, but have
since been using it in the LUA UI as well. See the functions
at the end of rts/Sim/Units/UnitDefHandler.cpp.
0 x

User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo » 26 Nov 2006, 18:55

Well, consider the commander, as i said, which is lvl10.

Also, consider some other examples:
XTA! All factories are called lvl-1.
AA, which has the restricted style of factories. First factories are called lvl-1. It's builders and units are called lvl-2. The next factories are called lvl-3, which include the hovercraft plant, which is considered to be a intermediate between lvl-1 and lvl-2 (that is, they are called lvl-1,5 tech).

I'm sorry if you were the one who coded it, i don't want to bash on the work. It is just that i would rather have that under my control.
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 26 Nov 2006, 19:11

That's fine, you aren't bashing my work, you just want something different.
My techLevel assignments do exactly what I want them to do: they provide
access to a unit type's build level in the hierarchical build tree.

You can build all of XTA's factories initially, so having them assigned a
techLevel of 1 means that my code is working just fine.

XTA already uses the FBI "Category" tag to assign levels (LEVEL1, LEVEL2,
LEVEL3). Is that not available to you for whatever it is that you are trying
to do? It's accessible to the engine code, AIs, the keybinding code, and the
LUA UI code (and probably in more places).
0 x

User avatar
Comp1337
Posts: 2434
Joined: 12 Oct 2005, 17:32

Post by Comp1337 » 27 Nov 2006, 12:39

trepan wrote:That's fine, you aren't bashing my work, you just want something different.
My techLevel assignments do exactly what I want them to do: they provide
access to a unit type's build level in the hierarchical build tree.

You can build all of XTA's factories initially, so having them assigned a
techLevel of 1 means that my code is working just fine.

XTA already uses the FBI "Category" tag to assign levels (LEVEL1, LEVEL2,
LEVEL3). Is that not available to you for whatever it is that you are trying
to do? It's accessible to the engine code, AIs, the keybinding code, and the
LUA UI code (and probably in more places).
He wants to maually override the lil nifty UI thing.
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 27 Nov 2006, 15:21

It can be done... sorta. You can tweak the tooltip
contents with the lua interface. I also have a
UnitDef Info lua widget started. It dislays all of the
vital stats for the selected unit type, with sub-panels
for its weapons and whatnot.

Image
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 27 Nov 2006, 17:24

Here's a link to some preliminary user icons:

http://trepan.bzflag.bz/spring/icons

The usericons.tdf file associates texture files to icon names.

The usericons.lua file associates icon names to unit types
(and is best viewed with an editor that supports LUA syntax highlighting)


P.S. The UserIconsUpdate() routine in usericons.lua is
called from the top level Update() call-in (every frame)
0 x

Post Reply

Return to “Lua Scripts”