add in-game chat & update gui post-runnables timing & fix panel elements removal
This commit is contained in:
@@ -217,6 +217,7 @@ void Engine::renderFrame() {
|
||||
Viewport viewport(Window::width, Window::height);
|
||||
DrawContext ctx(nullptr, viewport, nullptr);
|
||||
gui->draw(ctx, *assets);
|
||||
gui->postAct();
|
||||
}
|
||||
|
||||
void Engine::saveSettings() {
|
||||
|
||||
@@ -178,12 +178,6 @@ void GUI::actFocused() {
|
||||
}
|
||||
|
||||
void GUI::act(float delta, const Viewport& vp) {
|
||||
while (!postRunnables.empty()) {
|
||||
runnable callback = postRunnables.back();
|
||||
postRunnables.pop();
|
||||
callback();
|
||||
}
|
||||
|
||||
container->setSize(vp.size());
|
||||
container->act(delta);
|
||||
auto prevfocus = focus;
|
||||
@@ -206,6 +200,14 @@ void GUI::act(float delta, const Viewport& vp) {
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::postAct() {
|
||||
while (!postRunnables.empty()) {
|
||||
runnable callback = postRunnables.back();
|
||||
postRunnables.pop();
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::draw(const DrawContext& pctx, const Assets& assets) {
|
||||
auto ctx = pctx.sub(batch2D.get());
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ namespace gui {
|
||||
/// @param assets active assets storage
|
||||
void draw(const DrawContext& pctx, const Assets& assets);
|
||||
|
||||
void postAct();
|
||||
|
||||
/// @brief Add element to the main container
|
||||
/// @param node UI element
|
||||
void add(std::shared_ptr<UINode> node);
|
||||
|
||||
@@ -62,6 +62,11 @@ void Panel::add(const std::shared_ptr<UINode> &node) {
|
||||
fullRefresh();
|
||||
}
|
||||
|
||||
void Panel::remove(const std::shared_ptr<UINode> &node) {
|
||||
Container::remove(node);
|
||||
fullRefresh();
|
||||
}
|
||||
|
||||
void Panel::refresh() {
|
||||
UINode::refresh();
|
||||
std::stable_sort(nodes.begin(), nodes.end(), [](auto a, auto b) {
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace gui {
|
||||
Orientation getOrientation() const;
|
||||
|
||||
virtual void add(const std::shared_ptr<UINode>& node) override;
|
||||
virtual void remove(const std::shared_ptr<UINode>& node) override;
|
||||
|
||||
virtual void refresh() override;
|
||||
virtual void fullRefresh() override;
|
||||
|
||||
Reference in New Issue
Block a user