From 9c0ec5c4145ebc3255e1b5eabf1980177cb0a16c Mon Sep 17 00:00:00 2001 From: auria Date: Wed, 6 Apr 2011 22:39:54 +0000 Subject: [PATCH] Fix wrong resolution selected when enough resolutions to enable scrolling git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8228 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- .../widgets/dynamic_ribbon_widget.cpp | 51 ++++++++++++++----- .../widgets/dynamic_ribbon_widget.hpp | 3 +- src/states_screens/options_screen_video.cpp | 4 +- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index aa7436f3d..c54ab3d07 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -960,6 +960,29 @@ void DynamicRibbonWidget::update(float dt) } // ----------------------------------------------------------------------------- + +bool DynamicRibbonWidget::findItemInRows(const char* name, int* p_row, int* p_id) +{ + int row = -1; + int id; + + for (int r=0; r -1) + { + row = r; + break; + } + } + + *p_row = row; + *p_id = id; + return (row != -1); +} + +// ----------------------------------------------------------------------------- + bool DynamicRibbonWidget::setSelection(int item_id, const int playerID, const bool focusIt) { if (m_deactivated) return false; @@ -971,26 +994,26 @@ bool DynamicRibbonWidget::setSelection(int item_id, const int playerID, const bo const std::string& name = m_items[item_id].m_code_name; - int row = -1; + int row; int id; - for (int r=0; r -1) + // if we get here it means the item is scrolled out. Try to find it. + scroll(1); + + if (iterations > 50) { - row = r; - break; + assert(false); + std::cerr << "DynamicRibbonWidget::setSelection cannot find item " << item_id << " (" << name.c_str() << ")\n"; + return false; } + + iterations++; } - - if (row == -1) - { - //std::cerr << "DynamicRibbonWidget::setSelection cannot find item " << item_id << " (" << name.c_str() << ")\n"; - return false; - } - + //std::cout << "Player " << playerID << " has item " << item_id << " (" << name.c_str() << ") in row " << row << std::endl; m_rows[row].setSelection(id, playerID); if (focusIt) diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.hpp b/src/guiengine/widgets/dynamic_ribbon_widget.hpp index b293c6448..61f7f500a 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.hpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.hpp @@ -164,7 +164,8 @@ namespace GUIEngine virtual EventPropagation mouseHovered(Widget* child, const int playerID); virtual EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID); - + bool findItemInRows(const char* name, int* p_row, int* p_id); + public: diff --git a/src/states_screens/options_screen_video.cpp b/src/states_screens/options_screen_video.cpp index 2be877247..607eee61f 100644 --- a/src/states_screens/options_screen_video.cpp +++ b/src/states_screens/options_screen_video.cpp @@ -112,13 +112,13 @@ void OptionsScreenVideo::init() bool found_config_res = false; - // for some odd reason, irrlicht sometimes fails to erport the good old standard resolutions + // for some odd reason, irrlicht sometimes fails to report the good old standard resolutions // those are always useful for windowed mode bool found_800_600 = false; bool found_1024_640 = false; bool found_1024_768 = false; - for(int n=0; n