make [resolution] window_width/height, the minimum required window size

This commit is contained in:
gfgtdf 2017-06-13 20:25:47 +02:00 committed by GitHub
parent 222a7ae220
commit 96fecea66d
7 changed files with 37 additions and 13 deletions

View file

@ -423,8 +423,8 @@
description = "List of one or more add-ons."
[resolution]
window_width = 800
window_height = 600
window_width = 1
window_height = 0
[linked_group]
id = "icon"
@ -464,8 +464,8 @@
[/resolution]
[resolution]
window_width = 1024
window_height = 768
window_width = 900
window_height = 0
[linked_group]
id = "icon"
@ -512,6 +512,10 @@
[/resolution]
[resolution]
window_width = 1050
window_height = 0
[linked_group]
id = "icon"
fixed_width = true

View file

@ -788,8 +788,8 @@
description = "Addon selection dialog."
[resolution]
window_width=1280
window_height=800
window_width=1
window_height=1
definition = "addon_manager"
{GUI_WINDOW_FULLSCREEN}
@ -966,6 +966,9 @@
[resolution]
definition = "addon_manager"
window_width=1281
window_height=801
{GUI_WINDOW_FULLSCREEN}
[tooltip]

View file

@ -3,6 +3,8 @@
[resolution]
definition = "mp_create"
window_width, window_height = 1200, 0
{GUI_WINDOW_FULLSCREEN}
[linked_group]

View file

@ -1,7 +1,7 @@
#textdomain wesnoth-lib
[resolution]
window_width, window_height = 1024, 768
window_width, window_height = 900, 700
definition = "mp_create"
{GUI_WINDOW_FULLSCREEN}

View file

@ -1,7 +1,7 @@
#textdomain wesnoth-lib
[resolution]
window_width, window_height = 900, 700
window_width, window_height = 1, 1
definition = "mp_create"
{GUI_WINDOW_FULLSCREEN}

View file

@ -553,8 +553,8 @@
description = "Game staging area."
[resolution]
window_width = 1024
window_height = 768
window_width = 1
window_height = 1
# TODO: decide about background
#definition = "mp_staging"
definition = "borderless"
@ -740,6 +740,10 @@
[resolution]
# TODO: decide about background
#definition = "mp_staging"
window_width = 1100
window_height = 800
definition = "borderless"
{GUI_WINDOW_FULLSCREEN}

View file

@ -585,14 +585,25 @@ const builder_window::window_resolution& get_window_builder(const std::string& t
VALIDATE(!resolutions.empty(), formatter() << "Window '" << type << "' has no resolutions.\n");
const builder_window::window_resolution* best_resolution = nullptr;
int best_resolution_score = 0;
for(const auto& res : resolutions) {
if(settings::screen_width <= res.window_width && settings::screen_height <= res.window_height) {
return res;
int screen_w = settings::screen_width;
int screen_h = settings::screen_height;
int w = res.window_width ? res.window_width : screen_w;
int h = res.window_height ? res.window_height : screen_h;
int score = w * h;
if(score >= best_resolution_score && w <= screen_w && h <= screen_h) {
best_resolution = &res;
best_resolution_score = score;
}
}
// If no matching resolution was found, return the last builder.
return resolutions.back();
return best_resolution ? *best_resolution : resolutions.back();
}
/*WIKI