Added and deployed getter method for current window resolution

This commit is contained in:
Charles Dang 2015-12-27 17:41:30 +11:00
parent eb1335b64b
commit 8732d8179c
3 changed files with 11 additions and 8 deletions

View file

@ -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;
@ -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;
}

View file

@ -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)
@ -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)

View file

@ -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();