diff options
| author | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
|---|---|---|
| committer | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
| commit | 868e729d68b5913716bfe5ddb512f4099851e9a2 (patch) | |
| tree | 6441108754145dfd68a6e23bea382b5cb1ab63d5 /gamemode/cl_hud/vgui/mbbutton.lua | |
| download | gearfox-868e729d68b5913716bfe5ddb512f4099851e9a2.tar.gz gearfox-868e729d68b5913716bfe5ddb512f4099851e9a2.tar.bz2 gearfox-868e729d68b5913716bfe5ddb512f4099851e9a2.zip | |
Diffstat (limited to 'gamemode/cl_hud/vgui/mbbutton.lua')
| -rw-r--r-- | gamemode/cl_hud/vgui/mbbutton.lua | 66 |
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 |
