1
0

TouchScreenGUI: minor fixes

This commit is contained in:
Maksym H 2023-08-16 14:05:41 +03:00
parent 27548f8b13
commit 8daac0ba49
3 changed files with 11 additions and 7 deletions

View File

@ -168,12 +168,12 @@ void GUIModalMenu::quitMenu()
Environment->forceUpdateHoveredElement(); Environment->forceUpdateHoveredElement();
#endif #endif
this->drop();
#ifdef HAVE_TOUCHSCREENGUI #ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui && g_touchscreengui->isActive() && m_touchscreen_visible) if (g_touchscreengui && g_touchscreengui->isActive() && m_touchscreen_visible)
g_touchscreengui->show(); g_touchscreengui->show();
#endif #endif
this->drop();
} }
void GUIModalMenu::removeChildren() void GUIModalMenu::removeChildren()

View File

@ -598,7 +598,6 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc)
{ {
assert(tsrc); assert(tsrc);
m_visible = true;
m_texturesource = tsrc; m_texturesource = tsrc;
/* Init joystick display "button" /* Init joystick display "button"
@ -1095,10 +1094,10 @@ void TouchScreenGUI::handleChangedButton(const SEvent &event)
for (auto iter = m_buttons[i].ids.begin(); for (auto iter = m_buttons[i].ids.begin();
iter != m_buttons[i].ids.end(); ++iter) { iter != m_buttons[i].ids.end(); ++iter) {
if (event.TouchInput.ID == *iter) { if (event.TouchInput.ID == *iter) {
s32 current_button_id = touch_gui_button_id current_button_id =
getButtonID(event.TouchInput.X, event.TouchInput.Y); getButtonID(event.TouchInput.X, event.TouchInput.Y);
if (current_button_id == i) if (current_button_id == (touch_gui_button_id) i)
continue; continue;
// remove old button // remove old button
@ -1113,7 +1112,8 @@ void TouchScreenGUI::handleChangedButton(const SEvent &event)
} }
} }
s32 current_button_id = getButtonID(event.TouchInput.X, event.TouchInput.Y); touch_gui_button_id current_button_id = getButtonID(event.TouchInput.X,
event.TouchInput.Y);
if (current_button_id == after_last_element_id) if (current_button_id == after_last_element_id)
return; return;
@ -1289,6 +1289,10 @@ void TouchScreenGUI::registerHudItem(s32 index, const rect<s32> &rect)
void TouchScreenGUI::Toggle(bool visible) void TouchScreenGUI::Toggle(bool visible)
{ {
m_visible = visible; m_visible = visible;
if (!m_buttons_initialized)
return;
for (auto &button : m_buttons) { for (auto &button : m_buttons) {
if (button.guibutton) if (button.guibutton)
button.guibutton->setVisible(visible); button.guibutton->setVisible(visible);

View File

@ -225,7 +225,7 @@ private:
double m_touch_sensitivity; double m_touch_sensitivity;
std::map<int, rect<s32>> m_hud_rects; std::map<int, rect<s32>> m_hud_rects;
std::map<size_t, irr::EKEY_CODE> m_hud_ids; std::map<size_t, irr::EKEY_CODE> m_hud_ids;
bool m_visible; // is the gui visible bool m_visible = true; // is the gui visible
bool m_buttons_initialized = false; bool m_buttons_initialized = false;
// value in degree // value in degree