aboutsummaryrefslogtreecommitdiff
path: root/src/guiKeyChangeMenu.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 19:37:29 +0200
committerGitHub <noreply@github.com>2017-08-20 19:37:29 +0200
commitae9b5e00989756bb676429530dfe81039009001c (patch)
tree119c9ac4b886c24d42f418e21e4175a942eb95ff /src/guiKeyChangeMenu.cpp
parentc8d3d1133945138108aa195e6b3c93b07c6e4fa0 (diff)
downloadminetest-ae9b5e00989756bb676429530dfe81039009001c.tar.gz
minetest-ae9b5e00989756bb676429530dfe81039009001c.tar.bz2
minetest-ae9b5e00989756bb676429530dfe81039009001c.zip
Modernize code: very last fixes (#6290)
Last modernization fixes
Diffstat (limited to 'src/guiKeyChangeMenu.cpp')
-rw-r--r--src/guiKeyChangeMenu.cpp59
1 files changed, 24 insertions, 35 deletions
diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp
index 63e3354b7..da8d20051 100644
--- a/src/guiKeyChangeMenu.cpp
+++ b/src/guiKeyChangeMenu.cpp
@@ -85,18 +85,17 @@ GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
GUIModalMenu(env, parent, id, menumgr)
{
init_keys();
- for (size_t i = 0; i < key_settings.size(); i++)
- key_used.push_back(key_settings.at(i)->key);
+ for (key_setting *ks : key_settings)
+ key_used.push_back(ks->key);
}
GUIKeyChangeMenu::~GUIKeyChangeMenu()
{
removeChildren();
- for (std::vector<key_setting*>::iterator iter = key_settings.begin();
- iter != key_settings.end(); ++iter) {
- delete[] (*iter)->button_name;
- delete (*iter);
+ for (key_setting *ks : key_settings) {
+ delete[] ks->button_name;
+ delete ks;
}
key_settings.clear();
}
@@ -105,15 +104,12 @@ void GUIKeyChangeMenu::removeChildren()
{
const core::list<gui::IGUIElement*> &children = getChildren();
core::list<gui::IGUIElement*> children_copy;
- for (core::list<gui::IGUIElement*>::ConstIterator i = children.begin(); i
- != children.end(); i++)
- {
- children_copy.push_back(*i);
+ for (gui::IGUIElement*i : children) {
+ children_copy.push_back(i);
}
- for (core::list<gui::IGUIElement*>::Iterator i = children_copy.begin(); i
- != children_copy.end(); i++)
- {
- (*i)->remove();
+
+ for (gui::IGUIElement *i : children_copy) {
+ i->remove();
}
}
@@ -238,11 +234,10 @@ void GUIKeyChangeMenu::drawMenu()
bool GUIKeyChangeMenu::acceptInput()
{
- for(size_t i = 0; i < key_settings.size(); i++)
- {
- key_setting *k = key_settings.at(i);
+ for (key_setting *k : key_settings) {
g_settings->set(k->setting_name, k->key.sym());
}
+
{
gui::IGUIElement *e = getElementFromId(GUI_ID_CB_AUX1_DESCENDS);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
@@ -265,11 +260,8 @@ bool GUIKeyChangeMenu::resetMenu()
{
if (activeKey >= 0)
{
- for(size_t i = 0; i < key_settings.size(); i++)
- {
- key_setting *k = key_settings.at(i);
- if(k->id == activeKey)
- {
+ for (key_setting *k : key_settings) {
+ if (k->id == activeKey) {
const wchar_t *text = wgettext(k->key.name());
k->button->setText(text);
delete[] text;
@@ -317,11 +309,9 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
// But go on
{
key_setting *k = NULL;
- for(size_t i = 0; i < key_settings.size(); i++)
- {
- if(key_settings.at(i)->id == activeKey)
- {
- k = key_settings.at(i);
+ for (key_setting *ks : key_settings) {
+ if (ks->id == activeKey) {
+ k = ks;
break;
}
}
@@ -337,10 +327,10 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
if(shift_went_down){
shift_down = true;
return false;
- }else{
- activeKey = -1;
- return true;
}
+
+ activeKey = -1;
+ return true;
}
} else if (event.EventType == EET_KEY_INPUT_EVENT && activeKey < 0
&& event.KeyInput.PressedDown
@@ -372,11 +362,10 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
return true;
default:
key_setting *k = NULL;
- for(size_t i = 0; i < key_settings.size(); i++)
- {
- if(key_settings.at(i)->id == event.GUIEvent.Caller->getID())
- {
- k = key_settings.at(i);
+
+ for (key_setting *ks : key_settings) {
+ if (ks->id == event.GUIEvent.Caller->getID()) {
+ k = ks;
break;
}
}