The Battle for Wesnoth  1.19.4+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  * This class implements the title screen.
32  *
33  * The menu buttons return a result back to the caller with the button pressed.
34  * So at the moment it only handles the tips itself.
35  */
36 class title_screen : public modal_dialog
37 {
38 public:
40 
41  ~title_screen();
42 
43  /**
44  * Values for actions which leave the title screen.
45  * Actions that merely show a dialog are not included here.
46  */
47  enum result {
48  // Window was resized, so needs redrawing
49  REDRAW_BACKGROUND = 0, // Needs to be 0, the value of gui2::retval::NONE
50  // Start playing a single-player game, such as the tutorial or a campaign
52  // Connect to an MP server
54  // Host an MP game
56  // Start a local MP game
58  // Start the map/scenario editor
60  // Exit to desktop
62  // Used to reload all game data
64  // Used to reshow the titlescreen, for example,
65  // in the case of a gui2 theme change
67  };
68 
69 private:
70  virtual const std::string& window_id() const override;
71 
72  void init_callbacks();
73 
74  void register_button(const std::string& id, hotkey::HOTKEY_COMMAND hk, std::function<void()> callback);
75 
76  /***** ***** ***** ***** Callbacks ***** ***** ****** *****/
77 
78  void on_resize();
79 
80  /**
81  * Updates the tip of day widget.
82  *
83  * @param previous Show the previous tip, else shows the next one.
84  */
85  void update_tip(const bool previous);
86 
87  /** Updates UI labels that are not t_string after a language change. */
88  void update_static_labels();
89 
90  /** Shows the debug clock. */
92 
93  /** Shows the gui test window. */
94  void show_gui_test_dialog();
95 
96  /** Shows the preferences dialog. */
97  void show_preferences();
98 
100 
101  void show_achievements();
102 
103  void show_community();
104 
106 
107  void button_callback_cores();
108 
109  /** Holds the debug clock dialog. */
110  std::unique_ptr<modeless_dialog> debug_clock_;
111 
113 
114 };
115 
116 } // 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 register_button(const std::string &id, hotkey::HOTKEY_COMMAND hk, std::function< void()> callback)
void show_gui_test_dialog()
Shows the gui test window.
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.
void show_preferences()
Shows the preferences dialog.
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.