From 136a97e5cc3499077af7b37ba6cc6a5a00f52e75 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 25 Sep 2013 20:32:12 +0300 Subject: allow use only first video mode on Android. --- src/graphicsmanager.cpp | 47 +++++++++++------------------------------------ src/utils/sdlhelper.cpp | 8 ++++++++ 2 files changed, 19 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 29e65df1b..cee3e1223 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -351,44 +351,19 @@ void GraphicsManager::setVideoMode() const bool noFrame = config.getBoolValue("noframe"); #ifdef ANDROID - int width = config.getValue("screenwidth", 0); - int height = config.getValue("screenheight", 0); +// int width = config.getValue("screenwidth", 0); +// int height = config.getValue("screenheight", 0); StringVect videoModes; SDL::getAllVideoModes(videoModes); - if (!videoModes.empty()) - { - bool found(false); - std::string str = strprintf("%dx%d", width, height); - if (width != 0 && height != 0) - { - FOR_EACH (StringVectCIter, it, videoModes) - { - if (str == *it) - { - found = true; - break; - } - } - } - - if (!found) - { - if (width != 0 && height != 0) - { - logger->log("Current resolution %s is incorrect.", - str.c_str()); - } -// str = videoModes[0]; - std::vector res; - splitToIntVector(res, videoModes[0], 'x'); - if (res.size() == 2) - { - width = res[0]; - height = res[1]; - logger->log("Autoselect mode %dx%d", width, height); - } - } - } + if (videoModes.empty()) + logger->error("no video modes detected"); + std::vector res; + splitToIntVector(res, videoModes[0], 'x'); + if (res.size() != 2) + logger->error("no video modes detected"); + + int width = res[0]; + int height = res[1]; #else int width = config.getIntValue("screenwidth"); int height = config.getIntValue("screenheight"); diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp index 0034ee0e8..da81f03ea 100644 --- a/src/utils/sdlhelper.cpp +++ b/src/utils/sdlhelper.cpp @@ -37,6 +37,13 @@ bool SDL::getAllVideoModes(StringVect &modeList) SDL_Rect *const *const modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE); +#ifdef ANDROID + const std::string modeString = + toString(static_cast(modes[0]->w)).append("x") + .append(toString(static_cast(modes[0]->h))); + logger->log("support mode: " + modeString); + modeList.push_back(modeString); +#else /* Check which modes are available */ if (modes == static_cast(nullptr)) { @@ -60,6 +67,7 @@ bool SDL::getAllVideoModes(StringVect &modeList) } return true; } +#endif } void SDL::SetWindowTitle(const SDL_Surface *const window A_UNUSED, -- cgit v1.2.3-60-g2f50