OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
uibutton.h
1/*
2===========================================================================
3Copyright (C) 2024 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25extern Event W_Button_Pressed;
26
27class UIButtonBase : public UIWidget
28{
29protected:
30 mouseState_t m_mouseState;
31 str m_hoverSound;
32 str m_hoverCommand;
33 str m_mouseExitedCommand;
34
35public:
36 CLASS_PROTOTYPE(UIButtonBase);
37
38protected:
39 void Pressed(Event *ev);
40 void Released(Event *ev);
41 void MouseEntered(Event *ev);
42 void MouseExited(Event *ev);
43 void Dragged(Event *ev);
44 void SetHoverSound(Event *ev);
45 void SetHoverCommand(Event *ev);
46 void SetMouseExitedCommand(Event *ev);
47
48public:
49 UIButtonBase();
50
51 void Action(void);
52};
53
54class UIButton : public UIButtonBase
55{
56public:
57 CLASS_PROTOTYPE(UIButton);
58
59private:
60 void Draw(void) override;
61 virtual void DrawPressed(void);
62 virtual void DrawUnpressed(void);
63
64public:
65 UIButton();
66
67 qboolean KeyEvent(int key, unsigned int time) override;
68};
69
70class ToggleCVar : public USignal
71{
72protected:
73 str m_cvarname;
74 UIButton *m_button;
75
76protected:
77 CLASS_PROTOTYPE(ToggleCVar);
78
79 void Press(Event *ev);
80
81public:
82 ToggleCVar();
83 ToggleCVar(UIButton *button, const char *cvar);
84
85 void setCVar(const char *cvar);
86 void setButton(UIButton *button);
87};
88
89class ExecCmd : public USignal
90{
91protected:
92 UIButton *m_button;
93 str m_cmd;
94
95public:
96 CLASS_PROTOTYPE(ExecCmd);
97
98protected:
99 void Press(Event *ev);
100
101public:
102 ExecCmd();
103 ExecCmd(UIButton *button, const char *cmd);
104
105 void setCommand(const char *cmd);
106 void setButton(UIButton *button);
107};
Definition listener.h:246
Definition uibutton.h:55
Definition usignal.h:44
Definition str.h:77