#endif
}
-GUIConfirmRegistration::~GUIConfirmRegistration()
-{
- removeChildren();
-}
-
-void GUIConfirmRegistration::removeChildren()
-{
- const core::list<gui::IGUIElement *> &children = getChildren();
- core::list<gui::IGUIElement *> children_copy;
- for (gui::IGUIElement *i : children)
- children_copy.push_back(i);
- for (gui::IGUIElement *i : children_copy)
- i->remove();
-}
-
void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
{
acceptInput();
- removeChildren();
+ removeAllChildren();
/*
Calculate new sizes and positions
s32 id, IMenuManager *menumgr, Client *client,
const std::string &playername, const std::string &password,
bool *aborted, ISimpleTextureSource *tsrc);
- ~GUIConfirmRegistration();
-
- void removeChildren();
/*
Remove and re-add (or reposition) stuff
*/
GUIFormSpecMenu::~GUIFormSpecMenu()
{
- removeChildren();
+ removeAllChildren();
+ removeTooltip();
for (auto &table_it : m_tables)
table_it.second->drop();
}
}
-void GUIFormSpecMenu::removeChildren()
+void GUIFormSpecMenu::removeTooltip()
{
- const core::list<gui::IGUIElement*> &children = getChildren();
-
- while (!children.empty()) {
- (*children.getLast())->remove();
- }
-
if (m_tooltip_element) {
m_tooltip_element->remove();
m_tooltip_element->drop();
// 5. first focusable (not statictext, not tabheader)
// 6. first child element
- core::list<gui::IGUIElement*> children = getChildren();
-
- // in case "children" contains any NULL elements, remove them
- for (core::list<gui::IGUIElement*>::Iterator it = children.begin();
- it != children.end();) {
- if (*it)
- ++it;
- else
- it = children.erase(it);
- }
+ const auto& children = getChildren();
// 1. first empty editbox
for (gui::IGUIElement *it : children) {
}
// 4. last button
- for (core::list<gui::IGUIElement*>::Iterator it = children.getLast();
- it != children.end(); --it) {
+ for (auto it = children.rbegin(); it != children.rend(); ++it) {
if ((*it)->getType() == gui::EGUIET_BUTTON) {
Environment->setFocus(*it);
return;
if (children.empty())
Environment->setFocus(this);
else
- Environment->setFocus(*(children.begin()));
+ Environment->setFocus(children.front());
}
GUITable* GUIFormSpecMenu::getTable(const std::string &tablename)
}
// Remove children
- removeChildren();
+ removeAllChildren();
+ removeTooltip();
for (auto &table_it : m_tables)
table_it.second->drop();
pos_offset = v2f32();
// used for formspec versions < 3
- core::list<IGUIElement *>::Iterator legacy_sort_start = Children.getLast();
+ std::list<IGUIElement *>::iterator legacy_sort_start = std::prev(Children.end()); // last element
if (enable_prepends) {
// Backup the coordinates so that prepends can use the coordinates of choice.
// legacy sorting for formspec versions < 3
if (m_formspec_version >= 3)
// prepends do not need to be reordered
- legacy_sort_start = Children.getLast();
+ legacy_sort_start = std::prev(Children.end()); // last element
else if (version_backup >= 3)
// only prepends elements have to be reordered
legacySortElements(legacy_sort_start);
}
}
-void GUIFormSpecMenu::legacySortElements(core::list<IGUIElement *>::Iterator from)
+void GUIFormSpecMenu::legacySortElements(std::list<IGUIElement *>::iterator from)
{
/*
Draw order for formspec_version <= 2:
if (from == Children.end())
from = Children.begin();
else
- from++;
+ ++from;
- core::list<IGUIElement *>::Iterator to = Children.end();
+ std::list<IGUIElement *>::iterator to = Children.end();
// 1: Copy into a sortable container
- std::vector<IGUIElement *> elements;
- for (auto it = from; it != to; ++it)
- elements.emplace_back(*it);
+ std::vector<IGUIElement *> elements(from, to);
// 2: Sort the container
std::stable_sort(elements.begin(), elements.end(),
[this] (const IGUIElement *a, const IGUIElement *b) -> bool {
+ // TODO: getSpecByID is a linear search. It should made O(1), or cached here.
const FieldSpec *spec_a = getSpecByID(a->getID());
const FieldSpec *spec_b = getSpecByID(b->getID());
return spec_a && spec_b &&
});
// 3: Re-assign the pointers
- for (auto e : elements) {
- *from = e;
- from++;
- }
+ reorderChildren(from, to, elements);
}
#ifdef __ANDROID__
/*
This is where all the drawing happens.
*/
- core::list<IGUIElement*>::Iterator it = Children.begin();
- for (; it != Children.end(); ++it)
- if ((*it)->isNotClipped() ||
+ for (auto child : Children)
+ if (child->isNotClipped() ||
AbsoluteClippingRect.isRectCollided(
- (*it)->getAbsolutePosition()))
- (*it)->draw();
+ child->getAbsolutePosition()))
+ child->draw();
for (gui::IGUIElement *e : m_clickthrough_elements)
e->setVisible(false);
m_lockscreensize = basescreensize;
}
- void removeChildren();
+ void removeTooltip();
void setInitialFocus();
void setFocus(const std::string &elementname)
* types were drawn before others.
* This function sorts the elements in the old order for backwards compatibility.
*/
- void legacySortElements(core::list<IGUIElement *>::Iterator from);
+ void legacySortElements(std::list<IGUIElement *>::iterator from);
int m_btn_height;
gui::IGUIFont *m_font = nullptr;
GUIKeyChangeMenu::~GUIKeyChangeMenu()
{
- removeChildren();
+ removeAllChildren();
+ key_used_text = nullptr;
for (key_setting *ks : key_settings) {
delete[] ks->button_name;
key_settings.clear();
}
-void GUIKeyChangeMenu::removeChildren()
-{
- const core::list<gui::IGUIElement*> &children = getChildren();
- core::list<gui::IGUIElement*> children_copy;
- for (gui::IGUIElement*i : children) {
- children_copy.push_back(i);
- }
-
- for (gui::IGUIElement *i : children_copy) {
- i->remove();
- }
- key_used_text = nullptr;
-}
-
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
- removeChildren();
+ removeAllChildren();
+ key_used_text = nullptr;
const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
IMenuManager *menumgr, ISimpleTextureSource *tsrc);
~GUIKeyChangeMenu();
- void removeChildren();
/*
Remove and re-add (or reposition) stuff
*/
{
}
-GUIPasswordChange::~GUIPasswordChange()
-{
- removeChildren();
-}
-
-void GUIPasswordChange::removeChildren()
-{
- const core::list<gui::IGUIElement *> &children = getChildren();
- core::list<gui::IGUIElement *> children_copy;
- for (gui::IGUIElement *i : children) {
- children_copy.push_back(i);
- }
-
- for (gui::IGUIElement *i : children_copy) {
- i->remove();
- }
-}
void GUIPasswordChange::regenerateGui(v2u32 screensize)
{
/*
/*
Remove stuff
*/
- removeChildren();
+ removeAllChildren();
/*
Calculate new sizes and positions
GUIPasswordChange(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
IMenuManager *menumgr, Client *client,
ISimpleTextureSource *tsrc);
- ~GUIPasswordChange();
- void removeChildren();
/*
Remove and re-add (or reposition) stuff
*/
GUIFileSelectMenu::~GUIFileSelectMenu()
{
- removeChildren();
setlocale(LC_NUMERIC, "C");
}
void GUIFileSelectMenu::regenerateGui(v2u32 screensize)
{
- removeChildren();
+ removeAllChildren();
m_fileOpenDialog = 0;
core::dimension2du size(600 * m_gui_scale, 400 * m_gui_scale);
void GUIScrollContainer::draw()
{
if (isVisible()) {
- core::list<IGUIElement *>::Iterator it = Children.begin();
- for (; it != Children.end(); ++it)
- if ((*it)->isNotClipped() ||
+ for (auto child : Children)
+ if (child->isNotClipped() ||
AbsoluteClippingRect.isRectCollided(
- (*it)->getAbsolutePosition()))
- (*it)->draw();
+ child->getAbsolutePosition()))
+ child->draw();
}
}
{
}
-GUIVolumeChange::~GUIVolumeChange()
-{
- removeChildren();
-}
-
-void GUIVolumeChange::removeChildren()
-{
- if (gui::IGUIElement *e = getElementFromId(ID_soundText))
- e->remove();
-
- if (gui::IGUIElement *e = getElementFromId(ID_soundExitButton))
- e->remove();
-
- if (gui::IGUIElement *e = getElementFromId(ID_soundSlider))
- e->remove();
-
- if (gui::IGUIElement *e = getElementFromId(ID_soundMuteButton))
- e->remove();
-}
-
void GUIVolumeChange::regenerateGui(v2u32 screensize)
{
/*
Remove stuff
*/
- removeChildren();
+ removeAllChildren();
/*
Calculate new sizes and positions
*/
GUIVolumeChange(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id,
IMenuManager *menumgr, ISimpleTextureSource *tsrc);
- ~GUIVolumeChange();
-
- void removeChildren();
/*
Remove and re-add (or reposition) stuff
*/
// Remove all entries if there are duplicates
m_stack.remove(menu);
- /*core::list<GUIModalMenu*>::Iterator i = m_stack.getLast();
- assert(*i == menu);
- m_stack.erase(i);*/
-
if(!m_stack.empty())
m_stack.back()->setVisible(true);
}
#endif
}
-void GUIModalMenu::removeChildren()
-{
- const core::list<gui::IGUIElement *> &children = getChildren();
- core::list<gui::IGUIElement *> children_copy;
- for (gui::IGUIElement *i : children) {
- children_copy.push_back(i);
- }
-
- for (gui::IGUIElement *i : children_copy) {
- i->remove();
- }
-}
-
// clang-format off
bool GUIModalMenu::DoubleClickDetection(const SEvent &event)
{
bool canTakeFocus(gui::IGUIElement *e);
void draw();
void quitMenu();
- void removeChildren();
virtual void regenerateGui(v2u32 screensize) = 0;
virtual void drawMenu() = 0;
MapNode node;
bool position_valid;
- core::list<v3s16> validity_exceptions;
+ std::list<v3s16> validity_exceptions;
TC()
{
{
//return position_valid ^ (p==position_valid_exception);
bool exception = false;
- for(core::list<v3s16>::Iterator i=validity_exceptions.begin();
+ for(std::list<v3s16>::iterator i=validity_exceptions.begin();
i != validity_exceptions.end(); i++)
{
if(p == *i)