The Battle for Wesnoth  1.19.15+dev
title_screen.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2025
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  // Load and begin playing a saved game
52  // Start playing a single-player game, such as the tutorial or a campaign
54  // Connect to an MP server
56  // Host an MP game
58  // Start a local MP game
60  // Start the map/scenario editor
62  // Exit to desktop
64  // Used to reload all game data
66  // Used to reshow the titlescreen, for example,
67  // in the case of a gui2 theme change
69  };
70 
71 private:
72  virtual const std::string& window_id() const override;
73 
74  void init_callbacks();
75 
76  // Does different actions based on if it was called by clicking
77  // the button or by using the hotkey
78  void register_button(
79  const std::string& id,
81  const std::function<void()>& callback_btn,
82  const std::function<void()>& callback_hotkey);
83  void register_button(const std::string& id, hotkey::HOTKEY_COMMAND hk, const std::function<void()>& callback);
84 
85  /***** ***** ***** ***** Callbacks ***** ***** ****** *****/
86 
87  void on_resize();
88 
89  /**
90  * Updates the tip of day widget.
91  *
92  * @param previous Show the previous tip, else shows the next one.
93  */
94  void update_tip(const bool previous);
95 
96  /** Updates UI labels that are not t_string after a language change. */
97  void update_static_labels();
98 
99  /** Shows the debug clock. */
101 
102  /** Shows the preferences dialog. */
103  void show_preferences();
104 
106 
108 
109  void button_callback_cores();
110 
111  /** Holds the debug clock dialog. */
112  std::unique_ptr<modeless_dialog> debug_clock_;
113 
115 
116 };
117 
118 } // 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.
void show_preferences()
Shows the preferences dialog.
void register_button(const std::string &id, hotkey::HOTKEY_COMMAND hk, const std::function< void()> &callback_btn, const std::function< void()> &callback_hotkey)
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.