Cronoss Posted March 13, 2022 Share Posted March 13, 2022 All my dxDraws works, the rectangle, the images, but the text in other's screens seems weird, why? I'm using "guiGetScreenSize". But I don't understand why this doesn't work with text Code: dxDrawText("Password", screenW * 0.4844, screenH * 0.5093, screenW * 0.5188, screenH * 0.5222, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) and... how Could I convert this memo position to fit all screens too? (I made all the elements relative but for some reason the gui elements kept with those numbers) It works, yeah, and the position doesn't change to much in another screen BUT if the resolution of the player is lower than mine, he can't see anything he is writting guiCreateMemo(0.45, 0.42, 0.10, 0.03, "", true) Link to comment
βurak Posted March 13, 2022 Share Posted March 13, 2022 Can you try multiplying the size with screenW? --this dxDrawText("Password", screenW * 0.4844, screenH * 0.5093, screenW * 0.5188, screenH * 0.5222, tocolor(255, 255, 255, 255), screenW * 1.00, "default", "left", "top", false, false, false, false, false) Link to comment
Cronoss Posted March 14, 2022 Author Share Posted March 14, 2022 Now it's doesn't showing any text Link to comment
βurak Posted March 14, 2022 Share Posted March 14, 2022 (edited) I'm not sure but can you try this code this is a bit different from the math you use local screenW, screenH = guiGetScreenSize() local myW, myH = 1920, 1080 -- your resolution here local relX, relY = (screenW/myW),(screenH/myH) --this dxDrawText("Password", screenW * 0.4844, screenH * 0.5093, screenW * 0.5188, screenH * 0.5222, tocolor(255, 255, 255, 255), 1.00 * relX, "default", "left", "top", false, false, false, false, false) Edited March 14, 2022 by Burak5312 1 Link to comment
Moderators Citizen Posted March 14, 2022 Moderators Share Posted March 14, 2022 I don't really understand, do you have a problem with the dxDrawText ? Can you take a screenshot and show us what the problem is please ? I just want to point out that it looks like you want to make a password field. For this, you should use guiCreateEdit instead (there is also a method for edit to not show the password when writing in it: guiEditSetMasked). Memo are for multiline texts. But anyway, it won't fix your problem. Your problem is that you are giving a relative size (width and height) that is too small for it to work on small screen: 0.10 and 0.03 - on a 1920x1080 screen: it means 0.10 x 1920 = 192 pixels(px) of width (that's okay) and 0.03 x 1080 = 32.4px of height which is okay too, but - on a 1280×720 screen: it means 0.10 x 1280 = 128px width but 0.03 x 720 = 21.6px of height which is not okay because it's too small. Memo or Edit have some inner margin that you can't override so the text doesn't have enough space to show. To fix that one quick solution you can try is to make sure the height doesn't go under a minimum height by using math.max : guiCreateMemo(0.45*screenW, 0.42*screenH, 0.10*screenW, math.max(0.03*screenH, 30), "", false) -- back to false (absolute) I put 30 px as minimum but you can change it a bit (I don't know what the real minimum is for the text to show properly). NOTE: If it is part of a window (guiCreateWindow) then you have to instead to make it relative to the window (and not the entire screen) by setting the gui window as its parent: local window = guiCreateWindow(0.36, 0.27, 0.35, 0.34,"GUI Window", true) guiCreateMemo(0.45, 0.42, 0.10, 0.03, "", true, window) -- you have to rework the values here For more understanding, please consider reading this guide: https://wiki.multitheftauto.com/wiki/Introduction_to_Scripting_the_GUI 1 Link to comment
Cronoss Posted March 15, 2022 Author Share Posted March 15, 2022 On 14/03/2022 at 10:43, Burak5312 said: I'm not sure but can you try this code this is a bit different from the math you use local screenW, screenH = guiGetScreenSize() local myW, myH = 1920, 1080 -- your resolution here local relX, relY = (screenW/myW),(screenH/myH) --this dxDrawText("Password", screenW * 0.4844, screenH * 0.5093, screenW * 0.5188, screenH * 0.5222, tocolor(255, 255, 255, 255), 1.00 * relX, "default", "left", "top", false, false, false, false, false) Thank you Burak, this worked 20 hours ago, Citizen said: I just want to point out that it looks like you want to make a password field. For this, you should use guiCreateEdit instead (there is also a method for edit to not show the password when writing in it: guiEditSetMasked). Memo are for multiline texts. But anyway, it won't fix your problem. @Citizen, the dxDrawText that I made it's not a field, it's text that helps the player to understand what he should type Example: "Password: [ ] " 20 hours ago, Citizen said: Your problem is that you are giving a relative size (width and height) that is too small for it to work on small screen: 0.10 and 0.03 - on a 1920x1080 screen: it means 0.10 x 1920 = 192 pixels(px) of width (that's okay) and 0.03 x 1080 = 32.4px of height which is okay too, but - on a 1280×720 screen: it means 0.10 x 1280 = 128px width but 0.03 x 720 = 21.6px of height which is not okay because it's too small. Memo or Edit have some inner margin that you can't override so the text doesn't have enough space to show. To fix that one quick solution you can try is to make sure the height doesn't go under a minimum height by using math.max : guiCreateMemo(0.45*screenW, 0.42*screenH, 0.10*screenW, math.max(0.03*screenH, 30), "", false) -- back to false (absolute) Thank you for the help too Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now