local PANEL = {}
/*---------------------------------------------------------
Name: This function is used as the paint function for
selected buttons.
---------------------------------------------------------*/
local function HighlightedButtonPaint( self )
for i=2, 3 do
end
end
/*---------------------------------------------------------
Name: Init
---------------------------------------------------------*/
function PANEL:Init()
// A panellist is a panel that you shove other panels
// into and it makes a nice organised frame.
self.List:EnableHorizontal( true )
self.List:EnableVerticalScrollbar()
self.List:SetSpacing( 1 )
self.List:SetPadding( 3 )
self.Controls = {}
self.Height = 2
end
/*---------------------------------------------------------
Name: ControlValues
---------------------------------------------------------*/
function PANEL:AddModel( model, ConVars )
// Creeate a spawnicon and set the model
Icon.ConVars = ConVars or {}
local ConVarName = self:ConVar()
// Run a console command when the Icon is clicked
Icon.DoClick = function ( self )
for k, v
in pairs( self.ConVars
) do
end
// Note: We run this command after all the optional stuff
end
// Add the Icon us
self.List:AddItem( Icon )
end
/*---------------------------------------------------------
Name: ControlValues
---------------------------------------------------------*/
function PANEL:ControlValues( kv )
self.BaseClass.ControlValues( self, kv )
self.Height = kv.height or 2
// Load the list of models from our keyvalues file
if (kv.models) then
for k, v
in pairs( kv.models
) do
self:AddModel( k, v )
end
end
end
/*---------------------------------------------------------
Name: PerformLayout
---------------------------------------------------------*/
function PANEL:PerformLayout()
local y = self.BaseClass.PerformLayout( self )
local Height = 64 * self.Height + 6
y = y + Height
y = y + 5
end
/*---------------------------------------------------------
Name: SelectButton
---------------------------------------------------------*/
function PANEL:FindAndSelectButton( Value )
self.CurrentValue = Value
for k, Icon
in pairs( self.Controls
) do
if ( Icon.
Model == Value
) then
// Remove the old overlay
if ( self.SelectedIcon ) then
self.SelectedIcon.PaintOver = nil
end
// Add the overlay to this button
Icon.PaintOver = HighlightedButtonPaint;
self.SelectedIcon = Icon
end
end
end
/*---------------------------------------------------------
Name: TestForChanges
---------------------------------------------------------*/
function PANEL:TestForChanges()
if ( Value == self.CurrentValue ) then return end
self:FindAndSelectButton( Value )
end