• Derma Property Sheet Help
    13 replies, posted
Hi I currently have a small menu that is a work in progress: [LUA] function bs8814panel() test = vgui.Create("DFrame") -- My Frame button = vgui.Create("DButton") -- The Button button2 = vgui.Create("DButton") -- The Button button3 = vgui.Create("DButton") -- The Button button4 = vgui.Create("DButton") -- The Button button5 = vgui.Create("DButton") -- The Button button6 = vgui.Create("DButton") -- The Button test:SetPos(50,50)-- Frames Position test:SetSize(500,500)-- 750 x 750 pixels test:SetTitle( "bs8814's VGUI" )-- The Name at top test:SetVisible( true )-- Visible test:MakePopup()-- Pops up button:SetParent( test )-- What menu it is on button:SetText( "Downfall To Us All" )-- What the button says button:SetPos(10,35) button:SetSize(100,50) button.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic2.mp3") end button2:SetParent( test )-- What menu it is on button2:SetText( "F You" )-- What the button says button2:SetPos(10,85) button2:SetSize(100,50) button2.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic3.mp3") end button3:SetParent( test )-- What menu it is on button3:SetText( "Smack My B Up" )-- What the button says button3:SetPos(10,135) button3:SetSize(100,50) button3.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic4.mp3") end button4:SetParent( test )-- What menu it is on button4:SetText( "I Got High" )-- What the button says button4:SetPos(10,185) button4:SetSize(100,50) button4.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic5.mp3") end button5:SetParent( test )-- What menu it is on button5:SetText( "MotherFucker" )-- What the button says button5:SetPos(110,35) button5:SetSize(100,50) button5.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic6.mp3") end button6:SetParent( test )-- What menu it is on button6:SetText( "Guns Go Boom Boom" )-- What the button says button6:SetPos(110,85) button6:SetSize(100,50) button6.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic7.mp3") end end concommand.Add("bsvgui", bs8814panel) [/LUA] And I have been trying to add it into a property sheet: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexe102.html#DPropertySheet[/url] (So it looks neat) But when I have tried it doesnt work. Whenever I have tried it comes up with heaps of errors. If anyone knows how to do it can you just post it so I can use that as an example, thanks in advanced :)
I'm gonna bump this because I really need the solution:)
Use a DPanel instead of DFrame.
It can look neat with a DPanelList, you don't really need a PropertySheet. [IMG]http://puu.sh/25cgg[/IMG] [lua]local PRoundMusic = { {"Downfall To Us All", "sprays/endroundmusic2.mp3"}, {"F You", "sprays/endroundmusic3.mp3"}, {"Smack My B Up", "sprays/endroundmusic4.mp3"}, {"I Got High", "sprays/endroundmusic5.mp3"}, {"MotherFucker", "sprays/endroundmusic6.mp3"}, {"Guns Go Boom Boom", "sprays/endroundmusic7.mp3"} } local Buttons = {} function PRMusicSelection() local DMain = vgui.Create("DFrame") DMain:SetSize(500,500) DMain:Center() DMain:SetVisible(true) DMain:SetTitle("Post-Round Music") DMain:MakePopup() local DList = vgui.Create("DPanelList",DMain) DList:SetPos(25,47) DList:SetSize(DMain:GetWide()-50,DMain:GetTall()-72) DList:SetPadding(0) DList:SetSpacing(0) DList:EnableHorizontal(false) DList:EnableVerticalScrollbar(true) DList.Paint = function(self,w,h) draw.RoundedBox(0,0,0,w,h,Color(150,150,150,255)) end for i = 1, #PRoundMusic do Buttons[i] = vgui.Create("DButton") Buttons[i]:SetSize(100,50) Buttons[i]:SetText(PRoundMusic[i][1]) Buttons[i].DoClick = function(self) RunConsoleCommand("ulx","playsound",PRoundMusic[i][2]) end DList:AddItem(Buttons[i]) end end PRMusicSelection()[/lua]
[QUOTE=Kuro Light;39644457]Use a DPanel instead of DFrame.[/QUOTE] If anything, you would want to put the DProperySheet inside of the DFrame, then put a DPanelList inside of the DPropertySheet. From there you can just add the buttons(or anything) to the DPanelList. This is basically how it works: [lua] --You create the DFrame\\ local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50, 50 ) DermaPanel:SetSize( 400, 600 ) DermaPanel:SetTitle( "Testing Derma Stuff" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) ---------------------------\\ --Then you create the DPropertySheet\\ local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) //Make sure you parent this to the DFrame. PropertySheet:SetPos( 5, 30 ) PropertySheet:SetSize( 340, 500 ) ---------------------------\\ --Now you create the DPanelList(This will act as a "page" inside of your DPropertySheet)\\ local DermaList = vgui.Create( "DPanelList", DermaPanel ) DermaList:SetPos( 25,25 ) DermaList:SetSize( 200, 200 ) DermaList:SetSpacing( 5 ) -- Spacing between items DermaList:EnableHorizontal( false ) -- Only vertical items DermaList:EnableVerticalScrollbar( true ) -- Allow scrollbar if you exceed the Y axis ---------------------------\\ --Now that you have created your "page", this is how you add it to the DPropertySheet\\ PropertySheet:AddSheet( "Button Menu", DermaList, "gui/silkicons/user", false, false, "A list of buttons!" ) ---------------------------\\ --After this you should have a DFrame with a DPropertySheet inside of it with a DPanelList as the first page of the DPropertySheet. Now just add anything you want to the DPanelList like buttons, texts, check boxes, ect.\\ local DermaButton = vgui.Create( "DButton" ) DermaButton:SetText( "Kill yourself" ) DermaButton:SetSize( 338, 50 ) DermaButton.DoClick = function () RunConsoleCommand( "kill" ) -- What happens when you press the button end --Make sure you actually add the button to the DPanelList, DPaneList is different because you add items to it instead of parenting them on top of it. This is how you add items: DermaList:AddItem( DermaButton ) ---------------------------\\ [/lua] Hope that helps in some way. [editline]19th February 2013[/editline] Nvm, fuck you garry for still not fixing the fucked up lua tags.
[QUOTE=brandonj4;39646308]It can look neat with a DPanelList, you don't really need a PropertySheet. [IMG]http://puu.sh/25cgg[/IMG] [lua]local PRoundMusic = { {"Downfall To Us All", "sprays/endroundmusic2.mp3"}, {"F You", "sprays/endroundmusic3.mp3"}, {"Smack My B Up", "sprays/endroundmusic4.mp3"}, {"I Got High", "sprays/endroundmusic5.mp3"}, {"MotherFucker", "sprays/endroundmusic6.mp3"}, {"Guns Go Boom Boom", "sprays/endroundmusic7.mp3"} } local Buttons = {} function PRMusicSelection() local DMain = vgui.Create("DFrame") DMain:SetSize(500,500) DMain:Center() DMain:SetVisible(true) DMain:SetTitle("Post-Round Music") DMain:MakePopup() local DList = vgui.Create("DPanelList",DMain) DList:SetPos(25,47) DList:SetSize(DMain:GetWide()-50,DMain:GetTall()-72) DList:SetPadding(0) DList:SetSpacing(0) DList:EnableHorizontal(false) DList:EnableVerticalScrollbar(true) DList.Paint = function(self,w,h) draw.RoundedBox(0,0,0,w,h,Color(150,150,150,255)) end for i = 1, #PRoundMusic do Buttons[i] = vgui.Create("DButton") Buttons[i]:SetSize(100,50) Buttons[i]:SetText(PRoundMusic[i][1]) Buttons[i].DoClick = function(self) RunConsoleCommand("ulx","playsound",PRoundMusic[i][2]) end DList:AddItem(Buttons[i]) end end PRMusicSelection()[/lua][/QUOTE] When the list goes longer than the frame will it have a scroll bar?
Parent the DPanelList to a DScrollPanel and DScrollPanel parent to DFrame. Then you have a working scrollbar aswell. EDIT: Nvm it already has vertical scrollbar enabled, i usually do it with DListLayout and DScrollPanel, think DPanelList is getting removed at some point in the future.
Ok, thanks to brandonj4 I now have a neater looking menu with the DPanelList. I have a few more questions though. How Can I have Tabs? How do I make it center in the middle of the screen? How do I make it so when you press a key it will pop up? (without having to get ppl to bind it)
[QUOTE=bs8814;39654101]Ok, thanks to brandonj4 I now have a neater looking menu with the DPanelList. I have a few more questions though. How Can I have Tabs? How do I make it center in the middle of the screen? How do I make it so when you press a key it will pop up? (without having to get ppl to bind it)[/QUOTE] *Add the DPanelList(without DFrame) to a DPropertySheet(there are tutorials on DPropertySheet, check them out) *To center it i usually use Panel:SetPos(ScrW()/2-self.GetWide()/2,0) there are probably some better ways, maybe a dedicated function just for it, i'm not sure. *Check out the functions OnKeyPress and OnKeyRelease.
The key things is just confusing me (and not working), the center didnt work and I have tried property sheet before and what I tried didnt work, and I dont see how it would work this time.
* [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexa201-2.html[/url] It shows letter by letter how to add any panel to a DPropertySheet as a tab. Show what you tried i'll try and find what you did wrong. *Try using Panel:CenterHorizontal() and i misspelled it before, its self:GetWide() not self.GetWide(). *The key press one actually ain't good anyway, don't have anything good to hook it into (Think hook is bad). If you are fine with using F1-F4 then use one of the serverside hooks: ShowHelp - F1, ShowTeam - F2, ShowSpare1 - F3, ShowSpare2 - F4. I use concommand to execute a function clientside.
DPropertySheet doesnt work here is what I tried: [LUA] function bs8814panel() test = vgui.Create("DFrame") -- My Frame DermaList = vgui.Create( "DPanelList", test ) button = vgui.Create("DButton") -- The Button button2 = vgui.Create("DButton") -- The Button button3 = vgui.Create("DButton") -- The Button button4 = vgui.Create("DButton") -- The Button button5 = vgui.Create("DButton") -- The Button button6 = vgui.Create("DButton") -- The Button button7 = vgui.Create("DButton") -- The Button button8 = vgui.Create("DButton") -- The Button button9 = vgui.Create("DButton") -- The Button button10 = vgui.Create("DButton") -- The Button Sheet = vgui.Create("DPropertySheet", Panel); Sheet:SetPos(2, 20); Sheet:SetSize(Panel:GetWide() - 4, Panel:GetTall() - 22); Sheet:AddSheet("A sheet", DermaList, button, button2, button3, button4, button5, button6, button7, button8, button9, button10 "gui/silkicons/user", false, false, "Activate sv_cheats from here"); test:Center()-- Frames Position test:SetSize(500,500)-- 750 x 750 pixels test:SetTitle( "Donor's Menu" )-- The Name at top test:SetVisible( true )-- Visible test:MakePopup()-- Pops up DermaList:SetPos( 10,25 ) DermaList:SetSize( 470, 470 ) DermaList:SetSpacing( 5 ) -- Spacing between items DermaList:EnableHorizontal( false ) -- Only vertical items DermaList:EnableVerticalScrollbar( true ) -- Allow scrollbar if you exceed the Y axis button:SetParent( test )-- What menu it is on button:SetText( "Downfall To Us All" )-- What the button says button:SetSize(100,50) DermaList:AddItem( button ) button.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic2.mp3") end button2:SetParent( test )-- What menu it is on button2:SetText( "Fuck You" )-- What the button says button2:SetSize(100,50) DermaList:AddItem( button2 ) button2.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic3.mp3") end button3:SetParent( test )-- What menu it is on button3:SetText( "Smack My Bitch Up" )-- What the button says button3:SetSize(100,50) DermaList:AddItem( button3 ) button3.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic4.mp3") end button4:SetParent( test )-- What menu it is on button4:SetText( "Because I got High" )-- What the button says button4:SetSize(100,50) DermaList:AddItem( button4 ) button4.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic5.mp3") end button5:SetParent( test )-- What menu it is on button5:SetText( "Yippie-Kai-Yai Motherfucker" )-- What the button says button5:SetSize(100,50) DermaList:AddItem( button5 ) button5.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic6.mp3") end button6:SetParent( test )-- What menu it is on button6:SetText( "Firepower" )-- What the button says button6:SetSize(100,50) DermaList:AddItem( button6 ) button6.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic7.mp3") end button7:SetParent( test )-- What menu it is on button7:SetText( "Rage Valley" )-- What the button says button7:SetPos(10,335) button7:SetSize(100,50) DermaList:AddItem( button7 ) button7.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic8.mp3") end button8:SetParent( test )-- What menu it is on button8:SetText( "The Jungle" )-- What the button says button8:SetSize(100,50) DermaList:AddItem( button8 ) button8.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic9.mp3") end button9:SetParent( test )-- What menu it is on button9:SetText( "Pull The Trigger" )-- What the button says button9:SetSize(100,50) DermaList:AddItem( button9 ) button9.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic10.mp3") end button10:SetParent( test )-- What menu it is on button10:SetText( "Guns Dont Kill People, I Do" )-- What the button says button10:SetSize(100,50) DermaList:AddItem( button10 ) button10.DoClick = function () RunConsoleCommand("ulx","playsound","sprays/endroundmusic11.mp3") end end concommand.Add("donormenu", bs8814panel) [/LUA] And I got a bunch of errors, lemme know if you need em (forgot to copy em).
[QUOTE=bs8814;39676328]-snip-[/QUOTE] [B]It's like you didn't even learn anything from my post.[/B] Don't make global variable names for Panels. If you want it to be global put the panels in a table instead. The way you're adding buttons is extremely ugly and inconvenient. There is a perfectly good DProperty sheet tutorial [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb285.html"]here[/URL].
Ok, I will try this all over again...
Sorry, you need to Log In to post a reply to this thread.