Difference between revisions of "AddIconToken"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Created page with "<onlyinclude> Not really sure - think this places an icon marker on the minimap </onlyinclude> There are two variants, one of which will also accept a color (SColor). <syntax...")
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<onlyinclude>
 
<onlyinclude>
Not really sure - think this places an icon marker on the minimap
+
This defines a token (e.g. $EmptyShop$) for icon replacement in menus and suchlike.
 
</onlyinclude>
 
</onlyinclude>
There are two variants, one of which will also accept a color ([[SColor]]).
+
 
<syntaxhighlight lang="cpp">void AddIconMarker( const string &marker, const string &texture, dimension2di frameDimension, int frame, [[SColor]] color )</syntaxhighlight>
+
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 AddIconToken( const string &token, const string &texture, dimension2di frameDimension, int frame, SColor color )
 +
void AddIconToken( const string &token, const string &token, dimension2di frameDimension, int frame )</syntaxhighlight>
  
 
Example from Entities/Characters/Scripts/BuilderInventory.as:
 
Example from Entities/Characters/Scripts/BuilderInventory.as:
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
void [[onInit]]( [[CInventory]]@ this )
+
void onInit( CInventory@ this )
 
{
 
{
   AddIconMarker( "$EmptyShop$", "Entities/Workshops/Sprites/WorkshopIcons.png", dimension2di(16,16), 0 );
+
   AddIconToken( "$EmptyShop$", "Entities/Workshops/Sprites/WorkshopIcons.png", dimension2di(16,16), 0 );
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
This icon token means that whenever $EmptyShop$ is included in menu text, the first frame of the WorkshopIcons.png spritesheet will be substituted in.
  
 
[[Category:Scripting]]
 
[[Category:Scripting]]
 
[[Category:Global Functions]]
 
[[Category:Global Functions]]

Latest revision as of 14:03, 20 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.

void AddIconToken( const string &token, const string &texture, dimension2di frameDimension, int frame, SColor color )
void AddIconToken( const string &token, const string &token, dimension2di frameDimension, int frame )

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

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

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