On the store on my f1 menu, there is various sections, i wanted to create a new section called Transport, and put all of my vehicles in that section, How would i go about doing this?
Thanks!
Bump
You could do it using [url=http://wiki.garrysmod.com/?title=DPropertySheet]DPropertySheet [/url] it has tabs and you can make your new vehicle panel and then add it to the property sheet using [url=http://wiki.garrysmod.com/?title=DPropertySheet.AddSheet]DPropertySheet.AddSheet[/url]. Every you add a panel using :AddSheet() it adds another tab containing what you placed on the panel.
Hope this helps, I can post an example later, much later, tonight if this didn't help or I wasn't clear.
Well im new to this sort of stuff, and i've read through that thing but i don't understand :P
could you just give me and example? Thanks.
This is the some of the code from the menu in my meteor defense gamemode, I commented it so hopefully this helps, This should create a DFrame and Put a property sheet in with 2 tabs, this is not the complete code for the whole menu just the part that shows creating DPropertySheets and using them.
[lua]
-- Create a DFrame to hold the menu
MeteorMenu = vgui.Create('DFrame')
MeteorMenu:SetSize(513, 408)
MeteorMenu:Center()
MeteorMenu:SetTitle('Meteor Defense Menu')
MeteorMenu:SetDeleteOnClose(false)
-- Create the panels that will hold what I want in the tabs
-- Tab 1
propPanel = vgui.Create('DPanel')
propPanel:SetSize(208, 335)
-- Tab 2
entityPanel = vgui.Create('DPanel')
entityPanel:SetSize(208,335)
-- Create the Property sheet
iconSheet = vgui.Create('DPropertySheet')
iconSheet:SetParent(MeteorMenu) -- Parent the Sheet to the main menu frame
iconSheet:SetPos(10,34) -- While parented the position is relative to the the parent, i.e. 0,0 is the top left of the parent
iconSheet:SetSize(210,356)
-- Time to add content to the panels
-- Both panels use spawn Icons and contain OnMouse* code to make it do things
local rowCount = 0
local rowOffset = 10
local perCol = 3
local colCount = 0
local colOffset = 10
local spawnIconWidth = 62
local spawnIconHeight = 62
for k,v in pairs(props) do
local spawnIcon = vgui.Create('SpawnIcon') -- Create the Icon
spawnIcon:SetModel(v[2]) -- Set the model we want it to show
spawnIcon:SetParent(propPanel) -- Parent it to the prop panel (tab 1)
spawnIcon:SetPos((colOffset + ( colCount * spawnIconWidth)), (rowOffset + ( rowCount * spawnIconHeight)))
local toolTip = v[1] .. " \n " .. "Cost: " .. tostring(v[3])
spawnIcon:SetToolTip( toolTip )
spawnIcon.OnMousePressed = function() RunConsoleCommand("fan_buy", k) end
spawnIcon.OnMouseReleased = function() RememberCursorPosition( ) MeteorMenu:Close() end
colCount = colCount + 1
if colCount == perCol then
colCount = 0
rowCount = rowCount +1
end
end
rowCount = 0
colCount = 0
-- Now to do the same with the entity panel (tab 2)
for k,v in pairs(entities) do
local spawnIcon = vgui.Create('SpawnIcon') -- Create the Icon
spawnIcon:SetModel(v[2]) -- Set the model
spawnIcon:SetParent(entityPanel) -- Parent these to the entity panel (tab 2)
spawnIcon:SetPos((colOffset + ( colCount * spawnIconWidth)), (rowOffset + ( rowCount * spawnIconHeight)))
local toolTip = v[1] .. " \n "
.. "Radius: " .. tostring(v[4]) .. "\n"
.. "Energy: " .. tostring(v[5]) .. "\n"
.. "Cost: " .. tostring(v[6]) .. "\n"
spawnIcon:SetToolTip( toolTip )
spawnIcon.OnMousePressed = function() RunConsoleCommand("fan_buy", v[3], k ) end
spawnIcon.OnMouseReleased = function() RememberCursorPosition( ) MeteorMenu:Close() end
colCount = colCount + 1
if colCount == perCol then
colCount = 0
rowCount = rowCount +1
end
end
-- And finaly after making the content call AddSheet on the Property sheet
-- Variables:
-- "Props" = Name that shows in the tab
-- propPanel = The Panel that goes in the tab
-- "guil/silkicon/toybox" = The icon to show next to the tab text
-- false = NoStretchX -- Not really sure what this does, but false works for me
-- false = NoStretchY -- Not really sure what this does, but false works for me
-- "Things to build with." = Tool tip that shows when you hover over the tab.
iconSheet:AddSheet("Props", propPanel, "gui/silkicons/toybox", false, false, "Things to build with.")
-- Same as the one above but for the second tab.
iconSheet:AddSheet("Entities", entityPanel, "gui/silkicons/shield", false, false, "Things to help defend.")
--SNIP--
--More code for other buttons and stuff .......
[/lua]
Many thanks. I will try this later, where abouts would i put that?
Well don't put that anywhere, it's my menu's code, you would write your menu in a client side file. That is just an example.
[editline]15th March 2011[/editline]
If you want someone to write your whole menu you should put a request in the request section.
Sorry, you need to Log In to post a reply to this thread.