add in-game chat & update gui post-runnables timing & fix panel elements removal

This commit is contained in:
MihailRis
2025-01-18 07:17:52 +03:00
parent 731c72da7c
commit c6951e0965
11 changed files with 100 additions and 7 deletions
+8 -6
View File
@@ -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());
+2
View File
@@ -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);
+5
View File
@@ -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) {
+1
View File
@@ -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;