diff --git a/res/layouts/ingame_chat.xml.lua b/res/layouts/ingame_chat.xml.lua index ec4e12b0..dce62988 100644 --- a/res/layouts/ingame_chat.xml.lua +++ b/res/layouts/ingame_chat.xml.lua @@ -7,18 +7,11 @@ local initialized = false local max_lines = 15 local animation_fps = 30 -local function remove_line(line) - document[line[1]]:destruct() - time.post_runnable(function() - if world.is_open() then document.root:reposition() end - end) -end - local function update_line(line, uptime) local diff = uptime - line[2] if diff > timeout then - remove_line(line) - table.insert(dead_lines, i) + document[line[1]]:destruct() + table.insert(dead_lines, table.index(lines, line)) elseif diff > timeout-fadeout then local opacity = (timeout - diff) / fadeout document[line[1]].color = {0, 0, 0, opacity * 80} @@ -27,16 +20,16 @@ local function update_line(line, uptime) end events.on("core:chat", function(message) + while #lines >= max_lines do + document[lines[1][1]]:destruct() + table.remove(lines, 1) + end local current_time = time.uptime() local id = 'l'..tostring(nextid) document.root:add(gui.template("chat_line", {id=id})) document.root:reposition() document[id.."L"].text = message nextid = nextid + 1 - if #lines == max_lines then - remove_line(lines[1]) - table.remove(lines, 1) - end table.insert(lines, {id, current_time}) end) diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index ce29e8c1..c9de5a64 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -199,6 +199,7 @@ void Engine::updateFrontend() { audio::update(delta); gui->act(delta, Viewport(Window::width, Window::height)); screen->update(delta); + gui->postAct(); } void Engine::nextFrame() { @@ -217,7 +218,6 @@ void Engine::renderFrame() { Viewport viewport(Window::width, Window::height); DrawContext ctx(nullptr, viewport, nullptr); gui->draw(ctx, *assets); - gui->postAct(); } void Engine::saveSettings() { diff --git a/src/graphics/ui/elements/Panel.cpp b/src/graphics/ui/elements/Panel.cpp index d90b8830..d76866f0 100644 --- a/src/graphics/ui/elements/Panel.cpp +++ b/src/graphics/ui/elements/Panel.cpp @@ -53,6 +53,7 @@ void Panel::cropToContent() { void Panel::fullRefresh() { refresh(); cropToContent(); + reposition(); Container::fullRefresh(); }