mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
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.
This commit is contained in:
parent
1c91cb8f8f
commit
93bccb3490
12 changed files with 149 additions and 18 deletions
|
@ -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,
|
||||
|
@ -195,6 +196,21 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
|||
offset += v2s32(0, 25);
|
||||
}
|
||||
|
||||
{
|
||||
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);
|
||||
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue