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
This commit is contained in:
parent
09f9a85875
commit
9c0ec5c414
@ -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<m_row_amount; r++)
|
||||
{
|
||||
id = m_rows[r].findItemNamed(name);
|
||||
if (id > -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,24 +994,24 @@ 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<m_row_amount; r++)
|
||||
int iterations = 0; // a safeguard to avoid infinite loops (should not happen normally)
|
||||
|
||||
while (!findItemInRows(name.c_str(), &row, &id))
|
||||
{
|
||||
//printf("Looking for %s in row %i\n", name.c_str(), r);
|
||||
id = m_rows[r].findItemNamed(name.c_str());
|
||||
if (id > -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;
|
||||
}
|
||||
|
||||
if (row == -1)
|
||||
{
|
||||
//std::cerr << "DynamicRibbonWidget::setSelection cannot find item " << item_id << " (" << name.c_str() << ")\n";
|
||||
return false;
|
||||
iterations++;
|
||||
}
|
||||
|
||||
//std::cout << "Player " << playerID << " has item " << item_id << " (" << name.c_str() << ") in row " << row << std::endl;
|
||||
|
@ -164,6 +164,7 @@ 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:
|
||||
|
||||
|
@ -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<amount; n++)
|
||||
for (int n=0; n<amount; n++)
|
||||
{
|
||||
const int w = modes[n].width;
|
||||
const int h = modes[n].height;
|
||||
|
Loading…
Reference in New Issue
Block a user