mirror of
https://github.com/minetest/minetest.git
synced 2024-12-22 14:12:24 +01:00
TouchScreenGUI: Show status text above grid menu
This commit is contained in:
parent
88397c2908
commit
08de047033
@ -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<s32>(status_x ,
|
||||
guitext_status->setRelativePosition(core::rect<s32>(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
|
||||
|
@ -412,6 +412,10 @@ TouchControls::TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc)
|
||||
|
||||
pos.X += spacing.X;
|
||||
}
|
||||
|
||||
m_status_text = grab_gui_element<IGUIStaticText>(
|
||||
m_guienv->addStaticText(L"", recti(), false, false));
|
||||
m_status_text->setVisible(false);
|
||||
}
|
||||
|
||||
void TouchControls::addButton(std::vector<button_info> &buttons, touch_gui_button_id id,
|
||||
|
@ -177,6 +177,9 @@ public:
|
||||
void registerHotbarRect(u16 index, const recti &rect);
|
||||
std::optional<u16> 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<std::shared_ptr<IGUIStaticText>> m_overflow_button_titles;
|
||||
std::vector<recti> m_overflow_button_rects;
|
||||
|
||||
std::shared_ptr<IGUIStaticText> m_status_text;
|
||||
|
||||
void toggleOverflowMenu();
|
||||
void updateVisibility();
|
||||
void releaseAll();
|
||||
|
Loading…
Reference in New Issue
Block a user