Derma Issues

Okay, So I really hate clientside scripting, I normally do serverside. However, once in a blue moon I will work on some derma.

[LUA]

surface.CreateFont(“Tahoma”, 30, 1000, true, false, “SelectSexFont”);

function Choose_RPName()
local DFrame2
local Confirmation
local LastNameLabel
local FirstNameLabel
local LastNameText
local FirstNameText

DFrame2 = vgui.Create(‘DFrame’)
DFrame2:SetSize(ScrW() * 0.476, ScrH() * 0.424)
DFrame2:SetPos(ScrW() * 0.27, ScrH() * 0.346)
DFrame2:SetTitle(‘Choose Roleplay Name’)
DFrame2:SetDeleteOnClose(false)
DFrame2:ShowCloseButton(false)
DFrame2:MakePopup()

LastNameLabel = vgui.Create(‘DLabel’)
LastNameLabel:SetParent(DFrame2)
LastNameLabel:SetPos(ScrW() * 0.46, ScrH() * 0.558)
LastNameLabel:SetText(’ Last Name’)
LastNameLabel:SizeToContents()

FirstNameLabel = vgui.Create(‘DLabel’)
FirstNameLabel:SetParent(DFrame2)
FirstNameLabel:SetPos(ScrW() * 0.46, ScrH() * 0.446)
FirstNameLabel:SetText(’ First Name’)
FirstNameLabel:SizeToContents()

FirstNameText = vgui.Create(‘DTextEntry’)
FirstNameText:SetParent(DFrame2)
FirstNameText:SetSize(ScrW() * 0.187, ScrH() * 0.045)
FirstNameText:SetPos(ScrW() * 0.413, ScrH() * 0.491)
FirstNameText:SetText(’’)
FirstNameText.OnEnter = function() end

LastNameText = vgui.Create(‘DTextEntry’)
LastNameText:SetParent(DFrame2)
LastNameText:SetSize(ScrW() * 0.19, ScrH() * 0.045)
LastNameText:SetPos(ScrW() * 0.143, ScrH() * 0.257)
LastNameText:SetText(’’)
LastNameText.OnEnter = function() end

Confirmation = vgui.Create(‘DButton’)
Confirmation:SetParent(DFrame2)
Confirmation:SetSize(ScrW() * 0.127, ScrH() * 0.045)
Confirmation:SetPos(ScrW() * 0.444, ScrH() * 0.692)
Confirmation:SetText(‘Save!’)
Confirmation.DoClick =
function()
if FirstNameText:GetValue() == ‘’ or LastNameText:GetValue() == ‘’ then
draw.SimpleText(‘Incorrect Roleplay Name!’, ‘SelectSexFont’, ScrW() * .5 - W * .5, ScrH() * .5 - H * .85, Color(255, 255, 255, 255), 1, 1);
return
elseif string.len(FirstNameText:GetValue()) > 10 or string.len(LastNameText:GetValue()) > 15 then
draw.SimpleText(‘Shorter Name Please!’, ‘SelectSexFont’, ScrW() * .5 - W * .5, ScrH() * .5 - H * .85, Color(255, 255, 255, 255), 1, 1);
return
else
RunConsoleCommand(“crpname”, FirstNameText, LastNameText)
DFrame2:Remove()
end
end

end

[/LUA]

Problem: For some reason, LastNameText and DFrame2 are the only two things actually showing up. Any idea why?

Thanks.

http://img709.imageshack.us/img709/3460/indeed.png

[lua]surface.CreateFont(“Tahoma”, 30, 1000, true, false, “SelectSexFont”);

function Choose_RPName()
local DFrame2
local Confirmation
local LastNameLabel
local FirstNameLabel
local LastNameText
local FirstNameText

DFrame2 = vgui.Create(‘DFrame’)
DFrame2:SetSize(350,150)
DFrame2:SetPos(ScrW() * 0.27, ScrH() * 0.346)
DFrame2:SetTitle(‘Choose Roleplay Name’)
DFrame2:SetDeleteOnClose(false)
DFrame2:Center()
DFrame2:ShowCloseButton(true) – change to true when done, do not want unclosable Derma Sappen my view
DFrame2:MakePopup()

LastNameLabel = vgui.Create(‘DLabel’)
LastNameLabel:SetParent(DFrame2)
LastNameLabel:SetPos(45, 50)
LastNameLabel:SetText(’ Last Name’)
LastNameLabel:SizeToContents()

FirstNameLabel = vgui.Create(‘DLabel’)
FirstNameLabel:SetParent(DFrame2)
FirstNameLabel:SetPos(45, 85)
FirstNameLabel:SetText(’ First Name’)
FirstNameLabel:SizeToContents()

FirstNameText = vgui.Create(‘DTextEntry’)
FirstNameText:SetParent(DFrame2)
FirstNameText:SetSize(150,20)
FirstNameText:SetPos(115,45)
FirstNameText:SetText(’’)
FirstNameText.OnEnter = function() end

LastNameText = vgui.Create(‘DTextEntry’)
LastNameText:SetParent(DFrame2)
LastNameText:SetSize(150,20)
LastNameText:SetPos(115, 80)
LastNameText:SetText(’’)
LastNameText.OnEnter = function() end

Confirmation = vgui.Create(‘DButton’)
Confirmation:SetParent(DFrame2)
Confirmation:SetSize(75, 20)
Confirmation:SetPos(155, 115)
Confirmation:SetText(‘Save!’)
Confirmation.DoClick =
function()
if FirstNameText:GetValue() == ‘’ or LastNameText:GetValue() == ‘’ then
draw.SimpleText(‘Incorrect Roleplay Name!’, ‘SelectSexFont’, ScrW() * .5 - W * .5, ScrH() * .5 - H * .85, Color(255, 255, 255, 255), 1, 1);
return
elseif string.len(FirstNameText:GetValue()) > 10 or string.len(LastNameText:GetValue()) > 15 then
draw.SimpleText(‘Shorter Name Please!’, ‘SelectSexFont’, ScrW() * .5 - W * .5, ScrH() * .5 - H * .85, Color(255, 255, 255, 255), 1, 1);
return
else
RunConsoleCommand(“crpname”, FirstNameText, LastNameText)
DFrame2:Remove()
end
end
end

concommand.Add(“DOpen”, Choose_RPName) [/lua]

For some reason i dont know why doing ScrW() and ScrH() where screwing up so i just did the old fashion way and replaced them.

[editline]03:02AM[/editline]

:v: woops first and last are switched

If you wanted, you could also use DermaDesigner, which is supposed to make derma menus easier: http://www.facepunch.com/showthread.php?t=940310

/shamelessadvertising

No, but an very important concept is the idea of parenting. When you parent a child to a parent, then the child is “relative” to the parent in multiple ways. A very important use in this is that the origin of the coordinates on which you base your panel position becomes the position of the parent on the screen. Meaning (0,0) for a child is actually the parent’s (x,y) on the screen, if the parent does not have another parent. So, your problem is you set position absolutely for elements that should be positioned relatively.