Skip to content

Commit

Permalink
Added and deployed getter method for current window resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 1, 2016
1 parent eb1335b commit 8732d81
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/preferences_display.cpp
Expand Up @@ -133,17 +133,13 @@ bool show_video_mode_dialog(display& disp)
return false;
}

const std::pair<int,int> current_res(
disp.video().getSurface()->w
, disp.video().getSurface()->h);

std::vector<std::string> options;
unsigned current_choice = 0;

for(size_t k = 0; k < resolutions.size(); ++k) {
std::pair<int, int> const& res = resolutions[k];

if (res == current_res)
if (res == disp.video().current_resolution())
current_choice = static_cast<unsigned>(k);

std::ostringstream option;
Expand All @@ -161,7 +157,7 @@ bool show_video_mode_dialog(display& disp)

int choice = dlg.selected_index();

if(choice == -1 || resolutions[static_cast<size_t>(choice)] == current_res) {
if(choice == -1 || resolutions[static_cast<size_t>(choice)] == disp.video().current_resolution()) {
return false;
}

Expand Down
7 changes: 6 additions & 1 deletion src/video.cpp
Expand Up @@ -859,7 +859,7 @@ std::vector<std::pair<int, int> > CVideo::get_available_resolutions()
const std::pair<int,int> min_res = std::make_pair(preferences::min_allowed_width(),preferences::min_allowed_height());

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

for(int i = 0; modes[i] != NULL; ++i) {
if (modes[i]->w >= min_res.first && modes[i]->h >= min_res.second)
Expand All @@ -878,6 +878,11 @@ surface& CVideo::getSurface()
return frameBuffer;
}

std::pair<int,int> CVideo::current_resolution()
{
return std::make_pair(getSurface()->w, getSurface()->h);
}

bool CVideo::isFullScreen() const { return fullScreen; }

#if !SDL_VERSION_ATLEAST(2, 0, 0)
Expand Down
4 changes: 3 additions & 1 deletion src/video.hpp
Expand Up @@ -109,7 +109,9 @@ class CVideo : private boost::noncopyable {
*/
void set_resolution(const std::pair<int,int>& res);
bool set_resolution(const unsigned width, const unsigned height);


std::pair<int,int> current_resolution();

//did the mode change, since the last call to the modeChanged() method?
bool modeChanged();

Expand Down

0 comments on commit 8732d81

Please sign in to comment.