Skip to content

Commit

Permalink
Fix ESC in error dialog from closing Minetest (#10838)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamanq committed Jan 23, 2021
1 parent 009e39e commit 6417f4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions builtin/fstk/ui.lua
Expand Up @@ -18,6 +18,8 @@
ui = {}
ui.childlist = {}
ui.default = nil
-- Whether fstk is currently showing its own formspec instead of active ui elements.
ui.overridden = false

--------------------------------------------------------------------------------
function ui.add(child)
Expand Down Expand Up @@ -55,6 +57,7 @@ end
--------------------------------------------------------------------------------

function ui.update()
ui.overridden = false
local formspec = {}

-- handle errors
Expand All @@ -71,6 +74,7 @@ function ui.update()
"button[2,6.6;4,1;btn_reconnect_yes;" .. fgettext("Reconnect") .. "]",
"button[8,6.6;4,1;btn_reconnect_no;" .. fgettext("Main menu") .. "]"
}
ui.overridden = true
elseif gamedata ~= nil and gamedata.errormessage ~= nil then
local error_message = core.formspec_escape(gamedata.errormessage)

Expand All @@ -89,6 +93,7 @@ function ui.update()
error_title, error_message),
"button[5,6.6;4,1;btn_error_confirm;" .. fgettext("OK") .. "]"
}
ui.overridden = true
else
local active_toplevel_ui_elements = 0
for key,value in pairs(ui.childlist) do
Expand Down Expand Up @@ -185,6 +190,16 @@ end

--------------------------------------------------------------------------------
core.event_handler = function(event)
-- Handle error messages
if ui.overridden then
if event == "MenuQuit" then
gamedata.errormessage = nil
gamedata.reconnect_requested = false
ui.update()
end
return
end

if ui.handle_events(event) then
ui.update()
return
Expand Down

0 comments on commit 6417f4d

Please sign in to comment.