- Joined
- Jun 21, 2012
- Messages
- 431
JASS:
library IconLibrary/*
****************************************************************************************
*
* ************************************************************************************
*
* */ uses /*
* */ Table /* hiveworkshop.com/forums/jass-functions-413/snippet-new-table-188084/
*
* ************************************************************************************
*
* IconLibrary
* ___________
* v1.0.0.0
* by Thelordmarshall
*
*
* Define yours icons.
*
* Functions:
* __________
* - function SaveIcon takes integer rawCode, string icon returns nothing
* - takes unit or item rawCode and string icon.
* - function GetUnitIcon takes unit u returns string
* - returns icon of unit previusly saved.
* - function GetItemIcon takes item i returns string
* - returns icon of item previusly saved.
****************************************************************************************/
globals
private constant string DEFAULT_ICON = "UI\\Widgets\\Console\\Undead\\undead-inventory-slotfiller.blp"
private Table h
endglobals
function SaveIcon takes integer rawCode, string icon returns nothing
if(not h.string.has(rawCode))then
set h.string[rawCode]=icon
endif
endfunction
function GetUnitIcon takes unit u returns string
local integer id=GetUnitTypeId(u)
if(h.string.has(id))then
return h.string[id]
endif
return DEFAULT_ICON
endfunction
function GetItemIcon takes item i returns string
local integer id=GetItemTypeId(i)
if(h.string.has(id))then
return h.string[id]
endif
return DEFAULT_ICON
endfunction
private module Init
private static method onInit takes nothing returns nothing
set h=Table.create()
endmethod
endmodule
private struct i extends array
implement Init
endstruct
endlibrary