• Resolution problem for a menu
    8 replies, posted
Hey, Me and my friend are currently customizing a menu for GMOD and we're playing on different resolutions. He is on 720p and I'm on 1080p and when we were done fixing it and it looked fine on his screen when I joined the server, the menu was off by a long shot. I don't have a lot of experience with Lua (My friend knows more than me, but has never made a menu), but I've heard it depends on ScrW(), ScrH() or ScreenScale. My intention is to have it on my server that's under development. So it has to work on most resolutions. It's also intended to cover the whole screen, much like an f4 menu on DarkRP. I appreciate any help since we're both struggling here on what to do.
[CODE]local myW = 1920 local myH = 1080 local function myScreenScaleW(w) return (ScrW() * ((w or 0) / myW)) end local function myScreenScaleH(h) return (ScrH() * ((h or 0) / myH)) end[/CODE] Replace all the sizes and positioning pixels using these functions. Change myW and myH to your screen sizes, and you'll now have a correctly sized menu. This also works with fonts, set the font size to myScreenScaleH(whatever).
[QUOTE=BillyOnWiiU;49004635][CODE]local myW = 1920 local myH = 1080 local function myScreenScaleW(w) return (ScrW() * ((w or 0) / myW)) end local function myScreenScaleH(h) return (ScrH() * ((h or 0) / myH)) end[/CODE] Replace all the sizes and positioning pixels using these functions. Change myW and myH to your screen sizes, and you'll now have a correctly sized menu. This also works with fonts, set the font size to myScreenScaleH(whatever).[/QUOTE] Sorry for taking so long to reply, been sleeping. I will try this out, thanks a lot! EDIT: I tried this and it didn't seem to work for me. I'm either screwing up badly or it doesn't work
You're not actually supplying any pixels in the function. It's just going to return 0 if you don't supply anything. It can't read your mind. myScreenScaleW(600)
[QUOTE=BillyOnWiiU;49008370]You're not actually supplying any pixels in the function. It's just going to return 0 if you don't supply anything. It can't read your mind. myScreenScaleW(600)[/QUOTE] It looks good on 1080p now but the resolution scaling is fucked. [CODE] esc.menus = {} local myW = 1920 local myH = 1080 local function myScreenScaleW( w ) return (ScrW() * ((w or 0) / myW)) end local function myScreenScaleH( h ) return (ScrH() * ((h or 0) / myH)) end local fr function esc.openMenu() if IsValid(fr) and not fr.Closed then fr:SetVisible(false) fr.Closed = true return elseif IsValid(fr) and fr.Closed then fr:SetVisible(true) fr.Closed = false return end fr = vgui.Create('DPanel') fr:SetSize(myScreenScaleW(1920), myScreenScaleH(1080)) fr:MakePopup() fr.Paint = function(self, w, h) draw.Blur(self, 10) draw.Box(0, 0, w, h, esc.cfg.Background) end end [/CODE]
Could you not post large snippets of [URL="https://scriptfodder.com/scripts/view/778"]my addon[/URL]? I do hope you've actually purchased this too.
You should remove this code...
[QUOTE=StonedPenguin;49009480]Could you not post large snippets of [URL="https://scriptfodder.com/scripts/view/778"]my addon[/URL]? I do hope you've actually purchased this too.[/QUOTE] Oh I'm sorry, My friend who's helping me bought it. I'll fix it Edit: I tried to fix it, if it's not good enough just tell me again and I'll completely remove it or just delete thread
Since you're trying to "fix" a premium addon, I'd take this up with the developer. My code works absolutely fine and you are using the code wrong if it does not work.
Sorry, you need to Log In to post a reply to this thread.