The Battle for Wesnoth  1.17.0-dev
settings.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2021
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 
20 #define MAGIC_DPI_MATCH_VIDEO 96
21 #define MICRONS_PER_INCH 25400
22 
23 namespace gui2
24 {
25 bool new_widgets = false;
26 
27 namespace settings
28 {
29 unsigned screen_width = 0;
30 unsigned screen_height = 0;
32 unsigned gamemap_x_offset = 0;
33 
34 unsigned gamemap_width = 0;
35 unsigned gamemap_height = 0;
36 
37 unsigned popup_show_delay = 0;
38 unsigned popup_show_time = 0;
39 unsigned help_show_time = 0;
40 unsigned double_click_time = 0;
42 
43 std::string sound_button_click = "";
44 std::string sound_toggle_button_click = "";
45 std::string sound_toggle_panel_click = "";
46 std::string sound_slider_adjust = "";
47 
49 
50 std::vector<game_tip> tips;
51 
53 {
55  const SDL_Rect rect = vid.screen_area();
56 
57  screen_width = rect.w;
58  screen_height = rect.h;
59 
60  auto [scalew, scaleh] = vid.get_dpi_scale_factor();
61  float avgscale = (scalew + scaleh)/2;
62  screen_pitch_microns = MICRONS_PER_INCH / (avgscale * MAGIC_DPI_MATCH_VIDEO);
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
#define MICRONS_PER_INCH
Definition: settings.cpp:21
bool new_widgets
Do we wish to use the new library or not.
Definition: settings.cpp:25
static display * get_singleton()
Returns the display object if a display object exists.
Definition: display.hpp:92
unsigned double_click_time
Definition: settings.cpp:40
std::vector< game_tip > tips
Definition: settings.cpp:50
std::pair< float, float > get_dpi_scale_factor() const
The current scale factor on High-DPI screens.
Definition: video.cpp:417
Definition: video.hpp:32
std::string sound_button_click
Definition: settings.cpp:43
static CVideo & get_singleton()
Definition: video.hpp:49
unsigned gamemap_width
The size of the map area, if not available equal to the screen size.
Definition: settings.cpp:34
std::string sound_slider_adjust
Definition: settings.cpp:46
Generic file dialog.
Definition: field-fwd.hpp:23
unsigned repeat_button_repeat_time
Definition: settings.cpp:41
This file contains the settings handling of the widget library.
t_string has_helptip_message
Definition: settings.cpp:48
unsigned gamemap_height
Definition: settings.cpp:35
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:31
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:32
unsigned popup_show_time
Definition: settings.cpp:38
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
Definition: display.hpp:242
unsigned screen_width
The screen resolution and pixel pitch should be available for all widgets since their drawing method ...
Definition: settings.cpp:29
std::string sound_toggle_panel_click
Definition: settings.cpp:45
unsigned popup_show_delay
These are copied from the active gui.
Definition: settings.cpp:37
unsigned screen_height
Definition: settings.cpp:30
#define MAGIC_DPI_MATCH_VIDEO
Definition: settings.cpp:20
SDL_Rect screen_area(bool as_pixels=true) const
Returns the current window renderer area, either in pixels or screen coordinates. ...
Definition: video.cpp:277
std::string sound_toggle_button_click
Definition: settings.cpp:44
void update_screen_size_variables()
Update the size of the screen variables in settings.
Definition: settings.cpp:52
unsigned help_show_time
Definition: settings.cpp:39