Custom UI's issue in a screen with 1920x1200

Level 11
Joined
Sep 27, 2016
Messages
145
greetings guys..

i have a problem with Custom UI (Framework)

So, i made a fully costumized UI for my game, my screen's resolution is 1920x1080 and cannot be higher than that.. See the picture below:
WC3ScrnShot_112424_170615_000.png

Image: Custom UI with 1920x1080 screen's resolution

But in my friend's PC that have 1920x1200 screen's resolution.. some of the Framework look like they're off the screen..

image.png

Image: Custom UI with 1920x1200 screen's resolution
image 2.png

Image: The Friend's Video Setting.

How to fix this? How do I prevent the framework on a 1920x1200 screen from appearing like this? and how to detect the player's screen resolution ?
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
This happens because the frame coordinates are not precisely relative, what I mean, the x axis have a min and max value that changes whenever you stretch or narrow the window (the min and max y values remain constant no matter the window size).

So to solve this problem you need to move x value of the frames that are in the far left or far right of the window whenever you change the window size (the game window can't have a resolution lower than 4:3).

I dealt with this problem before, this is what I did:
Lua:
OnInit(function ()
    local onChangeDimensions = EventListener.create() -- Event that runs whenever the window size is changed
    local windowWidth = 1400
    local windowHeight = 900
    local minX, maxX = 0., 0.8

    local function check()
        local width = BlzGetLocalClientWidth()
        local height = BlzGetLocalClientHeight()
        -- Check the window size is different (and not equal to 0)
        if (width ~= windowWidth and width ~= 0) or (height ~= windowHeight and height ~= 0) then
            windowWidth = width
            windowHeight = height

            -- Formula to get the x values
            local extraWidth = ((windowWidth/windowHeight * 0.6) - 0.8) / 2
            minX, maxX = -extraWidth, 0.8+extraWidth

            onChangeDimensions:run()
        end
    end

    check() -- Run at map init
    OnInit.final(check) -- Run at game start
    Timed.echo(0.1, check) -- Run periodically

    -- Example frame when is created
    frame = BlzCreateFrame("EscMenuBackdrop", Console, 0, 0)
    BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPLEFT, minX + 0.18, 0.180000)
    BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMRIGHT, minX + 0.41, 0.00000)

    -- Update the frame x-coordinate
    onChangeDimensions:register(function ()
        BlzFrameClearAllPoints(frame)
        BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPLEFT, minX + 0.18, 0.180000)
        BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMRIGHT, minX + 0.41, 0.00000)
    end)
end)
 
Level 11
Joined
Sep 27, 2016
Messages
145
This happens because the frame coordinates are not precisely relative, what I mean, the x axis have a min and max value that changes whenever you stretch or narrow the window (the min and max y values remain constant no matter the window size).

So to solve this problem you need to move x value of the frames that are in the far left or far right of the window whenever you change the window size (the game window can't have a resolution lower than 4:3).

I dealt with this problem before, this is what I did:
Lua:
OnInit(function ()
    local onChangeDimensions = EventListener.create() -- Event that runs whenever the window size is changed
    local windowWidth = 1400
    local windowHeight = 900
    local minX, maxX = 0., 0.8

    local function check()
        local width = BlzGetLocalClientWidth()
        local height = BlzGetLocalClientHeight()
        -- Check the window size is different (and not equal to 0)
        if (width ~= windowWidth and width ~= 0) or (height ~= windowHeight and height ~= 0) then
            windowWidth = width
            windowHeight = height

            -- Formula to get the x values
            local extraWidth = ((windowWidth/windowHeight * 0.6) - 0.8) / 2
            minX, maxX = -extraWidth, 0.8+extraWidth

            onChangeDimensions:run()
        end
    end

    check() -- Run at map init
    OnInit.final(check) -- Run at game start
    Timed.echo(0.1, check) -- Run periodically

    -- Example frame when is created
    frame = BlzCreateFrame("EscMenuBackdrop", Console, 0, 0)
    BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPLEFT, minX + 0.18, 0.180000)
    BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMRIGHT, minX + 0.41, 0.00000)

    -- Update the frame x-coordinate
    onChangeDimensions:register(function ()
        BlzFrameClearAllPoints(frame)
        BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPLEFT, minX + 0.18, 0.180000)
        BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMRIGHT, minX + 0.41, 0.00000)
    end)
end)
Thats a problem's solve.. thank you.. one thing, out of the topic.. where did you got blizzard's natives like BlzGetLocalClientWidth() ?
 
Last edited:
Top