Name | Type | is_array | initial_value |
MyResourceFieldCount | integer | No | |
MyResourceFieldCreateFree | trigger | No | |
MyResourceFieldFreeX | real | No | |
MyResourceFieldFreeY | real | No | |
MyResourceFieldHideData | boolean | Yes | |
MyResourceFieldHideTrigger | trigger | No | |
MyResourceFieldIcons | imagefile | Yes | |
MyResourceFieldLastLineStart | integer | No | |
MyResourceFieldTooltipText | string | Yes | |
MyResourceFieldTooltipTitle | string | Yes | |
MyResourceFieldValue | string | Yes | |
PlayerIndex | integer | No |
library FrameLoader initializer init_function
// in 1.31 and upto 1.32.9 PTR (when I wrote this). Frames are not correctly saved and loaded, breaking the game.
// This library runs all functions added to it with a 0s delay after the game was loaded.
// function FrameLoaderAdd takes code func returns nothing
// func runs when the game is loaded.
globals
private trigger eventTrigger = CreateTrigger()
private trigger actionTrigger = CreateTrigger()
private timer t = CreateTimer()
endglobals
function FrameLoaderAdd takes code func returns nothing
call TriggerAddAction(actionTrigger, func)
endfunction
private function timerAction takes nothing returns nothing
call TriggerExecute(actionTrigger)
endfunction
private function eventAction takes nothing returns nothing
call TimerStart(t, 0, false, function timerAction)
endfunction
private function init_function takes nothing returns nothing
call TriggerRegisterGameEvent(eventTrigger, EVENT_GAME_LOADED)
call TriggerAddAction(eventTrigger, function eventAction)
endfunction
endlibrary
//MyResourceField 1.4b
//By Tasyen
function MyResourceFieldPlayerSize takes nothing returns integer
return 100 //the array is splited into sections of size 100. Each section is used by one player. Player Red uses 101 to 200. Blue Takes 201 to 300, allows to have 100 MyResourceFields.
endfunction
//Allow and Pos the checkbox hidding the additional Bars.
function MyResourceFieldCreateCheckBox takes nothing returns boolean
return true //(true) create a checkbox to tooggle visiblity of the additional ResourceBarFrames
endfunction
function MyResourceFieldCheckBoxX takes nothing returns real
return 0.1 //abs point of checkbox
endfunction
function MyResourceFieldCheckBoxY takes nothing returns real
return 0.57
endfunction
function MyResourceFieldCheckBoxLabelText takes nothing returns string
return "Hide Resources"
endfunction
//Where is the tooltip of this Bars placed.
function MyResourceFieldTooltipX takes nothing returns real
return 0.8
endfunction
function MyResourceFieldTooltipY takes nothing returns real
return 0.16
endfunction
function MyResourceFieldTooltipPoint takes nothing returns framepointtype
return FRAMEPOINT_BOTTOMRIGHT //Which point of Tooltip is positionate to abs point MyResourceFieldTooltipX/MyResourceFieldTooltipY
endfunction
//Default Sizes of TooltipBoxes
//You could change a TooltipBox size after they were created with: x should be a number from 1 to udg_MyResourceFieldCount. udg_MyResourceFieldCount would be the last created.
//call BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBoxedText", x), xsize, 0)
function MyResourceFieldTooltipSizeX takes nothing returns real
return 0.285
endfunction
function MyResourceFieldAutoCreateCols takes nothing returns integer
return 3
endfunction
function MyResourceFieldAutoCreateColAddEachRow takes nothing returns integer
return 0 //rows after the first one gain this amount of cols. -values are valid
endfunction
function MyResourceFieldAutoCreateRows takes nothing returns integer
return 2 //0 or below will not create any Fields.
endfunction
function MyResourceFieldAnchor 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 MyResourceFieldAnchor1OffsetX takes nothing returns real
return -0.15 //Offset the first bar by that amount from its FramePoint
endfunction
function MyResourceFieldAnchor1OffsetY takes nothing returns real
return 0.005
endfunction
function MyResourceFieldSizeX takes nothing returns real
return 0.064
endfunction
function MyResourceFieldSizeY takes nothing returns real
return 0.0218
endfunction
function MyResourceFieldCustomHiding takes nothing returns nothing
local integer index = udg_MyResourceFieldCount
local integer playerIndex
local integer playerId
if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then //not Replay Mode?
set playerId = GetConvertedPlayerId(GetLocalPlayer())
else
set playerId = R2I(BlzFrameGetValue(BlzGetFrameByName("ReplayVisionMenu",0))) + 1 //Replay Mode use the player observed
endif
set playerIndex = playerId * MyResourceFieldPlayerSize()
//Wana hide all, yes -> hide the parent?
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossSBest",0), not udg_MyResourceFieldHideData[playerId])
//Hide Specific Fields for that player.
loop
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceField", index), not udg_MyResourceFieldHideData[playerIndex + index])
set index = index -1
exitwhen index == 0
endloop
endfunction
function MyResourceFieldUpdateBars takes nothing returns nothing
local integer playerIndex
local integer index = 1
local integer visibleTooltipIndex = 0
//share visiblity for tooltips to Resources
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossF",0), BlzFrameIsVisible(BlzGetFrameByName("MyResourceFieldBossS",0)))
if MyResourceFieldCreateCheckBox() then //Has checkbox enabled?
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldCheckBox",0), not bj_cineModeAlreadyIn) //hide in cinematic
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldCheckBoxLabel",0), not bj_cineModeAlreadyIn)
endif
if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then //not replay mode?
set playerIndex = GetConvertedPlayerId(GetLocalPlayer()) * MyResourceFieldPlayerSize()
else
set playerIndex = (R2I(BlzFrameGetValue(BlzGetFrameByName("ReplayVisionMenu",0))) + 1) * MyResourceFieldPlayerSize()
endif
//Takes over all udg_MyResourceFieldValue data into the MyResourceFields also updates the title
//The outher Loop are the Bars, the inner Loop handles the tooltipTitle update
loop
call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldText", index), udg_MyResourceFieldValue[playerIndex + index])
if udg_MyResourceFieldIcons[playerIndex + index] == null or udg_MyResourceFieldIcons[playerIndex + index] == "" then
call BlzFrameSetTexture(BlzGetFrameByName("MyResourceFieldIcon", index), udg_MyResourceFieldIcons[index], 0 ,true)
else
call BlzFrameSetTexture(BlzGetFrameByName("MyResourceFieldIcon", index), udg_MyResourceFieldIcons[playerIndex + index], 0 ,true)
endif
// if this Frames shows its tooltip then update the tooltip
if BlzFrameIsVisible(BlzGetFrameByName("MyResourceFieldTooltip", index)) then
set visibleTooltipIndex = index
endif
set index = index + 1
exitwhen index > udg_MyResourceFieldCount
endloop
// when an tooltip is visible update the tooltip and show it
if visibleTooltipIndex != 0 then
set index = visibleTooltipIndex
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBoxedText", 0), true)
if udg_MyResourceFieldTooltipText[playerIndex + index] == null then
call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", 0), udg_MyResourceFieldTooltipText[index])
else
call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", 0), udg_MyResourceFieldTooltipText[playerIndex + index])
endif
if udg_MyResourceFieldTooltipTitle[playerIndex + index] == null then
call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", 0), udg_MyResourceFieldTooltipTitle[index]+": "+udg_MyResourceFieldValue[playerIndex +index])
else
call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", 0), udg_MyResourceFieldTooltipTitle[playerIndex + index]+": "+udg_MyResourceFieldValue[playerIndex + index])
endif
else
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBoxedText", 0), false)
endif
endfunction
function CreateMyResourceFieldFree takes nothing returns nothing
local framehandle field = BlzCreateSimpleFrame("MyResourceField", BlzGetFrameByName("MyResourceFieldBossS",0), udg_MyResourceFieldCount + 1)
local framehandle tooltip = BlzCreateFrameByType("SIMPLEFRAME", "MyResourceFieldTooltip", field, "", udg_MyResourceFieldCount + 1)
set udg_MyResourceFieldCount = udg_MyResourceFieldCount + 1
call BlzFrameSetAbsPoint(field, FRAMEPOINT_BOTTOMLEFT, udg_MyResourceFieldFreeX, udg_MyResourceFieldFreeY)
call BlzFrameSetSize(field, MyResourceFieldSizeX(), MyResourceFieldSizeY())
call BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBackground", udg_MyResourceFieldCount), MyResourceFieldSizeX(), MyResourceFieldSizeY() + 0.0102)
call BlzFrameSetTooltip(field, tooltip)
call BlzFrameSetVisible(tooltip, false) // BlzFrameSetTooltip, does not hide the SimpleFrame-tooltip hence enforce it. Does not happen for Frames.
set tooltip = null
set field = null
endfunction
function CreateMyResourceField takes boolean newLine returns nothing
local framehandle field = BlzCreateSimpleFrame("MyResourceField", BlzGetFrameByName("MyResourceFieldBossS",0), udg_MyResourceFieldCount + 1)
local framehandle tooltip = BlzCreateFrameByType("SIMPLEFRAME", "MyResourceFieldTooltip", field, "", udg_MyResourceFieldCount + 1)
set udg_MyResourceFieldCount = udg_MyResourceFieldCount + 1
call BlzFrameSetTooltip(field, tooltip)
call BlzFrameSetVisible(tooltip, false) // BlzFrameSetTooltip, does not hide the SimpleFrame-tooltip hence enforce it. Does not happen for Frames.
set tooltip = null
if udg_MyResourceFieldCount == 1 then //if this is the first create one Pos it below the default one
call BlzFrameSetPoint(field, MyResourceFieldAnchor(), BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME,0), MyResourceFieldAnchor(), MyResourceFieldAnchor1OffsetX(), MyResourceFieldAnchor1OffsetY())
set udg_MyResourceFieldLastLineStart = 1
else
if not newLine then
if MyResourceFieldAnchor() == FRAMEPOINT_BOTTOMLEFT or MyResourceFieldAnchor() == FRAMEPOINT_TOPLEFT or MyResourceFieldAnchor() == FRAMEPOINT_LEFT or MyResourceFieldAnchor() == FRAMEPOINT_TOP or MyResourceFieldAnchor() == FRAMEPOINT_BOTTOM then
call BlzFrameSetPoint(field, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldCount - 1), FRAMEPOINT_TOPRIGHT, 0, 0)
elseif MyResourceFieldAnchor() == FRAMEPOINT_BOTTOMRIGHT or MyResourceFieldAnchor() == FRAMEPOINT_RIGHT or MyResourceFieldAnchor() == FRAMEPOINT_TOPRIGHT then
call BlzFrameSetPoint(field, FRAMEPOINT_TOPRIGHT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldCount - 1), FRAMEPOINT_TOPLEFT, 0, 0)
else
call BlzFrameSetPoint(field, FRAMEPOINT_TOPRIGHT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldCount - 1), FRAMEPOINT_TOPLEFT, 0, 0)
endif
else
if MyResourceFieldAnchor() == FRAMEPOINT_TOPRIGHT or MyResourceFieldAnchor() == FRAMEPOINT_TOPLEFT or MyResourceFieldAnchor() == FRAMEPOINT_LEFT or MyResourceFieldAnchor() == FRAMEPOINT_TOP or MyResourceFieldAnchor() == FRAMEPOINT_RIGHT or MyResourceFieldAnchor() == FRAMEPOINT_CENTER then
call BlzFrameSetPoint(field, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldLastLineStart), FRAMEPOINT_BOTTOMLEFT, 0, 0)
else
call BlzFrameSetPoint(field, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldLastLineStart), FRAMEPOINT_TOPLEFT, 0, 0)
endif
set udg_MyResourceFieldLastLineStart = udg_MyResourceFieldCount
endif
endif
call BlzFrameSetSize(field, MyResourceFieldSizeX(), MyResourceFieldSizeY())
call BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBackground", udg_MyResourceFieldCount), MyResourceFieldSizeX(), MyResourceFieldSizeY() + 0.0102)
set field = null
endfunction
function MyResourceFieldsCheckBox takes nothing returns nothing
if GetTriggerPlayer() == GetLocalPlayer() then //only do something for the player having pressed the checkbox
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossF",0), BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
call BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossS",0), BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
endif
endfunction
function MyResourceFieldCreateCheckBoxAction takes nothing returns nothing
local trigger trig = CreateTrigger()
local framehandle fh = BlzCreateFrameByType("GLUECHECKBOX", "MyResourceFieldCheckBox", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"QuestCheckBox",0)
local framehandle fhText = BlzCreateFrameByType("TEXT", "MyResourceFieldCheckBoxLabel", fh, "", 0)
call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, MyResourceFieldCheckBoxX(), MyResourceFieldCheckBoxY())
call BlzFrameSetPoint(fhText, FRAMEPOINT_TOP, fh, FRAMEPOINT_BOTTOM, 0.0, 0.0)
call BlzFrameSetEnable(fhText, false)
call BlzFrameSetText(fhText, MyResourceFieldCheckBoxLabelText())
call BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_CHECKED)
call BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_UNCHECKED)
call TriggerAddAction(trig, function MyResourceFieldsCheckBox)
set fh = null
set fhText = null
set trig = null
endfunction
function MyResourceFieldInit takes nothing returns nothing
local integer rows = 1
local integer cols
local integer colsExit = MyResourceFieldAutoCreateCols()
local framehandle tooltip
local framehandle tooltipText
local framehandle tooltipTitle
call BlzLoadTOCFile("war3mapImported\\MyResourceField.toc")
set udg_MyResourceFieldCount = 0
if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then
call TriggerAddAction( gg_trg_MyResourceField, function MyResourceFieldUpdateBars)
if MyResourceFieldCreateCheckBox() then
call MyResourceFieldCreateCheckBoxAction()
endif
else
call TriggerAddAction( gg_trg_MyResourceField, function MyResourceFieldUpdateBars)
endif
call BlzCreateFrameByType("FRAME", "MyResourceFieldBossF", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"",0) //Parent of Frames (tooltips stuff)
call BlzCreateFrameByType("SIMPLEFRAME", "MyResourceFieldBossSBest", BlzGetFrameByName("ResourceBarFrame",0),"",0) //Upper Parent of the SimpleFrames it is used for the Hide Feature.
call BlzCreateFrameByType("SIMPLEFRAME", "MyResourceFieldBossS", BlzGetFrameByName("MyResourceFieldBossSBest",0),"",0) //Parent of SimpleFrames (bar and its content)
set tooltip = BlzCreateFrame("MyResourceFieldBoxedText", BlzGetFrameByName("MyResourceFieldBossF", 0), 0, 0)
set tooltipTitle = BlzGetFrameByName("MyResourceFieldBoxedTextTitle", 0)
set tooltipText = BlzGetFrameByName("MyResourceFieldBoxedTextValue", 0)
// when using TOP LEFT/RIGHT Title is the placed one, otherwise the Text
if GetHandleId(MyResourceFieldTooltipPoint()) <= 2 then
call BlzFrameSetAbsPoint(tooltipTitle, MyResourceFieldTooltipPoint(), MyResourceFieldTooltipX(), MyResourceFieldTooltipY())
call BlzFrameSetPoint(tooltipText, FRAMEPOINT_TOPLEFT, tooltipTitle, FRAMEPOINT_BOTTOMLEFT, 0, -0.002)
else
call BlzFrameSetAbsPoint(tooltipText, MyResourceFieldTooltipPoint(), MyResourceFieldTooltipX(), MyResourceFieldTooltipY())
call BlzFrameSetPoint(tooltipTitle, FRAMEPOINT_BOTTOMLEFT, tooltipText, FRAMEPOINT_TOPLEFT, 0, 0.002)
endif
call BlzFrameSetSize(tooltipTitle, MyResourceFieldTooltipSizeX(), 0)
call BlzFrameSetSize(tooltipText, MyResourceFieldTooltipSizeX(), 0)
call BlzFrameSetPoint(tooltip, FRAMEPOINT_TOPLEFT, tooltipTitle, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(tooltip, FRAMEPOINT_BOTTOMRIGHT, tooltipText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
set tooltip = null
if MyResourceFieldAutoCreateRows()> 0 then
loop
set cols = 1
loop
call CreateMyResourceField(cols == 1)
set cols = cols + 1
exitwhen cols > colsExit
endloop
set rows = rows + 1
set colsExit = colsExit + MyResourceFieldAutoCreateColAddEachRow()
exitwhen rows > MyResourceFieldAutoCreateRows() or colsExit <= 0
endloop
endif
endfunction
//===========================================================================
function InitTrig_MyResourceField takes nothing returns nothing
set gg_trg_MyResourceField = CreateTrigger()
set udg_MyResourceFieldCreateFree = CreateTrigger()
set udg_MyResourceFieldHideTrigger = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( gg_trg_MyResourceField , 0.1)
call TimerStart(CreateTimer(),0.0, false, function MyResourceFieldInit)
call FrameLoaderAdd(function MyResourceFieldInit)
call TriggerAddAction(udg_MyResourceFieldCreateFree, function CreateMyResourceFieldFree)
call TriggerAddAction(udg_MyResourceFieldHideTrigger, function MyResourceFieldCustomHiding)
endfunction