Skip to content

Commit

Permalink
make [resulution] window_width=, window_height= the minimum required …
Browse files Browse the repository at this point in the history
…window size

previously the game would always choose resolutions that were too big for the screen, in particular in the mp_create window.
  • Loading branch information
gfgtdf committed Jun 13, 2017
1 parent 73f1541 commit 9a81913
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/gui/widgets/settings.cpp
Expand Up @@ -585,14 +585,23 @@ const builder_window::window_resolution& get_window_builder(const std::string& t

VALIDATE(!resolutions.empty(), formatter() << "Window '" << type << "' has no resolutions.\n");

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 w = res.window_width ? res.window_width : settings::screen_width;
int h = res.window_height ? res.window_height : settings::screen_height;
int score = w * h;

if(score >= best_resolution_score && w <= settings::screen_width && h <= settings::screen_height) {
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
Expand Down

0 comments on commit 9a81913

Please sign in to comment.