The Battle for Wesnoth  1.19.8+dev
outro.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2024
3  by Charles Dang <exodia339@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
20 #include <chrono>
21 
23 
24 namespace gui2::dialogs
25 {
26 /** Dialog to display 'The End' at the end of a campaign. */
27 class outro : public modal_dialog
28 {
29 public:
31 
32  /**
33  * Displays a simple fading screen with any user-provided text.
34  * Used after the end of single-player campaigns.
35  */
37 
38  /** TLD override to update animations, called once per frame */
39  virtual void update() override;
40 
41 private:
42  virtual const std::string& window_id() const override;
43 
44  virtual void pre_show() override;
45 
46  /** Returns a normalized [0.0 .. 1.0] value representing elapsed fade time. */
47  double get_fade_progress(const std::chrono::steady_clock::time_point& now) const;
48 
49  /** The text to draw. Each entry is shown for the specified duration. */
50  std::vector<std::string> text_;
51 
52  /** The index of the text currently being shown. */
53  std::size_t text_index_;
54 
55  /** How long to display each text entry. */
56  std::chrono::milliseconds display_duration_;
57 
58  /** Tracks whether we're fading in, displaying text, or fading out. */
60 
61  /** The time point at which the current stage began. */
62  std::chrono::steady_clock::time_point stage_start_;
63 };
64 
65 } // namespace dialogs
Abstract base class for all modal dialogs.
Dialog to display 'The End' at the end of a campaign.
Definition: outro.hpp:28
virtual void update() override
Displays a simple fading screen with any user-provided text.
Definition: outro.cpp:107
std::chrono::milliseconds display_duration_
How long to display each text entry.
Definition: outro.hpp:56
virtual void pre_show() override
Actions to be taken before showing the window.
Definition: outro.cpp:100
std::chrono::steady_clock::time_point stage_start_
The time point at which the current stage began.
Definition: outro.hpp:62
outro(const game_classification &info)
Definition: outro.cpp:44
std::size_t text_index_
The index of the text currently being shown.
Definition: outro.hpp:53
virtual const std::string & window_id() const override
The ID of the window to build.
double get_fade_progress(const std::chrono::steady_clock::time_point &now) const
Returns a normalized [0.0 .
Definition: outro.cpp:167
std::vector< std::string > text_
The text to draw.
Definition: outro.hpp:50
stage
Tracks whether we're fading in, displaying text, or fading out.
Definition: outro.hpp:59
enum gui2::dialogs::outro::stage stage_
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...
logger & info()
Definition: log.cpp:319