fixes
This commit is contained in:
parent
e5a3178969
commit
dbf366eca3
@ -125,6 +125,7 @@ Engine::Engine(CoreParameters coreParameters)
|
||||
));
|
||||
}
|
||||
scripting::initialize(this);
|
||||
gui->setPageLoader(scripting::create_page_loader());
|
||||
keepAlive(settings.ui.language.observe([this](auto lang) {
|
||||
setLanguage(lang);
|
||||
}, true));
|
||||
@ -441,9 +442,6 @@ void Engine::setScreen(std::shared_ptr<Screen> screen) {
|
||||
|
||||
void Engine::setLanguage(std::string locale) {
|
||||
langs::setup(paths.getResourcesFolder(), std::move(locale), contentPacks);
|
||||
if (gui) {
|
||||
gui->getMenu()->setPageLoader(scripting::create_page_loader());
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::onWorldOpen(std::unique_ptr<Level> level) {
|
||||
|
||||
@ -46,6 +46,15 @@ GUI::GUI() : batch2D(std::make_unique<Batch2D>(1024)) {
|
||||
|
||||
GUI::~GUI() = default;
|
||||
|
||||
void GUI::setPageLoader(PageLoaderFunc pageLoader) {
|
||||
this->pagesLoader = std::move(pageLoader);
|
||||
menu->setPageLoader(this->pagesLoader);
|
||||
}
|
||||
|
||||
PageLoaderFunc GUI::getPagesLoader() {
|
||||
return pagesLoader;
|
||||
}
|
||||
|
||||
std::shared_ptr<Menu> GUI::getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
@ -51,6 +51,8 @@ namespace gui {
|
||||
class Container;
|
||||
class Menu;
|
||||
|
||||
using PageLoaderFunc = std::function<std::shared_ptr<UINode>(const std::string&)>;
|
||||
|
||||
/// @brief The main UI controller
|
||||
class GUI {
|
||||
std::unique_ptr<Batch2D> batch2D;
|
||||
@ -65,6 +67,8 @@ namespace gui {
|
||||
std::shared_ptr<Menu> menu;
|
||||
std::queue<runnable> postRunnables;
|
||||
|
||||
PageLoaderFunc pagesLoader;
|
||||
|
||||
float tooltipTimer = 0.0f;
|
||||
float doubleClickTimer = 0.0f;
|
||||
float doubleClickDelay = 0.5f;
|
||||
@ -78,6 +82,10 @@ namespace gui {
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
void setPageLoader(PageLoaderFunc pageLoader);
|
||||
|
||||
PageLoaderFunc getPagesLoader();
|
||||
|
||||
/// @brief Get the main menu (Menu) node
|
||||
std::shared_ptr<Menu> getMenu();
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ void guiutil::alert(
|
||||
const std::wstring& text,
|
||||
const runnable& on_hidden
|
||||
) {
|
||||
auto panel = std::make_shared<Panel>(glm::vec2(500, 300), glm::vec4(8.0f), 8.0f);
|
||||
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();
|
||||
@ -46,7 +46,7 @@ void guiutil::alert(
|
||||
|
||||
auto label = std::make_shared<Label>(text);
|
||||
label->setMultiline(true);
|
||||
label->setSize(glm::vec2(1, 90));
|
||||
label->setSize(glm::vec2(1, 24));
|
||||
panel->add(label);
|
||||
panel->add(std::make_shared<Button>(
|
||||
langs::get(L"Ok"), glm::vec4(10.f),
|
||||
|
||||
@ -302,9 +302,9 @@ void scripting::on_world_quit() {
|
||||
|
||||
void scripting::cleanup() {
|
||||
auto L = lua::get_main_state();
|
||||
lua::getglobal(L, "pack");
|
||||
lua::requireglobal(L, "pack");
|
||||
for (auto& pack : scripting::engine->getAllContentPacks()) {
|
||||
lua::getfield(L, "unload");
|
||||
lua::requirefield(L, "unload");
|
||||
lua::pushstring(L, pack.id);
|
||||
lua::call_nothrow(L, 1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user