16#define GETTEXT_DOMAIN "wesnoth-lib"
30using namespace std::chrono_literals;
36constexpr auto fade_duration = 500ms;
48 , display_duration_(info.end_text_duration)
49 , stage_(
stage::fading_in)
52 if(!info.end_text.empty()) {
53 text_.push_back(info.end_text);
55 text_.push_back(
_(
"The End"));
58 if(info.end_credits) {
62 for(
const auto&
about : (*campaign_credits)->sections) {
63 if(
about.names.empty()) {
68 static const float chunk_size = 5.0;
70 const unsigned num_names =
about.names.size();
71 const unsigned num_chunks = std::ceil(num_names / chunk_size);
73 for(std::size_t
i = 0;
i < num_chunks; ++
i) {
78 ss <<
about.title <<
"\n\n";
81 for(std::size_t k =
i * chunk_size; k < std::min<unsigned>((
i + 1) * chunk_size, num_names); ++k) {
86 std::string section_text = ss.str();
87 section_text.pop_back();
89 text_.push_back(std::move(section_text));
95 if(display_duration_ == 0ms) {
96 display_duration_ = 3500ms;
114 const auto now = std::chrono::steady_clock::now();
122 const auto goto_stage = [
this, &now](
stage new_stage) {
127 if(
stage_start_ == std::chrono::steady_clock::time_point{}) {
A simple canvas which can be drawn upon.
void set_variable(const std::string &key, wfl::variant &&value)
void update_size_variables()
Update WFL size variables.
Abstract base class for all modal dialogs.
Dialog to display 'The End' at the end of a campaign.
virtual void update() override
Displays a simple fading screen with any user-provided text.
std::chrono::milliseconds display_duration_
How long to display each text entry.
virtual void pre_show() override
Actions to be taken before showing the window.
std::chrono::steady_clock::time_point stage_start_
The time point at which the current stage began.
std::size_t text_index_
The index of the text currently being shown.
double get_fade_progress(const std::chrono::steady_clock::time_point &now) const
Returns a normalized [0.0 .
std::vector< std::string > text_
The text to draw.
stage
Tracks whether we're fading in, displaying text, or fading out.
enum gui2::dialogs::outro::stage stage_
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
void close()
Requests to close the window.
constexpr uint8_t float_to_color(double n)
Convert a double in the range [0.0,1.0] to an 8-bit colour value.
static std::string _(const char *str)
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
Display credits about all contributors.
utils::optional< credits_data::const_iterator > get_campaign_credits(const std::string &campaign)
Gets credits for a given campaign.
constexpr double normalize_progress(const std::chrono::duration< RepE, PeriodE > &elapsed, const std::chrono::duration< RepD, PeriodD > &duration)
std::string span_size(std::string_view size, Args &&... data)
Applies Pango markup to the input specifying its display size.