diff --git a/res/modules/internal/gui_util.lua b/res/modules/internal/gui_util.lua index 524bd7ae..28159833 100644 --- a/res/modules/internal/gui_util.lua +++ b/res/modules/internal/gui_util.lua @@ -126,7 +126,7 @@ function gui.show_message(text, actual_callback) end gui.root.root:add(string.format([[ - + @@ -135,4 +135,30 @@ function gui.show_message(text, actual_callback) input.add_callback("key:escape", callback, gui.root[id]) end +function gui.ask(text, on_yes, on_no) + on_yes = on_yes or function() end + on_no = on_no or function() end + + local id = "dialog_"..random.uuid() + + local yes_callback = function() + gui.root[id]:destruct() + on_yes() + end + local no_callback = function() + gui.root[id]:destruct() + on_no() + end + gui.root.root:add(string.format([[ + + + + + + + + ]], id, string.escape_xml(text)), {on_yes=yes_callback, on_no=no_callback}) + input.add_callback("key:escape", no_callback, gui.root[id]) +end + return gui_util