So when I run this on my resolution every word is lined up in the right spot, but when someone with a different resolution sees this, the positions of the words are in different places. How do I fix this so the positions are in the same place for everyone.
[lua]
function test2()
local ply = LocalPlayer()
--Background--
timer.Simple( 3, function()
ply:EmitSound( "music/HL2_song20_submix0.mp3" )
local MyDermab = vgui.Create( "DFrame" )
MyDermab:SetSize( ScreenScale( 640 ), ScreenScale( 640 ))
MyDermab:SetTitle( "" )
MyDermab:ShowCloseButton( false )
MyDermab:SetDeleteOnClose(true)
MyDermab:Center()
MyDermab.Paint = function()
draw.RoundedBox( 8, 0, 0, MyDermab:GetWide(), MyDermab:GetTall(), Color( 0, 0, 0, 250 ) )
end
timer.Simple( 3, function()
local MyLabel41 = vgui.Create( "DLabel", MyDermab )
MyLabel41:SetText( "RolePlay" )
MyLabel41:SetFont( "nonmlg4" )
MyLabel41:SetPos( ScrW() / 2.5, ScrH() / 3 )
MyLabel41:SetTextColor( Color( 255, 255, 255, 255 ) )
MyLabel41:SizeToContents()
end)
timer.Simple( 6, function()
local MyLabel36 = vgui.Create( "DLabel", MyDermab )
MyLabel36:SetText( "by GoproMgH/Larry v1.0" )
MyLabel36:SetPos( ScrW() / 1.7, ScrH() / 1.2 )
MyLabel36:SetSize( 600, 50 )
MyLabel36:SetFont("mlg90")
end)
local MyDerma = vgui.Create( "DFrame" )
MyDerma:SetSize( 3000, 2000 )
MyDerma:SetTitle( "" )
MyDerma:ShowCloseButton( false )
MyDerma:SetDeleteOnClose(true)
MyDerma:SetPos( -500 )
MyDerma:Center()
MyDerma.Paint = function()
draw.RoundedBox( 8, 0, 0, MyDerma:GetWide(), MyDerma:GetTall(), Color( 0, 0, 0, 0 ) )
end
local anim = Derma_Anim( "EaseInQuad", MyDerma, function( pnl, anim, delta, data )
pnl:SetPos( inQuad( delta, -500, ScrW() / 1.35 ), ScrH() / 6 )
end )
anim:Start( 2 )
MyDerma.Think = function( self )
if anim:Active() then
anim:Run()
end
end
local MyLabel21 = vgui.Create( "DLabel", MyDerma )
MyLabel21:SetText( "StarWars" )
MyLabel21:SetFont( "nonmlg2" )
MyLabel21:SetTextColor( Color( 0, 0, 0, 255 ) )
MyLabel21:SizeToContents()
local MyLabel20 = vgui.Create( "DLabel", MyDerma )
MyLabel20:SetText( "StarWars" )
MyLabel20:SetFont( "nonmlg" )
MyLabel20:SetTextColor( Color( 255, 255, 0, 255 ) )
MyLabel20:SizeToContents()
timer.Simple( 4, function()
local MyDerma2 = vgui.Create( "DFrame" )
MyDerma2:SetSize( 3000, 2000 )
MyDerma2:SetTitle( "" )
MyDerma2:ShowCloseButton( false )
MyDerma2:SetDeleteOnClose(true)
MyDerma2:Center()
MyDerma2.Paint = function()
draw.RoundedBox( 8, 0, 0, MyDerma2:GetWide(), MyDerma2:GetTall(), Color( 0, 0, 0, 0 ) )
end
local anim = Derma_Anim( "EaseInQuad", MyDerma2, function( pnl, anim, delta, data )
pnl:SetPos( inQuad( delta, -500, ScrW() / 1.35 ), ScrH() / 1.5 )
end )
anim:Start( 2 )
MyDerma2.Think = function( self )
if anim:Active() then
anim:Run()
end
end
local MyLabel30 = vgui.Create( "DLabel", MyDerma2 )
MyLabel30:SetText( "Omniscient-Networks" )
MyLabel30:SetFont( "mlg9" )
MyLabel30:SetTextColor( Color( 59, 89, 152, 255 ) )
MyLabel30:SizeToContents()
timer.Simple( 8, function()
MyDerma2:Close()
end )
end)
timer.Simple( 12, function()
MyDermab:Close()
MyDerma:Close()
end )
timer.Simple( 13, function()
TextFrame2 = vgui.Create( "DFrame" )
TextFrame2:SetSize( 600, 300 )
TextFrame2:Center()
TextFrame2:SetTitle( "" )
TextFrame2:MakePopup()
TextFrame2:ShowCloseButton( false )
TextFrame2:SetDeleteOnClose(true)
TextFrame2.Paint = function()
draw.RoundedBox( 8, 0, 0, TextFrame2:GetWide(), TextFrame2:GetTall(), Color( 0, 0, 0, 250 ) )
end
local Con = vgui.Create( "DLabel", TextFrame2 )
Con:SetPos( 40, 40 )
Con:SetText( "Do you want to install the content?" )
Con:SizeToContents()
local DermaButton = vgui.Create( "DButton", TextFrame2 )
DermaButton:SetText( "Yes" )
DermaButton:SetPos( TextFrame2:GetWide() / 3, 100 )
DermaButton:SetSize( 250, 30 )
DermaButton.DoClick = function()
gui.OpenURL( "http://steamcommunity.com/sharedfiles/filedetails/?id=895490281" )
ply:ConCommand("stopsound")
TextFrame2:Close()
end
local DermaButton2 = vgui.Create( "DButton", TextFrame2 )
DermaButton2:SetText( "No" )
DermaButton2:SetPos( TextFrame2:GetWide() / 3, 200 )
DermaButton2:SetSize( 250, 30 )
DermaButton2.DoClick = function()
TextFrame2:Close()
ply:ConCommand("stopsound")
end
end )
end)
end
concommand.Add("greatintro",test2)
[/lua]
What's the inQuad command?
You should use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScrW]ScrW[/url], [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScrH]ScrH[/url], and if you want to avoid calculations - [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ScreenScale]ScreenScale[/url]
See the 'Scaling' section of this: [url]http://wiki.garrysmod.com/page/Derma_Basic_Guide[/url]
Shows you a pretty painless way to turn the positions you have 'hardcoded' into positions that will scale with any other resolutions.
[QUOTE=Wepl123;52406966]See the 'Scaling' section of this: [url]http://wiki.garrysmod.com/page/Derma_Basic_Guide[/url]
Shows you a pretty painless way to turn the positions you have 'hardcoded' into positions that will scale with any other resolutions.[/QUOTE]
Adding to this: If you do go with this way, instead of using 0.xxx with every single number, simply have this line at the top of your code:
[lua]local screenScale = ScrW()/1920 -- Replace 1920 with your screen width[/lua]
Make your panel with regular numbers, and replace every number with [B]number * screenScale[/B]
Sorry, you need to Log In to post a reply to this thread.