world convert progress info
This commit is contained in:
@@ -84,6 +84,12 @@ void GUI::actMouse(float delta) {
|
||||
* @param delta delta time
|
||||
*/
|
||||
void GUI::act(float delta) {
|
||||
while (!postRunnables.empty()) {
|
||||
runnable callback = postRunnables.back();
|
||||
postRunnables.pop();
|
||||
callback();
|
||||
}
|
||||
|
||||
container->setSize(glm::vec2(Window::width, Window::height));
|
||||
container->act(delta);
|
||||
auto prevfocus = focus;
|
||||
@@ -176,3 +182,7 @@ void GUI::setFocus(std::shared_ptr<UINode> node) {
|
||||
std::shared_ptr<Container> GUI::getContainer() const {
|
||||
return container;
|
||||
}
|
||||
|
||||
void GUI::postRunnable(runnable callback) {
|
||||
postRunnables.push(callback);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef FRONTEND_GUI_GUI_H_
|
||||
#define FRONTEND_GUI_GUI_H_
|
||||
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -8,6 +9,8 @@
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "../../delegates.h"
|
||||
|
||||
class GfxContext;
|
||||
class Assets;
|
||||
class Camera;
|
||||
@@ -58,6 +61,7 @@ namespace gui {
|
||||
|
||||
std::unique_ptr<Camera> uicamera;
|
||||
std::shared_ptr<PagesControl> menu;
|
||||
std::queue<runnable> postRunnables;
|
||||
void actMouse(float delta);
|
||||
public:
|
||||
GUI();
|
||||
@@ -113,6 +117,8 @@ namespace gui {
|
||||
|
||||
/** Get the main container */
|
||||
std::shared_ptr<Container> getContainer() const;
|
||||
|
||||
void postRunnable(runnable callback);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ std::shared_ptr<UINode> Container::getAt(glm::vec2 pos, std::shared_ptr<UINode>
|
||||
}
|
||||
|
||||
void Container::act(float delta) {
|
||||
for (auto node : nodes) {
|
||||
if (node->isVisible()) {
|
||||
node->act(delta);
|
||||
}
|
||||
}
|
||||
for (IntervalEvent& event : intervalEvents) {
|
||||
event.timer += delta;
|
||||
if (event.timer > event.interval) {
|
||||
@@ -50,12 +55,6 @@ void Container::act(float delta) {
|
||||
return event.repeat == 0;
|
||||
}
|
||||
), intervalEvents.end());
|
||||
|
||||
for (auto node : nodes) {
|
||||
if (node->isVisible()) {
|
||||
node->act(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Container::scrolled(int value) {
|
||||
@@ -109,12 +108,6 @@ void Container::drawBackground(const GfxContext* pctx, Assets* assets) {
|
||||
batch->rect(coord.x, coord.y, size.x, size.y);
|
||||
}
|
||||
|
||||
void Container::addBack(std::shared_ptr<UINode> node) {
|
||||
nodes.insert(nodes.begin(), node);
|
||||
node->setParent(this);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Container::add(std::shared_ptr<UINode> node) {
|
||||
nodes.push_back(node);
|
||||
node->setParent(this);
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace gui {
|
||||
virtual void drawBackground(const GfxContext* pctx, Assets* assets);
|
||||
virtual void draw(const GfxContext* pctx, Assets* assets) override;
|
||||
virtual std::shared_ptr<UINode> getAt(glm::vec2 pos, std::shared_ptr<UINode> self) override;
|
||||
virtual void addBack(std::shared_ptr<UINode> node);
|
||||
virtual void add(std::shared_ptr<UINode> node);
|
||||
virtual void add(std::shared_ptr<UINode> node, glm::vec2 coord);
|
||||
virtual void remove(std::shared_ptr<UINode> node);
|
||||
|
||||
Reference in New Issue
Block a user