fix gui.alert
This commit is contained in:
parent
9443892406
commit
b12982655d
@ -37,7 +37,10 @@ local function complete_app_lib(app)
|
||||
app.tick = coroutine.yield
|
||||
app.get_version = core.get_version
|
||||
app.get_setting_info = core.get_setting_info
|
||||
app.load_content = core.load_content
|
||||
app.load_content = function()
|
||||
core.load_content()
|
||||
app.tick()
|
||||
end
|
||||
app.reset_content = core.reset_content
|
||||
app.is_content_loaded = core.is_content_loaded
|
||||
|
||||
@ -416,7 +419,18 @@ end
|
||||
|
||||
function start_coroutine(chunk, name)
|
||||
local co = coroutine.create(function()
|
||||
local status, error = xpcall(chunk, __vc__error)
|
||||
local status, error = xpcall(chunk, function(...)
|
||||
gui.alert(debug.traceback(), function()
|
||||
if world.is_open() then
|
||||
__vc_app.close_world()
|
||||
else
|
||||
__vc_app.reset_content()
|
||||
menu:reset()
|
||||
menu.page = "main"
|
||||
end
|
||||
end)
|
||||
return ...
|
||||
end)
|
||||
if not status then
|
||||
debug.error(error)
|
||||
end
|
||||
|
||||
@ -34,13 +34,14 @@ void guiutil::alert(
|
||||
auto panel = std::make_shared<Panel>(glm::vec2(500, 300), glm::vec4(4.0f), 4.0f);
|
||||
panel->setColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
||||
|
||||
auto menu = engine.getGUI()->getMenu();
|
||||
runnable on_hidden_final = [on_hidden, menu, &engine]() {
|
||||
menu->removePage("<alert>");
|
||||
auto menuPtr = engine.getGUI()->getMenu();
|
||||
auto& menu = *menuPtr;
|
||||
runnable on_hidden_final = [on_hidden, &menu, &engine]() {
|
||||
menu.removePage("<alert>");
|
||||
if (on_hidden) {
|
||||
on_hidden();
|
||||
} else {
|
||||
menu->back();
|
||||
menu.back();
|
||||
}
|
||||
};
|
||||
|
||||
@ -50,21 +51,21 @@ void guiutil::alert(
|
||||
panel->add(label);
|
||||
panel->add(std::make_shared<Button>(
|
||||
langs::get(L"Ok"), glm::vec4(10.f),
|
||||
[=](GUI*) {
|
||||
[on_hidden_final](GUI*) {
|
||||
on_hidden_final();
|
||||
}
|
||||
));
|
||||
panel->refresh();
|
||||
panel->keepAlive(Events::keyCallbacks[keycode::ENTER].add([=](){
|
||||
panel->keepAlive(Events::keyCallbacks[keycode::ENTER].add([on_hidden_final](){
|
||||
on_hidden_final();
|
||||
return true;
|
||||
}));
|
||||
panel->keepAlive(Events::keyCallbacks[keycode::ESCAPE].add([=](){
|
||||
panel->keepAlive(Events::keyCallbacks[keycode::ESCAPE].add([on_hidden_final](){
|
||||
on_hidden_final();
|
||||
return true;
|
||||
}));
|
||||
menu->addPage("<alert>", panel, true);
|
||||
menu->setPage("<alert>");
|
||||
menu.addPage("<alert>", panel, true);
|
||||
menu.setPage("<alert>");
|
||||
}
|
||||
|
||||
void guiutil::confirm(
|
||||
|
||||
@ -22,6 +22,9 @@ namespace lua {
|
||||
|
||||
inline void pop(lua::State* L, int n = 1) {
|
||||
#ifndef NDEBUG
|
||||
if (n < 0) {
|
||||
abort();
|
||||
}
|
||||
if (lua_gettop(L) < n) {
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -86,7 +86,10 @@ public:
|
||||
}
|
||||
|
||||
void update() override {
|
||||
if (lua::getglobal(L, "__vc_resume_coroutine")) {
|
||||
if (id == 0) {
|
||||
return;
|
||||
}
|
||||
if (lua::requireglobal(L, "__vc_resume_coroutine")) {
|
||||
lua::pushinteger(L, id);
|
||||
if (lua::call(L, 1)) {
|
||||
alive = lua::toboolean(L, -1);
|
||||
@ -102,10 +105,10 @@ public:
|
||||
}
|
||||
|
||||
void terminate() override {
|
||||
if (lua::getglobal(L, "__vc_stop_coroutine")) {
|
||||
lua::pushinteger(L, id);
|
||||
lua::pop(L, lua::call(L, 1));
|
||||
}
|
||||
lua::requireglobal(L, "__vc_stop_coroutine");
|
||||
lua::pushinteger(L, id);
|
||||
lua::pop(L, lua::call(L, 1));
|
||||
id = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user