Skip to content

Commit

Permalink
Merge pull request #151 from aquileia/clean_up
Browse files Browse the repository at this point in the history
Fix resolution selection dialog
  • Loading branch information
AI0867 committed Apr 16, 2014
2 parents 681e667 + e93dfa0 commit 8cb1e4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/preferences_display.cpp
Expand Up @@ -283,18 +283,16 @@ bool show_video_mode_dialog(display& disp)

for(size_t k = 0; k < resolutions.size(); ++k) {
std::pair<int, int> const& res = resolutions[k];
if(res.first < min_allowed_width() || res.second < min_allowed_height()) {
continue;
}

if (res == current_res)
current_choice = static_cast<unsigned>(k);

std::ostringstream option;
option << res.first << utils::unicode_multiplication_sign << res.second;
const int div = boost::math::gcd(res.first, res.second);
if (div >= 10)
option << " (" << res.first/div << ':' << res.second/div << ')';
const int ratio[2] = {res.first/div, res.second/div};
if (ratio[0] <= 10 || ratio[1] <= 10)
option << " (" << ratio[0] << ':' << ratio[1] << ')';
options.push_back(option.str());
}

Expand Down
11 changes: 8 additions & 3 deletions src/video.cpp
Expand Up @@ -611,10 +611,15 @@ std::vector<std::pair<int, int> > CVideo::get_available_resolutions()
std::cerr << "No modes supported\n";
return result;
}

result.push_back(std::make_pair(getSurface()->w, getSurface()->h));

const std::pair<int,int> min_res = std::make_pair(preferences::min_allowed_width(),preferences::min_allowed_height());

if (getSurface()->w >= min_res.first && getSurface()->h >= min_res.second)
result.push_back(std::make_pair(getSurface()->w, getSurface()->h));

for(int i = 0; modes[i] != NULL; ++i) {
result.push_back(std::make_pair(modes[i]->w,modes[i]->h));
if (modes[i]->w >= min_res.first && modes[i]->h >= min_res.second)
result.push_back(std::make_pair(modes[i]->w,modes[i]->h));
}

std::sort(result.begin(), result.end());
Expand Down

0 comments on commit 8cb1e4f

Please sign in to comment.