@@ -38,26 +38,105 @@ typedef enum {
38
38
backward_id,
39
39
left_id,
40
40
right_id,
41
- inventory_id,
42
- drop_id,
43
41
jump_id,
44
42
crunch_id,
43
+ after_last_element_id,
44
+ settings_starter_id,
45
+ rare_controls_starter_id,
45
46
fly_id,
46
47
noclip_id,
47
48
fast_id,
48
49
debug_id,
49
- chat_id,
50
50
camera_id,
51
51
range_id,
52
- after_last_element_id
52
+ chat_id,
53
+ inventory_id,
54
+ drop_id
53
55
} touch_gui_button_id;
54
56
57
+ typedef enum {
58
+ AHBB_Dir_Top_Bottom,
59
+ AHBB_Dir_Bottom_Top,
60
+ AHBB_Dir_Left_Right,
61
+ AHBB_Dir_Right_Left
62
+ } autohide_button_bar_dir;
63
+
55
64
#define MIN_DIG_TIME_MS 500
56
65
#define MAX_TOUCH_COUNT 64
57
66
#define BUTTON_REPEAT_DELAY 0 .2f
58
67
68
+ #define SETTINGS_BAR_Y_OFFSET 6.5
69
+ #define RARE_CONTROLS_BAR_Y_OFFSET 4
70
+
59
71
extern const char ** touchgui_button_imagenames;
60
72
73
+ struct button_info {
74
+ float repeatcounter;
75
+ float repeatdelay;
76
+ irr::EKEY_CODE keycode;
77
+ std::vector<int > ids;
78
+ IGUIButton* guibutton;
79
+ bool immediate_release;
80
+ };
81
+
82
+ class AutoHideButtonBar
83
+ {
84
+ public:
85
+
86
+ AutoHideButtonBar ( IrrlichtDevice *device, IEventReceiver* receiver );
87
+
88
+ void init (ISimpleTextureSource* tsrc, const char * starter_img,
89
+ int button_id, v2s32 UpperLeft, v2s32 LowerRight,
90
+ autohide_button_bar_dir dir, float timeout);
91
+
92
+ ~AutoHideButtonBar ();
93
+
94
+ /* add button to be shown */
95
+ void addButton (touch_gui_button_id id, const wchar_t * caption,
96
+ const char * btn_image);
97
+
98
+ /* detect settings bar button events */
99
+ bool isButton (const SEvent &event);
100
+
101
+ /* handle released hud buttons */
102
+ bool isReleaseButton (int eventID);
103
+
104
+ /* step handler */
105
+ void step (float dtime);
106
+
107
+ /* deactivate button bar */
108
+ void deactivate ();
109
+
110
+ /* hide the whole buttonbar */
111
+ void hide ();
112
+
113
+ /* unhide the buttonbar */
114
+ void show ();
115
+
116
+ private:
117
+ ISimpleTextureSource* m_texturesource;
118
+ irr::video::IVideoDriver* m_driver;
119
+ IGUIEnvironment* m_guienv;
120
+ IEventReceiver* m_receiver;
121
+ v2u32 m_screensize;
122
+ button_info m_starter;
123
+ std::vector<button_info*> m_buttons;
124
+
125
+ v2s32 m_upper_left;
126
+ v2s32 m_lower_right;
127
+
128
+ /* show settings bar */
129
+ bool m_active;
130
+
131
+ bool m_visible;
132
+
133
+ /* settings bar timeout */
134
+ float m_timeout;
135
+ float m_timeout_value;
136
+ bool m_initialized;
137
+ autohide_button_bar_dir m_dir;
138
+ };
139
+
61
140
class TouchScreenGUI
62
141
{
63
142
public:
@@ -66,7 +145,7 @@ class TouchScreenGUI
66
145
67
146
void translateEvent (const SEvent &event);
68
147
69
- void init (ISimpleTextureSource* tsrc, float density );
148
+ void init (ISimpleTextureSource* tsrc);
70
149
71
150
double getYaw () { return m_camera_yaw; }
72
151
double getPitch () { return m_camera_pitch; }
@@ -77,8 +156,8 @@ class TouchScreenGUI
77
156
void registerHudItem (int index, const rect<s32> &rect);
78
157
void Toggle (bool visible);
79
158
80
- void Hide ();
81
- void Show ();
159
+ void hide ();
160
+ void show ();
82
161
83
162
private:
84
163
IrrlichtDevice* m_device;
@@ -104,15 +183,6 @@ class TouchScreenGUI
104
183
bool m_move_sent_as_mouse_event;
105
184
v2s32 m_move_downlocation;
106
185
107
- struct button_info {
108
- float repeatcounter;
109
- float repeatdelay;
110
- irr::EKEY_CODE keycode;
111
- std::vector<int > ids;
112
- IGUIButton* guibutton;
113
- bool immediate_release;
114
- };
115
-
116
186
button_info m_buttons[after_last_element_id];
117
187
118
188
/* gui button detection */
@@ -142,7 +212,7 @@ class TouchScreenGUI
142
212
std::vector<id_status> m_known_ids;
143
213
144
214
/* handle a button event */
145
- void ButtonEvent (touch_gui_button_id bID, int eventID, bool action);
215
+ void handleButtonEvent (touch_gui_button_id bID, int eventID, bool action);
146
216
147
217
/* handle pressed hud buttons */
148
218
bool isHUDButton (const SEvent &event);
@@ -156,6 +226,9 @@ class TouchScreenGUI
156
226
/* handle release event */
157
227
void handleReleaseEvent (int evt_id);
158
228
229
+ /* get size of regular gui control button */
230
+ int getGuiButtonSize ();
231
+
159
232
/* doubleclick detection variables */
160
233
struct key_event {
161
234
unsigned int down_time;
@@ -168,6 +241,12 @@ class TouchScreenGUI
168
241
169
242
/* array for doubletap detection */
170
243
key_event m_key_events[2 ];
244
+
245
+ /* settings bar */
246
+ AutoHideButtonBar m_settingsbar;
247
+
248
+ /* rare controls bar */
249
+ AutoHideButtonBar m_rarecontrolsbar;
171
250
};
172
251
extern TouchScreenGUI *g_touchscreengui;
173
252
#endif
0 commit comments