The Battle for Wesnoth  1.17.12+dev
settings.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2022
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 /** screen_pitch_microns is deprecated. Do not use it.
30  *
31  * This value corresponds to a physical DPI of 96. But physical DPI should
32  * not be used to make rendering decisions. With the ability to set pixel
33  * scale, it can be assumed that one pixel in draw-space is neither too
34  * small nor too large.
35  */
36 const unsigned screen_pitch_microns = 265;
37 unsigned gamemap_x_offset = 0;
38 
39 unsigned gamemap_width = 0;
40 unsigned gamemap_height = 0;
41 
42 unsigned popup_show_delay = 0;
43 unsigned popup_show_time = 0;
44 unsigned help_show_time = 0;
45 unsigned double_click_time = 0;
47 
48 std::string sound_button_click = "";
49 std::string sound_toggle_button_click = "";
50 std::string sound_toggle_panel_click = "";
51 std::string sound_slider_adjust = "";
52 
54 
55 std::vector<game_tip> tips;
56 
58 {
59  point canvas_size = video::game_canvas_size();
60 
61  screen_width = canvas_size.x;
62  screen_height = canvas_size.y;
63 
64  gamemap_width = screen_width;
65  gamemap_height = screen_height;
66 
68  const SDL_Rect rect_gm = display->map_outside_area();
69 
70  if(rect_gm.w && rect_gm.h) {
71  gamemap_width = rect_gm.w;
72  gamemap_height = rect_gm.h;
73  gamemap_x_offset = rect_gm.x;
74  }
75  }
76 }
77 
78 } // namespace settings
79 
80 } // namespace gui2
bool new_widgets
Do we wish to use the new library or not.
Definition: settings.cpp:23
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:98
unsigned double_click_time
Definition: settings.cpp:45
std::vector< game_tip > tips
Definition: settings.cpp:55
std::string sound_button_click
Definition: settings.cpp:48
unsigned gamemap_width
The size of the map area, if not available equal to the screen size.
Definition: settings.cpp:39
std::string sound_slider_adjust
Definition: settings.cpp:51
Generic file dialog.
unsigned repeat_button_repeat_time
Definition: settings.cpp:46
This file contains the settings handling of the widget library.
t_string has_helptip_message
Definition: settings.cpp:53
unsigned gamemap_height
Definition: settings.cpp:40
map_display and display: classes which take care of displaying the map and game-data on the screen...
Contains the general settings which have a default.
unsigned gamemap_x_offset
The offset between the left edge of the screen and the gamemap.
Definition: settings.cpp:37
unsigned popup_show_time
Definition: settings.cpp:43
point game_canvas_size()
The size of the game canvas, in drawing coordinates / game pixels.
Definition: video.cpp:427
Holds a 2D point.
Definition: point.hpp:24
unsigned screen_width
The screen resolution and pixel pitch should be available for all widgets since their drawing method ...
Definition: settings.cpp:27
std::string sound_toggle_panel_click
Definition: settings.cpp:50
unsigned popup_show_delay
These are copied from the active gui.
Definition: settings.cpp:42
unsigned screen_height
Definition: settings.cpp:28
rect map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.cpp:564
const unsigned screen_pitch_microns
screen_pitch_microns is deprecated.
Definition: settings.cpp:36
std::string sound_toggle_button_click
Definition: settings.cpp:49
void update_screen_size_variables()
Update the size of the screen variables in settings.
Definition: settings.cpp:57
unsigned help_show_time
Definition: settings.cpp:44