The Battle for Wesnoth  1.19.7+dev
settings.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 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 #include "gui/widgets/settings.hpp"
17 
18 #include "display.hpp"
19 #include "video.hpp"
20 
21 namespace gui2
22 {
23 bool new_widgets = false;
24 
25 namespace settings
26 {
27 unsigned screen_width = 0;
28 unsigned screen_height = 0;
29 unsigned gamemap_x_offset = 0;
30 
31 unsigned gamemap_width = 0;
32 unsigned gamemap_height = 0;
33 
34 std::chrono::milliseconds popup_show_delay{0};
35 std::chrono::milliseconds popup_show_time{0};
36 std::chrono::milliseconds help_show_time{0};
37 std::chrono::milliseconds double_click_time{0};
38 std::chrono::milliseconds repeat_button_repeat_time{0};
39 
40 std::string sound_button_click = "";
41 std::string sound_toggle_button_click = "";
42 std::string sound_toggle_panel_click = "";
43 std::string sound_slider_adjust = "";
44 
46 
47 std::vector<game_tip> tips;
48 
50 {
51  point canvas_size = video::game_canvas_size();
52 
53  screen_width = canvas_size.x;
54  screen_height = canvas_size.y;
55 
58 
60  const SDL_Rect rect_gm = display->map_outside_area();
61 
62  if(rect_gm.w && rect_gm.h) {
63  gamemap_width = rect_gm.w;
64  gamemap_height = rect_gm.h;
65  gamemap_x_offset = rect_gm.x;
66  }
67  }
68 }
69 
70 } // namespace settings
71 
72 } // namespace gui2
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:97
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.cpp:521
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:111
map_display and display: classes which take care of displaying the map and game-data on the screen.
t_string has_helptip_message
Definition: settings.cpp:45
unsigned screen_width
The screen resolution and pixel pitch should be available for all widgets since their drawing method ...
Definition: settings.cpp:27
std::vector< game_tip > tips
Definition: settings.cpp:47
std::chrono::milliseconds double_click_time
Definition: settings.cpp:37
std::string sound_slider_adjust
Definition: settings.cpp:43
std::string sound_toggle_button_click
Definition: settings.cpp:41
std::chrono::milliseconds popup_show_delay
These are copied from the active gui.
Definition: settings.cpp:34
unsigned screen_height
Definition: settings.cpp:28
unsigned gamemap_x_offset
The offset between the left edge of the screen and the gamemap.
Definition: settings.cpp:29
unsigned gamemap_height
Definition: settings.cpp:32
std::string sound_button_click
Definition: settings.cpp:40
std::chrono::milliseconds popup_show_time
Definition: settings.cpp:35
std::chrono::milliseconds help_show_time
Definition: settings.cpp:36
std::string sound_toggle_panel_click
Definition: settings.cpp:42
unsigned gamemap_width
The size of the map area, if not available equal to the screen size.
Definition: settings.cpp:31
void update_screen_size_variables()
Update the size of the screen variables in settings.
Definition: settings.cpp:49
std::chrono::milliseconds repeat_button_repeat_time
Definition: settings.cpp:38
Generic file dialog.
bool new_widgets
Do we wish to use the new library or not.
Definition: settings.cpp:23
Contains the general settings which have a default.
point game_canvas_size()
The size of the game canvas, in drawing coordinates / game pixels.
Definition: video.cpp:432
This file contains the settings handling of the widget library.
Holds a 2D point.
Definition: point.hpp:25