• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

MyResourceBar

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.

Introduction

MyResourceBar is a System that adds addtional Resource Bars below the default Bar. Each of such a custom ResourceBar can show 4 resources. The Resources have an text, icon and a tooltip. The Icon and tooltips can be configured to be unqiue for each player.

When your map has only 1 Multiboard, 1 Leaderboard. Then they will fit below the bars (y-wise).


How To install

Copy the ResourceBar Trigger-Folder into your map.
Export
MyResourceBar.fdf
MyResourceBar.toc

import them into your map keeping the war3mapimported folder prefix.


Examples

  • MyResourceBar Change data
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • -------- Player part of the array --------
      • -------- 100 should be the number choosen in function MyResourceBarPlayerSize --------
      • Set PlayerIndex = (100 x (Player number of (Owner of (Killing unit))))
      • -------- Change Data of player at index 11. --------
      • -------- Index 11 is the first resource in the first addtional Bar. --------
      • Set MyResourceValue[(PlayerIndex + 11)] = ((Owner of (Killing unit)) Units Killed)
      • Set MyResourceValue[(PlayerIndex + 12)] = ((Owner of (Killing unit)) Heroes Killed)
      • Set MyResourceValue[(PlayerIndex + 13)] = ((Owner of (Killing unit)) Structures Razed)
      • Set MyResourceValue[(PlayerIndex + 14)] = ((Owner of (Killing unit)) Items Gained)
  • MyResourceBarInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Icons of Custom Resource Bars --------
      • -------- 11 is the icon for the 1. Resource of the 1. Custom ResourceBar --------
      • -------- 12 is the icon for the 2. Resource of the 1. Custom ResourceBar --------
      • -------- 23 is the icon for the 3. Resource of the 2. Custom ResourceBar --------
      • Set MyResourceBarIcons[11] = ReplaceableTextures\CommandButtons\BTNSteelMelee.blp
      • Set MyResourceBarIcons[12] = ReplaceableTextures\CommandButtons\BTNHumanArmorUpOne.blp
      • Set MyResourceBarIcons[13] = ReplaceableTextures\CommandButtons\BTNPriestAdept.blp
      • Set MyResourceBarIcons[14] = ReplaceableTextures\CommandButtons\BTNSorceressAdept.blp
      • -------- Icons of Custom Resource Bar 2 --------
      • Set MyResourceBarIcons[21] = ReplaceableTextures\CommandButtons\BTNOrcMeleeUpOne.blp
      • Set MyResourceBarIcons[22] = ReplaceableTextures\CommandButtons\BTNSteelArmor.blp
      • Set MyResourceBarIcons[23] = ReplaceableTextures\CommandButtons\BTNLiquidFire.blp
      • Set MyResourceBarIcons[24] = ReplaceableTextures\CommandButtons\BTNEnsnare.blp
      • -------- Tooltips of Custom Bar 1 --------
      • Set MyResourceBarTooltipTitle[11] = Swords
      • Set MyResourceBarTooltipTitle[12] = Shields
      • Set MyResourceBarTooltipTitle[13] = Wands
      • Set MyResourceBarTooltipTitle[14] = Books
      • Set MyResourceBarTooltipText[11] = Swords are gained frequently by smiths
      • Set MyResourceBarTooltipText[12] = Shields are needed by tanks
      • Set MyResourceBarTooltipText[13] = Wands give spell dmg
      • Set MyResourceBarTooltipText[14] = Books are requiered by Spellcasters
      • -------- Tooltips of Custom Bar 2 --------
      • Set MyResourceBarTooltipTitle[21] = Axes
      • Set MyResourceBarTooltipTitle[22] = Bucklers
      • Set MyResourceBarTooltipTitle[23] = Fire Bombs
      • Set MyResourceBarTooltipTitle[24] = Nets
      • Set MyResourceBarTooltipText[21] = Axes can hurt
      • Set MyResourceBarTooltipText[22] = Not as heavy as shields
      • Set MyResourceBarTooltipText[23] = Nice aoe damge
      • Set MyResourceBarTooltipText[24] = No one wil escape our riders
      • -------- One could define player specific Icons and Tooltips by using an offset 100 * Number of Player (Red uses 1) --------
      • -------- The 100 is the playerArraySize, it should match MyResourceBarPlayerSize() --------
      • -------- The next Line would Let player Red have unique Icon and tooltips for Reosurce 1 of Bar 1 --------
      • Set MyResourceBarIcons[111] = ReplaceableTextures\CommandButtons\BTNCreatureAttack.blp
      • Set MyResourceBarTooltipTitle[111] = Claws
      • Set MyResourceBarTooltipText[111] = Claws are found by creatures

Source Code


JASS:
//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


Changelog

V1.2d tooltipBox are now as Big as needed for the TooltipText.
V1.2c
There is now a function at the top of the jass code to change the text below the checkbox.
Fused BoxedText.fdf and MyResourceBar.fdf, The tooltip frames do not have generic names anymore.​
V1.2b
MyResourceValue is now of Type String allows displaying non numbers. Increased max chars in one custom field to 10.​
V1.2a
In replaymode: Icons and Tooltips of Resourcebars update now to the current observed players data.​
V1.2
The show Checkbox to toggle visiblity for custom ResourceBars won't be created in replay mode anymore.
Fixed shown values in replaymode.​
V1.1
Bars are now positionated relative to a World Frame Point
Moved the tooltips offset values into definition function at the top of code.​
Previews
Contents

MyResourceBar 1.2d (Map)

Reviews
MyPad
Moved to Substandard due to a new iteration of the resource, which can be downloaded here: MyResourceField That being said, this is still fully operational and can be reliably used without too much worry. (Deprecation)

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Thanks for making this. It helps a lot with figuring out how this UI stuff works.

Here's some suggestions if you plan on expanding upon this system.
Note that I'm not sure if these are even possible:

1) A Boolean to Hide the default Gold/Lumber/Food UI. "HideDefaultResourceUI = True/False"

2) A variable to define which part of the screen you want to anchor the UI. For example you could have a variable named "AnchorPosition" that you can set to either Top Left, Top Right, Bottom Left, Bottom Right, Bottom Center, or Top Center. The position of the UI you use in your map would be considered Top Right.

3) An option to replace the default Gold/Lumber/Food UI with the new UI.
So if you set the "AnchorPosition" to "Top Right" and set "ReplaceDefaultUI = True" then your new UI bars will start at the position of the default resource bar (replacing it) instead of below it.

4) Variables to define the position of the Hide Resources button. Corners, near the CommandCard, etc..
 
Last edited:
1) A Boolean to Hide the default Gold/Lumber/Food UI. "HideDefaultResourceUI = True/False"
One could hide the default Icons and shown text, would also affect the tooltips which is good. But hiding the background is only doable with sideeffects, cause they are only accessable over their parent beeing ConsoleUI. ConsoleUI shows all background texture, icluding also the top left one and the ones at bottom and does alot of other stuff.
Easier might be not hiding it, instead moving it out of the screen which can sometimes somehow expend the time to exith the map/game.Other ugly sideffects: hero buttons and Upkeep warning message do move, if one moves the upper part of ConsolUI.

2) A variable to define which part of the screen you want to anchor the UI. For example you could have a variable named "AnchorPosition" that you can set to either Top Left, Top Right, Bottom Left, Bottom Right, Bottom Center, or Top Center. The position of the UI you use in your map would be considered Top Right.
On default UI, Other positions would colide with other UI. Top Left would be an option, if one pushes down the heroes. With Bottom you mean the bottom of the screen or above the bottom UI? But I think it would not look that well, cause the current used texture is looking down. The border downwards is much stronger then upwards.

But it is possible.

4) Variables to define the position of the Hide Resources button. Corners, near the CommandCard, etc..
One can choose at the start of the jass code which x/y pos the checkbox takes.

Thanks for your feedback.
I might consider your ideas.
 
Last edited:

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Great system.

I love that you added the functionality to move the bars at different locations of the screen.

I've got a question tho:
There doesn't seem to be an option to change the amount of resources on a bar (Currently 4)?

Unless I am missing it, I think it would be a nice addition.
 
There doesn't seem to be an option to change the amount of resources on a bar (Currently 4)?
The current apporach copies the default resourcebar in background texture with that the amount of possible fields per resourcebar. To support more resourcefields it would be requiered to scale down the size of each resource, increasing the bar size or have multiple resources in one field. If one has only 1 digit numbers one could probably have 3 resources in one resourcefield (at least it looks like it could work in a photoshop test), But that will look quite squeezed.

I ask myself if it would be better to change the type of MyResourceValue to string. Then one could display something like 3/4 or III.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
I am basically trying to use your system to display Custom Hero Stats as opposed to Resources.

I tried to go for a bottom center positioning:

Stats.png



However, the default tooltip for abilities (and other) collides with it there:

Collision.png



So, I was wondering if an alternative, 4x2 (Green) instead of 2x4 (Red) setup would work, which would result in something like this:

Setup.png




I ask myself if it would be better to change the type of MyResourceValue to string. Then one could display something like 3/4 or III.
I'd love to see that, since I was trying to have a stat be for example "0%" instead of simply "0"
 
Uploaded V1.2b. It changed the type of value to string and increased the max amount of chars in one field to 10 from 8.

This resource has hardcoded 4 field bars. I probably soon release a resource creating fields one by one instead of bars with 4. Creating them one by one, allows such 2x4 boxes. They also will be smaller.

You also colide at bottomLeft. The only 2 places you do not colide with something is FRAMEPOINT_TOPLEFT and FRAMEPOINT_CENTER.
 
Level 20
Joined
Jul 12, 2010
Messages
1,717
First of all, please don't tell me that after creating MyResourceField you will drop support for this :(

Second: I seem to have a bit of trouble moving the "hide box" to the place I want, when I set the X to 0.79 it looks like this:
ResourceBar2.jpg
Setting it to anything from 0.8 and above just makes it disappear, why I can't move it in the area I highlighted?

Anyway right now I'm using it like this:
ResourceBar1.jpg
It's working just fine! As I said before, you made a very useful and easy to modify system :)

Also another minor thing you might want to consider is adding an option to change the "HideResources" text.
Yes I know it's easy to find it and manually change it and only takes 5 minutes(the first time) but I'm just making a suggestion :p
 
Second: I seem to have a bit of trouble moving the "hide box" to the place I want, when I set the X to 0.79 it looks like this:
Setting it to anything from 0.8 and above just makes it disappear, why I can't move it in the area I highlighted?
Thats cause this system uses a Gluecheckbox which is a frame, normal Frames can only be in the 4:3 screen. Only SimpleFrames can be moved into the 16:9 Area.
 
Top