Difference between revisions of "AddIconToken"

From King Arthur's Gold Wiki
Jump to: navigation, search
Line 5: Line 5:
  
 
There are two variants, one of which will also accept a color ([[SColor]]), used as a background colour.
 
There are two variants, one of which will also accept a color ([[SColor]]), used as a background colour.
<syntaxhighlight lang="cpp">void AddIconMarker( const string &token, const string &texture, dimension2di frameDimension, int frame, [[SColor]] color )
+
<pre><syntaxhighlight lang="cpp">void AddIconMarker( const string &token, const string &texture, dimension2di frameDimension, int frame, [[SColor]] color )
void AddIconMarker( const string &marker, const string &token, dimension2di frameDimension, int frame )</syntaxhighlight>
+
void AddIconMarker( const string &marker, const string &token, dimension2di frameDimension, int frame )</syntaxhighlight></pre>
  
 
Example from Entities/Characters/Scripts/BuilderInventory.as:
 
Example from Entities/Characters/Scripts/BuilderInventory.as:

Revision as of 16:38, 15 August 2012

This defines a token (e.g. $EmptyShop$) for icon replacement in menus and suchlike.

It takes a string representing the token to be replaced, a string giving the filepath to the spritesheet, the dimensions of the sprite and the frame number of the spritesheet to use.

There are two variants, one of which will also accept a color (SColor), used as a background colour.

<syntaxhighlight lang="cpp">void AddIconMarker( const string &token, const string &texture, dimension2di frameDimension, int frame, [[SColor]] color )
void AddIconMarker( const string &marker, const string &token, dimension2di frameDimension, int frame )</syntaxhighlight>

Example from Entities/Characters/Scripts/BuilderInventory.as:

void [[onInit]]( [[CInventory]]@ this )
{
  AddIconMarker( "$EmptyShop$", "Entities/Workshops/Sprites/WorkshopIcons.png", dimension2di(16,16), 0 );
}

This icon marker means that whenever $EmptyShop$ is included in menu text, the first frame of the WorkshopIcons.png spritesheet will be substituted in.