1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  5. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  6. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  7. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  8. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

MyResourceField

Submitted by Tasyen
This bundle is marked as pending. It has not been reviewed by a staff member yet.

Introduction


MyResourceField is an UI-System allowing to create ResourceFields on the screen. Out of the Box it also creates a table of Resource Fields at a point of the world Frame, that tables position row and col count can be changed. Through it is quite easy to place loose ones anywhere on the screen.

With MyResourceField you will not be able to create ResourceBars that look like the default one.

How to Install


Copy the MyResourceField Trigger-Folder into your map.

Export
MyResourceField.fdf
MyResourceField.toc

Import them into your map keeping the war3mapimported folder prefix.

MyResourceField uses "ResourceBarFrame" as parent for its SIMPLEFRAMEs. if you do not show the default ResourceBar, you have to change this parentship, Inside function MyResourceFieldInit.



The Trigger MyResourceField will update all custom created ResourceFields 5 times a second. One could disable that trigger to stop the updating.

How to write to ResourceFields


MyResourceFieldValue is an String Array. The values of the arrayMembers is displayed in the ResourceFields. That array is splited into sections, Every player uses a part of it hence one needs 2 indexes to access it.

MyResourceFieldValue[PlayerIndex * MyResourceFieldPlayerSize() + resourceField Creation Index]
MyResourceFieldPlayerSize() is in the jass code at the top a function on default 100.
To write onto field 1 for player red one would have to write onto MyResourceFieldValue[101] cause Reds section starts at 100 and the first Field is 1; 100 + 1 = 101.
In this setting one can have maximum 100 custom Fields, if one wants more one needs to increase the value MyResourceFieldPlayerSize() returns and fit your MyResourceFieldValue access acording to that.

GUI Examples



  • This GUI Trigger changes the shown-data for a player killing an unit.
    • MyResourceField Change data
      • Events
        • Unit - A unit Dies
      • Conditions
      • Actions
        • -------- Player part of the array --------
        • -------- 100 should be the number choosen in function MyResourceFieldPlayerSize --------
        • Set PlayerIndex = (100 x (Player number of (Owner of (Killing unit))))
        • Set MyResourceFieldValue[(PlayerIndex + 1)] = (String(((Owner of (Killing unit)) Units Killed)))
        • Set MyResourceFieldValue[(PlayerIndex + 2)] = (String(((Owner of (Killing unit)) Heroes Killed)))
        • Set MyResourceFieldValue[(PlayerIndex + 3)] = (String(((Owner of (Killing unit)) Structures Razed)))
        • Set MyResourceFieldValue[(PlayerIndex + 4)] = (String(((Owner of (Killing unit)) Items Gained)))
        • Set MyResourceFieldValue[(PlayerIndex + 5)] = |cff6f2583I|r|cffff0000V|r
        • Set MyResourceFieldValue[(PlayerIndex + 6)] = 100%
        • Set MyResourceFieldValue[(PlayerIndex + 7)] = 523/893
        • Set MyResourceFieldValue[(PlayerIndex + 8)] = IIIII


  • This Trigger creates 3 loose ResourceFields somewhere on the screen. The coordinates are absolute and one should look into [JASS/AI] - UI: Positionate Frames when using this.
    • MyReosurceField CreateFreeOnes
      • Events
        • Time - Elapsed game time is 0.01 seconds
      • Conditions
      • Actions
        • -------- This Trigger should happen after 0.00s, to avoid colliding with the autogenerated fields. --------
        • -------- Set the X andY then run CreateFree to generate a ResourceField with its Bottom Left at that abs point --------
        • Set MyResourceFieldFreeX = 0.40
        • Set MyResourceFieldFreeY = 0.30
        • Trigger - Run MyResourceFieldCreateFree (ignoring conditions)
        • Set MyResourceFieldFreeX = 0.50
        • Set MyResourceFieldFreeY = 0.40
        • Trigger - Run MyResourceFieldCreateFree (ignoring conditions)
        • Set MyResourceFieldFreeX = 0.30
        • Set MyResourceFieldFreeY = 0.30
        • Trigger - Run MyResourceFieldCreateFree (ignoring conditions)


  • In this Init Trigger one defines Icons and Tooltips for MyResourceFields. MyResourceField supports chaninging Icons and tooltips during the game. As it also supports player specific Icons Tooltips. At the end of this trigger an example is shown Resource Filed 1 will show a claw for Player Red.
    • MyResourceFieldInit
      • Events
        • Map initialization
      • Conditions
      • Actions
        • -------- Icons of Custom Resource Fields --------
        • Set MyResourceFieldIcons[1] = ReplaceableTextures\CommandButtons\BTNSteelMelee.blp
        • Set MyResourceFieldIcons[2] = ReplaceableTextures\CommandButtons\BTNHumanArmorUpOne.blp
        • Set MyResourceFieldIcons[3] = ReplaceableTextures\CommandButtons\BTNPriestAdept.blp
        • Set MyResourceFieldIcons[4] = ReplaceableTextures\CommandButtons\BTNSorceressAdept.blp
        • Set MyResourceFieldIcons[5] = ReplaceableTextures\CommandButtons\BTNOrcMeleeUpOne.blp
        • Set MyResourceFieldIcons[6] = ReplaceableTextures\CommandButtons\BTNSteelArmor.blp
        • Set MyResourceFieldIcons[7] = ReplaceableTextures\CommandButtons\BTNLiquidFire.blp
        • Set MyResourceFieldIcons[8] = ReplaceableTextures\CommandButtons\BTNEnsnare.blp
        • -------- Tooltips --------
        • Set MyResourceFieldTooltipTitle[1] = Swords
        • Set MyResourceFieldTooltipTitle[2] = Shields
        • Set MyResourceFieldTooltipTitle[3] = Wands
        • Set MyResourceFieldTooltipTitle[4] = Books
        • Set MyResourceFieldTooltipText[1] = Swords are gained frequently by smiths
        • Set MyResourceFieldTooltipText[2] = Shields are needed by tanks
        • Set MyResourceFieldTooltipText[3] = Wands give spell dmg
        • Set MyResourceFieldTooltipText[4] = Books are requiered by Spellcasters
        • Set MyResourceFieldTooltipTitle[5] = Axes
        • Set MyResourceFieldTooltipTitle[6] = Bucklers
        • Set MyResourceFieldTooltipTitle[7] = Fire Bombs
        • Set MyResourceFieldTooltipTitle[8] = Nets
        • Set MyResourceFieldTooltipText[5] = Axes can hurt
        • Set MyResourceFieldTooltipText[6] = Not as heavy as shields
        • Set MyResourceFieldTooltipText[7] = Nice aoe damge
        • Set MyResourceFieldTooltipText[8] = 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 MyResourceFieldPlayerSize() --------
          • -------- The next Line would Let player Red have unique Icon and tooltips for Resource 1 --------
          • Set MyResourceFieldIcons[101] = ReplaceableTextures\CommandButtons\BTNCreatureAttack.blp
          • Set MyResourceFieldTooltipTitle[101] = Claws
          • Set MyResourceFieldTooltipText[101] = Claws are found by creatures
          • -------- Default values for all Players. --------
          • -------- Without default values the ResourceFields will show no text. --------
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Set PlayerIndex = (100 x (Player number of (Picked player)))
              • For each (Integer A) from 1 to 8, do (Actions)
                • Loop - Actions
                  • Set MyResourceFieldValue[(PlayerIndex + (Integer A))] = 0


  • When selecting Blutmagier show all for player red.
    • MyReosurceField CustomHiding Select
      • Events
        • Player - Player 1 (Red) Selects a unit
      • Conditions
        • (Triggering unit) Equal to Blutmagier 0000 <gen>
      • Actions
        • Set PlayerIndex = (100 x (Player number of (Triggering player)))
        • -------- Should all CustomResources be hidden for that player? --------
        • Set MyResourceFieldHideData[(Player number of (Triggering player))] = False
        • -------- hide ResourceField 1 for that player? --------
        • Set MyResourceFieldHideData[(PlayerIndex + 1)] = False
        • Trigger - Run MyResourceFieldHideTrigger (ignoring conditions)

    When deselecting Blutmagier hide field 1 for player red.
    • MyReosurceField CustomHiding Deselect
      • Events
        • Player - Player 1 (Red) Deselects a unit
      • Conditions
        • (Triggering unit) Equal to Blutmagier 0000 <gen>
      • Actions
        • Set PlayerIndex = (100 x (Player number of (Triggering player)))
        • -------- Should all CustomResources be hidden for that player? --------
        • Set MyResourceFieldHideData[(Player number of (Triggering player))] = False
        • -------- hide ResourceField 1 for that player? --------
        • Set MyResourceFieldHideData[(PlayerIndex + 1)] = True
        • Trigger - Run MyResourceFieldHideTrigger (ignoring conditions)


    • MyResourceField Custom Tooltip Size
      • Events
        • Time - Elapsed game time is 1.00 seconds
      • Conditions
      • Actions
        • -------- Change the size of the TooltipBox of MyResourceField 1 to that value --------
        • Custom script: call BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBoxedText", 1), 0.285, 0.0365)


  • Definitions inside the jass code. They define some default behaviour.
    Code (vJASS):


    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, ysize)
    function MyResourceFieldTooltipSizeX takes nothing returns real
       return 0.285
    endfunction
    function MyResourceFieldTooltipSizeY takes nothing returns real
       return 0.06
    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
     


  • Lua

    Code (Lua):

    --MyResourceField 1.2a
    --By Tasyen
    do
       local Settings = {}
     
       Settings.PlayerSectionSize = 100 --the array is splited into sections of size 100. Each section is used by one . Player Red uses 101 to 200. Blue Takes 201 to 300, allows to have 100 MyResourceFields.
     
       Settings.CreateCheckBox = true --(true) create a checkbox to tooggle visiblity of the additional ResourceBarFrames
       Settings.CheckBoxX = 0.1 --abs point of checkbox
       Settings.CheckBoxY = 0.57
       Settings.CheckBoxText = "Hide Resources"
     
       --Default Position of the TooltipBoxes its absolute
       Settings.TooltipX = 0.8
       Settings.TooltipY = 0.16
       Settings.TooltipPoint = FRAMEPOINT_BOTTOMRIGHT
       --Default Sizes of TooltipBoxes
       Settings.TooltipSizeX = 0.285
       Settings.TooltipSizeY = 0.06
       --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.
       --BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBoxedText", x), xsize, ysize)
     
       Settings.AutoCreateCols = 3
       Settings.AutoCreateRows = 2 --0 or below will not create any Fields.
       Settings.AutoCreateColsAddEachRow = 0 --rows after the first one gain this amount of cols. -values are valid
       --where to create the autocreated Fields, this point is relative to world Frame.
       Settings.AutoCreatePoint = FRAMEPOINT_BOTTOM
     
       --Offset from the relative point, to positionate the first autocreated field.
       Settings.AutoCreatePointX = -0.15
       Settings.AutoCreatePointY = 0.005
     
       Settings.FieldSizeX = 0.064
       Settings.FieldSizeY = 0.0218

       --not really settings.
       Settings.LastLineStart = 0 --which field to be relative to when starting a new row
     
       local function UpdateBars()
           local playerIndex
           local index = 1
     
           --share visiblity for tooltips to Resources
           BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossF",0), BlzFrameIsVisible(BlzGetFrameByName("MyResourceFieldBossS",0)))
           if Settings.CreateCheckBox then --Has checkbox enabled?
               BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldCheckBox",0), not bj_cineModeAlreadyIn) --hide in cinematic
               BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldCheckBoxLabel",0), not bj_cineModeAlreadyIn)
           end

           if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then --not replay mode?
               playerIndex = GetConvertedPlayerId(GetLocalPlayer()) * Settings.PlayerSectionSize
           else
               playerIndex = (R2I(BlzFrameGetValue(BlzGetFrameByName("ReplayVisionMenu",0))) + 1) * Settings.PlayerSectionSize
           end
     
           --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
           repeat
               BlzFrameSetText(BlzGetFrameByName("MyResourceFieldText", index), udg_MyResourceFieldValue[playerIndex + index])
         
               if udg_MyResourceFieldIcons[playerIndex + index] == "" then
                   BlzFrameSetTexture(BlzGetFrameByName("MyResourceFieldIcon", index), udg_MyResourceFieldIcons[index], 0 ,true)
               else
                   BlzFrameSetTexture(BlzGetFrameByName("MyResourceFieldIcon", index), udg_MyResourceFieldIcons[playerIndex + index], 0 ,true)
               end
               if udg_MyResourceFieldTooltipText[playerIndex + index] == "" then
                   BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", index), udg_MyResourceFieldTooltipText[index])
               else
                   BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", index), udg_MyResourceFieldTooltipText[playerIndex + index])
               end
               if udg_MyResourceFieldTooltipTitle[playerIndex + index] == "" then
                   BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", index), udg_MyResourceFieldTooltipTitle[index]..": "..udg_MyResourceFieldValue[playerIndex  +index])
               else
                   BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", index), udg_MyResourceFieldTooltipTitle[playerIndex + index]..": "..udg_MyResourceFieldValue[playerIndex + index])
               end

               index = index + 1
           until index > udg_MyResourceFieldCount

       end

       local function CreateTooltip(targetFrameLeft, targetFrameRight, title, text, index)
           local box = BlzGetFrameByName("MyResourceFieldBossF",0)
           local fhHover = BlzCreateFrameByType("FRAME", "MyResourceHover", box, "", index)
           local tooltipBox = BlzCreateFrame("MyResourceFieldBoxedText", box,0, index)
           BlzFrameSetPoint(fhHover, FRAMEPOINT_BOTTOMLEFT, targetFrameLeft, FRAMEPOINT_BOTTOMLEFT, 0, 0)
           BlzFrameSetPoint(fhHover, FRAMEPOINT_TOPRIGHT, targetFrameRight, FRAMEPOINT_TOPRIGHT, 0, 0)
           BlzFrameSetTooltip(fhHover, tooltipBox)
     
           BlzFrameSetAbsPoint(tooltipBox, Settings.TooltipPoint, Settings.TooltipX, Settings.TooltipY)
           BlzFrameSetSize(tooltipBox, Settings.TooltipSizeX, Settings.TooltipSizeY)
     
           BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", index), title)
           BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", index), text)
       end

       function CreateMyResourceFieldFree(x, y)
           udg_MyResourceFieldCount = udg_MyResourceFieldCount + 1
           local field = BlzCreateSimpleFrame("MyResourceField", BlzGetFrameByName("MyResourceFieldBossS",0), udg_MyResourceFieldCount)
           BlzFrameSetAbsPoint(field, FRAMEPOINT_BOTTOMLEFT, x, y)
           BlzFrameSetSize(field, Settings.FieldSizeX, Settings.FieldSizeY)
           BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBackground", udg_MyResourceFieldCount), Settings.FieldSizeX, Settings.FieldSizeY + 0.0102)
           CreateTooltip(BlzGetFrameByName("MyResourceFieldIcon", udg_MyResourceFieldCount), BlzGetFrameByName("MyResourceFieldText", udg_MyResourceFieldCount), udg_MyResourceFieldTooltipTitle[udg_MyResourceFieldCount], udg_MyResourceFieldTooltipText[udg_MyResourceFieldCount], udg_MyResourceFieldCount)
       end

       function CreateMyResourceField(newLine)
           udg_MyResourceFieldCount = udg_MyResourceFieldCount + 1
           local field = BlzCreateSimpleFrame("MyResourceField", BlzGetFrameByName("MyResourceFieldBossS",0), udg_MyResourceFieldCount)
     
           if udg_MyResourceFieldCount == 1 then --if this is the first create one Pos it below the default one
               BlzFrameSetPoint(field, Settings.AutoCreatePoint, BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME,0), Settings.AutoCreatePoint, Settings.AutoCreatePointX, Settings.AutoCreatePointY)
               Settings.LastLineStart = 1
           else
     
               if not newLine then
                   if Settings.AutoCreatePoint == FRAMEPOINT_BOTTOMLEFT or Settings.AutoCreatePoint == FRAMEPOINT_TOPLEFT or Settings.AutoCreatePoint == FRAMEPOINT_LEFT or Settings.AutoCreatePoint == FRAMEPOINT_TOP or Settings.AutoCreatePoint == FRAMEPOINT_BOTTOM then
                       BlzFrameSetPoint(field, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldCount - 1), FRAMEPOINT_TOPRIGHT, 0, 0)
                   elseif Settings.AutoCreatePoint == FRAMEPOINT_BOTTOMRIGHT or Settings.AutoCreatePoint == FRAMEPOINT_RIGHT or Settings.AutoCreatePoint == FRAMEPOINT_TOPRIGHT then
                       BlzFrameSetPoint(field, FRAMEPOINT_TOPRIGHT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldCount - 1), FRAMEPOINT_TOPLEFT, 0, 0)
                   else
                       BlzFrameSetPoint(field, FRAMEPOINT_TOPRIGHT, BlzGetFrameByName("MyResourceField", udg_MyResourceFieldCount - 1), FRAMEPOINT_TOPLEFT, 0, 0)
                   end
               else
                   if Settings.AutoCreatePoint == FRAMEPOINT_TOPRIGHT or Settings.AutoCreatePoint == FRAMEPOINT_TOPLEFT or Settings.AutoCreatePoint == FRAMEPOINT_LEFT or Settings.AutoCreatePoint == FRAMEPOINT_TOP or Settings.AutoCreatePoint == FRAMEPOINT_RIGHT or Settings.AutoCreatePoint == FRAMEPOINT_CENTER then
                       BlzFrameSetPoint(field, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("MyResourceField", Settings.LastLineStart), FRAMEPOINT_BOTTOMLEFT, 0, 0)
                   else
                       BlzFrameSetPoint(field, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("MyResourceField", Settings.LastLineStart), FRAMEPOINT_TOPLEFT, 0, 0)
                   end
                   Settings.LastLineStart = udg_MyResourceFieldCount
               end
           end
           BlzFrameSetSize(field, Settings.FieldSizeX, Settings.FieldSizeY)
           BlzFrameSetSize(BlzGetFrameByName("MyResourceFieldBackground", udg_MyResourceFieldCount), Settings.FieldSizeX, Settings.FieldSizeY + 0.0102)
           CreateTooltip(BlzGetFrameByName("MyResourceFieldIcon", udg_MyResourceFieldCount), BlzGetFrameByName("MyResourceFieldText", udg_MyResourceFieldCount), udg_MyResourceFieldTooltipTitle[udg_MyResourceFieldCount], udg_MyResourceFieldTooltipText[udg_MyResourceFieldCount], udg_MyResourceFieldCount)
       end

       local function CustomHide()
           local index = udg_MyResourceFieldCount
           local playerIndex
           local playerId
           if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then --not Replay Mode?
               playerId = GetConvertedPlayerId(GetLocalPlayer())
           else
               playerId = R2I(BlzFrameGetValue(BlzGetFrameByName("ReplayVisionMenu",0))) + 1 --Replay Mode use the  observed
           end
           playerIndex = playerId * Settings.PlayerSectionSize
     
           --Wana hide all, yes -> hide the parent?
           BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossSBest",0), not udg_MyResourceFieldHideData[playerId])
     
           --Hide Specific Fields for that .
           repeat
               BlzFrameSetVisible(BlzGetFrameByName("MyResourceField", index), not udg_MyResourceFieldHideData[playerIndex + index])
               BlzFrameSetVisible(BlzGetFrameByName("MyResourceHover", index), not udg_MyResourceFieldHideData[playerIndex + index])
               index = index -1
           until index == 0
       end
     
       local function CreateCheckBoxFunction()
           local trig = CreateTrigger()
           local fh = BlzCreateFrameByType("GLUECHECKBOX", "MyResourceFieldCheckBox", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"QuestCheckBox",0)
           local fhText = BlzCreateFrameByType("TEXT", "MyResourceFieldCheckBoxLabel", fh, "", 0)
     
           BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, Settings.CheckBoxX, Settings.CheckBoxY)
           BlzFrameSetPoint(fhText, FRAMEPOINT_TOP, fh, FRAMEPOINT_BOTTOM, 0.0, 0.0)
           BlzFrameSetEnable(fhText, false)
           BlzFrameSetText(fhText, Settings.CheckBoxText)
           BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_CHECKED)
           BlzTriggerRegisterFrameEvent(trig, fh, FRAMEEVENT_CHECKBOX_UNCHECKED)
           TriggerAddAction(trig, function()
               if GetTriggerPlayer() == GetLocalPlayer() then --only do something for the  having pressed the checkbox
                   BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossF",0), BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
                   BlzFrameSetVisible(BlzGetFrameByName("MyResourceFieldBossS",0), BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_UNCHECKED)
               end
           end
           )
       end
     
       function MyResourceFieldInit()
           BlzLoadTOCFile("war3mapImported\\MyResourceField.toc")
           BlzCreateFrameByType("FRAME", "MyResourceFieldBossF", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0),"",0) --Parent of Frames (tooltips stuff)
           BlzCreateFrameByType("SIMPLEFRAME", "MyResourceFieldBossSBest", BlzGetFrameByName("ResourceBarFrame",0),"",0) --Upper Parent of the SimpleFrames it is used for the Hide Feature.
           BlzCreateFrameByType("SIMPLEFRAME", "MyResourceFieldBossS", BlzGetFrameByName("MyResourceFieldBossSBest",0),"",0) --Parent of SimpleFrames (bar and its content)

           --Transform the setup Trigger into updating the bars
           TriggerClearActions(gg_trg_MyResourceField)
           TriggerClearConditions(gg_trg_MyResourceField)
           TriggerAddAction(gg_trg_MyResourceField, UpdateBars)
           TriggerRegisterTimerEventPeriodic(gg_trg_MyResourceField , 0.2)


           udg_MyResourceFieldCreateFree = CreateTrigger()
           TriggerAddAction(udg_MyResourceFieldCreateFree, function() CreateMyResourceFieldFree(udg_MyResourceFieldFreeX, udg_MyResourceFieldFreeY) end)

           udg_MyResourceFieldHideTrigger = CreateTrigger()
           TriggerAddAction(udg_MyResourceFieldHideTrigger, CustomHide)
     
           --AutoCreate as soon game started.
           TimerStart(CreateTimer(),0.0,false, function()
               local rows = 1
               local cols
               local colsExit = Settings.AutoCreateCols
               if not BlzFrameIsVisible(BlzGetFrameByName("SimpleReplayPanel",0)) then
                   TriggerAddAction(gg_trg_MyResourceField, UpdateBars)
                   if Settings.CreateCheckBox then
                       CreateCheckBoxFunction()
                   end
               else
                   TriggerAddAction(gg_trg_MyResourceField, UpdateBars)
               end
         
               if Settings.AutoCreateRows > 0 then
                   repeat
                       cols = 1
                       repeat
                           CreateMyResourceField(cols == 1)
                           cols = cols + 1
                           until cols > colsExit
                       rows = rows + 1
                       colsExit = colsExit + Settings.AutoCreateColsAddEachRow
                   until rows > Settings.AutoCreateRows or colsExit <= 0
               end
               DestroyTimer(GetExpiredTimer())
           end
           )
       end
    end

     

    Jass

    Code (vJASS):

    //MyResourceField 1.2a
    //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, ysize)
    function MyResourceFieldTooltipSizeX takes nothing returns real
       return 0.285
    endfunction
    function MyResourceFieldTooltipSizeY takes nothing returns real
       return 0.06
    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])
           call BlzFrameSetVisible(BlzGetFrameByName("MyResourceHover", 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
     
       //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 udg_MyResourceFieldTooltipText[playerIndex + index] == null then
               call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", index), udg_MyResourceFieldTooltipText[index])
           else
               call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", index), udg_MyResourceFieldTooltipText[playerIndex + index])
           endif
           if udg_MyResourceFieldTooltipTitle[playerIndex + index] == null then
               call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", index), udg_MyResourceFieldTooltipTitle[index]+": "+udg_MyResourceFieldValue[playerIndex  +index])
           else
               call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", index), udg_MyResourceFieldTooltipTitle[playerIndex + index]+": "+udg_MyResourceFieldValue[playerIndex + index])
           endif

           set index = index + 1
           exitwhen index > udg_MyResourceFieldCount
       endloop

    endfunction

    function MyResourceFieldCreateTooltip takes framehandle targetFrameLeft, framehandle targetFrameRight, string title, string text, integer index returns nothing
       local framehandle box = BlzGetFrameByName("MyResourceFieldBossF",0)
       local framehandle fhHover = BlzCreateFrameByType("FRAME", "MyResourceHover", box, "", index)
       local framehandle tooltipBox = BlzCreateFrame("MyResourceFieldBoxedText", 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, MyResourceFieldTooltipPoint(), MyResourceFieldTooltipX(), MyResourceFieldTooltipY())
       call BlzFrameSetSize(tooltipBox, MyResourceFieldTooltipSizeX(), MyResourceFieldTooltipSizeY())
     
       call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextTitle", index), title)
       call BlzFrameSetText(BlzGetFrameByName("MyResourceFieldBoxedTextValue", index), text)
     
       set box = null
       set fhHover = null
       set tooltipBox = null
    endfunction

    function CreateMyResourceFieldFree takes nothing returns nothing
       local framehandle field = BlzCreateSimpleFrame("MyResourceField", BlzGetFrameByName("MyResourceFieldBossS",0), 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 MyResourceFieldCreateTooltip(BlzGetFrameByName("MyResourceFieldIcon", udg_MyResourceFieldCount), BlzGetFrameByName("MyResourceFieldText", udg_MyResourceFieldCount), udg_MyResourceFieldTooltipTitle[udg_MyResourceFieldCount], udg_MyResourceFieldTooltipText[udg_MyResourceFieldCount], udg_MyResourceFieldCount)
     
       set field = null
    endfunction

    function CreateMyResourceField takes boolean newLine returns nothing
       local framehandle field = BlzCreateSimpleFrame("MyResourceField", BlzGetFrameByName("MyResourceFieldBossS",0), udg_MyResourceFieldCount + 1)
     
       set udg_MyResourceFieldCount = udg_MyResourceFieldCount + 1
       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)
       call MyResourceFieldCreateTooltip(BlzGetFrameByName("MyResourceFieldIcon", udg_MyResourceFieldCount), BlzGetFrameByName("MyResourceFieldText", udg_MyResourceFieldCount), udg_MyResourceFieldTooltipTitle[udg_MyResourceFieldCount], udg_MyResourceFieldTooltipText[udg_MyResourceFieldCount], udg_MyResourceFieldCount)
     
       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()
       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)
     
       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.2)
       call TimerStart(CreateTimer(),0.0, false, function MyResourceFieldInit)
       call TriggerAddAction(udg_MyResourceFieldCreateFree, function CreateMyResourceFieldFree)
       call TriggerAddAction(udg_MyResourceFieldHideTrigger, function MyResourceFieldCustomHiding)

        call BlzLoadTOCFile("war3mapImported\\MyResourceField.toc")
    endfunction

     




Changelog


1.2a
Removed some unneeded code.
Added a Lua version.​
V1.2
New feature: Show/Hide All MyResourceFields or specific ones for one player.
Added a demo trigger showing how to change the size of a tooltip box after it was created.
The Default TooltipBox size is now also a function at the top of jass code.​
V1.1a
Checkbox creation does now consider the settings​
V1.1
Hides itself during Cinematics.
Outsourced the CheckboxLabelText into a function at top of the code.​
Previews
Contents

MyResourceField 1.2a (Map)

MyResourceField 1.2a Lua (Map)

  1. MyPad

    MyPad

    Spell Reviewer

    Joined:
    May 9, 2014
    Messages:
    1,304
    Resources:
    7
    Models:
    1
    Icons:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    7
    The UI natives are already complex enough as they are. Making this just shows how juicy the new wc3 natives can be, and how one can complement the UI display of wc3, or supersede it, making a completely new game.

    Kudos to you!

    With this, will MyResourceBar be deprecated? This is more generic, and appears to fulfil the purpose of the resource above as well.
     
  2. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,295
    Resources:
    16
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    4
    JASS:
    1
    Resources:
    16
    Yes, one can move MyResourceBar to graveyard or whaterver or should I delete it.
    Although this is not able to create exact copies of the normal resourcebar. That is cause the normal Resourcebar is based on 3 Textures. MyResourceField only uses 1 of them and only a small part of that used Texture (1 Field).
     
  3. SpasMaster

    SpasMaster

    Joined:
    Jan 29, 2010
    Messages:
    1,868
    Resources:
    4
    Icons:
    2
    Maps:
    2
    Resources:
    4
    Very glad you put this out.

    I only encountered 2 issues so far:

    1) The Toggle Checkbox is visible during Cinematic Mode, which kinda annoying:

    HideStats.png


    2) Once more during Cinematic Mode, while moving your mouse, if you happen to land on where the stats window is supposed to be, the tooltips will appear:

    2.png


    Here are the solutions I have in mind:
    • For the first issue - perhaps a boolean variable that we can set to True or False to enable/disable the checkbox? That way, as soon as a cinematic starts/ends, one would be able to enable/disable the checkbox.
    • For the second issue - once more a boolean that either has the checkbox ticked or not by default. If it's ticked by default (aka, Resources hidden by default), there will be nothing to mouse over during cinematics.
     
  4. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,295
    Resources:
    16
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    4
    JASS:
    1
    Resources:
    16
    Uploaded V1.1a. MyResourceField detects now cinematic mode started by the GUI action (by checking for bj_cineModeAlreadyIn). Inside such a cinematic this system now hides the checkbox, its label and all custom ResourceFields.

    Checkbox creation does now consider the settings
     
    Last edited: Jul 13, 2019
  5. Kelroy

    Kelroy

    Joined:
    May 29, 2019
    Messages:
    15
    Resources:
    0
    Resources:
    0
    Wow, I tried it to implement it in my RPG map, it is quite usefull as i can add easely into a UI a player Spell Power and custom stats like that :eek:

    10/10
     
  6. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,295
    Resources:
    16
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    4
    JASS:
    1
    Resources:
    16
    Uploaded V1.2.
    One can now hide all MyResourceFields or single ones player specific, by setting up a boolean array (MyResourceFieldHideData) and using a Trigger (MyResourceFieldHideTrigger). MyResourceFieldHideData is a hide feature when one sets a field to true, it will not be shown, use false to show it.
    When MyResourceFieldHideTrigger runs it reads MyResourceFieldHideData: a true at a playerIndex (GUI-Indexing) will hide all custom created MyResourceFields. Setting true at 100 * PlayerIndex + 1 will hide the 1.MyResourceField for that player. 100 should match the return value of function MyResourceFieldPlayerSize. For Player Red that would result into MyResourceFieldHideData[101] = true; to hide Field 1.
    When one never uses MyResourceFieldHideTrigger, it won't have any effect.
    There is now an further parent for the simpleframes named "MyResourceFieldBossSBest" which made that feature easier to create without coliding with the checkbox feature.​

    Added a demo GUI Trigger; showing how to change the size of a tooltip box after it was created.

    Moved the default size values of tooltipboxes into functions at top of the jass code.
     
  7. GhostOfPast

    GhostOfPast

    Joined:
    Feb 8, 2015
    Messages:
    283
    Resources:
    1
    Template:
    1
    Resources:
    1
    Quite useful indeed. I may suggest a way to hide separately each icons for each players (for example when a resource/info is unlocked) though it's quite nitpick.
    It would make marvels combined with a custom ressource library.
     
  8. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,266
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    Supremely useful, I applaud your efforts to document the new UI natives.
     
  9. DarkImagine

    DarkImagine

    Joined:
    Saturday
    Messages:
    1
    Resources:
    0
    Resources:
    0
    Very useful, but how to apply this system to this - Resource System
    I tried, but nothing happens...
     
  10. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,295
    Resources:
    16
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    4
    JASS:
    1
    Resources:
    16
    Did you import the two files inside the demo Map to your map?
    war3mapImported\MyResourceField.fdf
    war3mapImported\MyResourceField.toc
    After you placed them were they were. You have to tell MyResorceField what to display.
    Example Trigger for the default resources of the linked system.
    Code (vJASS):

    function Trig_Show_Resources_Actions takes nothing returns nothing
        local integer playerId = GetPlayerId(GetLocalPlayer())
        set udg_PlayerIndex = ( 100 * GetConvertedPlayerId(GetLocalPlayer()) )
        set udg_MyResourceFieldValue[udg_PlayerIndex + 1] = I2S(PlayerResource[playerId][Wood])
        set udg_MyResourceFieldValue[udg_PlayerIndex + 2] = I2S(PlayerResource[playerId][Food])
        set udg_MyResourceFieldValue[udg_PlayerIndex + 3] = I2S(PlayerResource[playerId][Stone])
        set udg_MyResourceFieldValue[udg_PlayerIndex + 4] = I2S(PlayerResource[playerId][Gold])
    endfunction
    //===========================================================================
    function InitTrig_Show_Resources takes nothing returns nothing
        set gg_trg_Show_Resources = CreateTrigger(  )
        call TriggerRegisterTimerEventPeriodic( gg_trg_Show_Resources, 1.00 )
        call TriggerAddAction( gg_trg_Show_Resources, function Trig_Show_Resources_Actions )
    endfunction