mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +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
|
@ -439,27 +439,14 @@ function make.key(setting)
|
||||||
return height
|
return height
|
||||||
end
|
end
|
||||||
|
|
||||||
local critical_keys = {
|
|
||||||
keymap_drop = 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
|
if o.type == "key" and o.name ~= setting.name and
|
||||||
|
is_keybinding_critical(setting.name, o.name) and
|
||||||
has_keybinding_conflict(core.settings:get(o.name):split("|"), value) then
|
has_keybinding_conflict(core.settings:get(o.name):split("|"), value) then
|
||||||
|
|
||||||
local is_current_close_world = setting.name == "keymap_close_world"
|
table.insert(fs, ("label[0,%f;%s]"):format(height + 0.3,
|
||||||
local is_other_close_world = o.name == "keymap_close_world"
|
core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext(o.readable_name)))))
|
||||||
local is_current_critical = critical_keys[setting.name]
|
height = height + 0.6
|
||||||
local is_other_critical = critical_keys[o.name]
|
|
||||||
|
|
||||||
if (is_other_critical or is_current_critical) or
|
|
||||||
(not is_current_close_world and not is_other_close_world) then
|
|
||||||
table.insert(fs, ("label[0,%f;%s]"):format(height + 0.3,
|
|
||||||
core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext(o.readable_name)))))
|
|
||||||
height = height + 0.6
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return height
|
return height
|
||||||
|
|
|
@ -28,8 +28,9 @@ local function get_formspec(dialogdata)
|
||||||
for idx, key in ipairs(value) do
|
for idx, key in ipairs(value) do
|
||||||
local prefix = ""
|
local prefix = ""
|
||||||
for _, o in ipairs(core.full_settingtypes) do
|
for _, o in ipairs(core.full_settingtypes) do
|
||||||
if o.type == "key" and o.name ~= name
|
if o.type == "key" and o.name ~= name and
|
||||||
and has_keybinding_conflict(core.settings:get(o.name):split("|"), key) then
|
is_keybinding_critical(name, o.name) and
|
||||||
|
has_keybinding_conflict(core.settings:get(o.name):split("|"), key) then
|
||||||
prefix = mt_color_orange
|
prefix = mt_color_orange
|
||||||
if idx == selection then
|
if idx == selection then
|
||||||
warning = core.colorize(mt_color_orange, fgettext([[Conflicts with "$1"]], fgettext_ne(o.readable_name)))
|
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
|
end
|
||||||
return false
|
return false
|
||||||
end
|
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