Permalink
Browse files

New spawnmenu hover/selected graphics

  • Loading branch information...
1 parent 0634b73 commit eb1459fb3a34b4cf458585fdbdc7aac9a4581300 @robotboy655 robotboy655 committed Jun 24, 2016
Showing with 55 additions and 83 deletions.
  1. +9 −37 garrysmod/lua/vgui/matselect.lua
  2. +7 −6 garrysmod/lua/vgui/propselect.lua
  3. +39 −40 garrysmod/lua/vgui/spawnicon.lua
@@ -6,23 +6,18 @@ AccessorFunc( PANEL, "ItemHeight", "ItemHeight", FORCE_NUMBER )
AccessorFunc( PANEL, "Height", "NumRows", FORCE_NUMBER )
AccessorFunc( PANEL, "m_bSizeToContent", "AutoHeight", FORCE_BOOL )
---[[---------------------------------------------------------
- Name: This function is used as the paint function for
- selected buttons.
------------------------------------------------------------]]
-local function HighlightedButtonPaint( self )
+local border = 0
+local border_w = 8
+local matHover = Material( "gui/ps_hover.png", "nocull" )
+local boxHover = GWEN.CreateTextureBorder( border, border, 64 - border * 2, 64 - border * 2, border_w, border_w, border_w, border_w, matHover )
- surface.SetDrawColor( 255, 200, 0, 255 )
+-- This function is used as the paint function for selected buttons.
+local function HighlightedButtonPaint( self, w, h )
- for i=2, 3 do
- surface.DrawOutlinedRect( i, i, self:GetWide() - i * 2, self:GetTall() - i * 2 )
- end
+ boxHover( 0, 0, w, h, color_white )
end
---[[---------------------------------------------------------
- Name: Init
------------------------------------------------------------]]
function PANEL:Init()
-- A panellist is a panel that you shove other panels
@@ -41,9 +36,6 @@ function PANEL:Init()
end
---[[---------------------------------------------------------
- Name: SetAutoHeight
------------------------------------------------------------]]
function PANEL:SetAutoHeight( bAutoHeight )
self.m_bSizeToContent = bAutoHeight
@@ -53,9 +45,6 @@ function PANEL:SetAutoHeight( bAutoHeight )
end
---[[---------------------------------------------------------
- Name: AddMaterial
------------------------------------------------------------]]
function PANEL:AddMaterial( label, value )
-- Creeate a spawnicon and set the model
@@ -79,9 +68,6 @@ function PANEL:AddMaterial( label, value )
end
---[[---------------------------------------------------------
- Name: SetItemSize
------------------------------------------------------------]]
function PANEL:SetItemSize( pnl )
local maxW = self:GetWide()
@@ -104,9 +90,6 @@ function PANEL:SetItemSize( pnl )
end
---[[---------------------------------------------------------
- Name: AddMaterialEx
------------------------------------------------------------]]
function PANEL:AddMaterialEx( label, material, value, convars )
-- Creeate a spawnicon and set the model
@@ -133,9 +116,6 @@ function PANEL:AddMaterialEx( label, material, value, convars )
end
---[[---------------------------------------------------------
- Name: ControlValues
------------------------------------------------------------]]
function PANEL:ControlValues( kv )
self.BaseClass.ControlValues( self, kv )
@@ -162,9 +142,6 @@ function PANEL:ControlValues( kv )
end
---[[---------------------------------------------------------
- Name: PerformLayout
------------------------------------------------------------]]
function PANEL:PerformLayout()
self.List:SetPos( 0, 0 )
@@ -199,9 +176,6 @@ function PANEL:PerformLayout()
end
---[[---------------------------------------------------------
- Name: FindAndSelectMaterial
------------------------------------------------------------]]
function PANEL:FindAndSelectMaterial( Value )
self.CurrentValue = Value
@@ -212,10 +186,11 @@ function PANEL:FindAndSelectMaterial( Value )
-- Remove the old overlay
if ( self.SelectedMaterial ) then
- self.SelectedMaterial.PaintOver = nil
+ self.SelectedMaterial.PaintOver = self.OldSelectedPaintOver
end
-- Add the overlay to this button
+ self.OldSelectedPaintOver = Mat.PaintOver
Mat.PaintOver = HighlightedButtonPaint
self.SelectedMaterial = Mat
@@ -225,9 +200,6 @@ function PANEL:FindAndSelectMaterial( Value )
end
---[[---------------------------------------------------------
- Name: TestForChanges
------------------------------------------------------------]]
function PANEL:TestForChanges()
local cvar = self:ConVar()
@@ -1,14 +1,15 @@
local PANEL = {}
--- This function is used as the paint function for selected buttons.
-local function HighlightedButtonPaint( self )
+local border = 0
+local border_w = 8
+local matHover = Material( "gui/ps_hover.png", "nocull" )
+local boxHover = GWEN.CreateTextureBorder( border, border, 64 - border * 2, 64 - border * 2, border_w, border_w, border_w, border_w, matHover )
- surface.SetDrawColor( 255, 200, 0, 255 )
+-- This function is used as the paint function for selected buttons.
+local function HighlightedButtonPaint( self, w, h )
- for i = 2, 3 do
- surface.DrawOutlinedRect( i, i, self:GetWide() - i * 2, self:GetTall() - i * 2 )
- end
+ boxHover( 0, 0, w, h, color_white )
end
@@ -1,17 +1,11 @@
-local matHover = Material( "vgui/spawnmenu/hover" )
-
local PANEL = {}
AccessorFunc( PANEL, "m_strModelName", "ModelName" )
AccessorFunc( PANEL, "m_iSkin", "SkinID" )
AccessorFunc( PANEL, "m_strBodyGroups", "BodyGroup" )
AccessorFunc( PANEL, "m_strIconName", "IconName" )
-
---[[---------------------------------------------------------
- Name: Paint
------------------------------------------------------------]]
function PANEL:Init()
self:SetDoubleClickingEnabled( false )
@@ -45,21 +39,26 @@ end
function PANEL:Paint( w, h )
- if ( !self.Hovered ) then return end
-
- //derma.SkinHook( "Paint", "Shadow", self, w, h )
+ self.OverlayFade = math.Clamp( ( self.OverlayFade or 0 ) - RealFrameTime() * 640 * 2, 0, 255 )
+
+ if ( dragndrop.IsDragging() || !self:IsHovered() ) then return end
+
+ self.OverlayFade = math.Clamp( self.OverlayFade + RealFrameTime() * 640 * 8, 0, 255 )
end
-function PANEL:PaintOver( w, h)
+local border = 4
+local border_w = 5
+local matHover = Material( "gui/sm_hover.png", "nocull" )
+local boxHover = GWEN.CreateTextureBorder( border, border, 64 - border * 2, 64 - border * 2, border_w, border_w, border_w, border_w, matHover )
- self:DrawSelections()
+function PANEL:PaintOver( w, h )
- if ( !self.Hovered ) then return end
+ if ( self.OverlayFade > 0 ) then
+ boxHover( 0, 0, w, h, Color( 255, 255, 255, self.OverlayFade ) )
+ end
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial( matHover )
- self:DrawTexturedRect()
+ self:DrawSelections()
end
@@ -85,18 +84,18 @@ function PANEL:SetBodyGroup( k, v )
if ( v < 0 ) then return end
if ( v > 9 ) then return end
- self.m_strBodyGroups = self.m_strBodyGroups:SetChar( k+1, v )
+ self.m_strBodyGroups = self.m_strBodyGroups:SetChar( k + 1, v )
end
function PANEL:SetModel( mdl, iSkin, BodyGorups )
- if (!mdl) then debug.Trace() return end
+ if ( !mdl ) then debug.Trace() return end
self:SetModelName( mdl )
self:SetSkinID( iSkin )
- if ( tostring(BodyGorups):len() != 9 ) then
+ if ( tostring( BodyGorups ):len() != 9 ) then
BodyGorups = "000000000"
end
@@ -105,7 +104,7 @@ function PANEL:SetModel( mdl, iSkin, BodyGorups )
self.Icon:SetModel( mdl, iSkin, BodyGorups )
if ( iSkin && iSkin > 0 ) then
- self:SetTooltip( Format( "%s (Skin %i)", mdl, iSkin+1 ) )
+ self:SetTooltip( Format( "%s (Skin %i)", mdl, iSkin + 1 ) )
else
self:SetTooltip( Format( "%s", mdl ) )
end
@@ -218,8 +217,8 @@ spawnmenu.AddContentType( "model", function( container, obj )
menu:AddOption( "Spawn using Toolgun", function() RunConsoleCommand( "gmod_tool", "creator" ) RunConsoleCommand( "creator_type", "4" ) RunConsoleCommand( "creator_name", obj.model ) end )
local submenu = menu:AddSubMenu( "Re-Render", function() icon:RebuildSpawnIcon() end )
- submenu:AddOption( "This Icon", function() icon:RebuildSpawnIcon() end )
- submenu:AddOption( "All Icons", function() container:RebuildAll() end )
+ submenu:AddOption( "This Icon", function() icon:RebuildSpawnIcon() end )
+ submenu:AddOption( "All Icons", function() container:RebuildAll() end )
menu:AddOption( "Edit Icon", function()
@@ -242,25 +241,25 @@ spawnmenu.AddContentType( "model", function( container, obj )
end
local submenu = menu:AddSubMenu( "Resize", function() end )
- submenu:AddOption( "64 x 64 (default)", function() ChangeIconSize( 64, 64 ) end )
- submenu:AddOption( "64 x 128", function() ChangeIconSize( 64, 128 ) end )
- submenu:AddOption( "64 x 256", function() ChangeIconSize( 64, 256 ) end )
- submenu:AddOption( "64 x 512", function() ChangeIconSize( 64, 512 ) end )
- submenu:AddSpacer()
- submenu:AddOption( "128 x 64", function() ChangeIconSize( 128, 64 ) end )
- submenu:AddOption( "128 x 128", function() ChangeIconSize( 128, 128 ) end )
- submenu:AddOption( "128 x 256", function() ChangeIconSize( 128, 256 ) end )
- submenu:AddOption( "128 x 512", function() ChangeIconSize( 128, 512 ) end )
- submenu:AddSpacer()
- submenu:AddOption( "256 x 64", function() ChangeIconSize( 256, 64 ) end )
- submenu:AddOption( "256 x 128", function() ChangeIconSize( 256, 128 ) end )
- submenu:AddOption( "256 x 256", function() ChangeIconSize( 256, 256 ) end )
- submenu:AddOption( "256 x 512", function() ChangeIconSize( 256, 512 ) end )
- submenu:AddSpacer()
- submenu:AddOption( "512 x 64", function() ChangeIconSize( 512, 64 ) end )
- submenu:AddOption( "512 x 128", function() ChangeIconSize( 512, 128 ) end )
- submenu:AddOption( "512 x 256", function() ChangeIconSize( 512, 256 ) end )
- submenu:AddOption( "512 x 512", function() ChangeIconSize( 512, 512 ) end )
+ submenu:AddOption( "64 x 64 (default)", function() ChangeIconSize( 64, 64 ) end )
+ submenu:AddOption( "64 x 128", function() ChangeIconSize( 64, 128 ) end )
+ submenu:AddOption( "64 x 256", function() ChangeIconSize( 64, 256 ) end )
+ submenu:AddOption( "64 x 512", function() ChangeIconSize( 64, 512 ) end )
+ submenu:AddSpacer()
+ submenu:AddOption( "128 x 64", function() ChangeIconSize( 128, 64 ) end )
+ submenu:AddOption( "128 x 128", function() ChangeIconSize( 128, 128 ) end )
+ submenu:AddOption( "128 x 256", function() ChangeIconSize( 128, 256 ) end )
+ submenu:AddOption( "128 x 512", function() ChangeIconSize( 128, 512 ) end )
+ submenu:AddSpacer()
+ submenu:AddOption( "256 x 64", function() ChangeIconSize( 256, 64 ) end )
+ submenu:AddOption( "256 x 128", function() ChangeIconSize( 256, 128 ) end )
+ submenu:AddOption( "256 x 256", function() ChangeIconSize( 256, 256 ) end )
+ submenu:AddOption( "256 x 512", function() ChangeIconSize( 256, 512 ) end )
+ submenu:AddSpacer()
+ submenu:AddOption( "512 x 64", function() ChangeIconSize( 512, 64 ) end )
+ submenu:AddOption( "512 x 128", function() ChangeIconSize( 512, 128 ) end )
+ submenu:AddOption( "512 x 256", function() ChangeIconSize( 512, 256 ) end )
+ submenu:AddOption( "512 x 512", function() ChangeIconSize( 512, 512 ) end )
menu:AddSpacer()
menu:AddOption( "Delete", function() icon:Remove() hook.Run( "SpawnlistContentChanged" ) end )

0 comments on commit eb1459f

Please sign in to comment.