move menu pages loader to Lua & add gui.load_document, file.ext(), file.prefix() & add core:gui_util module
This commit is contained in:
@@ -79,10 +79,14 @@ void Menu::back() {
|
||||
setPage(page, false);
|
||||
}
|
||||
|
||||
void Menu::setPageLoader(page_loader_func loader) {
|
||||
void Menu::setPageLoader(PageLoaderFunc loader) {
|
||||
pagesLoader = std::move(loader);
|
||||
}
|
||||
|
||||
PageLoaderFunc Menu::getPageLoader() {
|
||||
return pagesLoader;
|
||||
}
|
||||
|
||||
Page& Menu::getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace gui {
|
||||
bool temporal = false;
|
||||
};
|
||||
|
||||
using page_loader_func = std::function<std::shared_ptr<UINode>(const std::string& name)>;
|
||||
using PageLoaderFunc = std::function<std::shared_ptr<UINode>(const std::string&)>;
|
||||
|
||||
class Menu : public Container {
|
||||
protected:
|
||||
@@ -19,7 +19,7 @@ namespace gui {
|
||||
std::stack<Page> pageStack;
|
||||
Page current;
|
||||
std::unordered_map<std::string, supplier<std::shared_ptr<UINode>>> pageSuppliers;
|
||||
page_loader_func pagesLoader = nullptr;
|
||||
PageLoaderFunc pagesLoader = nullptr;
|
||||
public:
|
||||
Menu();
|
||||
|
||||
@@ -49,7 +49,9 @@ namespace gui {
|
||||
);
|
||||
|
||||
/// @brief Page loader is called if accessed page is not found
|
||||
void setPageLoader(page_loader_func loader);
|
||||
void setPageLoader(PageLoaderFunc loader);
|
||||
|
||||
PageLoaderFunc getPageLoader();
|
||||
|
||||
/// @brief Set page to previous saved in history
|
||||
void back();
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "elements/TrackBar.hpp"
|
||||
#include "elements/InputBindBox.hpp"
|
||||
#include "elements/InventoryView.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
#include "frontend/menu.hpp"
|
||||
#include "frontend/locale.hpp"
|
||||
@@ -616,8 +618,8 @@ static std::shared_ptr<UINode> readInventory(UiXmlReader& reader, const xml::xml
|
||||
|
||||
static std::shared_ptr<UINode> readPageBox(UiXmlReader& reader, const xml::xmlelement& element) {
|
||||
auto menu = std::make_shared<Menu>();
|
||||
// fixme
|
||||
menu->setPageLoader(menus::create_page_loader(*scripting::engine));
|
||||
// FIXME
|
||||
menu->setPageLoader(scripting::engine->getGUI()->getMenu()->getPageLoader());
|
||||
_readContainer(reader, element, *menu);
|
||||
|
||||
return menu;
|
||||
|
||||
Reference in New Issue
Block a user