mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
GameUI refactor (part 2/X): Move Game::guitext to GameUI + enhancements on StaticText
Other enhancements: * C++ friendlyness for addStaticText() -> move to static StaticText::add()
This commit is contained in:
parent
0ebaed430a
commit
3a772e7ed6
8 changed files with 159 additions and 134 deletions
|
@ -149,9 +149,8 @@ GUIEngine::GUIEngine(JoystickController *joystick,
|
|||
g_fontengine->getTextHeight());
|
||||
rect += v2s32(4, 0);
|
||||
|
||||
m_irr_toplefttext =
|
||||
addStaticText(RenderingEngine::get_gui_env(), m_toplefttext,
|
||||
rect, false, true, 0, -1);
|
||||
m_irr_toplefttext = gui::StaticText::add(RenderingEngine::get_gui_env(),
|
||||
m_toplefttext, rect, false, true, 0, -1);
|
||||
|
||||
//create formspecsource
|
||||
m_formspecgui = new FormspecFormSource("");
|
||||
|
@ -560,9 +559,8 @@ void GUIEngine::updateTopLeftTextSize()
|
|||
rect += v2s32(4, 0);
|
||||
|
||||
m_irr_toplefttext->remove();
|
||||
m_irr_toplefttext =
|
||||
addStaticText(RenderingEngine::get_gui_env(), m_toplefttext,
|
||||
rect, false, true, 0, -1);
|
||||
m_irr_toplefttext = gui::StaticText::add(RenderingEngine::get_gui_env(),
|
||||
m_toplefttext, rect, false, true, 0, -1);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -950,12 +950,12 @@ void GUIFormSpecMenu::parsePwdField(parserData* data, const std::string &element
|
|||
Environment->setFocus(e);
|
||||
}
|
||||
|
||||
if (label.length() >= 1)
|
||||
{
|
||||
if (label.length() >= 1) {
|
||||
int font_height = g_fontengine->getTextHeight();
|
||||
rect.UpperLeftCorner.Y -= font_height;
|
||||
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + font_height;
|
||||
addStaticText(Environment, spec.flabel.c_str(), rect, false, true, this, 0);
|
||||
gui::StaticText::add(Environment, spec.flabel.c_str(), rect, false, true,
|
||||
this, 0);
|
||||
}
|
||||
|
||||
e->setPasswordBox(true,L'*');
|
||||
|
@ -1017,7 +1017,8 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,
|
|||
|
||||
if (name.empty()) {
|
||||
// spec field id to 0, this stops submit searching for a value that isn't there
|
||||
addStaticText(Environment, spec.flabel.c_str(), rect, false, true, this, spec.fid);
|
||||
gui::StaticText::add(Environment, spec.flabel.c_str(), rect, false, true, this,
|
||||
spec.fid);
|
||||
} else {
|
||||
spec.send = true;
|
||||
gui::IGUIElement *e;
|
||||
|
@ -1050,7 +1051,8 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,
|
|||
int font_height = g_fontengine->getTextHeight();
|
||||
rect.UpperLeftCorner.Y -= font_height;
|
||||
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + font_height;
|
||||
addStaticText(Environment, spec.flabel.c_str(), rect, false, true, this, 0);
|
||||
gui::StaticText::add(Environment, spec.flabel.c_str(), rect, false, true,
|
||||
this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1164,8 @@ void GUIFormSpecMenu::parseTextArea(parserData* data, std::vector<std::string>&
|
|||
int font_height = g_fontengine->getTextHeight();
|
||||
rect.UpperLeftCorner.Y -= font_height;
|
||||
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + font_height;
|
||||
addStaticText(Environment, spec.flabel.c_str(), rect, false, true, this, 0);
|
||||
gui::StaticText::add(Environment, spec.flabel.c_str(), rect, false, true,
|
||||
this, 0);
|
||||
}
|
||||
|
||||
if (parts.size() >= 6) {
|
||||
|
@ -1237,11 +1240,9 @@ void GUIFormSpecMenu::parseLabel(parserData* data, const std::string &element)
|
|||
L"",
|
||||
258+m_fields.size()
|
||||
);
|
||||
gui::IGUIStaticText *e =
|
||||
addStaticText(Environment, spec.flabel.c_str(),
|
||||
rect, false, false, this, spec.fid);
|
||||
e->setTextAlignment(gui::EGUIA_UPPERLEFT,
|
||||
gui::EGUIA_CENTER);
|
||||
gui::IGUIStaticText *e = gui::StaticText::add(Environment,
|
||||
spec.flabel.c_str(), rect, false, false, this, spec.fid);
|
||||
e->setTextAlignment(gui::EGUIA_UPPERLEFT, gui::EGUIA_CENTER);
|
||||
m_fields.push_back(spec);
|
||||
}
|
||||
|
||||
|
@ -1291,8 +1292,8 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data, const std::string &elemen
|
|||
L"",
|
||||
258+m_fields.size()
|
||||
);
|
||||
gui::IGUIStaticText *t =
|
||||
addStaticText(Environment, spec.flabel.c_str(), rect, false, false, this, spec.fid);
|
||||
gui::IGUIStaticText *t = gui::StaticText::add(Environment, spec.flabel.c_str(),
|
||||
rect, false, false, this, spec.fid);
|
||||
t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_CENTER);
|
||||
m_fields.push_back(spec);
|
||||
return;
|
||||
|
@ -2024,7 +2025,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
assert(!m_tooltip_element);
|
||||
// Note: parent != this so that the tooltip isn't clipped by the menu rectangle
|
||||
m_tooltip_element = addStaticText(Environment, L"",core::rect<s32>(0,0,110,18));
|
||||
m_tooltip_element = gui::StaticText::add(Environment, L"",
|
||||
core::rect<s32>(0,0,110,18));
|
||||
m_tooltip_element->enableOverrideColor(true);
|
||||
m_tooltip_element->setBackgroundColor(m_default_tooltip_bgcolor);
|
||||
m_tooltip_element->setDrawBackground(true);
|
||||
|
@ -3669,14 +3671,14 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||
m_invmgr->inventoryAction(a);
|
||||
} else if (craft_amount > 0) {
|
||||
assert(s.isValid());
|
||||
|
||||
|
||||
// if there are no items selected or the selected item
|
||||
// belongs to craftresult list, proceed with crafting
|
||||
if (m_selected_item == NULL ||
|
||||
!m_selected_item->isValid() || m_selected_item->listname == "craftresult") {
|
||||
|
||||
|
||||
m_selected_content_guess = ItemStack(); // Clear
|
||||
|
||||
|
||||
assert(inv_s);
|
||||
|
||||
// Send IACTION_CRAFT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue