diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-30 14:42:09 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-30 14:42:09 -0400 |
| commit | 2736f498f30220b858fc6fac23e7ddc4a597df6d (patch) | |
| tree | 374ceadedb654b00e09dac321620a8320830f734 /gamemode/vgui | |
| download | redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.gz redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.bz2 redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.zip | |
Inital commit
Diffstat (limited to 'gamemode/vgui')
| -rw-r--r-- | gamemode/vgui/vgui_categorybutton.lua | 144 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_classpicker.lua | 76 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_dialogue.lua | 114 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_endgame.lua | 314 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_goodmodelpanel.lua | 202 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_helpmenu.lua | 104 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_itemdisplay.lua | 157 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_itempanel.lua | 404 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_panelbase.lua | 78 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_panelsheet.lua | 413 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_playerdisplay.lua | 166 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_playerpanel.lua | 68 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_scroller.lua | 105 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_shopmenu.lua | 77 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_sidebutton.lua | 131 | ||||
| -rw-r--r-- | gamemode/vgui/vgui_zombieclasses.lua | 76 |
16 files changed, 2629 insertions, 0 deletions
diff --git a/gamemode/vgui/vgui_categorybutton.lua b/gamemode/vgui/vgui_categorybutton.lua new file mode 100644 index 0000000..0b45c97 --- /dev/null +++ b/gamemode/vgui/vgui_categorybutton.lua @@ -0,0 +1,144 @@ +local PANEL = {} + +PANEL.OnSound = Sound( "common/talk.wav" ) +PANEL.OffSound = Sound( "weapons/sniper/sniper_zoomin.wav" ) + +surface.CreateFont ( "CategoryButton", { size = 16, weight = 500, antialias = true, additive = false, font = "Typenoksidi" } ) + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + //self:SetDraggable( false ) + + self:SetCursor( "hand" ) + + self.Image = vgui.Create( "DImageButton", self ) + self.Image:SetImage( "icon16/car.png" ) + self.Image:SetStretchToFit( false ) + self.Image.DoClick = function() + + self:Toggle() + + end + + self.Selected = false + self.Text = "" + +end + +function PANEL:SetImage( img ) + + self.Image:SetImage( img ) + +end + +function PANEL:SetText( text ) + + self.Text = text + +end + +function PANEL:Toggle( bool ) + + self:SetSelectedState( bool or !self.Selected ) + + if not bool then + + self:OnToggle( self.Selected ) + + end + +end + +function PANEL:OnToggle( bool ) // override this + +end + +function PANEL:DoSound( bool ) + + if bool then + + surface.PlaySound( self.OnSound ) + + else + + surface.PlaySound( self.OffSound ) + + end + +end + +function PANEL:SetSelectedState( bool, ignore ) + + self.Selected = tobool( bool ) + + if ignore then return end + + self:DoSound( bool ) + +end + +function PANEL:OnMousePressed( mousecode ) + + self:MouseCapture( true ) + +end + +function PANEL:OnMouseReleased( mousecode ) + + self:MouseCapture( false ) + self:Toggle() + +end + +function PANEL:GetPadding() + return 5 +end + +function PANEL:PerformLayout() + + local imgsize = self:GetTall() - ( 2 * self:GetPadding() ) + + self.Image:SetSize( imgsize, imgsize ) + self.Image:SetPos( self:GetWide() - imgsize - self:GetPadding(), self:GetPadding() ) + + //self:SizeToContents() + +end + +function PANEL:Paint() + + local tx, ty = self:GetPadding() * 2, self:GetTall() * 0.5 - 8 + //local px, py = self.Image:GetPos() + local imgsize = self:GetTall() - ( 2 * self:GetPadding() ) + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 180 ) ) + + if self.Selected then + + draw.RoundedBox( 4, self:GetWide() - imgsize - self:GetPadding(), self:GetPadding(), imgsize, imgsize, Color( 100, 100, 100, 100 ) ) + + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + + draw.SimpleText( self.Text, "CategoryButton", tx, ty, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT ) + + else + + draw.RoundedBox( 4, self:GetWide() - imgsize - self:GetPadding(), self:GetPadding(), imgsize, imgsize, Color( 100, 100, 100, 100 ) ) + + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + + draw.SimpleText( self.Text, "CategoryButton", tx, ty, Color( 100, 100, 100, 255 ), TEXT_ALIGN_LEFT ) + + end + +end + +derma.DefineControl( "CategoryButton", "A shitty button thing.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_classpicker.lua b/gamemode/vgui/vgui_classpicker.lua new file mode 100644 index 0000000..5954296 --- /dev/null +++ b/gamemode/vgui/vgui_classpicker.lua @@ -0,0 +1,76 @@ +local PANEL = {} + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + self:ChooseParent() + + self.Items = {} + + for k,v in pairs( { CLASS_SCOUT, CLASS_COMMANDO, CLASS_SPECIALIST, CLASS_ENGINEER } ) do + + local desc = GAMEMODE.ClassDescriptions[k] or "TEH" + local logo = GAMEMODE.ClassLogos[k] or "brick/brick_model" + + local button = vgui.Create( "DImageButton", self ) + button:SetImage( logo ) + button:SetSize( 100, 100 ) + button.OnMousePressed = function() RunConsoleCommand( "changeclass", k ) RunConsoleCommand( "changeteam", TEAM_ARMY ) self:Remove() end + button.ID = id + + local label = vgui.Create( "DLabel", self ) + label:SetWrap( true ) + label:SetText( desc ) + label:SetFont( "ItemDisplayFont" ) + label:SetSize( 300, 100 ) + + table.insert( self.Items, { button, label } ) + + end + +end + +function PANEL:Think() + + self.Dragging = false + +end + +function PANEL:ChooseParent() + +end + +function PANEL:GetPadding() + + return 5 + +end + +function PANEL:PerformLayout() + + local x,y = self:GetPadding(), self:GetPadding() + 50 + + for k,v in pairs( self.Items ) do + + v[1]:SetPos( x, y ) + v[2]:SetPos( x + 100 + self:GetPadding(), y ) + + y = y + 100 + self:GetPadding() + + end + + self:SizeToContents() + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 150 ) ) + + //draw.SimpleText( "Class Menu", "ItemDisplayFont", self:GetWide() * 0.5, 10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + +end + +derma.DefineControl( "ClassPicker", "A class picker menu.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_dialogue.lua b/gamemode/vgui/vgui_dialogue.lua new file mode 100644 index 0000000..ef76419 --- /dev/null +++ b/gamemode/vgui/vgui_dialogue.lua @@ -0,0 +1,114 @@ +local PANEL = {} + +function PANEL:Init() + + //self:ShowCloseButton( false ) + self:SetKeyboardInputEnabled( false ) + //self:SetDraggable( true ) + + self.Button = vgui.Create( "DButton", self ) + self.Button:SetText( "Close" ) + self.Button.OnMousePressed = function() + + if not InventoryScreen:IsVisible() and not SaleScreen:IsVisible() then + + gui.EnableScreenClicker( false ) + + end + + self:Remove() + + end + + self.TextSizeY = 20 + +end + +function PANEL:SetText( text ) + + self.Text = text + self:InvalidateLayout() + +end + +function PANEL:GetPadding() + + return 20 + +end + +function PANEL:Think() + + if self.Dragging then + + local x = gui.MouseX() - self.Dragging[1] + local y = gui.MouseY() - self.Dragging[2] + + x = math.Clamp( x, 0, ScrW() - self:GetWide() ) + y = math.Clamp( y, 0, ScrH() - self:GetTall() ) + + self:SetPos( x, y ) + + end + +end + +function PANEL:PerformLayout() + + if self.Button then + + self.Button:SetPos( self:GetWide() * 0.5 - self.Button:GetWide() * 0.5, self.TextSizeY + 16 ) + self.Button:SetSize( 48, 18 ) + + end + + self:SetSize( 400, self.TextSizeY + 42 ) + +end + +function PANEL:Paint() + + Derma_DrawBackgroundBlur( self ) + + surface.SetFont( "ItemDisplayFont" ) + + local tbl = string.Explode( " ", self.Text ) + local str = { "" } + local pos = 1 + + for k,v in pairs( tbl ) do + + local test = str[pos] .. " " .. v + local size = surface.GetTextSize( test ) + + if size > self:GetWide() - 40 then + + str[pos] = string.Trim( str[pos] ) + pos = pos + 1 + str[pos] = ( str[pos] or "" ) .. v + + else + + str[pos] = str[pos] .. " " .. v + + end + + end + + self.TextSizeY = 20 + ( pos - 1 ) * 15 + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 100 ) ) + + draw.RoundedBox( 4, 10, 10, self:GetWide() - 20, self.TextSizeY, Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 11, 11, self:GetWide() - 22, self.TextSizeY - 2, Color( 150, 150, 150, 150 ) ) + + for k,v in pairs( str ) do + + draw.SimpleText( v, "ItemDisplayFont", self:GetWide() * 0.5, 20 + ( ( k - 1 ) * 15 ), Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + end + +end + +derma.DefineControl( "Dialogue", "A HUD Element with a label and close buton.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_endgame.lua b/gamemode/vgui/vgui_endgame.lua new file mode 100644 index 0000000..9ea2974 --- /dev/null +++ b/gamemode/vgui/vgui_endgame.lua @@ -0,0 +1,314 @@ +local PANEL = {} + +function PANEL:Init() + + self:PerformLayout() + + self.Wait = CurTime() + 5 + self.Pos = 1 + self.YPos = 220 + self.ListMode = true + self.DrawTbl = {} + self.Awards = {} + + self.Lists = {} + self.Lists[1] = { 5, ScrW() * 0.30, "Survivors", function() return self:GetSurvivors() end, "bot/whoo2.wav" } + self.Lists[2] = { ScrW() * 0.50 - ScrW() * 0.15, ScrW() * 0.30, "Top Killers", function() return self:GetTopKillers() end, "weapons/357_fire2.wav" } + self.Lists[3] = { ScrW() - ( ScrW() * 0.30 ) - 5, ScrW() * 0.30, "Big Spenders", function() return self:GetTopSpenders() end, "physics/metal/chain_impact_soft1.wav" } + + local x, w = ScrW() * 0.50 - ScrW() * 0.15, ScrW() * 0.65 - 5 + + self:ListNewAward( { x, w, "Grey Matter:", "got the most headshots.", function() return self:GetStatMax( "Headshot" ) end, "zombie craniums", "player/headshot1.wav" } ) + self:ListNewAward( { x, w, "Silent Partner:", "got the most kill assists.", function() return self:GetStatMax( "Assist" ) end, "assists", "weapons/357/357_spin1.wav" } ) + self:ListNewAward( { x, w, "Longshot:", "got the longest distance kill.", function() return self:GetStatMax( "Longshot" ) end, "feet", "weapons/fx/nearmiss/bulletLtoR05.wav" } ) + self:ListNewAward( { x, w, "Big Game Hunter:", "dismembered the most zombies with a shotgun.", function() return self:GetStatMax( "Meat" ) end, "zombies poached", "nuke/gore/blood01.wav", true } ) + self:ListNewAward( { x, w, "Bullet Hose:", "used the most ammunition.", function() return self:GetStatMax( "Bullets" ) end, "rounds fired", "player/pl_shell1.wav" } ) + self:ListNewAward( { x, w, "Meat Grinder:", "butchered the most zombies with a melee weapon.", function() return self:GetStatMax( "Knife" ) end, "melee kills", "weapons/knife/knife_hit2.wav", true } ) + self:ListNewAward( { x, w, "Demolitionist:", "killed the most zombies with explosives.", function() return self:GetStatMax( "Explode" ) end, "unidentified bodies", "weapons/underwater_explode3.wav", true } ) + self:ListNewAward( { x, w, "Firebug:", "ignited the most zombies.", function() return self:GetStatMax( "Igniter" ) end, "crispy corpses", "ambient/fire/mtov_flame2.wav", true } ) + self:ListNewAward( { x, w, "Kleptomaniac:", "picked up the most items.", function() return self:GetStatMax( "Loot" ) end, "items taken", "items/itempickup.wav" } ) + self:ListNewAward( { x, w, "Broke The Bank:", "bought the most expensive weapon.", function() return self:GetStatMax( "Pricey" ) end, GAMEMODE.CurrencyName .. "s spent", "ambient/office/coinslot1.wav" } ) + self:ListNewAward( { x, w, "Meet The Engineer:", "built the most barricades.", function() return self:GetStatMax( "Wood" ) end, "barricades built", "npc/dog/dog_servo6.wav", true } ) + self:ListNewAward( { x, w, "Brain Munch:", "dealt the most damage to humans.", function() return self:GetStatMax( "ZedDamage" ) end, "health points", "npc/zombie/zombie_voice_idle2.wav", true } ) + self:ListNewAward( { x, w, "Get To Ze Choppa:", "was the first to reach the evacuation zone.", function() return self:GetStatMax( "Evac" ) end, nil, "ambient/machines/spinup.wav", true } ) + self:ListNewAward( { x, w, "Martyr:", "was the first human to die.", function() return self:GetStatMax( "Martyr" ) end, nil, "npc/crow/alert1.wav", true } ) + self:ListNewAward( { x, w, "Unhealthy Glow:", "was irradiated the most.", function() return self:GetStatMax( "Rad" ) end, "malignant tumors", "player/geiger3.wav", true } ) + self:ListNewAward( { x, w, "Cum Dumpster:", "was infected by zombies the most.", function() return self:GetStatMax( "Infections" ) end, "infections", "ambient/voices/cough1.wav", true } ) + self:ListNewAward( { x, w, "Accident Prone:", "took the most damage from zombies.", function() return self:GetStatMax( "Damage" ) end, "damage", "bot/pain2.wav" } ) + self:ListNewAward( { x, w, "Roleplayer:", "did jack shit.", function() return self:GetWorstPlayer() end, "kills", "ambient/sheep.wav" } ) + //self:ListNewAward( { x, w, "Piss Poor:", "spent the least " .. GAMEMODE.CurrencyName .. "s.", function() return self:GetStatMin( "Spent" ) end, GAMEMODE.CurrencyName .. "s spent", "bot/i_got_nothing.wav" } ) + +end + +function PANEL:ListNewAward( tbl ) + + table.insert( self.Awards, tbl ) + +end + +function PANEL:GetWorstPlayer() + + local min = 9000 + local ply = NULL + + for k,v in pairs( player.GetAll() ) do + + if v:Frags() < min then + + min = v:Frags() + ply = v + + end + + end + + return ply, min + +end + +function PANEL:GetStatMin( name ) + + local min = 9000 + local ply = NULL + + for k,v in pairs( PlayerStats ) do + + if v.Stats and ( v.Stats[ name ] or 0 ) < min then + + min = ( v.Stats[ name ] or 0 ) + ply = v.Player + + end + + end + + return ply, min + +end + +function PANEL:GetStatMax( name ) + + local max = -1 + local ply = NULL + + for k,v in pairs( PlayerStats ) do + + if v.Stats and ( v.Stats[ name ] or 0 ) > max then + + max = ( v.Stats[ name ] or 0 ) + ply = v.Player + + end + + end + + return ply, max + +end + +function PANEL:GetSurvivors() + + local tbl = {} + + for k,v in pairs( team.GetPlayers( TEAM_ARMY ) ) do + + table.insert( tbl, { v } ) + + end + + return tbl + +end + +function PANEL:GetTopSpenders() + + local num = math.min( #player.GetAll(), 5 ) + local tbl = {} + local ignore = {} + + for i=1, num do + + local count = -1 + local ply = NULL + + for k,v in pairs( PlayerStats ) do + + if v.Stats and ( v.Stats[ "Spent" ] or 0 ) > count and not table.HasValue( ignore, v.Player ) then + + ply = v.Player + count = ( v.Stats[ "Spent" ] or 0 ) + + end + + end + + if ply != NULL then + + table.insert( tbl, { ply, count } ) + table.insert( ignore, ply ) + + end + + end + + return tbl + +end + +function PANEL:GetTopKillers() + + local num = math.min( #player.GetAll(), 5 ) + local plys = player.GetAll() + local tbl = {} + + for i=1, num do + + local count = -1 + local ply = NULL + local pos = 0 + + for k,v in pairs( plys ) do + + if v:Frags() > count then + + ply = v + pos = k + count = v:Frags() + + end + + end + + if ply != NULL then + + table.remove( plys, pos ) + table.insert( tbl, { ply, ply:Frags() } ) + + end + + end + + return tbl + +end + +function PANEL:PerformLayout() + + self:SetSize( ScrW(), ScrH() ) + +end + +function PANEL:AddList( pos, width, title, players, sound ) + + surface.PlaySound( sound ) + + table.insert( self.DrawTbl, { X = pos + width * 0.5, Y = 35, Text = title, Style = TEXT_ALIGN_CENTER, Font = "EndGameBig" } ) + + if not players[1] then return end + + local ypos = 60 + + for k,v in pairs( players ) do + + local list = vgui.Create( "PlayerPanel" ) + list:SetPlayerEnt( v[1] ) + list:SetCount( v[2] ) + list:SetTall( 26 ) + list:SetWide( width ) + list:SetPos( pos, ypos ) + + ypos = ypos + 31 + + end + +end + +function PANEL:AddAward( ypos, pos, width, title, desc, ply, amt, append, sound, condition ) + + if condition and amt < 1 then + + self.Wait = 0 + + return + + end + + surface.PlaySound( sound ) + + self.YPos = self.YPos + 31 + self.Wait = CurTime() + 1.5 + + table.insert( self.DrawTbl, { X = pos + 2, Y = ypos + 5, Text = title, Style = TEXT_ALIGN_LEFT, Font = "EndGame" } ) + + local offset = 150 + + local list = vgui.Create( "PlayerPanel" ) + list:SetPlayerEnt( ply ) + list:SetDescription( desc ) + list:SetTall( 26 ) + list:SetWide( width - offset ) + list:SetPos( pos + offset, ypos ) + + if append then + + list:SetCount( amt .. " " .. append ) + + end + +end + +function PANEL:Think() + + if self.Wait and self.Wait < CurTime() then + + self.Wait = CurTime() + 0.5 + + if self.ListMode then + + local alist = self.Lists[ self.Pos ] + + self:AddList( alist[1], alist[2], alist[3], alist[4](), alist[5] ) + + self.Pos = self.Pos + 1 + + if self.Pos > #self.Lists then + + self.ListMode = false + self.Wait = CurTime() + 1.5 + self.Pos = 1 + + end + + else + + local alist = self.Awards[ self.Pos ] + + local ply, amt = alist[5]() + + self:AddAward( self.YPos, alist[1], alist[2], alist[3], alist[4], ply, amt, alist[6], alist[7], alist[8] ) + + self.Pos = self.Pos + 1 + + if self.Pos > #self.Awards then + + self.Wait = nil + + end + + end + + end + +end + +function PANEL:Paint() + + for k,v in pairs( self.DrawTbl ) do + + draw.SimpleText( v.Text, v.Font, v.X, v.Y, Color( 255, 255, 255 ), v.Style, v.Style ) + + end + +end + +derma.DefineControl( "EndGame", "The end-game stat page", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_goodmodelpanel.lua b/gamemode/vgui/vgui_goodmodelpanel.lua new file mode 100644 index 0000000..4434e56 --- /dev/null +++ b/gamemode/vgui/vgui_goodmodelpanel.lua @@ -0,0 +1,202 @@ +/* _ + ( ) + _| | __ _ __ ___ ___ _ _ + /'_` | /'__`\( '__)/' _ ` _ `\ /'_` ) +( (_| |( ___/| | | ( ) ( ) |( (_| | +`\__,_)`\____)(_) (_) (_) (_)`\__,_) sucks shit + +*/ +local PANEL = {} + +AccessorFunc( PANEL, "m_fAnimSpeed", "AnimSpeed" ) +AccessorFunc( PANEL, "Entity", "Entity" ) +AccessorFunc( PANEL, "vCamPos", "CamPos" ) +AccessorFunc( PANEL, "fFOV", "FOV" ) +AccessorFunc( PANEL, "vLookatPos", "LookAt" ) +AccessorFunc( PANEL, "colAmbientLight", "AmbientLight" ) +AccessorFunc( PANEL, "colColor", "Color" ) +AccessorFunc( PANEL, "bAnimated", "Animated" ) + +function PANEL:Init() + + self.Entity = nil + self.NextModel = "" + self.StopRender = false + self.NextSetModel = nil + self.LastPaint = 0 + self.DirectionalLight = {} + + self:SetCamPos( Vector( 50, 50, 50 ) ) + self:SetLookAt( Vector( 0, 0, 40 ) ) + self:SetFOV( 70 ) + + self:SetText( "" ) + self:SetAnimSpeed( 0.5 ) + self:SetAnimated( false ) + + self:SetAmbientLight( Color( 50, 50, 50 ) ) + + self:SetDirectionalLight( BOX_TOP, Color( 255, 255, 255 ) ) + self:SetDirectionalLight( BOX_FRONT, Color( 255, 255, 255 ) ) + + self:SetColor( Color( 255, 255, 255, 255 ) ) + +end + +function PANEL:SetModel( model ) + + if self.NextModel == model then return end + + self.NextModel = model + self.StopRender = true + self.NextSetModel = CurTime() + 0.01 + +end + +function PANEL:Think() + + if self.NextSetModel and self.NextSetModel < CurTime() then + + self:SpecialSetModel( self.NextModel ) + self.StopRender = false + self.NextSetModel = nil + + end + +end + +function PANEL:SpecialSetModel( model ) + + if IsValid( self.Entity ) then + + self.Entity:Remove() + self.Entity = nil + + end + + if not ClientsideModel then return end + + self.LastModel = model + self.Entity = ClientsideModel( model, RENDERGROUP_OPAQUE ) + + if not IsValid( self.Entity ) then return end + + self.Entity:SetNoDraw( true ) + + local seq = self:ChooseSequence( model ) + + if seq > 0 then self.Entity:ResetSequence( seq ) end + +end + +function PANEL:GetSequenceList() + + return { "walk_all", "WalkUnarmed_all", "walk_all_moderate", "idle" } + +end + +function PANEL:ExcludedModels() + + return { "player", "models/human", "eli", "police" } + +end + +function PANEL:ChooseSequence( model ) + + local seq = 0 + + for k,v in pairs( self:ExcludedModels() ) do + + if string.find( model, v ) then + + return self.Entity:LookupSequence( "idle" ) + + end + + end + + for k,v in pairs( self:GetSequenceList() ) do + + if seq <= 0 then seq = self.Entity:LookupSequence( v ) end + + end + + return seq + +end + +function PANEL:Paint() + + if ( !IsValid( self.Entity ) ) then return end + if self.StopRender then return end + + local x, y = self:LocalToScreen( 0, 0 ) + local w, h = self:GetSize() + + local sl, st, sr, sb = x, y, x + w, y + h + + local p = self + + while p:GetParent() do + + p = p:GetParent() + + local pl, pt = p:LocalToScreen( 0, 0 ) + local pr, pb = pl + p:GetWide(), pt + p:GetTall() + + sl = sl < pl and pl or sl + st = st < pt and pt or st + sr = sr > pr and pr or sr + sb = sb > pb and pb or sb + + end + + render.SetScissorRect( sl, st, sr, sb, true ) + + self:LayoutEntity( self.Entity ) + + cam.Start3D( self.vCamPos, (self.vLookatPos-self.vCamPos):Angle(), self.fFOV, x, y, self:GetWide(), self:GetTall() ) + cam.IgnoreZ( true ) + + render.SuppressEngineLighting( true ) + render.SetLightingOrigin( self.Entity:GetPos() ) + render.ResetModelLighting( self.colAmbientLight.r / 255, self.colAmbientLight.g / 255, self.colAmbientLight.b / 255 ) + render.SetColorModulation( self.colColor.r / 255, self.colColor.g / 255, self.colColor.b / 255 ) + render.SetBlend( self.colColor.a / 255 ) + + for i=0, 6 do + local col = self.DirectionalLight[ i ] + if ( col ) then + render.SetModelLighting( i, col.r / 255, col.g / 255, col.b / 255 ) + end + end + + if IsValid( self.Entity ) and not GetGlobalBool( "GameOver", false ) then + + self.Entity:DrawModel() + + end + + render.SuppressEngineLighting( false ) + cam.IgnoreZ( false ) + cam.End3D() + + render.SetScissorRect( 0, 0, 0, 0, false ) + + self.LastPaint = RealTime() + +end + +function PANEL:LayoutEntity( Entity ) + + if self.StopRender then return end + + if ( self.bAnimated ) then + self:RunAnimation() + end + + Entity:SetAngles( Angle( 0, RealTime() * 10, 0) ) + +end + +derma.DefineControl( "GoodModelPanel", "A panel containing a model that isn't broken and gay", PANEL, "DModelPanel" ) diff --git a/gamemode/vgui/vgui_helpmenu.lua b/gamemode/vgui/vgui_helpmenu.lua new file mode 100644 index 0000000..6724302 --- /dev/null +++ b/gamemode/vgui/vgui_helpmenu.lua @@ -0,0 +1,104 @@ +local PANEL = {} + +PANEL.Text = { "<html><body style=\"background-color:DimGray;\">", +"<p style=\"font-family:tahoma;color:red;font-size:25;text-align:center\"><b>READ THIS!</b></p>", +"<p style=\"font-family:verdana;color:black;font-size:10px;text-align:left\"><b>The Inventory System:</b> ", +"To toggle your inventory, press your spawn menu button (default Q). Click an item in your inventory to interact with it. To interact with dropped items, press your USE key (default E) on them.<br><br>", +"<b>Purchasing Items:</b> Press F2 to purchase and order items to be airdropped to you. You can only order items outdoors.<br><br>", +"<b>The Panic Button:</b> Press F3 to activate the panic button. It automatically detects your ailments and attempts to fix them using what you have in your inventory.<br><br>", +"<b>The HUD:</b> The location of important locations and items are marked on your screen. Your teammates are highlighted through walls, as well as the antidote.", +"If you have radiation poisoning, an icon indicating the severity of the poisoning will appear on the bottom left of your screen. An icon will also appear if you are bleeding or infected.<br><br>", +"<b>Evacuation:</b> At the last minute of the round, a helicopter will come to rescue your squad. Run to the evac zone marked on your HUD to be rescued.<br><br>", +"<b>The Infection:</b> The common undead will infect you when they hit you. To cure infection, go to the antidote and press your USE key to access it. The antidote location is always marked on your HUD.<br><br>", +"<b>The Zombie Lord:</b> If there are more than 8 players then a zombie lord will be chosen. If the zombie lord manages to fill their blood meter, they will respawn as a human with a special reward.<br><br>", +"<b>Radiation:</b> Radiation is visually unnoticeable. When near radiation, your handheld geiger counter will make sounds indicating how close you are to a radioactive deposit. Radiation poisoning is cured by vodka or Anti-Rad.<br><br>" } + +PANEL.ButtonText = { "Holy Shit I Don't Care", +"I Didn't Read Any Of That", +"That's A Lot Of Words", +"I'd Rather Just Whine For Help", +"Just Wanna Play Video Games", +"Who Gives A Shit?", +"Help Menus Are For Nerds", +"I Thought This Was A Roleplay Server", +"How I Shoot Zobies", +"How Do I Buy Wepon", +"HEY GUYS WHERES ANTIDOTE this game suck", +"WHERE MY INVENTOREY", +"TL;DR", +"FUCK OFF" } + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + self:ChooseParent() + + local text = "" + + for k,v in pairs( self.Text ) do + + text = text .. v + + end + + self.Label = vgui.Create( "HTML", self ) + self.Label:SetHTML( text ) + + self.Button = vgui.Create( "DButton", self ) + self.Button:SetText( table.Random( self.ButtonText ) ) + self.Button.OnMousePressed = function() + + self:Remove() + + if LocalPlayer():Team() != TEAM_UNASSIGNED then return end + + local classmenu = vgui.Create( "ClassPicker" ) + classmenu:SetSize( 415, 475 ) + classmenu:Center() + classmenu:MakePopup() + + end + +end + +function PANEL:Think() + + self.Dragging = false + +end + +function PANEL:ChooseParent() + +end + +function PANEL:GetPadding() + + return 5 + +end + +function PANEL:PerformLayout() + + local x,y = self:GetPadding(), self:GetPadding() + 10 + + self.Label:SetSize( self:GetWide() - ( self:GetPadding() * 2 ) - 5, self:GetTall() - 50 ) + self.Label:SetPos( x + 5, y + 5 ) + + self.Button:SetSize( 250, 20 ) + self.Button:SetPos( self:GetWide() * 0.5 - self.Button:GetWide() * 0.5, self:GetTall() - 30 ) + + self:SizeToContents() + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 150 ) ) + + draw.SimpleText( "Help Menu", "ItemDisplayFont", self:GetWide() * 0.5, 10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + +end + +derma.DefineControl( "HelpMenu", "A help menu.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_itemdisplay.lua b/gamemode/vgui/vgui_itemdisplay.lua new file mode 100644 index 0000000..d4a734b --- /dev/null +++ b/gamemode/vgui/vgui_itemdisplay.lua @@ -0,0 +1,157 @@ +local PANEL = {} + +surface.CreateFont ( "ItemDisplayFont", { size = 12, weight = 300, antialias = true, additive = true, font = "Verdana" } ) + +function PANEL:Init() + + //self:ShowCloseButton( false ) + self:SetKeyboardInputEnabled( false ) + //self:SetDraggable( false ) + + self.Text = "Click an item to see its description." + self.Title = "N/A" + self.Style = "Stash" + self.PriceScale = 1 + self.Price = 0 + self.Weight = 0 + +end + +function PANEL:SetItemDesc( text, title, style, scale, price, weight ) + + self.Text = text + self.Title = title + self.Style = style + self.PriceScale = scale + self.Price = price + self.Weight = weight + +end + +function PANEL:SetModel( model, campos, origin ) + + if not self.ModelPanel then + + self.ModelPanel = vgui.Create( "GoodModelPanel", self ) + + end + + self.ModelPanel:SetModel( model ) + self.ModelPanel:SetCamPos( Vector(20,10,5) ) + self.ModelPanel:SetLookAt( Vector(0,0,0) ) + self.ModelPanel.LayoutEntity = function( this, ent ) end + + --[[if string.find( model, "models/weapons/w_" ) then + + self.ModelPanel.LayoutEntity = function( this, ent ) if IsValid( ent ) then ent:SetAngles( Angle( 0, 0, 0 ) ) end end + + else + + self.ModelPanel.LayoutEntity = function( this, ent ) if IsValid( ent ) then ent:SetAngles( Angle( 0, RealTime() * 10, 0 ) ) end end + + end]] + + if CamPosOverride then + + campos = CamPosOverride + + end + + if CamOrigOverride then + + origin = CamOrigOverride + + end + + if campos then + + self.ModelPanel:SetCamPos( campos ) + + end + + if origin then + + self.ModelPanel:SetLookAt( origin ) + + end + + self:InvalidateLayout() + +end + +function PANEL:OnMousePressed( mc ) + +end + +function PANEL:Think() + + local tbl, style, scale = GAMEMODE:GetItemToPreview() + + if tbl then + + self:SetModel( tbl.Model, tbl.CamPos, tbl.CamOrigin ) + self:SetItemDesc( tbl.Description, tbl.Name, style, scale, tbl.Price, tbl.Weight ) + + //GAMEMODE:SetItemToPreview() + + end + +end + +function PANEL:PerformLayout() + + if self.ModelPanel then + + local size = math.Min( self:GetWide(), self:GetTall() * 0.85 ) + local pos = ( self:GetWide() - size ) / 2 + + self.ModelPanel:SetPos( pos, 25 ) + self.ModelPanel:SetSize( size, size ) + + end + + self:SizeToContents() + +end + +function PANEL:GetPadding() + + return 5 + +end + +function PANEL:Paint() + + //draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + //draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 100 ) ) + + //draw.RoundedBox( 4, 10, ( self:GetTall() * 0.85 ) - 10, self:GetWide() - 20, self:GetTall() * 0.15, Color( 0, 0, 0, 255 ) ) + //draw.RoundedBox( 4, 11, ( self:GetTall() * 0.85 ) - 9, self:GetWide() - 22, self:GetTall() * 0.15 - 2, Color( 150, 150, 150, 150 ) ) + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 180 ) ) + draw.RoundedBox( 0, 35, 40, self:GetWide() - 70, self:GetTall() - 80, Color( 80, 80, 80, 50 ) ) + + surface.SetDrawColor( 200, 200, 200, 200 ) + surface.DrawOutlinedRect( 35, 40, self:GetWide() - 70, self:GetTall() - 80 ) + + draw.SimpleText( self.Title or "N/A", "ItemDisplayFont", self:GetWide() * 0.5, 10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + if self.Style != "Stash" then + + if not self.Price or self.Price == 0 then + + draw.SimpleText( "Cost: N/A", "ItemDisplayFont", self:GetWide() * 0.5, 25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + else + + draw.SimpleText( "Cost: "..self.Price.." "..GAMEMODE.CurrencyName.."s", "ItemDisplayFont", self:GetWide() * 0.5, 25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + end + + end + + draw.SimpleText( self.Text or "N/A", "ItemDisplayFont", self:GetWide() * 0.5, self:GetTall() - 10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + +end + +derma.DefineControl( "ItemDisplay", "A HUD Element with a big model in the middle and a label", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_itempanel.lua b/gamemode/vgui/vgui_itempanel.lua new file mode 100644 index 0000000..d017c71 --- /dev/null +++ b/gamemode/vgui/vgui_itempanel.lua @@ -0,0 +1,404 @@ +local PANEL = {} + +function PANEL:Init() + + //self:ShowCloseButton( false ) + self:SetKeyboardInputEnabled( false ) + //self:SetDraggable( true ) + self.FuncList = {} + + self.Stashable = false + self.StashStyle = "Take" + self.PriceScale = 1 + +end + +function PANEL:SetPriceScale( scale ) + + self.PriceScale = scale + +end + +function PANEL:SetStashable( bool, style ) + + self.Stashable = bool + self.StashStyle = style + +end + +function PANEL:Think() + +end + +function PANEL:OnMousePressed() + + self:MouseCapture( true ) + + if ( self.NextClick or 0 ) > CurTime() then + + if self.StashStyle == "Buy" then + + if LocalPlayer():GetNWInt( "Cash", 0 ) >= self.ItemTable.Price then + + RunConsoleCommand( "inv_buy", self.ID, 1 ) + GAMEMODE:AddToCart( self.ItemTable, 1 ) + //SaleScreen:AddItems( self.ID, 1 ) + + end + + end + + else + + GAMEMODE:SetItemToPreview( self.ID, self.StashStyle, self.PriceScale, self:GetCount() ) + + self.NextClick = CurTime() + 0.3 + + end + +end + +function PANEL:OnMouseReleased( mc ) + + self.Dragging = nil + self:MouseCapture( false ) + + if mc != MOUSE_RIGHT then return end + + self:MouseMenu() + +end + +function PANEL:MouseMenu() + + local menu = vgui.Create( "DMenu", self ) + menu:AddOption( "Cancel" ) + + if self.Stashable then + + if self.StashStyle == "Take" then + + menu:AddOption( self.StashStyle, function() RunConsoleCommand( "inv_take", self.ID, 1 ) end ) + + if self:GetCount() > 1 then + + if self:GetCount() > 3 then + + local submenu = menu:AddSubMenu( "Take Multiple" ) + + for k,v in pairs{ 3, 5, 10, 20 } do + + if self:GetCount() > v then + + submenu:AddOption( "Take "..v, function() RunConsoleCommand( "inv_take", self.ID, v ) end ) + + end + + end + + end + + menu:AddOption( "Take All", function() RunConsoleCommand( "inv_take", self.ID, self:GetCount() ) end ) + + end + + menu:Open() + return + + elseif self.StashStyle == "Buy" then + + menu:AddOption( self.StashStyle, function() if LocalPlayer():GetNWInt( "Cash", 0 ) >= self.ItemTable.Price then + + RunConsoleCommand( "inv_buy", self.ID, 1 ) + GAMEMODE:AddToCart( self.ItemTable, 1 ) + //SaleScreen:AddItems( self.ID, 1 ) + + end end ) + + local submenu = menu:AddSubMenu( "Buy Multiple" ) + + for k,v in pairs{ 3, 5, 10, 20 } do + + submenu:AddOption( "Buy "..v, function() if LocalPlayer():GetNWInt( "Cash", 0 ) >= self.ItemTable.Price * v then + + RunConsoleCommand( "inv_buy", self.ID, v ) + GAMEMODE:AddToCart( self.ItemTable, v ) + //SaleScreen:AddItems( self.ID, 1 ) + + end end ) + + end + + menu:Open() + return + + elseif self.StashStyle == "Sell" then + + if !self.NotSellable then + + menu:AddOption( self.StashStyle, function() RunConsoleCommand( "inv_sell", self.ID, 1 ) end ) + + if self:GetCount() > 1 then + + if self:GetCount() > 3 then + + local submenu = menu:AddSubMenu( "Sell Multiple" ) + + for k,v in pairs{ 3, 5, 10, 20 } do + + if self:GetCount() > v then + + submenu:AddOption( "Sell "..v, function() RunConsoleCommand( "inv_sell", self.ID, v ) end ) + + end + + end + + end + + menu:AddOption( "Sell All", function() RunConsoleCommand( "inv_sell", self.ID, self:GetCount() ) end ) + + end + + end + + else + + menu:AddOption( self.StashStyle, function() RunConsoleCommand( "inv_store", self.ID, 1 ) end ) + + if self:GetCount() > 1 then + + if self:GetCount() > 3 then + + local submenu = menu:AddSubMenu( "Stash Multiple" ) + + for k,v in pairs{ 3, 5, 10, 20 } do + + if self:GetCount() > v then + + submenu:AddOption( "Stash "..v, function() RunConsoleCommand( "inv_store", self.ID, v ) end ) + + end + + end + + end + + menu:AddOption( "Stash All", function() RunConsoleCommand( "inv_store", self.ID, self:GetCount() ) end ) + + end + + end + + end + + if not self.IsWeapon then + + menu:AddOption( "Drop", function() RunConsoleCommand( "inv_drop", self.ID, 1 ) end ) + + end + + if self:GetCount() > 1 and not self.IsWeapon then + + if self:GetCount() > 3 then + + local submenu = menu:AddSubMenu( "Drop Multiple" ) + + for k,v in pairs{ 3, 5, 10, 20 } do + + if self:GetCount() > v then + + submenu:AddOption( "Drop "..v, function() RunConsoleCommand( "inv_drop", self.ID, v ) end ) + + end + + end + + end + + menu:AddOption( "Drop All", function() RunConsoleCommand( "inv_drop", self.ID, self:GetCount() ) end ) + + end + + for k,v in pairs( self.FuncList ) do + + menu:AddOption( v( 0, 0, true ), function() RunConsoleCommand( "inv_action", self.ID, k ) end ) + + end + + menu:Open() + +end + +function PANEL:SetCount( num ) + + self.ItemCount = num + + if num > 1 then + + self:SetTitle( tostring( num ) ) + + else + + self:SetTitle( "" ) + + end + +end + +function PANEL:GetCount() + + return self.ItemCount or 0 + +end + +function PANEL:AddCount( num ) + + self:SetCount( self:GetCount() + num ) + +end + +function PANEL:GetID() + + return self.ID or 0 + +end + +function PANEL:IsStackable() + + return self.Stackable + +end + +function PANEL:SetItemTable( tbl ) + + self:SetModel( tbl.Model, tbl.CamPos, tbl.CamOrigin ) + self.FuncList = tbl.Functions + self.ID = tbl.ID + self.IsWeapon = tbl.Weapon + self.Stackable = tbl.Stackable + self.PanelModel = tbl.Model + self.ItemTable = tbl + self.ItemTable.Price = tbl.Price or 0 + + if tbl.Sellable != nil and tbl.Sellable == false then + + self.NotSellable = true + + end + +end + +function PANEL:SetModel( model, campos, origin ) + + self.ModelPanel = vgui.Create( "GoodModelPanel", self ) + self.ModelPanel:SetModel( model ) + self.ModelPanel.LayoutEntity = function( ent ) end + self.ModelPanel:SetCamPos( Vector(20,10,5) ) + self.ModelPanel:SetLookAt( Vector(0,0,0) ) + self.ModelPanel.OnMousePressed = function( mc ) self:OnMousePressed( mc ) end + self.ModelPanel.OnMouseReleased = function( mc ) self:OnMouseReleased( mc ) end + + if CamPosOverride then + + campos = CamPosOverride + + end + + if CamOrigOverride then + + origin = CamOrigOverride + + end + + if campos then + + self.ModelPanel:SetCamPos( campos ) + self.ModelPos = campos + + end + + if origin then + + self.ModelPanel:SetLookAt( origin ) + self.ModelOrigin = origin + + end + +end + +function PANEL:SetSizeOverride( size ) + + self.SizeOverride = size + +end + +function PANEL:PerformLayout() + + if self.ModelPanel then + + self.ModelPanel:SetPos( self:GetPadding(), self:GetPadding() ) + + if self.SizeOverride then + + self.ModelPanel:SetSize( self.SizeOverride - 2, self.SizeOverride - 2 ) + + else + + self.ModelPanel:SetSize( 62, 62 ) + + end + + end + + self:SizeToContents() + + if self.SizeOverride then + + self:SetSize( self.SizeOverride, self.SizeOverride ) + + else + + self:SetSize( 64, 64 ) + + end + +end + +function PANEL:Paint() + + if ( self.ItemCount or 1 ) > 1 then + + draw.SimpleText( self.ItemCount, "ItemDisplayFont", self:GetWide() / 8, self:GetTall() / 8, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + end + + //if self.SizeOverride then + + draw.RoundedBox( 0, 3, 3, self:GetWide() - 6, self:GetTall() - 6, Color( 80, 80, 80, 50 ) ) + + if self.StashStyle == "Buy" then + + if LocalPlayer():GetNWInt( "Cash", 0 ) >= self.ItemTable.Price then + + surface.SetDrawColor( 100, 200, 100, 200 ) + + else + + surface.SetDrawColor( 200, 100, 100, 200 ) + + end + + else + + surface.SetDrawColor( 200, 200, 200, 200 ) + + end + + + surface.DrawOutlinedRect( 3, 3, self:GetWide() - 6, self:GetTall() - 6 ) + + +end + +derma.DefineControl( "ItemPanel", "A HUD Element with a model in the middle", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_panelbase.lua b/gamemode/vgui/vgui_panelbase.lua new file mode 100644 index 0000000..b7a4d19 --- /dev/null +++ b/gamemode/vgui/vgui_panelbase.lua @@ -0,0 +1,78 @@ +local PANEL = {} + +function PANEL:Init() + + //self:SetTitle( "" ) + self:ChooseParent() + +end + +function PANEL:ChooseParent() + +end + +function PANEL:OnMousePressed( mc ) + + self.Dragging = { gui.MouseX() - self.x, gui.MouseY() - self.y } + self:MouseCapture( true ) + +end + +function PANEL:Think() + + if self.Dragging then + + local x = gui.MouseX() - self.Dragging[1] + local y = gui.MouseY() - self.Dragging[2] + + x = math.Clamp( x, 0, ScrW() - self:GetWide() ) + y = math.Clamp( y, 0, ScrH() - self:GetTall() ) + + self:SetPos( x, y ) + + end + +end + +function PANEL:GetPadding() + return 1 +end + +function PANEL:GetDefaultTextColor() + return Color( 255, 255, 255, 255 ) +end + +function PANEL:GetTextLabelColor() + return Color( 255, 255, 0 ) +end + +function PANEL:GetTextLabelFont() + return "PanelText" +end + +function PANEL:SetTitle( title ) + + self.Title = title + +end + +function PANEL:GetTitle() + + return self.Title + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 150 ) ) + + if self.Title then + + draw.SimpleText( self.Title, "ItemDisplayFont", 5, 5, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + end + +end + +derma.DefineControl( "PanelBase", "A HUD Base Element", PANEL, "DPanel" ) diff --git a/gamemode/vgui/vgui_panelsheet.lua b/gamemode/vgui/vgui_panelsheet.lua new file mode 100644 index 0000000..38771ed --- /dev/null +++ b/gamemode/vgui/vgui_panelsheet.lua @@ -0,0 +1,413 @@ +local PANEL = {} + +function PANEL:Init() + + self:ChooseParent() + self.Stashable = false + self.StashStyle = "Stash" + self.PriceScale = 1 + self.Categories = {} + + self:SetDraggableName( "GlobalDPanel" ); + + self.pnlCanvas = vgui.Create( "DPanel", self ) + self.pnlCanvas:SetPaintBackground( false ) + self.pnlCanvas.OnMousePressed = function( self, code ) self:GetParent():OnMousePressed( code ) end + self.pnlCanvas.OnChildRemoved = function() self:OnChildRemoved() end + self.pnlCanvas:SetMouseInputEnabled( true ) + self.pnlCanvas.InvalidateLayout = function() self:InvalidateLayout() end + + self.Items = {} + self.YOffset = 0 + self.m_fAnimTime = 0; + self.m_fAnimEase = -1; -- means ease in out + self.m_iBuilds = 0 + + self:SetSpacing( 0 ) + self:SetPadding( 0 ) + self:EnableHorizontal( false ) + self:SetAutoSize( false ) + self:SetDrawBackground( true ) + //self:SetBottomUp( false ) + self:SetNoSizing( false ) + + self:SetMouseInputEnabled( true ) + + -- This turns off the engine drawing + self:SetPaintBackgroundEnabled( false ) + self:SetPaintBorderEnabled( false ) + + self.ScrollAmt = 0 + +end + +function PANEL:ToggleVisible( tbl, bool ) + + if bool then + + local newtbl = {} + + for k,v in pairs( self.Categories ) do // remove all of tbl from categories + + if not table.HasValue( tbl, v ) then + + table.insert( newtbl, v ) + + end + + end + + self.Categories = newtbl + + else + + for k,v in pairs( tbl ) do // insert all of tbl into categories + + if not table.HasValue( self.Categories, v ) then + + table.insert( self.Categories, v ) + + end + + end + + end + +end + +function PANEL:ChooseParent() + +end + +function PANEL:SetPriceScale( scale ) + + self.PriceScale = scale + +end + +function PANEL:SetStashable( bool, style, localinv ) + + self.Stashable = bool + self.StashStyle = style + self.IsLocalInv = localinv + + for k,v in pairs( self:GetItems() ) do + + v:SetPriceScale( self.PriceScale ) + v:SetStashable( bool, style ) + + end + +end + +function PANEL:GetCash() + + return LocalPlayer():GetNWInt( "Cash", 0 ) + +end + +function PANEL:HasItem( id ) + + for k,v in pairs( self:GetItems() ) do + + if v:GetID() == id then + + return v + + end + + end + +end + +function PANEL:GetItemPnlSize() // determine the size of item panels, always needs to add up to 1.0 + + --[[if self.StashStyle == "Buy" then + + return ( self:GetWide() * 0.2 ) + + end]] + + return ( self:GetWide() * 0.25 ) + +end + +function PANEL:IsBlacklisted( id ) + + local tbl = item.GetByID( id ) + local cat = tbl.Type + + return table.HasValue( self.Categories, cat ) + +end + +function PANEL:RefreshItems( tbl ) + + self:Clear( true ) + + for k,v in pairs( tbl ) do + + local pnl = self:HasItem( v ) + + if pnl and pnl:IsStackable() then + + pnl:AddCount( 1 ) + + elseif not self:IsBlacklisted( v ) then + + local pnl = vgui.Create( "ItemPanel" ) + pnl:SetItemTable( item.GetByID( v ) ) + pnl:SetCount( 1 ) + pnl:SetPriceScale( self.PriceScale ) + pnl:SetStashable( self.Stashable, self.StashStyle ) + pnl:SetSizeOverride( self:GetItemPnlSize() ) //bigg0r + + self:AddItem( pnl ) + + end + + end + + if #tbl < 1 then + + self:InvalidateLayout() + + end + + if self.StashButton then + + self.StashButton:Remove() + self.StashButton = nil + + end + + if self.CashBox then + + self.CashBox:Remove() + self.CashBox = nil + + end + + if self.CashButton then + + self.CashButton:Remove() + self.CashButton = nil + + end + + if self.StashStyle != "Buy" then + + self.CashBox = vgui.Create( "DNumberWang", self ) + self.CashBox:SetDecimals( 0 ) + self.CashBox:SetValue( math.max( self:GetCash(), 5 ) ) + self.CashBox:SetMinMax( 5, math.max( self:GetCash(), 5 ) ) + self.CashBox:SetWide( 80 ) + + self.CashButton = vgui.Create( "DButton", self ) + + if self.StashStyle == "Take" then + + self.CashButton:SetText( self.StashStyle ) + self.CashButton.OnMousePressed = function() + + RunConsoleCommand( "cash_take", math.min( tonumber( self.CashBox:GetValue() ) or 0, self:GetCash() ) ) + + end + + elseif self.StashStyle == "Stash" and self.Stashable then + + self.CashButton:SetText( self.StashStyle ) + self.CashButton.OnMousePressed = function() + + RunConsoleCommand( "cash_stash", math.min( tonumber( self.CashBox:GetValue() ) or 0, self:GetCash() ) ) + + end + + else + + self.CashButton:SetText( "Drop" ) + self.CashButton.OnMousePressed = function() + + RunConsoleCommand( "cash_drop", math.min( tonumber( self.CashBox:GetValue() ) or 0, self:GetCash() ) ) + + end + + end + + end + + if ( self.StashStyle == "Stash" or self.StashStyle == "Take" ) and not self.IsLocalInv and #self:GetItems() > 0 then + + self.StashButton = vgui.Create( "DButton", self ) + self.StashButton:SetText( "Take All" ) + self.StashButton.OnMousePressed = function() + + if #self:GetItems() < 1 then return end + + for k,v in pairs( self:GetItems() ) do + + RunConsoleCommand( "inv_take", v:GetID(), v:GetCount() ) + + end + + end + + end + +end + +function PANEL:Think() + + if self.CashBox then + + if self:GetCash() < 5 then + + self.CashBox:SetMinMax( 5, 5 ) + self.CashBox:SetValue( 5 ) + self.CashButton:SetDisabled( true ) + + else + + self.CashBox:SetMinMax( 5, math.max( self:GetCash(), 5 ) ) + self.CashButton:SetDisabled( false ) + + end + + end + +end + +function PANEL:AddScroll( amt ) + + self.ScrollAmt = self.ScrollAmt + amt + + self.pnlCanvas:SetPos( 0, self.ScrollAmt * self:GetItemPnlSize() ) + +end + +function PANEL:OnVScroll( offset ) + + self.pnlCanvas:SetPos( 0, offset ) + +end + +function PANEL:PerformLayout() + + local wide = self:GetWide() + + if ( !self.Rebuild ) then + debug.Trace() + end + + self:Rebuild() + + self.pnlCanvas:SetPos( 0, self.ScrollAmt * self:GetItemPnlSize() ) + self.pnlCanvas:SetWide( wide ) + + self:Rebuild() + +end + +function PANEL:Rebuild() + + local Offset = 0 + + if ( self.Horizontal ) then + + local x, y = self.Padding, self.Padding + + for k, panel in pairs( self.Items ) do + + if ( panel:IsVisible() ) then + + local w = self:GetItemPnlSize() + local h = self:GetItemPnlSize() + + if ( x + w > self:GetWide() ) then // move down + + x = self.Padding + y = y + h + self.Spacing + + end + + panel:SetPos( x, y ) + + x = x + w + self.Spacing + Offset = y + h + self.Spacing + + end + + end + + else + + for k, panel in pairs( self.Items ) do + + if ( panel:IsVisible() ) then + + if ( self.m_bNoSizing ) then + panel:SizeToContents() + panel:SetPos( (self:GetCanvas():GetWide() - panel:GetWide()) * 0.5, self.Padding + Offset ) + else + panel:SetSize( self:GetCanvas():GetWide() - self.Padding * 2, panel:GetTall() ) + panel:SetPos( self.Padding, self.Padding + Offset ) + end + + panel:InvalidateLayout( true ) + + Offset = Offset + panel:GetTall() + self.Spacing + + end + + end + + Offset = Offset + self.Padding + + end + + self:GetCanvas():SetTall( self:GetTall() + Offset - self.Spacing ) + + if ( self.m_bNoSizing and self:GetCanvas():GetTall() < self:GetTall() ) then + + self:GetCanvas():SetPos( 0, (self:GetTall()-self:GetCanvas():GetTall()) * 0.5 ) + + end + + if self.StashButton then + + self.StashButton:SetSize( 48, 20 ) + self.StashButton:SetPos( self:GetWide() - self:GetPadding() * 2 - self.StashButton:GetWide(), self:GetTall() - self:GetPadding() * 2 - self.StashButton:GetTall() ) + + end + + if self.CashBox then + + self.CashBox:SetPos( self:GetPadding() * 2, self:GetTall() - ( self:GetPadding() * 2 ) - 20 ) + + end + + if self.CashButton then + + self.CashButton:SetSize( 48, 20 ) + self.CashButton:SetPos( ( self:GetPadding() * 2 ) + 5 + self.CashBox:GetWide(), self:GetTall() - ( self:GetPadding() * 2 ) - 20 ) + + end + +end + +function PANEL:Paint() + + //draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + //draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 100 ) ) + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 180 ) ) + + if self.StashStyle == "Buy" then return end + + draw.SimpleText( "Cash: $" .. self:GetCash(), "ItemDisplayFont", self:GetPadding() * 2, self:GetTall() - ( self:GetPadding() * 2 ) - 35, Color( 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT ) + + //draw.TexturedQuad( { texture = surface.GetTextureID( "radbox/menu_trade" ), x = self:GetPadding() * 2, y = self:GetTall() - ( self:GetPadding() * 2 ) - 40, w = 40, h = 40, color = Color( 200, 200, 200 ) } ) + +end + +derma.DefineControl( "ItemSheet", "A sheet for storing HUD elements", PANEL, "DPanelList" ) diff --git a/gamemode/vgui/vgui_playerdisplay.lua b/gamemode/vgui/vgui_playerdisplay.lua new file mode 100644 index 0000000..b508efb --- /dev/null +++ b/gamemode/vgui/vgui_playerdisplay.lua @@ -0,0 +1,166 @@ +local PANEL = {} + +function PANEL:Init() + + //self:ShowCloseButton( false ) + self:SetKeyboardInputEnabled( false ) + //self:SetDraggable( false ) + + self.Text = "" + self.Title = "" + self.LastModel = "" + +end + +function PANEL:SetupCam( campos, origin ) + + self.CamPos = campos + self.Origin = origin + +end + +function PANEL:SetModel( campos, origin ) + + if not self.ModelPanel then + + self.ModelPanel = vgui.Create( "GoodModelPanel", self ) + + end + + self.ModelPanel:SetModel( LocalPlayer():GetModel() ) + + if campos then + + self.ModelPanel:SetCamPos( campos ) + + end + + if origin then + + self.ModelPanel:SetLookAt( origin ) + + end + + self:InvalidateLayout() + +end + +function PANEL:Think() + + if not IsValid( LocalPlayer() ) then return end + + if self.LastModel != LocalPlayer():GetModel() then + + self:SetModel( self.CamPos, self.Origin ) + self.LastModel = LocalPlayer():GetModel() + + end + +end + +function PANEL:PerformLayout() + + if self.ModelPanel then + + local size = math.Min( self:GetWide(), self:GetTall() * 0.85 ) + local pos = ( self:GetWide() - size ) / 2 + + self.ModelPanel:SetPos( pos, 0 ) + self.ModelPanel:SetSize( size, size ) + + end + + self:SizeToContents() + +end + +function PANEL:GetStats() + + local tbl = {} + local weight = math.Round( LocalPlayer():GetNWFloat( "Weight", 0 ) * 100 ) / 100 + local cash = LocalPlayer():GetNWInt( "Cash", 0 ) + + if cash < 20 then + + table.insert( tbl, { GAMEMODE.CurrencyName .. "s: " .. cash, Color(255,150,50) } ) + + else + + table.insert( tbl, { GAMEMODE.CurrencyName .. "s: " .. cash, Color(255,255,255) } ) + + end + + if weight < GAMEMODE.OptimalWeight then + + table.insert( tbl, { "Weight: " .. weight .. " lbs", Color(255,255,255) } ) + + elseif weight < GAMEMODE.MaxWeight then + + table.insert( tbl, { "Weight: " .. weight .. " lbs", Color(255,150,50) } ) + + else + + table.insert( tbl, { "Weight: " .. weight .. " lbs", Color(255,100,100) } ) + + end + + if LocalPlayer():GetNWBool( "Infected", false ) then + + table.insert( tbl, { "Health Status: Infected", Color(255,100,100) } ) + + elseif LocalPlayer():GetNWBool( "Bleeding", false ) then + + table.insert( tbl, { "Health Status: Bleeding", Color(255,100,100) } ) + + elseif LocalPlayer():Health() < 75 then + + table.insert( tbl, { "Health Status: Critical", Color(255,100,100) } ) + + elseif LocalPlayer():Health() < 140 then + + table.insert( tbl, { "Health Status: Injured", Color(255,150,50) } ) + + else + + table.insert( tbl, { "Health Status: Normal", Color(255,255,255) } ) + + end + + if LocalPlayer():GetNWInt( "Radiation", 0 ) > 2 then + + table.insert( tbl, { "Radiation Levels: Lethal", Color(255,100,100) } ) + + elseif LocalPlayer():GetNWInt( "Radiation", 0 ) > 0 then + + table.insert( tbl, { "Radiation Levels: Elevated", Color(255,150,50) } ) + + else + + table.insert( tbl, { "Radiation Levels: Normal", Color(255,255,255) } ) + + end + + return tbl + +end + +function PANEL:Paint() + + if not IsValid( LocalPlayer() ) then return end + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 100 ) ) + + surface.SetFont( "ItemDisplayFont" ) + + for k,v in pairs( self:GetStats() ) do + + draw.SimpleText( v[1], "ItemDisplayFont", self:GetWide() * 0.5, self:GetTall() * 0.83 + ( ( k - 1 ) * 15 ), v[2], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + + end + + draw.SimpleText( LocalPlayer():Name(), "ItemDisplayFont", self:GetWide() * 0.5, 15, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + +end + +derma.DefineControl( "PlayerDisplay", "A HUD Element with a big model in the middle and player stats.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_playerpanel.lua b/gamemode/vgui/vgui_playerpanel.lua new file mode 100644 index 0000000..9779466 --- /dev/null +++ b/gamemode/vgui/vgui_playerpanel.lua @@ -0,0 +1,68 @@ +local PANEL = {} + +function PANEL:Init() + + //self:ShowCloseButton( false ) + + self.Avatar = vgui.Create( "AvatarImage", self ) + self.PlayerName = "N/A" + self.Desc = "" + + self:PerformLayout() + +end + +function PANEL:SetPlayerEnt( ply ) + + self.Avatar:SetPlayer( ply ) + + if IsValid( ply ) then + + self.PlayerName = ply:Nick() + + end + +end + +function PANEL:SetCount( num ) + + self.Count = num + +end + +function PANEL:SetDescription( text ) + + self.Desc = text + +end + +function PANEL:GetPadding() + + return 5 + +end + +function PANEL:PerformLayout() + + self.Avatar:SetSize( 16, 16 ) + self.Avatar:SetPos( self:GetPadding(), self:GetPadding() ) + + self:SetTall( 16 + self:GetPadding() * 2 ) + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 2, 2, self:GetWide() - 4, self:GetTall() - 4, Color( 100, 100, 100, 255 ) ) + + draw.SimpleText( self.PlayerName .. " " .. self.Desc, "EndGame", self:GetPadding() * 3 + 16, self:GetTall() * 0.4 - self:GetPadding(), Color( 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT ) + + if self.Count then + + draw.SimpleText( self.Count, "EndGame", self:GetWide() - self:GetPadding() * 2, self:GetTall() * 0.4 - self:GetPadding(), Color( 255, 50, 50 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT ) + + end + +end + +derma.DefineControl( "PlayerPanel", "A HUD Element with a player name and avatar", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_scroller.lua b/gamemode/vgui/vgui_scroller.lua new file mode 100644 index 0000000..0fb9e51 --- /dev/null +++ b/gamemode/vgui/vgui_scroller.lua @@ -0,0 +1,105 @@ +local PANEL = {} + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + //self:SetDraggable( false ) + + self.Image = vgui.Create( "DImageButton", self ) + self.Image:SetImage( "icon16/car.png" ) + self.Image:SetStretchToFit( false ) + self.Image.OnMousePressed = function() + + self.Depressed = true + + end + + self.Image.OnMouseReleased = function() + + self.Depressed = false + + end + + self:SetCursor( "hand" ) + self.Up = true + self.MoveTime = 0 + +end + +function PANEL:SetImage( img ) + + self.Image:SetImage( img ) + +end + +function PANEL:SetScrollUp( bool ) + + self.Up = bool + +end + +function PANEL:Think() + + if not self.Target then return end + + if self.Depressed and self.MoveTime < CurTime() then + + self.MoveTime = CurTime() + 0.2 + + if self.Up then + + self.Target:AddScroll( 1 ) + + else + + self.Target:AddScroll( -1 ) + + end + + surface.PlaySound( "buttons/lightswitch2.wav" ) + + end + +end + +function PANEL:SetTarget( pnl ) + + self.Target = pnl + +end + +function PANEL:OnMousePressed( mousecode ) + + self.Depressed = true + self:MouseCapture( true ) + +end + +function PANEL:OnMouseReleased( mousecode ) + + self.Depressed = false + self:MouseCapture( false ) + +end + +function PANEL:GetPadding() + return 5 +end + +function PANEL:PerformLayout() + + self.Image:SetSize( self:GetWide() - 10, self:GetTall() - 10 ) + self.Image:SetPos( 5, 5 ) + + //self:SizeToContents() + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 180 ) ) + +end + +derma.DefineControl( "Scroller", "A shitty scroller thing.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_shopmenu.lua b/gamemode/vgui/vgui_shopmenu.lua new file mode 100644 index 0000000..99a201e --- /dev/null +++ b/gamemode/vgui/vgui_shopmenu.lua @@ -0,0 +1,77 @@ +local PANEL = {} + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + //self:SetDraggable( false ) + + self.Items = {} + + self.List = vgui.Create( "DListView", self ) + + local col1 = self.List:AddColumn( "Ordered Item" ) + local col2 = self.List:AddColumn( "Cost" ) + + col1:SetMinWidth( 150 ) + col2:SetMinWidth( 50 ) + col2:SetMaxWidth( 100 ) + + self.Button = vgui.Create( "DImageButton", self ) + self.Button:SetImage( "toxsin/airdrop" ) + self.Button.OnMousePressed = function() self.List:Clear() self.Items = {} RunConsoleCommand( "ordershipment" ) RunConsoleCommand( "gm_showteam" ) end + +end + +function PANEL:AddItems( id, amt ) + + local tbl = item.GetByID( id ) + + if tbl.Price * amt > LocalPlayer():GetNWInt( "Cash", 0 ) then return end + + for i=1,amt do + + table.insert( self.Items, id ) + + end + + self.List:Clear() + + for k,v in pairs( self.Items ) do + + local tbl = item.GetByID( v ) + + self.List:AddLine( tbl.Name, tbl.Price ) + + end + +end + +function PANEL:GetPadding() + return 5 +end + +function PANEL:PerformLayout() + + local x,y = self:GetPadding(), self:GetPadding() + 30 + + self.List:SetSize( self:GetWide() * 0.5 - ( 2 * self:GetPadding() ), self:GetTall() - ( 2 * self:GetPadding() ) - 30 ) + self.List:SetPos( x, y ) + + self.Button:SetSize( self:GetWide() * 0.5 - ( 2 * self:GetPadding() ), self:GetTall() - ( 2 * self:GetPadding() ) - 30 ) + self.Button:SetPos( x + self.List:GetWide() + self:GetPadding(), self:GetPadding() + 30 ) + + self:SizeToContents() + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 150 ) ) + + draw.SimpleText( "Shipment Display", "ItemDisplayFont", self:GetWide() * 0.5, 10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + +end + +derma.DefineControl( "ShopMenu", "A shop menu.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_sidebutton.lua b/gamemode/vgui/vgui_sidebutton.lua new file mode 100644 index 0000000..f7de0e6 --- /dev/null +++ b/gamemode/vgui/vgui_sidebutton.lua @@ -0,0 +1,131 @@ +local PANEL = {} + +PANEL.Sound = Sound( "common/talk.wav" ) + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + //self:SetDraggable( false ) + + self.Image = vgui.Create( "DImageButton", self ) + self.Image:SetImage( "icon16/car.png" ) + self.Image:SetStretchToFit( false ) + self.Image.DoClick = function() + + self:DoClick() + + end + + self:SetCursor( "hand" ) + self.Text = "" + self.White = 255 + self.ColorTime = 0 + +end + +function PANEL:SetImage( img ) + + self.Image:SetImage( img ) + +end + +function PANEL:SetText( text ) + + self.Text = text + +end + +function PANEL:DoClick() + + self.Func() + surface.PlaySound( self.Sound ) + +end + +function PANEL:SetFunction( func ) + + self.Func = func + +end + +function PANEL:SetSelectedState( bool, ignore ) + + self.Selected = tobool( bool ) + + if ignore then return end + + self:DoSound( bool ) + +end + +function PANEL:OnMousePressed( mousecode ) + + self:MouseCapture( true ) + +end + +function PANEL:OnMouseReleased( mousecode ) + + self:MouseCapture( false ) + self:DoClick() + +end + +function PANEL:GetPadding() + return 5 +end + +function PANEL:PerformLayout() + + local imgsize = self:GetTall() - ( 2 * self:GetPadding() ) + + self.Image:SetSize( imgsize, imgsize ) + self.Image:SetPos( self:GetWide() - imgsize - self:GetPadding(), self:GetPadding() ) + + //self:SizeToContents() + +end + +function PANEL:Paint() + + local tx, ty = self:GetPadding() * 2, self:GetTall() * 0.5 - 8 + //local px, py = self.Image:GetPos() + local imgsize = self:GetTall() - ( 2 * self:GetPadding() ) + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 180 ) ) + + if self.Hovered then + + draw.RoundedBox( 4, self:GetWide() - imgsize - self:GetPadding(), self:GetPadding(), imgsize, imgsize, Color( 100, 100, 100, 100 ) ) + + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + + if self.ColorTime < CurTime() then + + self.ColorTime = CurTime() + math.Rand( 0, 0.3 ) + self.White = math.random( 150, 255 ) + + end + + draw.SimpleText( self.Text, "CategoryButton", tx, ty, Color( self.White, self.White, self.White, 255 ), TEXT_ALIGN_LEFT ) + + else + + draw.RoundedBox( 4, self:GetWide() - imgsize - self:GetPadding(), self:GetPadding(), imgsize, imgsize, Color( 100, 100, 100, 100 ) ) + + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx+1, ty-1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + draw.SimpleText( self.Text, "CategoryButton", tx-1, ty+1, Color( 0, 0, 0, 150 ), TEXT_ALIGN_LEFT ) + + draw.SimpleText( self.Text, "CategoryButton", tx, ty, Color( 100, 100, 100, 255 ), TEXT_ALIGN_LEFT ) + + end + +end + +derma.DefineControl( "SideButton", "A shitty action button thing.", PANEL, "PanelBase" ) diff --git a/gamemode/vgui/vgui_zombieclasses.lua b/gamemode/vgui/vgui_zombieclasses.lua new file mode 100644 index 0000000..057c1b6 --- /dev/null +++ b/gamemode/vgui/vgui_zombieclasses.lua @@ -0,0 +1,76 @@ +local PANEL = {} + +function PANEL:Init() + + //self:SetTitle( "" ) + //self:ShowCloseButton( false ) + self:ChooseParent() + + self.Items = {} + + for k,v in pairs( GAMEMODE.ZombieNames ) do + + local desc = GAMEMODE.ZombieDescriptions[k] or "TEH" + local logo = GAMEMODE.ZombieLogos[k] or "brick/brick_model" + + local button = vgui.Create( "DImageButton", self ) + button:SetImage( logo ) + button:SetSize( 100, 100 ) + button.OnMousePressed = function() RunConsoleCommand( "changeclass", k ) surface.PlaySound( "npc/zombie/claw_strike1.wav" ) self:Remove() end + button.ID = id + + local label = vgui.Create( "DLabel", self ) + label:SetWrap( true ) + label:SetText( desc ) + label:SetFont( "ItemDisplayFont" ) + label:SetSize( 300, 100 ) + + table.insert( self.Items, { button, label } ) + + end + +end + +function PANEL:Think() + + self.Dragging = false + +end + +function PANEL:ChooseParent() + +end + +function PANEL:GetPadding() + + return 5 + +end + +function PANEL:PerformLayout() + + local x,y = self:GetPadding(), self:GetPadding() + 50 + + for k,v in pairs( self.Items ) do + + v[1]:SetPos( x, y ) + v[2]:SetPos( x + 100 + self:GetPadding(), y ) + + y = y + 100 + self:GetPadding() + + end + + self:SizeToContents() + +end + +function PANEL:Paint() + + draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) + draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 150 ) ) + + draw.SimpleText( "Class Menu", "ItemDisplayFont", self:GetWide() * 0.5, 10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + +end + +derma.DefineControl( "ZombieClassPicker", "A zombie class picker menu.", PANEL, "PanelBase" ) |
