• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[vJASS] UI - Text on top of simplebar

Status
Not open for further replies.
Level 24
Joined
Feb 28, 2007
Messages
3,479
Hello again,

I'm getting a migraine from trying to make a simple healthbar with a text-frame on top.

My code is below:

JASS:
globals
    private framehandle UI_BackBar_HP
    public framehandle UI_Bar_HP

    public framehandle UI_HP_Text
endglobals

private function Actions takes nothing returns nothing
    call BlzHideOriginFrames(true)
    call BlzEnableUIAutoPosition(false)

    call BlzFrameSetSize(BlzGetFrameByName("ConsoleUIBackdrop",0), 0, 0.0001)
    set UI_BackBar_HP = BlzCreateFrame("EscMenuControlBackdropTemplate", BlzGetFrameByName("ConsoleUIBackdrop", 0), 0, 0)
    set UI_Bar_HP = BlzCreateFrameByType("SIMPLESTATUSBAR", "", BlzGetFrameByName("ConsoleUI", 0), "", 0)
       
    call BlzFrameSetAbsPoint(UI_BackBar_HP, FRAMEPOINT_CENTER, -0.03, 0.57)
    call BlzFrameSetSize(UI_BackBar_HP, 0.2, 0.025)
       
    call BlzFrameSetPoint(UI_Bar_HP, FRAMEPOINT_TOPLEFT, UI_BackBar_HP, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
    call BlzFrameSetPoint(UI_Bar_HP, FRAMEPOINT_BOTTOMRIGHT, UI_BackBar_HP, FRAMEPOINT_BOTTOMRIGHT, -0.006, 0.006)
    call BlzFrameSetTexture(UI_Bar_HP, "ui\\feedback\\xpbar\\human-bigbar-fill", 0, false)
    call BlzFrameSetVertexColor(UI_Bar_HP, BlzConvertColor(255, 55, 255, 55))
    call BlzFrameSetVertexColor(UI_BackBar_HP, BlzConvertColor(255, 55, 255, 55))

    set UI_HP_Text = BlzCreateFrameByType("TEXT", "MyTextFrame",  BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    call BlzFrameSetEnable(UI_HP_Text, true)
    call BlzFrameSetPoint(UI_HP_Text, FRAMEPOINT_CENTER, UI_Bar_HP, FRAMEPOINT_CENTER, 0.0, 0.0)
    call BlzFrameSetScale(UI_HP_Text, 2)
    call BlzFrameSetText(UI_HP_Text, "abc def")
endfunction

The result in-game looks like this:
1658301576213.png


So the "a" is drawn, although in the wrong spot, and that's about it.

I tried messing with text alignments and z-values of different frames and what not but nothing seems to work for me.

Any help would be greatly appreciated, thanks!

Edit: Probably solved, apparently we can't draw text outside the 4:3 area.
 
Last edited:
Level 18
Joined
Oct 17, 2012
Messages
849
Text can appear outside the 4:3 area. You just need a different parent for it. ConsoleUIBackdrop or a child of it will do. I would use UI_Bar_HP as the text frame's parent. Children of frame will always appear above the parent.

Only the letter 'a' appears because the size of the text frame is too small. If you were to add BlzFrameSetSize(UI_HP_TEXT, 0, whatever) to your code, then the text frame would then adapt to the width of the text content. You will then be able to see the full text no matter how long it is.

Regarding the alignment, you mentioned that you were messing with text alignments. You did not show that here tho. Were you doing the following,
BlzFrameSetTextAlignment(UI_HP_TEXT, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_CENTER) ?

Instead of lining up the centers of the two frames, I would instead line up the top left corner and bottom right corner. This plus the the alignment adjustments would ensure that the text content would be smacked dead in the center of the HP bar.
 
Last edited:
Status
Not open for further replies.
Top