mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
use critical key check for keymap_close_world in keybinding change dialog
This commit is contained in:
parent
12e83deece
commit
efabcd7377
2 changed files with 21 additions and 19 deletions
|
@ -28,8 +28,9 @@ local function get_formspec(dialogdata)
|
|||
for idx, key in ipairs(value) do
|
||||
local prefix = ""
|
||||
for _, o in ipairs(core.full_settingtypes) do
|
||||
if o.type == "key" and o.name ~= name
|
||||
and has_keybinding_conflict(core.settings:get(o.name):split("|"), key) then
|
||||
if o.type == "key" and o.name ~= name and
|
||||
is_keybinding_critical(name, o.name) and
|
||||
has_keybinding_conflict(core.settings:get(o.name):split("|"), key) then
|
||||
prefix = mt_color_orange
|
||||
if idx == selection then
|
||||
warning = core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext_ne(o.readable_name)))
|
||||
|
@ -156,3 +157,17 @@ function has_keybinding_conflict(t1, t2) -- not local as it is also used by the
|
|||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local critical_keys = {
|
||||
keymap_drop = true,
|
||||
keymap_dig = true,
|
||||
keymap_place = true,
|
||||
}
|
||||
function is_keybinding_critical(n1, n2)
|
||||
local is_current_close_world = n1 == "keymap_close_world"
|
||||
local is_other_close_world = n2 == "keymap_close_world"
|
||||
local is_current_critical = critical_keys[n1]
|
||||
local is_other_critical = critical_keys[n2]
|
||||
return (is_other_critical or is_current_critical) or
|
||||
(not is_current_close_world and not is_other_close_world)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue