• 🏆 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!

How to move top left hero buttons (ORIGIN_FRAME_HERO_BUTTON)? (faulty code and map file inside)

Status
Not open for further replies.
Level 1
Joined
Jun 27, 2014
Messages
2
Hello! I'm trying to move the top left hero buttons (ORIGIN_FRAME_HERO_BUTTON), but it seems they're stuck to the left side of the hero bar (ORIGIN_FRAME_HERO_BAR).

With some experimentation, it seems hero buttons have two hardcoded UI layout behavior
1. Stick to the left of the hero bar
2. Distribute evenly in the vertical space of the hero bar, with hero #1 icon being at the very top, and hero #7 icon at the very bottom

Below code attempts to reverse the hero icon order, (hero #7, hero #6, etc.) and to move them to be horizontally side by side. It results in this (also please see attached map for the same):
reposition.jpg



Sorry for the long code, I just manually referenced all the UI elements to work with them, instead of looping and such. I called BlzEnableUIAutoPosition(false) as well as BlzFrameClearAllPoints on a bunch of stuff, hoping it would break any anchors these UI elements have, but it seems they still have some sort of anchors, or else I'm just missing something.

Main code

JASS:
scope ScopeName initializer init
    private function init takes nothing returns nothing
     local framehandle fh_game = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI,0)
     local framehandle fh_world = BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME,0)

     local framehandle fh_herobar = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BAR,0)

     local framehandle fh0 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,0)
     local framehandle fh1 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,1)
     local framehandle fh2 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,2)
     local framehandle fh3 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,3)
     local framehandle fh4 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,4)
     local framehandle fh5 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,5)
     local framehandle fh6 = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON,6)

     local framehandle fh0hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,0)
     local framehandle fh1hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,1)
     local framehandle fh2hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,2)
     local framehandle fh3hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,3)
     local framehandle fh4hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,4)
     local framehandle fh5hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,5)
     local framehandle fh6hp = BlzGetOriginFrame(ORIGIN_FRAME_HERO_HP_BAR,6)

     local framehandle fh0mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,0)
     local framehandle fh1mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,1)
     local framehandle fh2mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,2)
     local framehandle fh3mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,3)
     local framehandle fh4mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,4)
     local framehandle fh5mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,5)
     local framehandle fh6mana = BlzGetOriginFrame(ORIGIN_FRAME_HERO_MANA_BAR,6)

     local framehandle fh0i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,0)
     local framehandle fh1i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,1)
     local framehandle fh2i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,2)
     local framehandle fh3i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,3)
     local framehandle fh4i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,4)
     local framehandle fh5i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,5)
     local framehandle fh6i = BlzGetOriginFrame(ORIGIN_FRAME_HERO_BUTTON_INDICATOR,6)

     call BlzEnableUIAutoPosition(false)

     call BlzFrameClearAllPoints(fh_game)
     call BlzFrameClearAllPoints(fh_world)

     call BlzFrameClearAllPoints(fh_herobar)

     call BlzFrameClearAllPoints(fh0)
     call BlzFrameClearAllPoints(fh1)
     call BlzFrameClearAllPoints(fh2)
     call BlzFrameClearAllPoints(fh3)
     call BlzFrameClearAllPoints(fh4)
     call BlzFrameClearAllPoints(fh5)
     call BlzFrameClearAllPoints(fh6)
     //call BlzFrameSetVisible(fh0, false)
     //call BlzFrameSetVisible(fh1, false)
     //call BlzFrameSetVisible(fh2, false)
     //call BlzFrameSetVisible(fh3, false)
     //call BlzFrameSetVisible(fh4, false)
     //call BlzFrameSetVisible(fh5, false)
     //call BlzFrameSetVisible(fh6, false)


     call BlzFrameClearAllPoints(fh0hp)
     call BlzFrameClearAllPoints(fh1hp)
     call BlzFrameClearAllPoints(fh2hp)
     call BlzFrameClearAllPoints(fh3hp)
     call BlzFrameClearAllPoints(fh4hp)
     call BlzFrameClearAllPoints(fh5hp)
     call BlzFrameClearAllPoints(fh6hp)
     call BlzFrameSetVisible(fh0hp, false)
     call BlzFrameSetVisible(fh1hp, false)
     call BlzFrameSetVisible(fh2hp, false)
     call BlzFrameSetVisible(fh3hp, false)
     call BlzFrameSetVisible(fh4hp, false)
     call BlzFrameSetVisible(fh5hp, false)
     call BlzFrameSetVisible(fh6hp, false)

     call BlzFrameClearAllPoints(fh0mana)
     call BlzFrameClearAllPoints(fh1mana)
     call BlzFrameClearAllPoints(fh2mana)
     call BlzFrameClearAllPoints(fh3mana)
     call BlzFrameClearAllPoints(fh4mana)
     call BlzFrameClearAllPoints(fh5mana)
     call BlzFrameClearAllPoints(fh6mana)
     call BlzFrameSetVisible(fh0mana, false)
     call BlzFrameSetVisible(fh1mana, false)
     call BlzFrameSetVisible(fh2mana, false)
     call BlzFrameSetVisible(fh3mana, false)
     call BlzFrameSetVisible(fh4mana, false)
     call BlzFrameSetVisible(fh5mana, false)
     call BlzFrameSetVisible(fh6mana, false)

     call BlzFrameClearAllPoints(fh0i)
     call BlzFrameClearAllPoints(fh1i)
     call BlzFrameClearAllPoints(fh2i)
     call BlzFrameClearAllPoints(fh3i)
     call BlzFrameClearAllPoints(fh4i)
     call BlzFrameClearAllPoints(fh5i)
     call BlzFrameClearAllPoints(fh6i)
     call BlzFrameSetVisible(fh0i, false)
     call BlzFrameSetVisible(fh1i, false)
     call BlzFrameSetVisible(fh2i, false)
     call BlzFrameSetVisible(fh3i, false)
     call BlzFrameSetVisible(fh4i, false)
     call BlzFrameSetVisible(fh5i, false)
     call BlzFrameSetVisible(fh6i, false)

     // Move hero bar to 0.21,0.14 which is a bit to the top right of minimap area
     call BlzFrameSetAbsPoint(fh_herobar, FRAMEPOINT_BOTTOMLEFT, 0.21, 0.14)
     call BlzFrameSetAbsPoint(fh_herobar, FRAMEPOINT_TOPRIGHT, 0.44, 0.17) // width: 6*0.03 + 5*0.01 = 0.18+0.05 = 0.23 -> 0.21+0.23=0.44; height: 0.03 -> 0.14+0.03=0.17

     // Move hero #7's icon bottom left to the bottom left of the hero bar, and move hero #7's top right 0.03,0.03 away from its own bottom left
     call BlzFrameSetPoint(fh6, FRAMEPOINT_BOTTOMLEFT, fh_herobar, FRAMEPOINT_BOTTOMLEFT, 0.0, 0.0)
     call BlzFrameSetPoint(fh6, FRAMEPOINT_TOPRIGHT, fh6, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     // Move hero #6's icon bottom left 0.01 right of the bottom right of hero #7's icon, and move hero #6's top right 0.03,0.03 away from its own bottom left
     call BlzFrameSetPoint(fh5, FRAMEPOINT_BOTTOMLEFT, fh6, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh5, FRAMEPOINT_TOPRIGHT, fh5, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     // Repeat for the other icons...
     call BlzFrameSetPoint(fh4, FRAMEPOINT_BOTTOMLEFT, fh5, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh4, FRAMEPOINT_TOPRIGHT, fh4, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     call BlzFrameSetPoint(fh3, FRAMEPOINT_BOTTOMLEFT, fh4, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh3, FRAMEPOINT_TOPRIGHT, fh3, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     call BlzFrameSetPoint(fh2, FRAMEPOINT_BOTTOMLEFT, fh3, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh2, FRAMEPOINT_TOPRIGHT, fh2, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     call BlzFrameSetPoint(fh1, FRAMEPOINT_BOTTOMLEFT, fh2, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_TOPRIGHT, fh1, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     call BlzFrameSetPoint(fh0, FRAMEPOINT_BOTTOMLEFT, fh1, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh0, FRAMEPOINT_TOPRIGHT, fh0, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)


  endfunction
endscope


Also tried moving every single framepoint (tried both BlzFrameSetPoint and BlzFrameSetAbsPoint), in case that can overcome this seemingly built-in anchor. Also tried setting a different parent. None of it helped.
JASS:
     call BlzFrameSetParent(fh1, fh_game)

     call BlzFrameSetPoint(fh1, FRAMEPOINT_BOTTOMLEFT, fh2, FRAMEPOINT_BOTTOMRIGHT, 0.01, 0.0)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_BOTTOM, fh1, FRAMEPOINT_BOTTOMLEFT, 0.015, 0.0)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_BOTTOMRIGHT, fh1, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.0)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_LEFT, fh1, FRAMEPOINT_BOTTOMLEFT, 0.0, 0.015)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_CENTER, fh1, FRAMEPOINT_BOTTOMLEFT, 0.015, 0.015)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_RIGHT, fh1, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.015)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_TOPLEFT, fh1, FRAMEPOINT_BOTTOMLEFT, 0.0, 0.03)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_TOP, fh1, FRAMEPOINT_BOTTOMLEFT, 0.015, 0.03)
     call BlzFrameSetPoint(fh1, FRAMEPOINT_TOPRIGHT, fh1, FRAMEPOINT_BOTTOMLEFT, 0.03, 0.03)

     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_BOTTOMLEFT, 0.0, 0.0)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_BOTTOM, 0.015, 0.0)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_BOTTOMRIGHT, 0.03, 0.0)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_LEFT, 0.0, 0.015)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_CENTER, 0.015, 0.015)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_RIGHT, 0.03, 0.015)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_TOPLEFT, 0.0, 0.03)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_TOP, 0.015, 0.03)
     call BlzFrameSetAbsPoint(fh1, FRAMEPOINT_TOPRIGHT, 0.03, 0.03)


References:​

 

Attachments

  • RepositionHeroButton.w3x
    19.3 KB · Views: 24
Last edited:
Interresting it seems like moving the herobar triggers a reposing of the heroButtons which moves them back to this column formation inside the herobar (with a short delay)

Could either not move/resize the bar.
Or clear&move the heroButtons after some time passed (short timer 1s or smaller) after moving/resizeing the bar

I didn't move the bar, it does not limit the space the hero Buttons can take.
 
Last edited:
Status
Not open for further replies.
Top