diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp index 7631f9c78..41071ef66 100644 --- a/src/client/gameui.cpp +++ b/src/client/gameui.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gui/mainmenumanager.h" #include "gui/guiChatConsole.h" #include "gui/guiFormSpecMenu.h" +#include "gui/touchcontrols.h" #include "util/enriched_string.h" #include "util/pointedthing.h" #include "client.h" @@ -191,16 +192,27 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ } } - setStaticText(m_guitext_status, m_statustext.c_str()); - m_guitext_status->setVisible(!m_statustext.empty()); + IGUIStaticText *guitext_status; + bool overriden = g_touchcontrols && g_touchcontrols->isStatusTextOverriden(); + if (overriden) { + guitext_status = g_touchcontrols->getStatusText(); + m_guitext_status->setVisible(false); + } else { + guitext_status = m_guitext_status; + if (g_touchcontrols) + g_touchcontrols->getStatusText()->setVisible(false); + } + + setStaticText(guitext_status, m_statustext.c_str()); + guitext_status->setVisible(!m_statustext.empty()); if (!m_statustext.empty()) { - s32 status_width = m_guitext_status->getTextWidth(); - s32 status_height = m_guitext_status->getTextHeight(); - s32 status_y = screensize.Y - 150; + s32 status_width = guitext_status->getTextWidth(); + s32 status_height = guitext_status->getTextHeight(); + s32 status_y = screensize.Y - (overriden ? 15 : 150); s32 status_x = (screensize.X - status_width) / 2; - m_guitext_status->setRelativePosition(core::rect(status_x , + guitext_status->setRelativePosition(core::rect(status_x , status_y - status_height, status_x + status_width, status_y)); // Fade out @@ -208,8 +220,8 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ final_color.setAlpha(0); video::SColor fade_color = m_statustext_initial_color.getInterpolated_quadratic( m_statustext_initial_color, final_color, m_statustext_time / statustext_time_max); - m_guitext_status->setOverrideColor(fade_color); - m_guitext_status->enableOverrideColor(true); + guitext_status->setOverrideColor(fade_color); + guitext_status->enableOverrideColor(true); } // Hide chat when disabled by server or when console is visible diff --git a/src/gui/touchcontrols.cpp b/src/gui/touchcontrols.cpp index 7d7cd6e09..4a673ccf3 100644 --- a/src/gui/touchcontrols.cpp +++ b/src/gui/touchcontrols.cpp @@ -412,6 +412,10 @@ TouchControls::TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc) pos.X += spacing.X; } + + m_status_text = grab_gui_element( + m_guienv->addStaticText(L"", recti(), false, false)); + m_status_text->setVisible(false); } void TouchControls::addButton(std::vector &buttons, touch_gui_button_id id, diff --git a/src/gui/touchcontrols.h b/src/gui/touchcontrols.h index 0a86fe34e..102c85f09 100644 --- a/src/gui/touchcontrols.h +++ b/src/gui/touchcontrols.h @@ -177,6 +177,9 @@ public: void registerHotbarRect(u16 index, const recti &rect); std::optional getHotbarSelection(); + bool isStatusTextOverriden() { return m_overflow_open; } + IGUIStaticText *getStatusText() { return m_status_text.get(); } + private: IrrlichtDevice *m_device = nullptr; IGUIEnvironment *m_guienv = nullptr; @@ -235,6 +238,8 @@ private: std::vector> m_overflow_button_titles; std::vector m_overflow_button_rects; + std::shared_ptr m_status_text; + void toggleOverflowMenu(); void updateVisibility(); void releaseAll();