• Collapsed Catorgory doesn't open
    17 replies, posted
  • Avatar of Zyler
  • [URL=http://img33.imageshack.us/i/2011120300002.jpg/][IMG]http://img33.imageshack.us/img33/3341/2011120300002.th.jpg[/IMG][/URL] [URL=http://img684.imageshack.us/i/2011120300001.jpg/][IMG]http://img684.imageshack.us/img684/7999/2011120300001.th.jpg[/IMG][/URL] here's the whole code: [lua]// Clientside only stuff goes here function ShowTeamMenu() local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself DermaPanel:SetPos( 80,80 ) -- Position on the players screen DermaPanel:SetSize( 600, 500 ) -- Size of the frame DermaPanel:SetTitle( "Main Menu" ) -- Title of the frame DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) -- Draggable by mouse? DermaPanel:ShowCloseButton( true ) -- Show the close button? DermaPanel:MakePopup() -- Show the frame local TestingPanel = vgui.Create( "DPanel", DermaPanel ) TestingPanel:SetPos( 25, 50 ) TestingPanel:SetSize( 550, 50 ) TestingPanel.Paint = function() -- Paint function surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect surface.DrawText( "Message of the Day: Zyler Rocks!" ) end local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) PropertySheet:SetPos( 25, 110 ) PropertySheet:SetSize( 550, 315 ) local Welcome = vgui.Create( "DLabel" ) Welcome:SetText( "A" ) Welcome:SetColor(Color(191,255,0,255)) Welcome:SizeToContents() local Character = vgui.Create( "DPanel" ) Character:SetSize( 305, 305 ) Character.paint = function() surface.SetDrawColor(Color(191,255,0,255)) surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) surface.DrawText( "Characters" ) end local Props = vgui.Create( "DPanel" ) Props:SetSize( 305, 305 ) Props.paint = function() surface.SetDrawColor(Color(191,255,0,255)) surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) surface.DrawText( "Pick props to spawn" ) end local food = {} food[1] = "models/props_junk/garbage_milkcarton002a.mdl" food[2] = "models/props_junk/PopCan01a.mdl" food[3] = "models/props_junk/garbage_takeoutcarton001a.mdl" food[4] = "models/props_junk/watermelon01.mdl" food[5] = "models/props_junk/garbage_metalcan001a.mdl" food[6] = "models/props_lab/box01a.mdl" food[7] = "models/props_lab/box01b.mdl" local Proplist1 = vgui.Create("DCollapsibleCategory", Props) Proplist1:SetPos(25, 50) Proplist1:SetSize( 450, 50 ) -- Keep the second number at 50 Proplist1:SetLabel( "Proplist1" ) Proplist1menu = vgui.Create("DModelSelect", Proplist1 ) Proplist1menu:SetSize( 300, 300 ) Proplist1menu:SetSpacing( 5 ) Proplist1menu:EnableHorizontal( true ) Proplist1menu:EnableVerticalScrollbar( false ) Proplist1menu:SetPadding( 4 ) for k,v in pairs(food) do local icon = vgui.Create( "SpawnIcon", Proplist1menu ) icon:SetModel( v ) Proplist1menu:AddItem( icon ) icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end end Proplist1:SetContents(Proplist1menu) PropertySheet:AddSheet( "Welcome", Welcome, "gui/silkicons/user", false, false, "Rules and stuff" ) PropertySheet:AddSheet( "Character/Groups", Character, "gui/silkicons/group", false, false, "Manage your character and groups" ) PropertySheet:AddSheet( "Props/Tools", Props, "gui/silkicons/group", false, false, "Get Props and Tools" ) local groupsnamesasdf = {} groupsnamesasdf[1] = "Civil Service" groupsnamesasdf[2] = "Government" groupsnamesasdf[3] = "Employable" local groupslist = vgui.Create("DCollapsibleCategory", Character) groupslist:SetPos(25, 50) groupslist:SetSize( 450, 45 ) -- Keep the second number at 50 groupslist:SetLabel( "Groups" ) local group1 = vgui.Create("DLabel", groupslist) group1:SetPos(20,20) group1:SetColor(Color(255,255,255,255)) group1:SetFont("default") group1:SetText(groupsnamesasdf[1]) group1:SizeToContents() group1menu = vgui.Create("DModelSelect", groupslist ) group1menu:SetPos(40, 40) group1menu:SetSize( 300, 300 ) group1menu:SetSpacing( 5 ) group1menu:EnableHorizontal( true ) group1menu:EnableVerticalScrollbar( false ) group1menu:SetPadding( 4 ) for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER local spawnicon = vgui.Create( "SpawnIcon", group1menu ) spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them" group1menu:AddItem( spawnicon ) end end usermessage.Hook( "call_vgui", ShowTeamMenu )[/lua] the code in question: [lua]local groupsnamesasdf = {} groupsnamesasdf[1] = "Civil Service" groupsnamesasdf[2] = "Government" groupsnamesasdf[3] = "Employable" local groupslist = vgui.Create("DCollapsibleCategory", Character) groupslist:SetPos(25, 50) groupslist:SetSize( 450, 45 ) -- Keep the second number at 50 groupslist:SetLabel( "Groups" ) local group1 = vgui.Create("DLabel", groupslist) group1:SetPos(20,20) group1:SetColor(Color(255,255,255,255)) group1:SetFont("default") group1:SetText(groupsnamesasdf[1]) group1:SizeToContents() group1menu = vgui.Create("DModelSelect", groupslist ) group1menu:SetPos(40, 40) group1menu:SetSize( 300, 300 ) group1menu:SetSpacing( 5 ) group1menu:EnableHorizontal( true ) group1menu:EnableVerticalScrollbar( false ) group1menu:SetPadding( 4 ) for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER local spawnicon = vgui.Create( "SpawnIcon", group1menu ) spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them" group1menu:AddItem( spawnicon ) end end[/lua]
  • Avatar of Deadman123
  • [LUA]groupslist:SetSize( 450, 45 ) -- Keep the second number at 50[/LUA] line 8 of questionable code. Durrrr
  • Avatar of Zyler
  • [QUOTE=Deadman123;33545198][LUA]groupslist:SetSize( 450, 45 ) -- Keep the second number at 50[/LUA] line 8 of questionable code. Durrrr[/QUOTE] That just affects the size of the Collapsible Catorgory before you open it. I've tried changing the value to different things and it makes no difference whether it is set to 50, 45 or even 150, except changing the actual size of the Catorgory before it is opened. No matter what size I set it to it still doesn't expand however
  • Avatar of Deadman123
  • Then go to the wiki? lemme look at the code more Edit: Is DModelSelect even a Derma control? last time i checked it wasn't, or I at least didnt see it
  • Avatar of Zyler
  • [QUOTE=Deadman123;33552489]Then go to the wiki? lemme look at the code more Edit: Is DModelSelect even a Derma control? last time i checked it wasn't, or I at least didnt see it[/QUOTE] [url]http://wiki.garrysmod.com/?title=DModelSelect[/url] It's a panel of spawnicons.
  • Avatar of Deadman123
  • I see Edit: You could just use Spawnicons and a loop with a .DoClick function, thats the way i always do it and it works
  • Avatar of Zyler
  • [QUOTE=Deadman123;33558234]I see Edit: You could just use Spawnicons and a loop with a .DoClick function, thats the way i always do it and it works[/QUOTE] Could I have an example?
  • Avatar of Deadman123
  • like [LUA] props = {} props[1] = "Models/hurrdurr.mdl" props[2] = "Models/hurrdurr2.mdl" for k,v in pairs(props) do icon = vgui.Create("SpawnIcon", <Parent Panel Here>) icon:SetModel(v) icon.DoClick = function() RunConsoleCommand("gm_spawn"..v) end [/LUA] something along those lines
  • Avatar of Zyler
  • tried this: [lua] local groupslist = vgui.Create("DCollapsibleCategory", Character) groupslist:SetPos(25, 50) groupslist:SetSize( 450, 45 ) -- Keep the second number at 50 groupslist:SetLabel( "Groups" ) local group1 = vgui.Create("DLabel", groupslist) group1:SetPos(20,20) group1:SetColor(Color(255,255,255,255)) group1:SetFont("default") group1:SetText(groupsnamesasdf[1]) group1:SizeToContents() for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER local spawnicon = vgui.Create( "SpawnIcon", groupslist ) spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them" group1menu:AddItem( spawnicon ) end[/lua] Didn't work, got this: [URL=http://img831.imageshack.us/i/2011120400001.jpg/][IMG]http://img831.imageshack.us/img831/5544/2011120400001.th.jpg[/IMG][/URL] [URL=http://img841.imageshack.us/i/2011120400002.jpg/][IMG]http://img841.imageshack.us/img841/2833/2011120400002.th.jpg[/IMG][/URL] Still doesn't open :(
  • Avatar of Zyler
  • [QUOTE=Blasphemy;33583553]You need groupslist:SetContents(group1menu) after your for loop.[/QUOTE] no effect :(. [URL=http://img440.imageshack.us/i/2011120900002.jpg/][IMG]http://img440.imageshack.us/img440/6977/2011120900002.th.jpg[/IMG][/URL] [URL=http://img805.imageshack.us/i/2011120900001.jpg/][IMG]http://img805.imageshack.us/img805/48/2011120900001.th.jpg[/IMG][/URL] I tried both inside (at the end of) and outside the loop: [lua]// Clientside only stuff goes here function ShowTeamMenu() local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself DermaPanel:SetPos( 80,80 ) -- Position on the players screen DermaPanel:SetSize( 600, 500 ) -- Size of the frame DermaPanel:SetTitle( "Main Menu" ) -- Title of the frame DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) -- Draggable by mouse? DermaPanel:ShowCloseButton( true ) -- Show the close button? DermaPanel:MakePopup() -- Show the frame local TestingPanel = vgui.Create( "DPanel", DermaPanel ) TestingPanel:SetPos( 25, 50 ) TestingPanel:SetSize( 550, 50 ) TestingPanel.Paint = function() -- Paint function surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect surface.DrawText( "Message of the Day: Zyler Rocks!" ) end local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) PropertySheet:SetPos( 25, 110 ) PropertySheet:SetSize( 550, 315 ) local Welcome = vgui.Create( "DLabel" ) Welcome:SetText( "A" ) Welcome:SetColor(Color(191,255,0,255)) Welcome:SizeToContents() local Character = vgui.Create( "DPanel" ) Character:SetSize( 305, 305 ) Character.paint = function() surface.SetDrawColor(Color(191,255,0,255)) surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) surface.DrawText( "Characters" ) end local Props = vgui.Create( "DPanel" ) Props:SetSize( 305, 305 ) Props.paint = function() surface.SetDrawColor(Color(191,255,0,255)) surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) surface.DrawText( "Pick props to spawn" ) end local food = {} food[1] = "models/props_junk/garbage_milkcarton002a.mdl" food[2] = "models/props_junk/PopCan01a.mdl" food[3] = "models/props_junk/garbage_takeoutcarton001a.mdl" food[4] = "models/props_junk/watermelon01.mdl" food[5] = "models/props_junk/garbage_metalcan001a.mdl" food[6] = "models/props_lab/box01a.mdl" food[7] = "models/props_lab/box01b.mdl" local Proplist1 = vgui.Create("DCollapsibleCategory", Props) Proplist1:SetPos(25, 50) Proplist1:SetSize( 450, 50 ) -- Keep the second number at 50 Proplist1:SetLabel( "Proplist1" ) Proplist1menu = vgui.Create("DModelSelect", Proplist1 ) Proplist1menu:SetSize( 300, 300 ) Proplist1menu:SetSpacing( 5 ) Proplist1menu:EnableHorizontal( true ) Proplist1menu:EnableVerticalScrollbar( false ) Proplist1menu:SetPadding( 4 ) for k,v in pairs(food) do local icon = vgui.Create( "SpawnIcon", Proplist1menu ) icon:SetModel( v ) Proplist1menu:AddItem( icon ) icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end end Proplist1:SetContents(Proplist1menu) PropertySheet:AddSheet( "Welcome", Welcome, "gui/silkicons/user", false, false, "Rules and stuff" ) PropertySheet:AddSheet( "Character/Groups", Character, "gui/silkicons/group", false, false, "Manage your character and groups" ) PropertySheet:AddSheet( "Props/Tools", Props, "gui/silkicons/group", false, false, "Get Props and Tools" ) local groupsnamesasdf = {} groupsnamesasdf[1] = "Civil Service" groupsnamesasdf[2] = "Government" groupsnamesasdf[3] = "Employable" local groupslist = vgui.Create("DCollapsibleCategory", Character) groupslist:SetPos(25, 50) groupslist:SetSize( 450, 45 ) -- Keep the second number at 50 groupslist:SetLabel( "Groups" ) local group1 = vgui.Create("DLabel", groupslist) group1:SetPos(20,20) group1:SetColor(Color(255,255,255,255)) group1:SetFont("default") group1:SetText(groupsnamesasdf[1]) group1:SizeToContents() for _, pl in pairs( team.GetPlayers( 1 ) ) do -- loop through all the players on TEAM_WHATEVER local spawnicon = vgui.Create( "SpawnIcon", groupslist ) spawnicon:SetModel( pl:GetModel() ) -- get their model, set the spawnicon to it spawnicon:SetTooltip( pl:Nick() ) -- "little yellow speech bubbles when you move your cursor over them" group1menu:AddItem( spawnicon ) end groupslist:SetContents(group1menu) end usermessage.Hook( "call_vgui", ShowTeamMenu )[/lua]
  • Avatar of Blasphemy
  • [url]http://pastebin.com/v9bHDCsh[/url] That works perfectly, you changed a lot of stuff around in your newer code when all you needed was to grouplist:SetContents(group1menu) in your old code.
  • Avatar of Zyler
  • [QUOTE=Blasphemy;33640564][url]http://pastebin.com/v9bHDCsh[/url] That works perfectly, you changed a lot of stuff around in your newer code when all you needed was to grouplist:SetContents(group1menu) in your old code.[/QUOTE] works now, but nothing appears in the Collapsed Catorgory: [URL=http://imageshack.us/photo/my-images/846/2011121000001.jpg/][IMG]http://img846.imageshack.us/img846/4650/2011121000001.jpg[/IMG][/URL] Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
  • Avatar of Zyler
  • [QUOTE=Blasphemy;33647122]That would mean there are no players in team 1.[/QUOTE] It sets the players team to team 1 in the server code, how would I make a user message that specifies this?
  • Avatar of Zyler
  • [QUOTE=Zyler;33650510]It sets the players team to team 1 in the server code, how would I make a user message that specifies this?[/QUOTE] bump! It doesn't have to be a user message
  • Avatar of Blasphemy
  • You don't need a usermessage. There obviously are no players in team 1, change what it's sorting through to player.GetAll() to verify.