update gui.confirm

This commit is contained in:
MihailRis 2025-01-06 00:41:57 +03:00
parent 435a8299b7
commit 5a34e8d522

View File

@ -754,29 +754,25 @@ static int l_gui_escape_markup(lua::State* L) {
static int l_gui_confirm(lua::State* L) { static int l_gui_confirm(lua::State* L) {
auto question = lua::require_wstring(L, 1); auto question = lua::require_wstring(L, 1);
lua::pushvalue(L, 2); runnable onconfirm = nullptr;
auto onconfirm = lua::create_runnable(L); if (lua::gettop(L) >= 2) {
lua::pushvalue(L, 2);
onconfirm = lua::create_runnable(L);
}
runnable ondeny = nullptr; runnable ondeny = nullptr;
if (lua::gettop(L) > 2) { if (lua::gettop(L) >= 3) {
lua::pushvalue(L, 3); lua::pushvalue(L, 3);
ondeny = lua::create_runnable(L); ondeny = lua::create_runnable(L);
} }
std::wstring yestext = L""; std::wstring yestext = L"";
if (lua::gettop(L) > 3) { if (lua::gettop(L) >= 4) {
yestext = lua::require_wstring(L, 4); yestext = lua::require_wstring(L, 4);
} }
std::wstring notext = L""; std::wstring notext = L"";
if (lua::gettop(L) > 4) { if (lua::gettop(L) >= 5) {
notext = lua::require_wstring(L, 5); notext = lua::require_wstring(L, 5);
} }
guiutil::confirm( guiutil::confirm(*engine, question, onconfirm, ondeny, yestext, notext);
*engine,
question,
onconfirm,
ondeny,
yestext,
notext
);
return 0; return 0;
} }