The Battle for Wesnoth  1.17.0-dev
settings.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "gui/widgets/settings.hpp"
16 
17 #include "display.hpp"
18 
19 #define MAGIC_DPI_MATCH_VIDEO 96
20 #define MICRONS_PER_INCH 25400
21 
22 namespace gui2
23 {
24 bool new_widgets = false;
25 
26 namespace settings
27 {
28 unsigned screen_width = 0;
29 unsigned screen_height = 0;
31 unsigned gamemap_x_offset = 0;
32 
33 unsigned gamemap_width = 0;
34 unsigned gamemap_height = 0;
35 
36 unsigned popup_show_delay = 0;
37 unsigned popup_show_time = 0;
38 unsigned help_show_time = 0;
39 unsigned double_click_time = 0;
41 
42 std::string sound_button_click = "";
43 std::string sound_toggle_button_click = "";
44 std::string sound_toggle_panel_click = "";
45 std::string sound_slider_adjust = "";
46 
48 
49 std::vector<game_tip> tips;
50 
52 {
54  const SDL_Rect rect = vid.screen_area();
55 
56  screen_width = rect.w;
57  screen_height = rect.h;
58 
59  auto [scalew, scaleh] = vid.get_dpi_scale_factor();
60  float avgscale = (scalew + scaleh)/2;
61  screen_pitch_microns = MICRONS_PER_INCH / (avgscale * MAGIC_DPI_MATCH_VIDEO);
62 
63  gamemap_width = screen_width;
64  gamemap_height = screen_height;
65 
67  const SDL_Rect rect_gm = display->map_outside_area();
68 
69  if(rect_gm.w && rect_gm.h) {
70  gamemap_width = rect_gm.w;
71  gamemap_height = rect_gm.h;
72  gamemap_x_offset = rect_gm.x;
73  }
74  }
75 }
76 
77 } // namespace settings
78 
79 } // namespace gui2
#define MICRONS_PER_INCH
Definition: settings.cpp:20
bool new_widgets
Do we wish to use the new library or not.
Definition: settings.cpp:24
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:91
unsigned double_click_time
Definition: settings.cpp:39
std::vector< game_tip > tips
Definition: settings.cpp:49
std::pair< float, float > get_dpi_scale_factor() const
The current scale factor on High-DPI screens.
Definition: video.cpp:415
Definition: video.hpp:31
std::string sound_button_click
Definition: settings.cpp:42
static CVideo & get_singleton()
Definition: video.hpp:48
unsigned gamemap_width
The size of the map area, if not available equal to the screen size.
Definition: settings.cpp:33
std::string sound_slider_adjust
Definition: settings.cpp:45
Generic file dialog.
Definition: field-fwd.hpp:22
unsigned repeat_button_repeat_time
Definition: settings.cpp:40
This file contains the settings handling of the widget library.
t_string has_helptip_message
Definition: settings.cpp:47
unsigned gamemap_height
Definition: settings.cpp:34
map_display and display: classes which take care of displaying the map and game-data on the screen...
unsigned screen_pitch_microns
Definition: settings.cpp:30
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:31
unsigned popup_show_time
Definition: settings.cpp:37
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.hpp:241
unsigned screen_width
The screen resolution and pixel pitch should be available for all widgets since their drawing method ...
Definition: settings.cpp:28
std::string sound_toggle_panel_click
Definition: settings.cpp:44
unsigned popup_show_delay
These are copied from the active gui.
Definition: settings.cpp:36
unsigned screen_height
Definition: settings.cpp:29
#define MAGIC_DPI_MATCH_VIDEO
Definition: settings.cpp:19
SDL_Rect screen_area(bool as_pixels=true) const
Returns the current window renderer area, either in pixels or screen coordinates. ...
Definition: video.cpp:270
std::string sound_toggle_button_click
Definition: settings.cpp:43
void update_screen_size_variables()
Update the size of the screen variables in settings.
Definition: settings.cpp:51
unsigned help_show_time
Definition: settings.cpp:38