diff --git a/data/gui/window/loadscreen.cfg b/data/gui/window/loadscreen.cfg index 24405607ed4f..cc32b3b10d98 100644 --- a/data/gui/window/loadscreen.cfg +++ b/data/gui/window/loadscreen.cfg @@ -78,13 +78,14 @@ [image] definition = "logo" label = "misc/logo-bg.png" + #label = "wesnoth-logo-256.png" [/image] [/column] [/row] - {GUI_FILLER_ROW HEIGHT=30} + {GUI_FILLER_ROW HEIGHT=25} [row] grow_factor = 0 @@ -114,15 +115,44 @@ grow_factor = 1 border = "all" border_size = 5 - horizontal_grow = true + horizontal_alignment = "center" vertical_alignment = "center" - [label] - text_alignment = "center" - definition = "default_large" - id = "test_animation" - label = " " - [/label] + [drawing] + definition = "default" + id = "animation" + + width = 250 + height = 30 + + #{_WIDGET_DEBUG_BORDER} + + [draw] + + [text] + # + # Uses a bezier in-out easing to calculate the position of the dot each frame. + # + # First, it gets a normalized [0, 1] value based on the value of `tick` in the range [0, steps], then uses + # this value multiplied by the width of the drawing canvas (sans the width of the text, since there still + # needs to be enough horizontal space to render the dot on the last step of the loop) to get this frame's + # x-coordinate. Note that `steps` *must* be a decimal or the formula won't work. + # + # For the record, the original linear formula I came up with was: + # "(floor(jump * (tick % steps)) where jump = (width / steps) where steps = 40)" + # + x = "(round(w * (t * t * (3.0 - 2.0 * t))) where w = (width - text_width) where t = ((tick % steps) / steps) where steps = 40.0)" + y = 0 + w = "(text_width)" + h = "(height)" + text = "•" + font_size = {GUI_FONT_SIZE_DEFAULT} + color = {GUI__FONT_COLOR_ENABLED__DEFAULT} + [/text] + + [/draw] + + [/drawing] [/column] diff --git a/src/gui/dialogs/loading_screen.cpp b/src/gui/dialogs/loading_screen.cpp index ae78528590e6..7d862a2124a8 100644 --- a/src/gui/dialogs/loading_screen.cpp +++ b/src/gui/dialogs/loading_screen.cpp @@ -24,16 +24,17 @@ #include "gettext.hpp" #include "gui/auxiliary/find_widget.hpp" #include "gui/core/timer.hpp" +#include "gui/widgets/drawing.hpp" #include "gui/widgets/label.hpp" #include "gui/widgets/settings.hpp" #include "gui/widgets/window.hpp" #include "log.hpp" #include "preferences/general.hpp" -#include #include "video.hpp" #include #include +#include static lg::log_domain log_loadscreen("loadscreen"); #define ERR_LS LOG_STREAM(err, log_loadscreen) @@ -79,22 +80,13 @@ loading_screen::loading_screen(std::function f) , worker_result_() , cursor_setter_() , progress_stage_label_(nullptr) - , animation_label_(nullptr) + , animation_(nullptr) , current_stage_(loading_stage::none) , visible_stages_() - , animation_stages_() , current_visible_stage_() { - for(const auto& pair : stage_names) { - visible_stages_[pair.first] = t_string(pair.second, "wesnoth-lib") + "..."; - } - - animation_stages_.reserve(20); - - for(int i = 0; i != 20; ++i) { - std::string s(20, ' '); - s[i] = '.'; - animation_stages_.push_back(std::move(s)); + for(const auto& [stage, description] : stage_names) { + visible_stages_[stage] = t_string(description, "wesnoth-lib") + "..."; } current_visible_stage_ = visible_stages_.end(); @@ -119,7 +111,7 @@ void loading_screen::pre_show(window& window) } progress_stage_label_ = find_widget