Skip to content

Commit 6417f4d

Browse files
authored
Fix ESC in error dialog from closing Minetest (#10838)
1 parent 009e39e commit 6417f4d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

builtin/fstk/ui.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
ui = {}
1919
ui.childlist = {}
2020
ui.default = nil
21+
-- Whether fstk is currently showing its own formspec instead of active ui elements.
22+
ui.overridden = false
2123

2224
--------------------------------------------------------------------------------
2325
function ui.add(child)
@@ -55,6 +57,7 @@ end
5557
--------------------------------------------------------------------------------
5658

5759
function ui.update()
60+
ui.overridden = false
5861
local formspec = {}
5962

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

@@ -89,6 +93,7 @@ function ui.update()
8993
error_title, error_message),
9094
"button[5,6.6;4,1;btn_error_confirm;" .. fgettext("OK") .. "]"
9195
}
96+
ui.overridden = true
9297
else
9398
local active_toplevel_ui_elements = 0
9499
for key,value in pairs(ui.childlist) do
@@ -185,6 +190,16 @@ end
185190

186191
--------------------------------------------------------------------------------
187192
core.event_handler = function(event)
193+
-- Handle error messages
194+
if ui.overridden then
195+
if event == "MenuQuit" then
196+
gamedata.errormessage = nil
197+
gamedata.reconnect_requested = false
198+
ui.update()
199+
end
200+
return
201+
end
202+
188203
if ui.handle_events(event) then
189204
ui.update()
190205
return

0 commit comments

Comments
 (0)