summaryrefslogtreecommitdiff
path: root/gamemode/cl_hud/vgui/mbbutton.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/cl_hud/vgui/mbbutton.lua')
-rw-r--r--gamemode/cl_hud/vgui/mbbutton.lua66
1 files changed, 66 insertions, 0 deletions
diff --git a/gamemode/cl_hud/vgui/mbbutton.lua b/gamemode/cl_hud/vgui/mbbutton.lua
new file mode 100644
index 0000000..a5c0363
--- /dev/null
+++ b/gamemode/cl_hud/vgui/mbbutton.lua
@@ -0,0 +1,66 @@
+local PANEL = {}
+
+function PANEL:Init()
+ self.Hover = false
+ self.Pressed = false
+ self.Text = "No-Title Button"
+ self.ClickSound = "buttons/lightswitch2.wav"
+ self.ClickEnable = true
+
+ self.HoverSound = "common/bugreporter_succeeded.wav"
+ self.HoverEnable = false
+
+
+ self:SetText("")
+ self.SetText = function(s,txt) self.Text = txt end
+end
+
+function PANEL:OnCursorEntered()
+ self.Hover = true
+ if (self.HoverEnable) then surface.PlaySound(self.HoverSound) end
+end
+
+function PANEL:EnableHoverSound(bool)
+ self.HoverEnable = bool
+end
+
+function PANEL:SetHoverSound(sound)
+ self.HoverSound = sound
+end
+
+function PANEL:EnableClickSound(bool)
+ self.ClickEnable = bool
+end
+
+function PANEL:SetClickSound(sound)
+ self.ClickSound = sound
+end
+
+function PANEL:OnMousePressed()
+ self.Pressed = true
+ self:MouseCapture( true )
+end
+
+function PANEL:OnMouseReleased()
+ if (self.Pressed) then surface.PlaySound(self.ClickSound) self:DoClick() end
+
+ self.Pressed = false
+ self:MouseCapture( false )
+end
+
+function PANEL:OnCursorExited()
+ self.Hover = false
+end
+
+function PANEL:Paint(w,h)
+ if (self.Pressed) then DrawRect( 0 , 0 , w , h , MAIN_GREENCOLOR )
+ elseif (self.Hover) then DrawRect( 0 , 0 , w , h , MAIN_COLOR2 )
+ else DrawRect( 0 , 0 , w , h , MAIN_COLORD ) end
+
+ DrawText( self.Text, "Trebuchet18", w/2, h/2, MAIN_TEXTCOLOR, 1 )
+end
+
+function PANEL:PerformLayout()
+end
+
+vgui.Register( "MBButton", PANEL , "Button" ) \ No newline at end of file