mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Add keybinding for world close key (#16250)
Fix according to Lua code style guidelines (grorp) Fix order in defaultsettings.cpp (grorp) remove unrequired comment, and whitespace Co-authored-by: y5nw <y5nw@users.noreply.github.com> Co-authored-by: grorp <grorp@users.noreply.github.com>
This commit is contained in:
parent
43aad3711b
commit
80be9bf76e
5 changed files with 41 additions and 8 deletions
|
@ -137,6 +137,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
|||
// This is separate from other keyboard handling so that it also works in menus.
|
||||
if (event.EventType == EET_KEY_INPUT_EVENT) {
|
||||
KeyPress keyCode(event.KeyInput);
|
||||
|
||||
if (keyCode == getKeySetting("keymap_fullscreen")) {
|
||||
if (event.KeyInput.PressedDown && !fullscreen_is_down) {
|
||||
IrrlichtDevice *device = RenderingEngine::get_raw_device();
|
||||
|
@ -150,8 +151,15 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
|||
}
|
||||
fullscreen_is_down = event.KeyInput.PressedDown;
|
||||
return true;
|
||||
} else if (keyCode == EscapeKey &&
|
||||
event.KeyInput.PressedDown && event.KeyInput.Shift) {
|
||||
|
||||
} else if (keyCode == getKeySetting("keymap_close_world")) {
|
||||
close_world_down = event.KeyInput.PressedDown;
|
||||
|
||||
} else if (keyCode == EscapeKey) {
|
||||
esc_down = event.KeyInput.PressedDown;
|
||||
}
|
||||
|
||||
if (esc_down && close_world_down) {
|
||||
g_gamecallback->disconnect();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,9 @@ private:
|
|||
// Intentionally not reset by clearInput/releaseAllKeys.
|
||||
bool fullscreen_is_down = false;
|
||||
|
||||
bool close_world_down = false;
|
||||
bool esc_down = false;
|
||||
|
||||
PointerType last_pointer_type = PointerType::Mouse;
|
||||
};
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ void set_default_settings()
|
|||
USEKEY2("keymap_fullscreen", "SYSTEM_SCANCODE_68", "KEY_F11");
|
||||
USEKEY2("keymap_increase_viewing_range_min", "SYSTEM_SCANCODE_46", "+");
|
||||
USEKEY2("keymap_decrease_viewing_range_min", "SYSTEM_SCANCODE_45", "-");
|
||||
settings->setDefault("keymap_close_world", "");
|
||||
USEKEY2("keymap_slot1", "SYSTEM_SCANCODE_30", "KEY_KEY_1");
|
||||
USEKEY2("keymap_slot2", "SYSTEM_SCANCODE_31", "KEY_KEY_2");
|
||||
USEKEY2("keymap_slot3", "SYSTEM_SCANCODE_32", "KEY_KEY_3");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue