[JASS] Position of UI

Status
Not open for further replies.
you get a framehandle to the wanted frame, unbind current position, then move it.
example from UI: Positionate Frames
JASS:
function ReposMenuButtons2 takes nothing returns nothing
   local framehandle fh = BlzGetFrameByName("UpperButtonBarMenuButton",0)
   call BlzFrameClearAllPoints(fh)
   call BlzFrameSetAbsPoint(fh, FRAMEPOINT_RIGHT, 0.5, 0.5)
endfunction
you would replace BlzGetFrameByName("UpperButtonBarMenuButton",0) with something else to get the command button / animated portrait.

There is a section in the tutorial only about moving such default UI frames, with short code snippets, (it has examples for command button and animated portrait):
[JASS/AI] - The Big UI-Frame Tutorial. 3. Access Frames - Move Default UI
 
Last edited:
Level 4
Joined
Oct 24, 2021
Messages
61
you get a framehandle to the wanted frame, unbind current position, then move it.
example from UI: Positionate Frames
JASS:
function ReposMenuButtons2 takes nothing returns nothing
   local framehandle fh = BlzGetFrameByName("UpperButtonBarMenuButton",0)
   call BlzFrameClearAllPoints(fh)
   call BlzFrameSetAbsPoint(fh, FRAMEPOINT_RIGHT, 0.5, 0.5)
endfunction
you would replace BlzGetFrameByName("UpperButtonBarMenuButton",0) with something else to get the command button / animated portrait.

There is a section in the tutorial only about moving such default UI frames, with short code snippets, (it has examples for command button and animated portrait):
[JASS/AI] - The Big UI-Frame Tutorial. 3. Access Frames - Move Default UI
Could you tell me the names of frames
 
("CommandButton_0", 0)
("CommandButton_1", 0)
("CommandButton_10", 0)
("CommandButton_11", 0)
("CommandButton_2", 0)
("CommandButton_3", 0)
("CommandButton_4", 0)
("CommandButton_5", 0)
("CommandButton_6", 0)
("CommandButton_7", 0)
("CommandButton_8", 0)
("CommandButton_9", 0)

BlzGetOriginFrame(ORIGIN_FRAME_PORTRAIT, 0)
 
Level 4
Joined
Oct 24, 2021
Messages
61
("CommandButton_0", 0)
("CommandButton_1", 0)
("CommandButton_10", 0)
("CommandButton_11", 0)
("CommandButton_2", 0)
("CommandButton_3", 0)
("CommandButton_4", 0)
("CommandButton_5", 0)
("CommandButton_6", 0)
("CommandButton_7", 0)
("CommandButton_8", 0)
("CommandButton_9", 0)

BlzGetOriginFrame(ORIGIN_FRAME_PORTRAIT, 0)
I'm using 1.31
 
k, then the name version don't work for your Warcraft 3 version.

BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 0)
BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 1)
BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 2)
...
BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 11)

The name versions for command buttons were added in Warcraft 3 V1.32.x and should be used for moving them. But in V1.31.x you just use the Origin version. If you want your ui modification work in both versions you could get the version do an if and use the suited approach for the game version currently running your map. Or just don't care for other versions (makes it less work) :)
JASS:
if GetLocalizedString("REFORGED") == "REFORGED" then
    // runs in Not Reforged
    BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 0)
else
    // runs in Reforged (Warcraft 3 V1.32+)
    BlzGetFrameByName("CommandButton_0", 0)
endif
 
Last edited:
Level 4
Joined
Oct 24, 2021
Messages
61
k, then the name version don't work for your Warcraft 3 version.

BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 0)
BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 1)
BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 2)
...
BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 11)

The name versions for command buttons were added in Warcraft 3 V1.32.x and should be used for moving them. But in V1.31.x you just use the Origin version. If you want your ui modification work in both versions you could get the version do an if and use the suited approach for the game version currently running your map. Or just don't care for other versions (makes it less work) :)
JASS:
if GetLocalizedString("REFORGED") == "REFORGED" then
    // runs in Not Reforged
    BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 0)
else
    // runs in Reforged (Warcraft 3 V1.32+)
    BlzGetFrameByName("CommandButton_0", 0)
endif
I was trying but it doesn't work for me, could you please create a sample map
 
There you go, a jass map that moves the portrait and the first 3 command buttons works correctly in V1.31 and V1.32+.

But does not care about Save&Load.

The relevant jass code, if one does not want to download the map.
JASS:
function GetCommandButton takes integer index returns framehandle
    if GetLocalizedString("REFORGED") == "REFORGED" then
        // runs in Not Reforged
        return BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, index)
    else
        // runs in Reforged (Warcraft 3 V1.32+)
        return BlzGetFrameByName("CommandButton_" + I2S(index), 0)
    endif
endfunction
function Test takes nothing returns nothing
    local framehandle fh
    // ORIGIN_FRAME_PORTRAIT needs either call BlzHideOriginFrames(true) or call BlzEnableUIAutoPosition(false) to be moveable
    call BlzEnableUIAutoPosition(false)
    
    set fh=BlzGetOriginFrame(ORIGIN_FRAME_PORTRAIT, 0)
    call BlzFrameClearAllPoints(fh)
    call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPRIGHT, 0.4, 0.3)
    set fh=GetCommandButton(0)
    call BlzFrameClearAllPoints(fh)
    call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, 0.4, 0.22)
    set fh=GetCommandButton(1)
    call BlzFrameClearAllPoints(fh)
    call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, 0.44, 0.22)
    set fh=GetCommandButton(2)
    call BlzFrameClearAllPoints(fh)
    call BlzFrameSetAbsPoint(fh, FRAMEPOINT_TOPLEFT, 0.48, 0.22)

endfunction
 

Attachments

  • Some Frame Pos Map.w3x
    13.2 KB · Views: 17
In Warcraft 3 V1.31.x the buttons are relative to the bottom Center UI (Unit Info Panel)'s xxxRight. One would need to overwrite the relative positions.
-> Move each item button by itself
-> or set a relative chain and move the none relative.

The Inventory Background is part of the "ConsoleUI", can not be moved on it own and the image contains more than just it. When you want to keep such you would need to define a custom "SIMPLEFRAME" which has a Texture and uses TexCoord to find the correct rect inside the image.
The ConosleUITextures relevant for the inventory Background are
ui\console\human\humanuitile03
ui\console\human\humanuitile02

humanuitile03 contains most, but humanuitile02 could contains the left end.

Edit: Like this but with changed values and some other Name for "ConsoleUI"
Code:
Frame "SIMPLEFRAME" "ConsoleUI" {
    DecorateFileNames,
    Texture {
        File "ConsoleTexture03",
        Width 0.256,
        Height 0.176,
        TexCoord 0, 1, 0.3125, 1,
        AlphaMode "ALPHAKEY",
        Anchor BOTTOMRIGHT,-0.032,0.0,
    }
}


In Reforged: There is the SimpleFrame named ("SimpleInventoryBar",0) which one can move to move all the inventory Buttons, (without background) but it would keep the buttons in formation. Even when you not use Reforged the the relative position coords might of some use.
From InventoryBar.fdf
Code:
Frame "SIMPLEFRAME" "SimpleInventoryBar" {
    UseActiveContext,
    SetAllPoints,
   
    Frame "SIMPLEBUTTON" "InventoryButton_0" INHERITS "InventoryButtonTemplate" {
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0187, -0.0021,
    }
   
    Frame "SIMPLEBUTTON" "InventoryButton_1" INHERITS "InventoryButtonTemplate" {
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0587, -0.0021,
    }
   
    Frame "SIMPLEBUTTON" "InventoryButton_2" INHERITS "InventoryButtonTemplate" {
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0187, -0.0403,
    }
   
    Frame "SIMPLEBUTTON" "InventoryButton_3" INHERITS "InventoryButtonTemplate" {
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0587, -0.0403,
    }
   
    Frame "SIMPLEBUTTON" "InventoryButton_4" INHERITS "InventoryButtonTemplate" {
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0187, -0.0784,
    }
   
    Frame "SIMPLEBUTTON" "InventoryButton_5" INHERITS "InventoryButtonTemplate" {
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0587, -0.0784,
    }
    Frame "TEXT" "InventoryText"{
        Width 0.07125,
        Height 0.01125,   
        DecorateFileNames,
        SetPoint TOPLEFT, "SimpleInventoryBar", TOPRIGHT, 0.0187, 0.015,
        Text "INVENTORY",      
        FrameFont "MasterFont", 0.0109, "", 
        FontFlags "FIXEDSIZE",
        FontColor 0.99 0.827 0.070 1.0,
        FontShadowColor 0.0 0.0 0.0 0.9,   
        FontShadowOffset 0.001 -0.001, 
        FontJustificationH JUSTIFYCENTER,
    }    
}
 
Status
Not open for further replies.
Top