1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00
This commit is contained in:
DragonWrangler1 2025-06-26 19:25:47 -05:00 committed by GitHub
commit b9ab192600
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 54 additions and 8 deletions

View file

@ -438,13 +438,43 @@ function make.key(setting)
if value == "" then if value == "" then
return height return height
end end
local critical_keys = {
keymap_chat = true,
keymap_drop = true,
keymap_inventory = true,
keymap_cmd = true,
keymap_cmd_local = true,
keymap_dig = true,
keymap_place = true,
}
for _, o in ipairs(core.full_settingtypes) do for _, o in ipairs(core.full_settingtypes) do
if o.type == "key" and o.name ~= setting.name and core.are_keycodes_equal(core.settings:get(o.name), value) then if o.type == "key" and o.name ~= setting.name and
core.are_keycodes_equal(core.settings:get(o.name), value) then
local is_current_close_world = setting.name == "keymap_close_world"
local is_other_close_world = o.name == "keymap_close_world"
-- Current means current key you've messed with, other means the other key it conflicts with.
local is_current_critical = critical_keys[setting.name]
local is_other_critical = critical_keys[o.name]
local show_warning_current = false
if (is_current_close_world and is_other_critical)
or (is_other_close_world and is_current_critical)
or (not is_current_close_world and not is_other_close_world) then
show_warning_current = true
end
if show_warning_current then
table.insert(fs, ("label[0,%f;%s]"):format(height + 0.3, table.insert(fs, ("label[0,%f;%s]"):format(height + 0.3,
core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext(o.readable_name))))) core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext(o.readable_name)))))
height = height + 0.6 height = height + 0.6
end end
end end
end
return height return height
end end
return { return {

View file

@ -337,6 +337,10 @@ keymap_slot31 (Hotbar slot 31) key
keymap_slot32 (Hotbar slot 32) key keymap_slot32 (Hotbar slot 32) key
# Modifier key bind for closing your world.
# Requires ESC + the selected key to work.
keymap_close_world (Return to Main Menu) key SYSTEM_SCANCODE_225
[*Touchscreen] [*Touchscreen]
# Enables the touchscreen controls, allowing you to play the game with a touchscreen. # Enables the touchscreen controls, allowing you to play the game with a touchscreen.

View file

@ -137,6 +137,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
// This is separate from other keyboard handling so that it also works in menus. // This is separate from other keyboard handling so that it also works in menus.
if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.EventType == EET_KEY_INPUT_EVENT) {
KeyPress keyCode(event.KeyInput); KeyPress keyCode(event.KeyInput);
if (keyCode == getKeySetting("keymap_fullscreen")) { if (keyCode == getKeySetting("keymap_fullscreen")) {
if (event.KeyInput.PressedDown && !fullscreen_is_down) { if (event.KeyInput.PressedDown && !fullscreen_is_down) {
IrrlichtDevice *device = RenderingEngine::get_raw_device(); IrrlichtDevice *device = RenderingEngine::get_raw_device();
@ -150,8 +151,15 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
} }
fullscreen_is_down = event.KeyInput.PressedDown; fullscreen_is_down = event.KeyInput.PressedDown;
return true; 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(); g_gamecallback->disconnect();
return true; return true;
} }

View file

@ -128,6 +128,9 @@ private:
// Intentionally not reset by clearInput/releaseAllKeys. // Intentionally not reset by clearInput/releaseAllKeys.
bool fullscreen_is_down = false; bool fullscreen_is_down = false;
bool close_world_down = false;
bool esc_down = false;
PointerType last_pointer_type = PointerType::Mouse; PointerType last_pointer_type = PointerType::Mouse;
}; };

View file

@ -219,6 +219,7 @@ void set_default_settings()
settings->setDefault("keymap_slot30", ""); settings->setDefault("keymap_slot30", "");
settings->setDefault("keymap_slot31", ""); settings->setDefault("keymap_slot31", "");
settings->setDefault("keymap_slot32", ""); settings->setDefault("keymap_slot32", "");
USEKEY2("keymap_close_world", "SYSTEM_SCANCODE_225", "KEY_LSHIFT");
#ifndef NDEBUG #ifndef NDEBUG
// Default keybinds for quicktune in debug builds // Default keybinds for quicktune in debug builds