//MyResourceBar 1.2c
//By Tasyen
function MyResourceBarPlayerSize takes nothing returns integer
return 100 //each player has 100 slots allwing upto 9 additional bars (on default). MyResourceBarAutoCreateCount * MyResourceBarDataSize should not reach that number
endfunction
function MyResourceBarDataSize takes nothing returns integer
return 10 //each Bar takes that amount of slots
endfunction
function MyResourceBarAutoCreateCount takes nothing returns integer
return 2 //Create this amount of addtional Bars automatically.
endfunction
//Allow and Pos the checkbox hidding the additional Bars.
function MyResourceBarCreateCheckBox takes nothing returns boolean
return true //(true) create a checkbox to tooggle visiblity of the additional ResourceBarFrames
endfunction
function MyResourceBarCheckBoxLabelText takes nothing returns string
return "Hide Resources"
endfunction
function MyResourceBarCheckBoxX takes nothing returns real
return 0.1
endfunction
function MyResourceBarCheckBoxY takes nothing returns real
return 0.57
endfunction
//Where is the tooltip of this Bars placed.
function MyResourceBarTooltipX takes nothing returns real
return 0.8
endfunction
function MyResourceBarTooltipY takes nothing returns real
return 0.16
endfunction
function MyResourceBarTooltipPoint takes nothing returns framepointtype
return FRAMEPOINT_BOTTOMRIGHT
endfunction
function MyResourceBarAnchor takes nothing returns framepointtype
//Poses the first Bar where in the world Frame?
//I suggest to use a y-offset when using any Bottom Point.
//return FRAMEPOINT_TOPLEFT
//return FRAMEPOINT_TOP
return FRAMEPOINT_TOPRIGHT
//return FRAMEPOINT_BOTTOMLEFT
//return FRAMEPOINT_BOTTOM
//return FRAMEPOINT_BOTTOMRIGHT
//return FRAMEPOINT_LEFT
//return FRAMEPOINT_RIGHT
//return FRAMEPOINT_CENTER
endfunction
function MyResourceBarAnchor1OffsetX takes nothing returns real
return 0.0 //Offset the first bar by that amount from its FramePoint
endfunction
function MyResourceBarAnchor1OffsetY takes nothing returns real
return 0.0
endfunction
function MyResourceBarCreateTooltip takes framehandle targetFrameLeft, framehandle targetFrameRight, string title, string text, integer index returns nothing
local framehandle box = BlzGetFrameByName("MyResourceBarBoss",0)
local framehandle fhHover = BlzCreateFrameByType("FRAME", "MyResourceHover", box, "", index)
local framehandle tooltipBox = BlzCreateFrame("MyResourceBarBoxedText", box,0, index)
call BlzFrameSetPoint(fhHover, FRAMEPOINT_BOTTOMLEFT, targetFrameLeft, FRAMEPOINT_BOTTOMLEFT, 0, 0)
call BlzFrameSetPoint(fhHover, FRAMEPOINT_TOPRIGHT, targetFrameRight, FRAMEPOINT_TOPRIGHT, 0, 0)
call BlzFrameSetTooltip(fhHover, tooltipBox)
call BlzFrameSetAbsPoint(tooltipBox, MyResourceBarTooltipPoint(), MyResourceBarTooltipX(), MyResourceBarTooltipY())
call BlzFrameSetSize(tooltipBox, 0.285, 0.06)
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", index), title)
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", index), text)
set box = null
set fhHover = null
set tooltipBox = null
endfunction
function MyResourceBarSetup takes integer barIndex returns nothing //create an additonal ResourceBar between the orginal one.
local integer playerIndex = GetConvertedPlayerId(GetLocalPlayer()) * MyResourceBarPlayerSize()
local integer dataIndex = barIndex*MyResourceBarDataSize()
local integer loopIndex = 1
call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar1Icon", barIndex), BlzGetFrameByName("MyResourceBar1Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 1], udg_MyResourceBarTooltipText[dataIndex +1], dataIndex + 1)
call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar2Icon", barIndex), BlzGetFrameByName("MyResourceBar2Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 2], udg_MyResourceBarTooltipText[dataIndex +2], dataIndex + 2)
call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar3Icon", barIndex), BlzGetFrameByName("MyResourceBar3Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 3], udg_MyResourceBarTooltipText[dataIndex +3], dataIndex + 3)
call MyResourceBarCreateTooltip(BlzGetFrameByName("MyResourceBar4Icon", barIndex), BlzGetFrameByName("MyResourceBar4Text", barIndex), udg_MyResourceBarTooltipTitle[dataIndex + 4], udg_MyResourceBarTooltipText[dataIndex +4], dataIndex + 4)
loop
if udg_MyResourceBarIcons[playerIndex + dataIndex + loopIndex] == null or udg_MyResourceBarIcons[playerIndex + dataIndex + loopIndex] == "" then
call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(loopIndex)+"Icon", barIndex), udg_MyResourceBarIcons[dataIndex + loopIndex], 0 ,true)
else
call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(loopIndex)+"Icon", barIndex), udg_MyResourceBarIcons[playerIndex + dataIndex + loopIndex], 0 ,true)
endif
if udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + loopIndex] != null then //player specific Tooltip?
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + loopIndex), udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + loopIndex])
endif
if udg_MyResourceBarTooltipText[playerIndex + dataIndex + loopIndex] != null then //player specific TooltipText?
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", dataIndex + loopIndex), udg_MyResourceBarTooltipText[playerIndex + dataIndex + loopIndex])
endif
set loopIndex = loopIndex + 1
exitwhen loopIndex == 5
endloop
endfunction
function CreateMyResourceBar takes nothing returns nothing
local framehandle bar = BlzCreateSimpleFrame("MyResourceBarFrame", BlzGetFrameByName("MyResourceBarBoss2",0), udg_MyResourceBarCount + 1)
set udg_MyResourceBarCount = udg_MyResourceBarCount + 1
if udg_MyResourceBarCount == 1 then //if this is the first create one Pos it below the default one
call BlzFrameSetPoint(bar, MyResourceBarAnchor(), BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME,0), MyResourceBarAnchor(), MyResourceBarAnchor1OffsetX(), MyResourceBarAnchor1OffsetY())
else
if MyResourceBarAnchor() == FRAMEPOINT_TOPRIGHT or MyResourceBarAnchor() == FRAMEPOINT_TOPLEFT or MyResourceBarAnchor() == FRAMEPOINT_TOP then
call BlzFrameSetPoint(bar, FRAMEPOINT_TOP, BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount - 1), FRAMEPOINT_BOTTOM, 0, 0)
elseif MyResourceBarAnchor() == FRAMEPOINT_BOTTOMLEFT or MyResourceBarAnchor() == FRAMEPOINT_BOTTOM or MyResourceBarAnchor() == FRAMEPOINT_BOTTOMRIGHT then
call BlzFrameSetPoint(bar, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount - 1), FRAMEPOINT_TOPLEFT, 0, 0)
else
call BlzFrameSetPoint(bar, FRAMEPOINT_TOP, BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount - 1), FRAMEPOINT_BOTTOM, 0, 0)
endif
endif
call MyResourceBarSetup(udg_MyResourceBarCount)
set bar = null
endfunction
function MyResourceBarUpdateBarsReplay takes nothing returns nothing
local integer playerIndex = (R2I(BlzFrameGetValue(BlzGetFrameByName("ReplayVisionMenu",0))) + 1) * MyResourceBarPlayerSize()
local integer i
local integer barIndex = 1
local integer dataIndex
//Takes over all udg_MyResourceValue data into the MyResourceBarFrames also updates the title
//The outher Loop are the Bars, the inner Loop handles the tooltipTitle update
loop
set dataIndex = barIndex*MyResourceBarDataSize()
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar1Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 1])
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar2Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 2])
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar3Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 3])
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar4Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 4])
set i = 1
loop
if udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i] == null then
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[dataIndex + i]+": "+udg_MyResourceValue[playerIndex +dataIndex + i])
else
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i]+": "+udg_MyResourceValue[playerIndex +dataIndex + i])
endif
if udg_MyResourceBarTooltipText[playerIndex + dataIndex + i] == null then
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", dataIndex + i), udg_MyResourceBarTooltipText[dataIndex + i])
else
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextValue", dataIndex + i), udg_MyResourceBarTooltipText[playerIndex + dataIndex + i])
endif
if udg_MyResourceBarIcons[playerIndex + dataIndex + i] == null or udg_MyResourceBarIcons[playerIndex + dataIndex + i] == "" then
call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(i)+"Icon", barIndex), udg_MyResourceBarIcons[dataIndex + i], 0 ,true)
else
call BlzFrameSetTexture(BlzGetFrameByName("MyResourceBar"+I2S(i)+"Icon", barIndex), udg_MyResourceBarIcons[playerIndex + dataIndex + i], 0 ,true)
endif
set i = i + 1
exitwhen i == 5
endloop
set barIndex = barIndex + 1
exitwhen barIndex > udg_MyResourceBarCount
endloop
endfunction
function MyResourceBarUpdateBars takes nothing returns nothing
local integer playerIndex = GetConvertedPlayerId(GetLocalPlayer()) * MyResourceBarPlayerSize()
local integer i
local integer barIndex = 1
local integer dataIndex
//Takes over all udg_MyResourceValue data into the MyResourceBarFrames also updates the title
//The outher Loop are the Bars, the inner Loop handles the tooltipTitle update
loop
set dataIndex = barIndex*MyResourceBarDataSize()
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar1Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 1])
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar2Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 2])
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar3Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 3])
call BlzFrameSetText(BlzGetFrameByName("MyResourceBar4Text", barIndex), udg_MyResourceValue[playerIndex + dataIndex + 4])
set i = 1
loop
if udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i] == null then
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[dataIndex + i]+": "+udg_MyResourceValue[playerIndex +dataIndex + i])
else
call BlzFrameSetText(BlzGetFrameByName("MyResourceBarBoxedTextTitle", dataIndex + i), udg_MyResourceBarTooltipTitle[playerIndex + dataIndex + i]+": "+udg_MyResourceValue[playerIndex +dataIndex + i])
endif
set i = i + 1
exitwhen i == 5
endloop
set barIndex = barIndex + 1
exitwhen barIndex > udg_MyResourceBarCount
endloop
endfunction
function MyResourceBarsFitFrames takes nothing returns nothing
local framehandle leadbor = BlzGetFrameByName("Leaderboard",0)
local framehandle multi = BlzGetFrameByName("Multiboard",0)
local framehandle time = BlzGetFrameByName("TimerDialog",0)
local framehandle prev = BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount)
local framehandle resourcebar = BlzGetFrameByName("ResourceBarFrame", 0)
local real yPlus = -0.005
if MyResourceBarAnchor() == FRAMEPOINT_TOPRIGHT then
if not BlzFrameIsVisible(BlzGetFrameByName("MyResourceBarFrame", udg_MyResourceBarCount)) then
set prev = resourcebar
set yPlus = -0.0165
endif
if time != null then //bugs if the 1. timer window is destroyed
call BlzFrameSetPoint(time, FRAMEPOINT_TOPRIGHT, prev, FRAMEPOINT_BOTTOMRIGHT, 0, -0.005 + yPlus)
set yPlus = 0
set prev = time
endif
if multi != null then //bugs if the current shown multiboard is not the last created one
call BlzFrameSetPoint(multi, FRAMEPOINT_TOPRIGHT, prev, FRAMEPOINT_BOTTOMRIGHT, 0, -0.005 + yPlus)
set yPlus = 0
set prev = multi
endif
if leadbor != null then//bugs if the current shown leaderboard is not the last created one
call BlzFrameSetPoint(leadbor, FRAMEPOINT_TOPRIGHT, prev, FRAMEPOINT_BOTTOMRIGHT, 0, -0.005 + yPlus)
set yPlus = 0
set prev = leadbor
endif
endif
set leadbor = null
set multi = null
set time = null
set prev = null
set resourcebar = null
endfunction
function MyResourceBarsCheckBox takes nothing returns nothing
//In some test BlzGetFrameByName could disconnect the game hence done for all players
local framehandle fh = BlzGetFrameByName("MyResourceBarBoss",0)
local framehandle fh2 = BlzGetFrameByName("MyResourceBarBoss2",0)
if GetTriggerPlayer() == GetLocalPlayer() then //only do something for the player having pressed the checkbox
call BlzFrameSetVisible(fh, BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
call BlzFrameSetVisible(fh2, BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
endif
set fh = null
set fh2 = null
call MyResourceBarsFitFrames()
endfunction
function MyResourceBarCreateCheckBoxAction takes nothing returns nothing
local trigger trig = CreateTrigger()
local framehandle fh = BlzCreateFrameByType("GLUECHECKBOX", "MyResourceBarCheckBox", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"QuestCheckBox",0)
local framehandle fhText = BlzCreateFrameByType("TEXT", "MyResourceBarCheckBoxLabel", fh, "", 0)
call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, MyResourceBarCheckBoxX(), MyResourceBarCheckBoxY())
call BlzFrameSetPoint(fhText, FRAMEPOINT_TOP, fh, FRAMEPOINT_BOTTOM, 0.0, 0.0)
call BlzFrameSetEnable(fhText, false)
call BlzFrameSetText(fhText, MyResourceBarCheckBoxLabelText())
call BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_CHECKED)
call BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_UNCHECKED)
call TriggerAddAction(trig, function MyResourceBarsCheckBox)
set fh = null
set fhText = null
set trig = null
endfunction
function MyResourceBarsCreate takes nothing returns nothing
//Create Hide ResourceBar checkbox
local integer i = MyResourceBarAutoCreateCount()
if MyResourceBarCreateCheckBox() and not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then
call MyResourceBarCreateCheckBoxAction()
endif
//Create Parents of the ResourceBarFrames, one needs a SIMPLEFRAME and a FRAME. They allow to easyly hide/show the ResourceBarFrames
call BlzCreateFrameByType("FRAME", "MyResourceBarBoss", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"",0) //Parent of Frames (tooltips stuff)
call BlzCreateFrameByType("SIMPLEFRAME", "MyResourceBarBoss2", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"",0) //Parent of SimpleFrames (bar and its content)
//Create ResourceBarFrames
loop
exitwhen i <= 0
call CreateMyResourceBar()
set i = i - 1
endloop
//CleanUP
call DestroyTimer(GetExpiredTimer())
if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then
call TriggerAddAction( gg_trg_MyResourceBar, function MyResourceBarUpdateBars)
else
call TriggerAddAction( gg_trg_MyResourceBar, function MyResourceBarUpdateBarsReplay)
endif
endfunction
//===========================================================================
function InitTrig_MyResourceBar takes nothing returns nothing
set gg_trg_MyResourceBar = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_MyResourceBar , 0.2)
call TimerStart(CreateTimer(),0.0, false, function MyResourceBarsCreate)
call BlzLoadTOCFile("war3mapImported\\MyResourceBar.toc")
endfunction