summaryrefslogtreecommitdiff
path: root/src/gui/guiFormSpecMenu.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2018-01-03 17:28:57 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-01-05 20:59:30 +0100
commit3a772e7ed6c02f91de57320b1694c7d11e1c7618 (patch)
tree8662cc6a9ac690713d74abdf01406b30c86c8e3b /src/gui/guiFormSpecMenu.cpp
parent0ebaed430ad5cd2523d78d2e2c051576e948fe13 (diff)
downloadminetest-3a772e7ed6c02f91de57320b1694c7d11e1c7618.tar.gz
minetest-3a772e7ed6c02f91de57320b1694c7d11e1c7618.tar.bz2
minetest-3a772e7ed6c02f91de57320b1694c7d11e1c7618.zip
GameUI refactor (part 2/X): Move Game::guitext to GameUI + enhancements on StaticText
Other enhancements: * C++ friendlyness for addStaticText() -> move to static StaticText::add()
Diffstat (limited to 'src/gui/guiFormSpecMenu.cpp')
-rw-r--r--src/gui/guiFormSpecMenu.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index c83e6aa49..5926cca3a 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -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