local ui = require("ui") local L = require("lang").get local dialog = {} function dialog.show(dg, ...) dialog.active = dg if dg.show then dg:show(...) end end function dialog.refresh() if dialog.active then dialog.show(dialog.active) end end local function dialog_loading(game) return ui.popup_box(L("wait.generic"), L("dialog.cancel"), function() game.quit() end, function(self, msg) if msg then self.title.text:set(L("wait."..msg)) end end ) end local function dialog_error(game) local back_menu return ui.popup_box(L("error.generic"), L("dialog.back"), function() dialog.show(back_menu or game.main_menu) end, function(self, msg, back) if msg then self.title.text:set(L("error."..msg)) back_menu = back end end ) end function dialog.init(game) dialog.loading = dialog_loading(game) dialog.error = dialog_error(game) end return dialog