diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index 8af7162b7..f81633653 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -325,155 +325,14 @@ void OptionsScreenVideo::init() assert( rememberWinposText != NULL ); #endif - bool is_fullscreen_desktop = false; bool is_vulkan_fullscreen_desktop = false; #ifndef SERVER_ONLY - is_fullscreen_desktop = - GE::getGEConfig()->m_fullscreen_desktop; is_vulkan_fullscreen_desktop = GE::getDriver()->getDriverType() == video::EDT_VULKAN && - is_fullscreen_desktop; + GE::getGEConfig()->m_fullscreen_desktop; #endif - // --- get resolution list from irrlicht the first time - if (!m_inited) - { - res->clearItems(); - - const std::vector& modes = - irr_driver->getVideoModes(); - const int amount = (int)modes.size(); - - m_resolutions.clear(); - Resolution r; - - bool found_config_res = false; - - // for some odd reason, irrlicht sometimes fails to report the good - // old standard resolutions - // those are always useful for windowed mode - bool found_1024_768 = false; - bool found_1280_720 = false; - - for (int n=0; n::iterator it = m_resolutions.begin(); - it != m_resolutions.end(); it++) - { - const float ratio = it->getRatio(); - char name[32]; - sprintf(name, "%ix%i", it->width, it->height); - - core::stringw label; - label += it->width; - label += L"\u00D7"; - label += it->height; - -#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01) - - if (ABOUT_EQUAL( ratio, (5.0f/4.0f) )) - res->addItem(label, name, "/gui/icons/screen54.png"); - else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) )) - res->addItem(label, name, "/gui/icons/screen43.png"); - else if (ABOUT_EQUAL( ratio, (16.0f/10.0f))) - res->addItem(label, name, "/gui/icons/screen1610.png"); - else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) )) - res->addItem(label, name, "/gui/icons/screen53.png"); - else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) )) - res->addItem(label, name, "/gui/icons/screen32.png"); - else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) )) - res->addItem(label, name, "/gui/icons/screen169.png"); - else - res->addItem(label, name, "/gui/icons/screen_other.png"); -#undef ABOUT_EQUAL - } // add next resolution - } // end if not inited - - res->updateItemDisplay(); - - // ---- select current resolution every time - char searching_for[32]; - snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_real_width, - (int)UserConfigParams::m_real_height); - - - if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER, - false /* focus it */, true /* even if deactivated*/)) - { - Log::error("OptionsScreenVideo", "Cannot find resolution %s", searching_for); - } - - + configResolutionsList(); // --- set gfx settings values updateGfxSlider(); updateBlurSlider(); @@ -516,6 +375,164 @@ void OptionsScreenVideo::init() // -------------------------------------------------------------------------------------------- +void OptionsScreenVideo::onResize() +{ + Screen::onResize(); + configResolutionsList(); +} // onResize + +// -------------------------------------------------------------------------------------------- + +void OptionsScreenVideo::configResolutionsList() +{ + DynamicRibbonWidget* res = getWidget("resolutions"); + if (res == NULL) + return; + + bool is_fullscreen_desktop = false; +#ifndef SERVER_ONLY + is_fullscreen_desktop = + GE::getGEConfig()->m_fullscreen_desktop; +#endif + + res->clearItems(); + + const std::vector& modes = + irr_driver->getVideoModes(); + const int amount = (int)modes.size(); + + m_resolutions.clear(); + Resolution r; + + bool found_config_res = false; + + // for some odd reason, irrlicht sometimes fails to report the good + // old standard resolutions + // those are always useful for windowed mode + bool found_1024_768 = false; + bool found_1280_720 = false; + + for (int n=0; n::iterator it = m_resolutions.begin(); + it != m_resolutions.end(); it++) + { + const float ratio = it->getRatio(); + char name[32]; + sprintf(name, "%ix%i", it->width, it->height); + + core::stringw label; + label += it->width; + label += L"\u00D7"; + label += it->height; + +#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01) + + if (ABOUT_EQUAL( ratio, (5.0f/4.0f) )) + res->addItem(label, name, "/gui/icons/screen54.png"); + else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) )) + res->addItem(label, name, "/gui/icons/screen43.png"); + else if (ABOUT_EQUAL( ratio, (16.0f/10.0f))) + res->addItem(label, name, "/gui/icons/screen1610.png"); + else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) )) + res->addItem(label, name, "/gui/icons/screen53.png"); + else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) )) + res->addItem(label, name, "/gui/icons/screen32.png"); + else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) )) + res->addItem(label, name, "/gui/icons/screen169.png"); + else + res->addItem(label, name, "/gui/icons/screen_other.png"); +#undef ABOUT_EQUAL + } // add next resolution + + res->updateItemDisplay(); + + // ---- select current resolution every time + char searching_for[32]; + snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_real_width, + (int)UserConfigParams::m_real_height); + + + if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER, + false /* focus it */, true /* even if deactivated*/)) + { + Log::error("OptionsScreenVideo", "Cannot find resolution %s", searching_for); + } + +} // configResolutionsList + +// -------------------------------------------------------------------------------------------- + void OptionsScreenVideo::updateResolutionsList() { CheckBoxWidget* full = getWidget("fullscreen"); diff --git a/src/states_screens/options/options_screen_video.hpp b/src/states_screens/options/options_screen_video.hpp index f3d42330a..38fcdbd3e 100644 --- a/src/states_screens/options/options_screen_video.hpp +++ b/src/states_screens/options/options_screen_video.hpp @@ -102,6 +102,7 @@ private: void updateTooltip(); void updateBlurTooltip(); void updateResolutionsList(); + void configResolutionsList(); void initPresets(); static void onScrollResolutionsList(void* data); public: @@ -125,6 +126,8 @@ public: virtual bool onEscapePressed() OVERRIDE; + virtual void onResize() OVERRIDE; + void updateGfxSlider(); void updateBlurSlider(); void updateScaleRTTsSlider();