diff options
| -rw-r--r-- | gamemode/client/cl_inventory.lua | 168 | ||||
| -rw-r--r-- | gamemode/server/database.lua | 10 |
2 files changed, 168 insertions, 10 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua index 651017d..98bce3e 100644 --- a/gamemode/client/cl_inventory.lua +++ b/gamemode/client/cl_inventory.lua @@ -514,35 +514,187 @@ function PANEL:Init() end self.ControlPanel = vgui.Create("DForm",self) - self.ControlPanel:SetSize((dPanelWidth/3)*2,dPanelWidth) + self.ControlPanel:SetSize((dPanelWidth*2)/3,dPanelWidth) self.ControlPanel:SetPos(dPanelWidth/3,0) - local g = controlpanel.Get("Weld") - print(g) - self.ControlPanel:AddItem(g) + self.PanelProxy = {} + self.PanelProxy.cp = self.ControlPanel + self.PanelProxy.MatSelect = function(cmd,matlist,bool,x,y) + print("MatSelect's cmd is:") + PrintTable(cmd) + local grid = vgui.Create( "DGrid", frame ) + grid:SetPos( 10, 30 ) + grid:SetCols( 5 ) + grid:SetColWide( 36 ) + local MatSelectPanel = {} + MatSelectPanel.AddMaterial = function(name, path) + print("Adding material:") + PrintTable(name) + end + return MatSelectPanel + end + self.PanelProxy.AddControl = function(self,type,table) + print("Adding control...") + print("Type:" .. type) + print("Table:") + PrintTable(table) + print("I am:") + PrintTable(self) + if(type == "Header") then + self.cp:ControlHelp(table.Description) + elseif(type == "Slider") then + self.cp:NumSlider(table.Label,table.Command,table.Min,table.Max,0) + elseif(type == "Checkbox") then + self.cp:CheckBox(table.Label,table.Command) + elseif(type == "RopeMaterial") then + --TODO:Do this or something I guess + elseif(type == "Numpad") then + local binder = vgui.Create( "DBinder") + function binder:SetSelectedNumber( num ) + self.m_iSelectedNumber = num + end + self.cp:AddItem(binder) + elseif(type == "Color") then + local color = vgui.Create( "DRGBPicker" ) + local color_cube = vgui.Create( "DColorCube" ) + local colorvars = {} + local curcolor = {} + for k,v in pairs({"Red","Green","Blue"}) do + colorvars[v] = table[v] + end + curcolor.r = GetConVar(colorvars["Red"]):GetInt() + curcolor.g = GetConVar(colorvars["Green"]):GetInt() + curcolor.b = GetConVar(colorvars["Blue"]):GetInt() + print("Color convars are:") + PrintTable(colorvars) + color_cube:SetColor( curcolor ) + + function color:OnChange(tocolor) + color_cube:SetColor( tocolor ) + end + function color_cube:OnUserChanged(tocolor) + local t = self:GetRGB() + GetConVar(colorvars["Red"]):SetInt(t.r) + GetConVar(colorvars["Green"]):SetInt(t.g) + GetConVar(colorvars["Blue"]):SetInt(t.b) + end + self.cp:AddItem(color,color_cube) + elseif(type == "ComboBox") then + local DComboBox = vgui.Create( "DComboBox" ) + for k,v in pairs(table.Options) do + DComboBox:AddChoice(k,v) + end + DComboBox.OnSelect = function( panel, index, value ) + for k,v in pairs(table.Options[value]) do + print("Setting " .. k .. " to " .. v) + GetConVar(k):SetInt(v) + end + end + self.cp:AddItem(DComboBox) + elseif(type == "PropSelect") then + local grid = vgui.Create( "DGrid" ) + grid:SetPos( 10, 30 ) + grid:SetCols( 5 ) + grid:SetColWide( 36 ) + for k,v in pairs(table.Models) do + local icon = vgui.Create( "DModelPanel", Panel ) + icon:SetSize( 32, 32 ) + icon:SetModel( k ) + icon.DoClick = function() + GetConVar(table.ConVar):SetString(k) + end + grid:AddItem(icon) + end + self.cp:AddItem(grid) + else + print("I wanted to add a control, but I haven't written it yet!") + print("Type:" .. type) + print("Table:") + PrintTable(table) + print("I am:") + PrintTable(self) + debug.Trace() + end + end + + if(self.ControlPanel.AddControl == nil) then + print("Control panel's AddControl is nil!") + end + --self.ControlPanel:SetSize((dPanelWidth/3)*2,dPanelWidth) + --self.ControlPanel:SetPos(dPanelWidth/3,0) + --self.ControlPanel:Dock(FILL) + --local g = controlpanel.Get("Axis") + --print(g) + --self.ControlPanel:AddItem(g) for k,v in pairs(spawnmenu.GetTools()[1]["Items"]) do for i,j in pairs(v) do if(istable(j)) then local isprohibitied = false - for k,l in pairs(GMS.ProhibitedStools) do - if(j.ItemName == l) then + for l,m in pairs(GMS.ProhibitedStools) do + if(j.ItemName == m) then isprohibitied = true end end if(!isprohibitied) then local button = vgui.Create("DButton",self.Tools) - button:SetText(j.Text) + local btable = {} + for n,o in pairs(j) do + btable[n] = o + end + print("Btable is:") + PrintTable(btable) + button:SetText(btable.Text) + --button.Name = j.Text + button.PanelCreate = j.CPanelFunction --self.Tools:Add print("adding " .. j.Text) + button.DoClick = function() + --print("Before calling function, PanelProxy is:") + --PrintTable(self.PanelProxy) + LocalPlayer():ConCommand(btable.Command) + local cp = controlpanel.Get(btable.Text) + if ( !cp:GetInitialized() ) then + cp:FillViaTable( btable ) + end + self.ControlPanel:Clear() + self.ControlPanel:AddItem(cp) + button.PanelCreate(self.PanelProxy) + end end end end end - --PrintTable(spawnmenu.GetTools()[1]["Items"][1]) + --PrintTable(spawnmenu.GetTools()[1]["Items"]) end +function PANEL:EnableControlPanel( button ) + if(self.LastSelected) then + self.LastSelected:SetSelected(false) + end + button:SetSelected( true ) + self.LastSelected = button + + print(button.Name) + local cp = controlpanel.Get( button.Name ) + print("got control panel for:") + print(cp) + --if ( !cp:GetInitialized() ) then + --cp:FillViaTable( button ) + --end + + self.ControlPanel:Clear() + self.ControlPanel:AddItem( cp ) + self.ControlPanel:Rebuild() + + --[[ + if ( button.Command ) then + LocalPlayer():ConCommand( button.Command ) + end + ]] +end + function PANEL:Paint() draw.RoundedBox(0,0,0,self:GetWide(), self:GetTall(), Color(48,48,48,125)) end diff --git a/gamemode/server/database.lua b/gamemode/server/database.lua index 3a40fe5..9c4a827 100644 --- a/gamemode/server/database.lua +++ b/gamemode/server/database.lua @@ -34,11 +34,11 @@ function storeTable(uniqueIdentifier, table) end -local function convertTableToText(tbl) +local function storetable(tbl) if(GM.StorageMethod == "Text") then elseif(GM.StorageMethod == "Static Map") then - + local storagetable = convertTableStatic(tbl) elseif(GM.StorageMethod == "LZWCompressed") then else @@ -55,6 +55,12 @@ local function convertTableStatic(tbl) print("\tGM.StorageMethod is set to \"Static Map\", but GM.StoreageStaticMap is not defined!") return end + local converted = {} + + + +end +local function parseStaticTable(tbl) end |
