Jump to content

all resolution dx gui problem


JeViCo

Recommended Posts

Hello everyone, what's wring in code below?

local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender", root,
    function()
        dxDrawImage((screenW - 561) / 2, (screenH - 431) / 2, 561, 431, "images/back.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage((screenW - 517) / 2, (screenH - 465) / 2, 332, 86, "images/button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage((screenW - 522) / 2, (screenH - 459) / 2, 96, 96, "images/pay.png", 0, 0, 0, tocolor(0, 0, 0, 255), false)
        dxDrawImage((screenW - 520) / 2, (screenH - 456) / 2, 96, 96, "images/pay.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage((screenW - 906) / 2, (screenH - 179) / 2, 48, 48, "images/deny.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("Контрольно-пропускной\nпункт", (screenW - 539 - 1) / 2, (screenH - 173 - 1) / 2, 827 - 1, 268 - 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (screenW - 539 + 1) / 2, (screenH - 173 - 1) / 2, 827 + 1, 268 - 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (screenW - 539 - 1) / 2, (screenH - 173 + 1) / 2, 827 - 1, 268 + 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (screenW - 539 + 1) / 2, (screenH - 173 + 1) / 2, 827 + 1, 268 + 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (screenW - 539) / 2, (screenH - 173) / 2, 827, 268, tocolor(255, 255, 255, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Оплатить проезд", (screenW - 614) / 2, (screenH - 480) / 2, 814, 534, tocolor(0, 0, 0, 255), 2.30, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Оплатить проезд", (screenW - 614) / 2, (screenH - 477) / 2, 814, 531, tocolor(255, 255, 255, 255), 2.30, "default", "center", "center", false, false, false, false, false)
        dxDrawImage((screenW - 517) / 2, (screenH - 338) / 2, 332, 86, "images/button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("$", (screenW - 665) / 2, (screenH - 352) / 2, 691, 405, tocolor(0, 0, 0, 255), 4.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("$", (screenW - 663) / 2, (screenH - 348) / 2, 689, 401, tocolor(255, 254, 254, 255), 4.00, "default", "center", "center", false, false, false, false, false)
    end
)

guieditor makes only first line correct. Everything below 1 line is incorrect (coordinates)

Link to comment
9 hours ago, Dimos7 said:

What is your screen resolution?

1366x768 and everything stacks in top left corner. Their sizes are normal

5 hours ago, Skully said:

Code looks fine, try adjusting your screen resolution or make the GUI relative instead of absolute.

i'll try it

Link to comment
local sx, sy = guiGetScreenSize()
local sw, sh = sx/1366, sy/768

addEventHandler("onClientRender", root,
    function()
        dxDrawImage((sx - 561) / 2, (sy - 431) / 2, sw*561, sh*431, "images/back.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage((sx - 517) / 2, (sy - 465) / 2, sw*332, sh*86, "images/button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage((sx - 522) / 2, (sy - 459) / 2, sw*96, sh*96, "images/pay.png", 0, 0, 0, tocolor(0, 0, 0, 255), false)
        dxDrawImage((sx - 520) / 2, (sy - 456) / 2, sw*96, sh*96, "images/pay.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage((sx - 906) / 2, (sy - 179) / 2, sw*48, sh*48, "images/deny.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("Контрольно-пропускной\nпункт", (sx - 539 - 1) / 2, (sy - 173 - 1) / 2, sw*827 - 1, sh*268 - 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (sx - 539 + 1) / 2, (sy - 173 - 1) / 2, sw*827 + 1, sh*268 - 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (sx - 539 - 1) / 2, (sy - 173 + 1) / 2, sw*827 - 1, sh*268 + 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (sx - 539 + 1) / 2, (sy - 173 + 1) / 2, sw*827 + 1, sh*268 + 1, tocolor(0, 0, 0, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Контрольно-пропускной\nпункт", (sx - 539) / 2, (sy - 173) / 2, sw*827, sh*268, tocolor(255, 255, 255, 255), 2.50, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Оплатить проезд", (sx - 614) / 2, (sy - 480) / 2, sw*814, sh*534, tocolor(0, 0, 0, 255), 2.30, "default", "center", "center", false, false, false, false, false)
        dxDrawText("Оплатить проезд", (sx - 614) / 2, (sy - 477) / 2, sw*814, sh*531, tocolor(255, 255, 255, 255), 2.30, "default", "center", "center", false, false, false, false, false)
        dxDrawImage((sx - 517) / 2, (sy - 338) / 2, sw*332, sh*86, "images/button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("$", (sx - 665) / 2, (sy - 352) / 2, sw*691, sh*405, tocolor(0, 0, 0, 255), 4.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("$", (sx - 663) / 2, (sy - 348) / 2, sw*689, sh*401, tocolor(255, 254, 254, 255), 4.00, "default", "center", "center", false, false, false, false, false)
    end
)

try that i hope fit to all the resolution

Edited by Dimos7
Link to comment

It has a little bit different result but still keep stacking in one place(

10 hours ago, Skully said:

Code looks fine, try adjusting your screen resolution or make the GUI relative instead of absolute.

Thanks, everything on it's position. But now text doesn't fit in frames. :D How can i fix that?

Edited by Juuve
Link to comment
4 hours ago, Juuve said:

It has a little bit different result but still keep stacking in one place(

Thanks, everything on it's position. But now text doesn't fit in frames. :D How can i fix that?

If you mean they don't fit the windows, you can try reducing the font size of the text.

Link to comment
3 minutes ago, Skully said:

Why not make the windows larger than to fit the text?

you didn't understand me :D. I mean that text scale doesn't change with different resolutions and i don't know how to fix that. It is big on small resolutions and small on high resolutions

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...