The Battle for Wesnoth  1.19.0-dev
title_screen.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
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 class game_launcher;
21 
22 namespace gui2::dialogs
23 {
24 
25 class modeless_dialog;
26 
27 /** Do we wish to show the button for the debug clock. */
28 extern bool show_debug_clock_button;
29 
30 /**
31  * @ingroup GUIWindowDefinitionWML
32  *
33  * This class implements the title screen.
34  *
35  * The menu buttons return a result back to the caller with the button pressed.
36  * So at the moment it only handles the tips itself.
37  *
38  * Key |Type |Mandatory|Description
39  * ------------------|--------------|---------|-----------
40  * tutorial | @ref button |yes |The button to start the tutorial.
41  * campaign | @ref button |yes |The button to start a campaign.
42  * multiplayer | @ref button |yes |The button to start multiplayer mode.
43  * load | @ref button |yes |The button to load a saved game.
44  * editor | @ref button |yes |The button to start the editor.
45  * addons | @ref button |yes |The button to start managing the addons.
46  * cores | @ref button |yes |The button to start managing the cores.
47  * language | @ref button |yes |The button to select the game language.
48  * credits | @ref button |yes |The button to show Wesnoth's contributors.
49  * quit | @ref button |yes |The button to quit Wesnoth.
50  * tips | multi_page |yes |A multi_page to hold all tips, when this widget is used the area of the tips doesn't need to be resized when the next or previous button is pressed.
51  * tip | @ref label |no |Shows the text of the current tip.
52  * source | @ref label |no |The source (the one who's quoted or the book referenced) of the current tip.
53  * next_tip | @ref button |yes |The button show the next tip of the day.
54  * previous_tip | @ref button |yes |The button show the previous tip of the day.
55  * logo | progress_bar |no |A progress bar to "animate" the Wesnoth logo.
56  * revision_number | control |no |A widget to show the version number when the version number is known.
57  */
58 class title_screen : public modal_dialog
59 {
60 public:
62 
63  ~title_screen();
64 
65  /**
66  * Values for actions which leave the title screen.
67  * Actions that merely show a dialog are not included here.
68  */
69  enum result {
70  // Window was resized, so needs redrawing
71  REDRAW_BACKGROUND = 0, // Needs to be 0, the value of gui2::retval::NONE
72  // Start playing a single-player game, such as the tutorial or a campaign
74  // Connect to an MP server
76  // Host an MP game
78  // Start a local MP game
80  // Start the map/scenario editor
82  // Show credits
84  // Exit to desktop
86  // Used to reload all game data
88  };
89 
90 private:
91  virtual const std::string& window_id() const override;
92 
93  void init_callbacks();
94 
95  /***** ***** ***** ***** Callbacks ***** ***** ****** *****/
96 
97  void on_resize();
98 
99  /**
100  * Updates the tip of day widget.
101  *
102  * @param previous Show the previous tip, else shows the next one.
103  */
104  void update_tip(const bool previous);
105 
106  /** Updates UI labels that are not t_string after a language change. */
107  void update_static_labels();
108 
109  /** Shows the debug clock. */
111 
113 
114  void show_achievements();
115 
117 
118  void button_callback_cores();
119 
120  /** Holds the debug clock dialog. */
121  std::unique_ptr<modeless_dialog> debug_clock_;
122 
124 
125 };
126 
127 } // namespace dialogs
Abstract base class for all modal dialogs.
This class implements the title screen.
std::unique_ptr< modeless_dialog > debug_clock_
Holds the debug clock dialog.
virtual const std::string & window_id() const override
The ID of the window to build.
void update_tip(const bool previous)
Updates the tip of day widget.
title_screen(game_launcher &game)
void update_static_labels()
Updates UI labels that are not t_string after a language change.
void show_debug_clock_window()
Shows the debug clock.
result
Values for actions which leave the title screen.
bool show_debug_clock_button
Do we wish to show the button for the debug clock.