ibrary PlayerHUD
globals
private constant integer COLUMNS = 14
private constant real CLEAR_ITEM_WIDTH = 0.0001
private constant real ICON_WIDTH = 0.01
private constant real NAME_SPACE = 0.01
private constant real NAME_WIDTH = 0.12
private constant string CHAR_ICON = ""
endglobals
struct PlayerHUD
multiboard pHUD
integer Rows
unit PrevSelection
private method formatBlock takes integer row returns nothing
local integer colloop = 0
local integer rowloop = row
local multiboarditem mitem = null
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Clear Rows and Cols for the new block
loop
exitwhen colloop > COLUMNS
loop
exitwhen rowloop > row+3
set mitem = MultiboardGetItem(.pHUD, rowloop, colloop)
call MultiboardSetItemStyle(mitem, false, false)
call MultiboardSetItemWidth(mitem, CLEAR_ITEM_WIDTH) // Sets Cell Width
call MultiboardReleaseItem(mitem) // Clears multiboarditem mitem
set rowloop = rowloop+1
endloop
set rowloop = row
set colloop = colloop+1
endloop
set colloop = 0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Row 2
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Bar Setup
set rowloop = row+1
loop // Loops through col to set Icon only
exitwhen colloop > 11
loop
exitwhen rowloop > row+2
set mitem = MultiboardGetItem(.pHUD, rowloop, colloop)
call MultiboardSetItemStyle(mitem, false, true)
call MultiboardReleaseItem(mitem)
set rowloop = rowloop+1
endloop
set rowloop = row+1
set colloop = colloop+1
endloop
set colloop = 0
endmethod
method createBlock takes unit u, integer row returns nothing
local UnitData udat = LoadInteger(UnitHash, GetHandleId(u), 1)
local multiboarditem mitem = null
set .PrevSelection = u
set .Rows = .Rows+4
call MultiboardSetRowCount(.pHUD, .Rows)
call .formatBlock(row)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Unit Icon
set mitem = MultiboardGetItem(.pHUD, row, 0)
call MultiboardSetItemStyle(mitem, false, true) // Only Icon
call MultiboardSetItemWidth(mitem, ICON_WIDTH) // Sets Cell Width
call MultiboardReleaseItem(mitem) // Clears multiboarditem mitem
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Unit Name Space
set mitem = MultiboardGetItem(.pHUD, row, 1)
call MultiboardSetItemStyle(mitem, false, false)
call MultiboardSetItemWidth(mitem, NAME_SPACE) // Sets Cell Width
call MultiboardReleaseItem(mitem) // Clears multiboarditem mitem
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Unit Name
set mitem = MultiboardGetItem(.pHUD, row, 2)
call MultiboardSetItemStyle(mitem, true, false) // Only Text
call MultiboardSetItemValue(mitem, udat.Name)
call MultiboardSetItemWidth(mitem, NAME_WIDTH) // Sets Cell Width
call MultiboardReleaseItem(mitem) // Clears multiboarditem mitem
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Health Bar Space
set mitem = MultiboardGetItem(.pHUD, row+1, 0)
call MultiboardSetItemStyle(mitem, false, false)
call MultiboardSetItemWidth(mitem, 0.01) // Sets Cell Width
call MultiboardReleaseItem(mitem) // Clears multiboarditem mitem
// Creates the Health Bar that displays on the Multiboard
set udat.uH = MultibarHelper.create(udat.Unit, .pHUD, 1, row+1, 12, MULTIBAR_TYPE_HEALTH, MULTIBAR_HELPER_HEALTH)
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Energy Bar Space
set mitem = MultiboardGetItem(.pHUD, row+2, 0)
call MultiboardSetItemStyle(mitem, false, false)
call MultiboardSetItemWidth(mitem, 0.01) // Sets Cell Width
call MultiboardReleaseItem(mitem) // Clears multiboarditem mitem
// Creates the Energy Bar that displays on the Multiboard
set udat.uE = MultibarHelper.create(udat.Unit, .pHUD, 1, row+2, 12, MULTIBAR_TYPE_MANA, MULTIBAR_HELPER_MANA)
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
call udat.destroy()
endmethod
method removeBlock takes unit u returns nothing
local UnitData udat = LoadInteger(UnitHash, GetHandleId(u), 1)
call udat.uH.destroy()
call udat.uE.destroy()
set .Rows = .Rows-4
call udat.destroy()
endmethod
method activateHUD takes unit u returns nothing
local UnitData udat = LoadInteger(UnitHash, GetHandleId(u), 1)
set .pHUD = CreateMultiboard()
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Set Col and .Rows
set .Rows = 0
call MultiboardSetColumnCount(.pHUD, COLUMNS)
call MultiboardSetRowCount(.pHUD, .Rows)
call .createBlock(udat.Unit, 0)
if (GetOwningPlayer(udat.Unit) == GetLocalPlayer()) then
call MultiboardDisplay(.pHUD, true)
endif
call udat.destroy()
endmethod
endstruct
endlibrary