How do I do this I know I use ScrH somehow.? Complete noob with any interface items. If you need more explaination the text etc is different on everyone's screen
[lua]ScrW() * 0.50
ScrW() / 2[/lua]
These will return the width of half the screen no matter what resolution. Just use some math, and you'll be able to make your HUD as resolution independent as you want!
[QUOTE=Author.;47003585]
ScrW() * 0.50ScrW() / 2
These will return the width of half the screen no matter what resolution. Just use some math, and you'll be able to make your HUD as resolution independent as you want![/QUOTE]
Thanks :)
-EDIT
Shouldn't there be a ScrH too?
There is, you can do the same thing here too. Just be aware that some people can have other aspect ratios such as 4:30 or 16:10
[QUOTE=Author.;47003676]There is, you can do the same thing here too. Just be aware that some people can have other aspect ratios such as 4:30 or 16:10[/QUOTE]
What does it cause if people have 4:30, 16:10 etc?
If you aren't doing crazy things, it shouldn't change things really. Just consider putting sane maximums on the size of your controls, so people with super wide setups like eyefinity don't have your health bar stretch across two monitors or things like that.
Just don't scale to both the width and the height at the same time when doing anything with textures or anything that needs to be square.
You may want to also look into [url=http://wiki.garrysmod.com/page/Global/ScreenScale]ScreenScale[/url] for scaling items.
[QUOTE=Kozmic;47003786]You may want to also look into [url=http://wiki.garrysmod.com/page/Global/ScreenScale]ScreenScale[/url] for scaling items.[/QUOTE]
To people who voted 'disagree' - why?
[QUOTE=Neat-Nit;47005592]To people who voted 'disagree' - why?[/QUOTE]
i've never seen it used for anything other than scaling fonts
It's only meant for fonts.
But some, even most HUD elements have the only purpose of having text in them. For example, a health indicator (like the default one) has both the text part and the rounded rectangle surrounding it. The rectangle should be in a size matching the font size.
I can't imagine a HUD element that shouldn't be scaled in the same way as text.
Personally, I use this:
[lua]
function glu.util.sscale( size )
return size * ( ScrH() / 480.0 )
end
[/lua]
It based on height, but it will scale well with any resolution. I made a vgui menu on 2560x1080, and it looks just fine on 1024x768.
[QUOTE=vexx21322;47006039]It's only meant for fonts.[/QUOTE]
Fonts are apart of HUD and GUI, no? So why would it be wrong to use ScreenScale in having them sync to different display sizes?
[QUOTE=Drak_Thing;47007798]Personally, I use this:
[lua]
function glu.util.sscale( size )
return size * ( ScrH() / 480.0 )
end
[/lua]
It based on height, but it will scale well with any resolution. I made a vgui menu on 2560x1080, and it looks just fine on 1024x768.[/QUOTE]
You do realize that this is exactly the same as ScreenScale, just based on height instead of width, right?
I mean, the only difference is the effect of different aspect ratios, which personally I think width is better to scale by than height (depending on what you're doing, of course).
And I see someone has Disagreed with you already. I'd really like to hear the counterarguments: "it's only made for fonts" is a non-reason.
[QUOTE=Kozmic;47008596]Fonts are apart of HUD and GUI, no? So why would it be wrong to use ScreenScale in having them sync to different display sizes?[/QUOTE]
ScreenScale just returns the number times the current screen width divided by 640, so is only appropriate for scaling width, and will provided distorted results if you do not scale height by screen height divided by 480.
This means that on larger "standard" resolutions ( 1680x1050, 1920x1080, etc ), you are looking at all of your scaled values being roughly two to three times their initial value, but the vertical scale only changes minimally and will result in things being much larger than they need to be.
So, scale things that matter how tall they are by the screen height and things that matter how long they are by the screen width.
Syncing all huds together?? By the responses I'm inclined to think you want them to scale uniformly, but from the title I'm guessing you want a timer or something to sync...
Proper HUD Creation:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url]
An easy way to scale your hud: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html[/url] ( Elements; for font you'd need to use ScreenScale or another function on the size of the font in surface.CreateFont )
Time: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/time/understanding_time%20and_basic_time_calculations.lua.html[/url]
A Countdown which is synced ( because CurTime/RealTime, etc.. are synced to the client ) because we set the start-time and the duration and a small delay to ensure all clients receive it in time to witness the start: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/sh_hud_countdown.lua.html[/url]
Sorry, you need to Log In to post a reply to this thread.