scripting: PagesControl
This commit is contained in:
@@ -22,6 +22,7 @@ GUI::GUI() {
|
||||
uicamera->flipped = true;
|
||||
|
||||
menu = std::make_shared<PagesControl>();
|
||||
menu->setId("menu");
|
||||
container->add(menu);
|
||||
container->setScrollable(false);
|
||||
}
|
||||
|
||||
@@ -285,6 +285,10 @@ Page& PagesControl::getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
const std::string& PagesControl::getCurrentName() const {
|
||||
return curname;
|
||||
}
|
||||
|
||||
void PagesControl::clearHistory() {
|
||||
pageStack = std::stack<std::string>();
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace gui {
|
||||
void reset();
|
||||
|
||||
Page& getCurrent();
|
||||
const std::string& getCurrentName() const;
|
||||
};
|
||||
}
|
||||
#endif // GRAPHICS_UI_ELEMENTS_CONTAINERS_H_
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "../../logic/scripting/scripting.h"
|
||||
#include "../../frontend/locale/langs.h"
|
||||
#include "../../util/stringutil.h"
|
||||
#include "../../delegates.h"
|
||||
|
||||
using namespace gui;
|
||||
@@ -25,13 +26,11 @@ std::shared_ptr<Button> guiutil::gotoButton(
|
||||
std::shared_ptr<PagesControl> menu
|
||||
) {
|
||||
text = langs::get(text, L"menu");
|
||||
return std::make_shared<Button>(text, glm::vec4(10.f), [=](GUI* gui) {
|
||||
if (menu->has(page)) {
|
||||
menu->setPage(page);
|
||||
} else {
|
||||
menu->setPage("404");
|
||||
}
|
||||
});
|
||||
return std::dynamic_pointer_cast<Button>(create(
|
||||
"<button onclick='menu.page=\""+page+"\"' padding='10,10,10,10'>"+
|
||||
util::wstr2str_utf8(text)+
|
||||
"</button>"
|
||||
));
|
||||
}
|
||||
|
||||
std::shared_ptr<gui::UINode> guiutil::create(const std::string& source) {
|
||||
|
||||
Reference in New Issue
Block a user