Menu-related panels creation moved to frontend/menu module
This commit is contained in:
@@ -22,6 +22,9 @@ GUI::GUI() {
|
||||
uicamera = new Camera(vec3(), Window::height);
|
||||
uicamera->perspective = false;
|
||||
uicamera->flipped = true;
|
||||
|
||||
menu = new PagesControl();
|
||||
container->add(menu);
|
||||
}
|
||||
|
||||
GUI::~GUI() {
|
||||
@@ -29,6 +32,10 @@ GUI::~GUI() {
|
||||
delete container;
|
||||
}
|
||||
|
||||
PagesControl* GUI::getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
void GUI::act(float delta) {
|
||||
container->size(vec2(Window::width, Window::height));
|
||||
container->act(delta);
|
||||
@@ -94,6 +101,7 @@ void GUI::act(float delta) {
|
||||
}
|
||||
|
||||
void GUI::draw(Batch2D* batch, Assets* assets) {
|
||||
menu->setCoord((Window::size() - menu->size()) / 2.0f);
|
||||
uicamera->fov = Window::height;
|
||||
|
||||
Shader* uishader = assets->getShader("ui");
|
||||
|
||||
@@ -46,6 +46,7 @@ class Camera;
|
||||
namespace gui {
|
||||
class UINode;
|
||||
class Container;
|
||||
class PagesControl;
|
||||
|
||||
class GUI {
|
||||
Container* container;
|
||||
@@ -55,10 +56,13 @@ namespace gui {
|
||||
std::unordered_map<std::string, std::shared_ptr<UINode>> storage;
|
||||
|
||||
Camera* uicamera;
|
||||
PagesControl* menu;
|
||||
public:
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
PagesControl* getMenu();
|
||||
|
||||
std::shared_ptr<UINode> getFocused() const;
|
||||
bool isFocusCaught() const;
|
||||
|
||||
|
||||
@@ -183,10 +183,18 @@ void Panel::lock(){
|
||||
PagesControl::PagesControl() : Container(vec2(), vec2(1)){
|
||||
}
|
||||
|
||||
bool PagesControl::has(std::string name) {
|
||||
return pages.find(name) != pages.end();
|
||||
}
|
||||
|
||||
void PagesControl::add(std::string name, std::shared_ptr<UINode> panel) {
|
||||
pages[name] = Page{panel};
|
||||
}
|
||||
|
||||
void PagesControl::add(std::string name, UINode* panel) {
|
||||
add(name, shared_ptr<UINode>(panel));
|
||||
}
|
||||
|
||||
void PagesControl::set(std::string name, bool history) {
|
||||
auto found = pages.find(name);
|
||||
if (found == pages.end()) {
|
||||
|
||||
@@ -61,6 +61,10 @@ namespace gui {
|
||||
|
||||
struct Page {
|
||||
std::shared_ptr<UINode> panel = nullptr;
|
||||
|
||||
~Page() {
|
||||
panel = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
class PagesControl : public Container {
|
||||
@@ -72,8 +76,10 @@ namespace gui {
|
||||
public:
|
||||
PagesControl();
|
||||
|
||||
bool has(std::string name);
|
||||
void set(std::string name, bool history=true);
|
||||
void add(std::string name, std::shared_ptr<UINode> panel);
|
||||
void add(std::string name, UINode* panel);
|
||||
void back();
|
||||
void clearHistory();
|
||||
void reset();
|
||||
|
||||
Reference in New Issue
Block a user