Resolution problem for a menu

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.


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

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).

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)

It looks good on 1080p now but the resolution scaling is fucked.


 
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



Could you not post large snippets of my addon? I do hope you’ve actually purchased this too.

You should remove this code…

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.