summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBen Deutsch <ben@bendeutsch.de>2018-11-22 22:47:15 +0100
committerParamat <paramat@users.noreply.github.com>2018-11-22 21:47:15 +0000
commit93bccb349080b0b184cdda9e7ab4a364664efe70 (patch)
tree2ee9bff24225c1d50a0ca0ff5c671354af846e44 /src/gui
parent1c91cb8f8f6ea15dc1308aace666bd1ebd25a28c (diff)
downloadminetest-93bccb349080b0b184cdda9e7ab4a364664efe70.tar.gz
minetest-93bccb349080b0b184cdda9e7ab4a364664efe70.tar.bz2
minetest-93bccb349080b0b184cdda9e7ab4a364664efe70.zip
Client-side autojump. Remove Android-only stepheight autojump (#7228)
Works by detecting a collision while moving forward and then simulating a jump. If the simulated jump is more successful, an artificial jump key press is injected in the client. Includes setting and key change GUI element for enabling and disabling this feature.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiKeyChangeMenu.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gui/guiKeyChangeMenu.cpp b/src/gui/guiKeyChangeMenu.cpp
index ca97e0b9e..f3d8e8eef 100644
--- a/src/gui/guiKeyChangeMenu.cpp
+++ b/src/gui/guiKeyChangeMenu.cpp
@@ -77,6 +77,7 @@ enum
// other
GUI_ID_CB_AUX1_DESCENDS,
GUI_ID_CB_DOUBLETAP_JUMP,
+ GUI_ID_CB_AUTOJUMP,
};
GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
@@ -196,6 +197,21 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
}
{
+ s32 option_x = offset.X;
+ s32 option_y = offset.Y + 5;
+ u32 option_w = 280;
+ {
+ core::rect<s32> rect(0, 0, option_w, 30);
+ rect += topleft + v2s32(option_x, option_y);
+ const wchar_t *text = wgettext("Automatic jumping");
+ Environment->addCheckBox(g_settings->getBool("autojump"), rect, this,
+ GUI_ID_CB_AUTOJUMP, text);
+ delete[] text;
+ }
+ offset += v2s32(0, 25);
+ }
+
+ {
core::rect < s32 > rect(0, 0, 100, 30);
rect += topleft + v2s32(size.X / 2 - 105, size.Y - 40);
const wchar_t *text = wgettext("Save");
@@ -239,14 +255,19 @@ bool GUIKeyChangeMenu::acceptInput()
{
gui::IGUIElement *e = getElementFromId(GUI_ID_CB_AUX1_DESCENDS);
- if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
+ if(e && e->getType() == gui::EGUIET_CHECK_BOX)
g_settings->setBool("aux1_descends", ((gui::IGUICheckBox*)e)->isChecked());
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_CB_DOUBLETAP_JUMP);
- if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
+ if(e && e->getType() == gui::EGUIET_CHECK_BOX)
g_settings->setBool("doubletap_jump", ((gui::IGUICheckBox*)e)->isChecked());
}
+ {
+ gui::IGUIElement *e = getElementFromId(GUI_ID_CB_AUTOJUMP);
+ if(e && e->getType() == gui::EGUIET_CHECK_BOX)
+ g_settings->setBool("autojump", ((gui::IGUICheckBox*)e)->isChecked());
+ }
clearKeyCache();