This commit is contained in:
MihailRis
2024-12-30 17:25:51 +03:00
parent 19bef1ae76
commit 10f0bd0290
5 changed files with 26 additions and 34 deletions
+6 -6
View File
@@ -33,7 +33,7 @@ EngineController::EngineController(Engine& engine) : engine(engine) {
void EngineController::deleteWorld(const std::string& name) {
fs::path folder = engine.getPaths().getWorldFolderByName(name);
guiutil::confirm(
engine.getGUI(),
engine.getGUI()->getMenu(),
langs::get(L"delete-confirm", L"world") + L" (" +
util::str2wstr_utf8(folder.u8string()) + L")",
[=]() {
@@ -100,8 +100,8 @@ static void show_convert_request(
for (const auto& line : report->getDataLoss()) {
text += util::str2wstr_utf8(line) + L"\n";
}
guiutil::confirmWithMemo(
engine.getGUI(),
guiutil::confirm_with_memo(
engine.getGUI()->getMenu(),
langs::get(message),
text,
on_confirm,
@@ -111,7 +111,7 @@ static void show_convert_request(
return;
}
guiutil::confirm(
engine.getGUI(),
engine.getGUI()->getMenu(),
langs::get(message),
on_confirm,
L"",
@@ -156,7 +156,7 @@ static void load_world(
engine.onWorldOpen(std::move(level));
} catch (const world_load_error& error) {
guiutil::alert(
engine.getGUI(),
engine.getGUI()->getMenu(),
langs::get(L"Error") + L": " + util::str2wstr_utf8(error.what())
);
return;
@@ -326,7 +326,7 @@ void EngineController::reconfigPacks(
if (hasIndices) {
guiutil::confirm(
engine.getGUI(),
engine.getGUI()->getMenu(),
langs::get(L"remove-confirm", L"pack") + L" (" +
util::str2wstr_utf8(ss.str()) + L")",
[=]() { removeFunc(); }
+4 -13
View File
@@ -100,32 +100,23 @@ static int l_delete_world(lua::State* L) {
/// @param remPacks An array of packs to remove
static int l_reconfig_packs(lua::State* L) {
if (!lua::istable(L, 1)) {
throw std::runtime_error("strings array expected as the first argument"
);
throw std::runtime_error("strings array expected as the first argument");
}
if (!lua::istable(L, 2)) {
throw std::runtime_error("strings array expected as the second argument"
);
throw std::runtime_error("strings array expected as the second argument");
}
std::vector<std::string> addPacks;
if (!lua::istable(L, 1)) {
throw std::runtime_error("an array expected as argument 1");
}
int addLen = lua::objlen(L, 1);
for (int i = 0; i < addLen; i++) {
lua::rawgeti(L, i + 1, 1);
addPacks.emplace_back(lua::tostring(L, -1));
addPacks.emplace_back(lua::require_lstring(L, -1));
lua::pop(L);
}
std::vector<std::string> remPacks;
if (!lua::istable(L, 2)) {
throw std::runtime_error("an array expected as argument 2");
}
int remLen = lua::objlen(L, 2);
for (int i = 0; i < remLen; i++) {
lua::rawgeti(L, i + 1, 2);
remPacks.emplace_back(lua::tostring(L, -1));
remPacks.emplace_back(lua::require_lstring(L, -1));
lua::pop(L);
}
auto engineController = engine->getController();