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

Text Placement Fix

In the good old days text went where it was supposed to. Then came widescreen and what used to be the edge of the screen became the middle, but the text was just left where it was because Blizzard doesn't find games hot anymore when they're more than ten years old. Fixing it for widescreen would cause messages to start outside the screen for users on lower resolutions.

This trigger detects screen ratios and places text and chat boxes in approximately acceptable positions.

I am submitting my basic, half-assed work because this is something that's essential for every map. Hopefully someone will do it better soon.

If you just want to copy it without downloading anything, here:
JASS:
    local framehandle m = BlzGetOriginFrame(ORIGIN_FRAME_UNIT_MSG, 0)
    local framehandle c = BlzGetOriginFrame(ORIGIN_FRAME_CHAT_MSG, 0)
    call BlzFrameClearAllPoints(m)
    call BlzFrameClearAllPoints(c)
    // -
    if ( ( I2R(BlzGetLocalClientWidth()) / I2R(BlzGetLocalClientHeight()) ) > 1.61 ) then
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.125, 0.235)
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.5, 0.435)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.05, 0.1625)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.6, 0.4)
    else
    if ( ( I2R(BlzGetLocalClientWidth()) / I2R(BlzGetLocalClientHeight()) ) > 1.4 ) then
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.0625, 0.235)
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.50625, 0.435)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    else
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, 0.01, 0.235)
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.626, 0.435)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    endif
    endif

If you want to adjust the values yourself, here's tasyen's image showing how coordinates translate:
ANpu1MZ.jpg
Previews
Contents

Text Placement Fix (Map)

Reviews
MyPad
This is certainly one of those simple fixes that makes one wonder why wasn't this implemented in the first place. Splendid work. Would it be possible to adjust the script such that it becomes available to pre-reforged versions (v.1.31)? Even if not...
Level 17
Joined
Oct 10, 2011
Messages
459
It works really well. Super easy to use.
Really a good system

vJASS:
function setMessagePlacementOnScreen takes nothing returns nothing
    local framehandle m = BlzGetOriginFrame(ORIGIN_FRAME_UNIT_MSG, 0)
    local framehandle c = BlzGetOriginFrame(ORIGIN_FRAME_CHAT_MSG, 0)
    local real screenRatio = I2R(BlzGetLocalClientWidth()) / I2R(BlzGetLocalClientHeight())

    call BlzFrameClearAllPoints(m)
    call BlzFrameClearAllPoints(c)

    if screenRatio > 1.61 then
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.125, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.5, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.05, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.6, 0.4)
    elseif screenRatio  > 1.4 then
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.0625, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.50625, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    else
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, 0.01, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.626, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    endif

    call BJDebugMsg("Thanks doom_sheep :D")

endfunction

should be good like that no? What do you think?
Do you think framehandle variables should be nullified?
 
Last edited:
Level 17
Joined
Oct 10, 2011
Messages
459
Hello man,

Your piece of code is really good
I got a bug today, on the right side. the multiboard moved when a timer window get destroyed.

I'm jut initializing the code at the beginning of the map, then I don't change it. Do you think it can reset by itself?

here is my settings
Code:
function setScreenWidth takes nothing returns nothing
    local framehandle m = BlzGetOriginFrame(ORIGIN_FRAME_UNIT_MSG, 0)
    local framehandle c = BlzGetOriginFrame(ORIGIN_FRAME_CHAT_MSG, 0)
    local real screenRatio = I2R(BlzGetLocalClientWidth()) / I2R(BlzGetLocalClientHeight())

    call BlzFrameClearAllPoints(m)
    call BlzFrameClearAllPoints(c)

    if screenRatio > 1.61 then
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.08, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.5, 0.435)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0, 0.17)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.6, 0.4)
    elseif screenRatio  > 1.4 then
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.0625, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.50625, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    else
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, 0.01, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.626, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    endif

    set m = null
    set c = null

endfunction

Do you think your piece of code did that? Do you think how I can fix it?

Thank you man
 

Attachments

  • bug.png
    bug.png
    3.6 MB · Views: 99
Level 23
Joined
Jan 1, 2011
Messages
1,504
JASS:
I2R(BlzGetLocalClientWidth()) / I2R(BlzGetLocalClientHeight())
This ^ will cause a thread crash if the player is alt-tabbed (0 division), leading to bugs (best case scenario) or desyncs (most likely scenario). Considering you have it on a 3 second timer, chances are it will be in it's own thread, so the thread crash should be fine, but it might not be.

Just do
JASS:
BlzGetLocalClientHeight() != 0 and ....
to ensure 0 division doesn't occur.
 
Level 7
Joined
Sep 16, 2016
Messages
184
Hello man,

Your piece of code is really good
I got a bug today, on the right side. the multiboard moved when a timer window get destroyed.

I'm jut initializing the code at the beginning of the map, then I don't change it. Do you think it can reset by itself?

here is my settings
Code:
function setScreenWidth takes nothing returns nothing
    local framehandle m = BlzGetOriginFrame(ORIGIN_FRAME_UNIT_MSG, 0)
    local framehandle c = BlzGetOriginFrame(ORIGIN_FRAME_CHAT_MSG, 0)
    local real screenRatio = I2R(BlzGetLocalClientWidth()) / I2R(BlzGetLocalClientHeight())

    call BlzFrameClearAllPoints(m)
    call BlzFrameClearAllPoints(c)

    if screenRatio > 1.61 then
    call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.08, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.5, 0.435)
    call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0, 0.17)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.6, 0.4)
    elseif screenRatio  > 1.4 then
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, -0.0625, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.50625, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    else
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_BOTTOMLEFT, 0.01, 0.235)
        call BlzFrameSetAbsPoint(m, FRAMEPOINT_TOPRIGHT, 0.626, 0.435)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_BOTTOMLEFT, 0.175, 0.1625)
        call BlzFrameSetAbsPoint(c, FRAMEPOINT_TOPRIGHT, 0.725, 0.4)
    endif

    set m = null
    set c = null

endfunction

Do you think your piece of code did that? Do you think how I can fix it?

Thank you man
Did you find a fix?
 
Top