diff --git a/client/CMT.cpp b/client/CMT.cpp index 382bfd6e0..5151a8c39 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -357,17 +357,37 @@ int main(int argc, char** argv) std::string driverName(info.name); - - logGlobal->infoStream() << "\t" << driverName; - if(!preferredDriverName.empty() && driverName == preferredDriverName) { preferredDriverIndex = it; - logGlobal->infoStream() << "\t\twill select this"; - } + logGlobal->infoStream() << "\t" << driverName << " (active)"; + } + else + logGlobal->infoStream() << "\t" << driverName; } #endif // VCMI_SDL1 + config::CConfigHandler::GuiOptionsMap::key_type resPair(res["width"].Float(), res["height"].Float()); + if (conf.guiOptions.count(resPair) == 0) + { + // selected resolution was not found - complain & fallback to something that we do have. + logGlobal->errorStream() << "Selected resolution " << resPair.first << "x" << resPair.second << " was not found!"; + if (conf.guiOptions.empty()) + { + logGlobal->errorStream() << "Unable to continue - no valid resolutions found! Please reinstall VCMI to fix this"; + exit(1); + } + else + { + Settings newRes = settings.write["video"]["screenRes"]; + newRes["width"].Float() = conf.guiOptions.begin()->first.first; + newRes["height"].Float() = conf.guiOptions.begin()->first.second; + conf.SetResolution(newRes["width"].Float(), newRes["height"].Float()); + + logGlobal->errorStream() << "Falling back to " << newRes["width"].Float() << "x" << newRes["height"].Float(); + } + } + setScreenRes(res["width"].Float(), res["height"].Float(), video["bitsPerPixel"].Float(), video["fullscreen"].Bool()); logGlobal->infoStream() <<"\tInitializing screen: "<(x, y)]; + void SetResolution(int x, int y) + { + std::pair index(x, y); + if (guiOptions.count(index) == 0) + current = nullptr; + else + current = &guiOptions.at(index); } }; }