Veo Posted September 20, 2018 Share Posted September 20, 2018 Dear MTA:SA Community I have the issue, that i want do with dxGetTextWidth & dxDrawRectangle a Background, for the Map Text, it looks like that. https://i.imgur.com/HjwgkeY.png It works fine in 1920x1080, but if i Change it to 1360x768, then it looks like this https://i.imgur.com/dFflYj5.png Heres some Code: =============== function resY(value) return (value/1080) * y end function resX(value) return (value/1920) * s end =============== local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3]) rectangle = dxDrawRectangle(s*0.008,y*0.957,length+55,y*0.030, tocolor ( 0, 266, 0, 250 ) ) Link to comment
Moderators IIYAMA Posted September 20, 2018 Moderators Share Posted September 20, 2018 The IIYAMA rule: Scale EVERYTHING only over the Y as. Except for the X position. We are very lucky that they hardly design monitors with a portrait orientation... else it would have blown off my mind. This could be one of your issues, an absolute value: dxDrawRectangle(s*0.008,y*0.957, length + 55,y*0.030, tocolor ( 0, 266, 0, 250 ) ) dxDrawRectangle(s*0.008,y*0.957,length + resY(55),y*0.030, tocolor ( 0, 266, 0, 250 ) ) Link to comment
Veo Posted September 20, 2018 Author Share Posted September 20, 2018 (edited) 8 minutes ago, IIYAMA said: The IIYAMA rule: Scale EVERYTHING only over the Y as. Except for the X position. We are very lucky that they hardly design monitors with a portrait orientation... else it would have blown off my mind. This could be one of your issues, an absolute value: dxDrawRectangle(s*0.008,y*0.957, length + 55,y*0.030, tocolor ( 0, 266, 0, 250 ) ) dxDrawRectangle(s*0.008,y*0.957,length + resY(55),y*0.030, tocolor ( 0, 266, 0, 250 ) ) Thanks, i tried. but its still the same issue.. Edited September 20, 2018 by Veo Link to comment
Veo Posted September 20, 2018 Author Share Posted September 20, 2018 @IIYAMA i dont understand it, why that is not working. Link to comment
Dimos7 Posted September 20, 2018 Share Posted September 20, 2018 (edited) local sw, sh =guiGetScreenSize() local sx, sy = sw/1920, sh/1080 dxDrawRectangle(sx*0.008,sy*0.957,length + sx*55,sy*0.030, tocolor ( 0, 266, 0, 250 ) ) Edited September 20, 2018 by Dimos7 Link to comment
Moderators IIYAMA Posted September 20, 2018 Moderators Share Posted September 20, 2018 45 minutes ago, Veo said: @IIYAMA i dont understand it, why that is not working. Where is your dxDrawText function in your code? Link to comment
Veo Posted September 20, 2018 Author Share Posted September 20, 2018 23 minutes ago, IIYAMA said: Where is your dxDrawText function in your code? I can give it to you Tomorrow, Hes using this '_MapName' The Map Name. Link to comment
Erknneto Posted September 20, 2018 Share Posted September 20, 2018 Well, I always use this code to draw DX stuff, and I recommend you to try it so local sx,sy = guiGetScreenSize() local px,py = 1366,768 --Put your resolution here local x,y = (sx/px),(sy/py) --Example code dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false) dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false) It always fits in all resolutions. 1 Link to comment
Veo Posted September 21, 2018 Author Share Posted September 21, 2018 6 hours ago, Erknneto said: Well, I always use this code to draw DX stuff, and I recommend you to try it so local sx,sy = guiGetScreenSize() local px,py = 1366,768 --Put your resolution here local x,y = (sx/px),(sy/py) --Example code dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false) dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false) It always fits in all resolutions. I want that for all resolutions, Not just for 1360 Link to comment
Veo Posted September 21, 2018 Author Share Posted September 21, 2018 (edited) @Erknneto that dosnt Help me for mine code.. someone has maybe Discord? @Edit: If the Map changed, its change the Rectangle to the Map Name length. The Rectangle fits the Map length Name Edited September 21, 2018 by Veo Link to comment
Dimos7 Posted September 21, 2018 Share Posted September 21, 2018 @Veo did you try my code? Link to comment
Master_MTA Posted September 21, 2018 Share Posted September 21, 2018 11 hours ago, Veo said: I want that for all resolutions, Not just for 1360 yeah it's work for all Link to comment
Veo Posted September 21, 2018 Author Share Posted September 21, 2018 2 hours ago, Dimos7 said: @Veo did you try my code? Yes, i do. Here: local x,y = guiGetScreenSize() local sw, sh =guiGetScreenSize() local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3]) rectangle = dxDrawRectangle(s*0.008,y*0.957,length + sx*55,y*0.030, tocolor ( 0, 266, 0, 250 ) ) Link to comment
Erknneto Posted September 21, 2018 Share Posted September 21, 2018 (edited) 14 hours ago, Veo said: I want that for all resolutions, Not just for 1360 That code works for all resolutions, just put your resolution there and edit. It will work fine in all resolutions, just edit in your resolution and test in others. Edited September 21, 2018 by Erknneto Link to comment
JeViCo Posted September 21, 2018 Share Posted September 21, 2018 14 hours ago, Veo said: 21 hours ago, Erknneto said: Well, I always use this code to draw DX stuff, and I recommend you to try it so local sx,sy = guiGetScreenSize() local px,py = 1366,768 --Put your resolution here local x,y = (sx/px),(sy/py) --Example code dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false) dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false) It always fits in all resolutions. I want that for all resolutions, Not just for 1360 it WILL fit in each resolution - this is the simplest way. Your coordinates will be multiplied by (for example x: 1366/player_resolution) -> Bigger resolution x>0, smaller - 0<x<1 You can try it yourself by changing in-game/pc resolutions. By the way you should multiply dxDrawText's scale too Link to comment
Dimos7 Posted September 21, 2018 Share Posted September 21, 2018 (edited) local sw, sh =guiGetScreenSize() local sx, sy = sw/1920, sh/1080 dxDrawRectangle(sx*0.008,sy*0.957,length + sx*55,sy*0.030, tocolor ( 0, 266, 0, 250 ) ) 1 hour ago, Veo said: Yes, i do. Here: local x,y = guiGetScreenSize() local sw, sh =guiGetScreenSize() local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3]) rectangle = dxDrawRectangle(s*0.008,y*0.957,length + sx*55,y*0.030, tocolor ( 0, 266, 0, 250 ) ) That wasn't my code Edited September 21, 2018 by Dimos7 Link to comment
Veo Posted September 21, 2018 Author Share Posted September 21, 2018 #Fixed by a Friend. But Thanks for Helping guys. 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