This commit is contained in:
@clasher113
2024-01-21 15:42:38 +02:00
51 changed files with 1336 additions and 249 deletions
+30 -3
View File
@@ -195,13 +195,40 @@ Panel* create_worlds_panel(Engine* engine) {
if (!entry.is_directory()) {
continue;
}
auto name = entry.path().filename().u8string();
auto btn = new Button(util::str2wstr_utf8(name),
vec4(10.0f, 8.0f, 10.0f, 8.0f));
auto folder = entry.path();
auto name = folder.filename().u8string();
auto namews = util::str2wstr_utf8(name);
auto btn = std::make_shared<RichButton>(vec2(390, 46));
btn->color(vec4(1.0f, 1.0f, 1.0f, 0.1f));
btn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
auto label = std::make_shared<Label>(namews);
label->setInteractive(false);
btn->add(label, vec2(8, 8));
btn->listenAction([=](GUI*) {
open_world(name, engine);
});
auto image = std::make_shared<Image>("gui/delete_icon", vec2(32, 32));
image->color(vec4(1, 1, 1, 0.5f));
auto delbtn = std::make_shared<Button>(image, vec4(2));
delbtn->color(vec4(0.0f));
delbtn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
btn->add(delbtn, vec2(330, 3));
delbtn->listenAction([=](GUI* gui) {
guiutil::confirm(gui, langs::get(L"delete-confirm", L"world")+
L" ("+util::str2wstr_utf8(folder.u8string())+L")", [=]()
{
std::cout << "deleting " << folder.u8string() << std::endl;
fs::remove_all(folder);
menus::refresh_menus(engine, gui->getMenu());
});
});
panel->add(btn);
}
}