Give some eye candy to the GP list in the tracks selection screen + clean code along the way

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4689 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-02-12 02:21:07 +00:00
parent f29de6a89e
commit 10116f628b
8 changed files with 146 additions and 59 deletions

View File

@ -1107,6 +1107,9 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co
drawListSelection(rect, widget, focused); drawListSelection(rect, widget, focused);
} }
} }
// -----------------------------------------------------------------------------
void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, const bool pressed) void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, const bool pressed)
{ {
const int id = element->getID(); const int id = element->getID();
@ -1173,37 +1176,40 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
GUIEngine::getFont()->draw(idstring.c_str(), rect, color, true, true); GUIEngine::getFont()->draw(idstring.c_str(), rect, color, true, true);
} }
if (widget->m_lock_badge || widget->m_okay_badge || widget->m_bad_badge) if (widget->m_badges != 0)
{ {
drawBadgeOn(widget, rect); drawBadgeOn(widget, rect);
} }
} }
// -----------------------------------------------------------------------------
void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect) void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
{ {
video::ITexture* texture = NULL; video::ITexture* texture = NULL;
float max_icon_size = 0.35f; float max_icon_size = 0.35f;
bool badge_at_left = true; bool badge_at_left = true;
if (widget->m_lock_badge) if (widget->m_badges & LOCKED_BADGE)
{ {
texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png")); texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png"));
max_icon_size = 0.5f; // Lock badge can be quite big max_icon_size = 0.5f; // Lock badge can be quite big
} }
else if (widget->m_okay_badge) if (widget->m_badges & OK_BADGE)
{ {
texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png")); texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png"));
} }
else if (widget->m_bad_badge) if (widget->m_badges & BAD_BADGE)
{ {
texture = irr_driver->getTexture(file_manager->getTextureFile("red_mark.png")); texture = irr_driver->getTexture(file_manager->getTextureFile("red_mark.png"));
badge_at_left = false; badge_at_left = false;
} }
else if (widget->m_badges & TROPHY_BADGE)
{ {
assert(false); texture = irr_driver->getTexture(file_manager->getTextureFile("cup_bronze.png"));
return; badge_at_left = false;
} }
const core::dimension2d<u32>& texture_size = texture->getSize(); const core::dimension2d<u32>& texture_size = texture->getSize();
const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height; const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height;
const int h = rect.getHeight() <= 50 ? const int h = rect.getHeight() <= 50 ?
@ -1226,16 +1232,22 @@ void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
0 /* no clipping */, 0, true /* alpha */); 0 /* no clipping */, 0, true /* alpha */);
} }
// -----------------------------------------------------------------------------
void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip) void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{ {
process3DPane(element, rect, true /* pressed */ ); process3DPane(element, rect, true /* pressed */ );
} }
// -----------------------------------------------------------------------------
void Skin::draw3DButtonPaneStandard (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip) void Skin::draw3DButtonPaneStandard (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{ {
process3DPane(element, rect, false /* pressed */ ); process3DPane(element, rect, false /* pressed */ );
} }
// -----------------------------------------------------------------------------
void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool flat, bool fillBackGround, const core::rect< s32 > &rect, const core::rect< s32 > *clip) void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool flat, bool fillBackGround, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{ {
const int id = element->getID(); const int id = element->getID();
@ -1316,6 +1328,8 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool f
// GUIEngine::getDriver()->draw2DRectangle( SColor(255, 0, 150, 0), rect ); // GUIEngine::getDriver()->draw2DRectangle( SColor(255, 0, 150, 0), rect );
} }
// -----------------------------------------------------------------------------
void Skin::drawBGFadeColor() void Skin::drawBGFadeColor()
{ {
// fade out background // fade out background
@ -1326,6 +1340,8 @@ void Skin::drawBGFadeColor()
GUIEngine::getDriver()->getCurrentRenderTargetSize()) ); GUIEngine::getDriver()->getCurrentRenderTargetSize()) );
} }
// -----------------------------------------------------------------------------
#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR==7) #if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR==7)
core::rect< s32 > Skin::draw3DWindowBackground(IGUIElement *element, bool drawTitleBar, core::rect< s32 > Skin::draw3DWindowBackground(IGUIElement *element, bool drawTitleBar,
video::SColor titleBarColor, video::SColor titleBarColor,
@ -1365,30 +1381,43 @@ core::rect< s32 > Skin::draw3DWindowBackground(IGUIElement *element, bool drawTi
return rect; return rect;
} }
// -----------------------------------------------------------------------------
void Skin::draw3DMenuPane (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip) void Skin::draw3DMenuPane (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{ {
//printf("draw menu pane\n"); //printf("draw menu pane\n");
} }
// -----------------------------------------------------------------------------
void Skin::draw3DTabBody (IGUIElement *element, bool border, bool background, const core::rect< s32 > &rect, const core::rect< s32 > *clip, s32 tabHeight, gui::EGUI_ALIGNMENT alignment) void Skin::draw3DTabBody (IGUIElement *element, bool border, bool background, const core::rect< s32 > &rect, const core::rect< s32 > *clip, s32 tabHeight, gui::EGUI_ALIGNMENT alignment)
{ {
//printf("draw tab body\n"); //printf("draw tab body\n");
} }
// -----------------------------------------------------------------------------
void Skin::draw3DTabButton (IGUIElement *element, bool active, const core::rect< s32 > &rect, const core::rect< s32 > *clip, gui::EGUI_ALIGNMENT alignment) void Skin::draw3DTabButton (IGUIElement *element, bool active, const core::rect< s32 > &rect, const core::rect< s32 > *clip, gui::EGUI_ALIGNMENT alignment)
{ {
//printf("draw tab button\n"); //printf("draw tab button\n");
} }
// -----------------------------------------------------------------------------
void Skin::draw3DToolBar (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip) void Skin::draw3DToolBar (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{ {
} }
// -----------------------------------------------------------------------------
void Skin::drawIcon (IGUIElement *element, EGUI_DEFAULT_ICON icon, const core::position2di position, u32 starttime, u32 currenttime, bool loop, const core::rect< s32 > *clip) void Skin::drawIcon (IGUIElement *element, EGUI_DEFAULT_ICON icon, const core::position2di position, u32 starttime, u32 currenttime, bool loop, const core::rect< s32 > *clip)
{ {
// we won't let irrLicht decide when to call this, we draw them ourselves.
/* m_fallback_skin->drawIcon(element, icon, position, starttime, currenttime, loop, clip); */ /* m_fallback_skin->drawIcon(element, icon, position, starttime, currenttime, loop, clip); */
} }
// -----------------------------------------------------------------------------
video::SColor Skin::getColor (EGUI_DEFAULT_COLOR color) const video::SColor Skin::getColor (EGUI_DEFAULT_COLOR color) const
{ {
/* /*
@ -1433,16 +1462,23 @@ video::SColor Skin::getColor (EGUI_DEFAULT_COLOR color) const
} }
// -----------------------------------------------------------------------------
const wchar_t* Skin::getDefaultText (EGUI_DEFAULT_TEXT text) const const wchar_t* Skin::getDefaultText (EGUI_DEFAULT_TEXT text) const
{ {
// No idea what this is for
return L"SuperTuxKart"; return L"SuperTuxKart";
} }
// -----------------------------------------------------------------------------
IGUIFont* Skin::getFont (EGUI_DEFAULT_FONT which) const IGUIFont* Skin::getFont (EGUI_DEFAULT_FONT which) const
{ {
return GUIEngine::getFont(); return GUIEngine::getFont();
} }
// -----------------------------------------------------------------------------
u32 Skin::getIcon (EGUI_DEFAULT_ICON icon) const u32 Skin::getIcon (EGUI_DEFAULT_ICON icon) const
{ {
//return m_fallback_skin->getIcon(icon); //return m_fallback_skin->getIcon(icon);
@ -1450,44 +1486,58 @@ u32 Skin::getIcon (EGUI_DEFAULT_ICON icon) const
return 0; return 0;
} }
// -----------------------------------------------------------------------------
s32 Skin::getSize (EGUI_DEFAULT_SIZE texture_size) const s32 Skin::getSize (EGUI_DEFAULT_SIZE texture_size) const
{ {
return m_fallback_skin->getSize(texture_size); return m_fallback_skin->getSize(texture_size);
} }
// -----------------------------------------------------------------------------
IGUISpriteBank* Skin::getSpriteBank () const IGUISpriteBank* Skin::getSpriteBank () const
{ {
return m_fallback_skin->getSpriteBank(); return m_fallback_skin->getSpriteBank();
} }
//EGUI_SKIN_TYPE getType () const // -----------------------------------------------------------------------------
void Skin::setColor (EGUI_DEFAULT_COLOR which, video::SColor newColor) void Skin::setColor (EGUI_DEFAULT_COLOR which, video::SColor newColor)
{ {
m_fallback_skin->setColor(which, newColor); m_fallback_skin->setColor(which, newColor);
} }
// -----------------------------------------------------------------------------
void Skin::setDefaultText (EGUI_DEFAULT_TEXT which, const wchar_t *newText) void Skin::setDefaultText (EGUI_DEFAULT_TEXT which, const wchar_t *newText)
{ {
m_fallback_skin->setDefaultText(which, newText); m_fallback_skin->setDefaultText(which, newText);
} }
// -----------------------------------------------------------------------------
void Skin::setFont (IGUIFont *font, EGUI_DEFAULT_FONT which) void Skin::setFont (IGUIFont *font, EGUI_DEFAULT_FONT which)
{ {
m_fallback_skin->setFont(font, which); m_fallback_skin->setFont(font, which);
} }
// -----------------------------------------------------------------------------
void Skin::setIcon (EGUI_DEFAULT_ICON icon, u32 index) void Skin::setIcon (EGUI_DEFAULT_ICON icon, u32 index)
{ {
m_fallback_skin->setIcon(icon, index); m_fallback_skin->setIcon(icon, index);
} }
// -----------------------------------------------------------------------------
void Skin::setSize (EGUI_DEFAULT_SIZE which, s32 texture_size) void Skin::setSize (EGUI_DEFAULT_SIZE which, s32 texture_size)
{ {
m_fallback_skin->setSize(which, texture_size); m_fallback_skin->setSize(which, texture_size);
//printf("setting size\n"); //printf("setting size\n");
} }
// -----------------------------------------------------------------------------
void Skin::setSpriteBank (IGUISpriteBank *bank) void Skin::setSpriteBank (IGUISpriteBank *bank)
{ {
//printf("setting sprite bank\n"); //printf("setting sprite bank\n");

View File

@ -52,8 +52,11 @@ namespace GUIEngine
{ {
g_is_within_a_text_box = in; g_is_within_a_text_box = in;
} }
}
using namespace GUIEngine;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Widget::Widget(bool reserve_id) Widget::Widget(bool reserve_id)
{ {
m_magic_number = 0xCAFEC001; m_magic_number = 0xCAFEC001;
@ -84,11 +87,11 @@ Widget::Widget(bool reserve_id)
m_reserved_id = -1; m_reserved_id = -1;
m_lock_badge = false; m_badges = 0;
m_okay_badge = false;
m_bad_badge = false;
} }
// -----------------------------------------------------------------------------
Widget::~Widget() Widget::~Widget()
{ {
assert(m_magic_number == 0xCAFEC001); assert(m_magic_number == 0xCAFEC001);
@ -105,6 +108,8 @@ Widget::~Widget()
m_magic_number = 0xDEADBEEF; m_magic_number = 0xDEADBEEF;
} }
// -----------------------------------------------------------------------------
void Widget::elementRemoved() void Widget::elementRemoved()
{ {
assert(m_magic_number == 0xCAFEC001); assert(m_magic_number == 0xCAFEC001);
@ -123,8 +128,13 @@ void Widget::elementRemoved()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
static unsigned int id_counter = 0; namespace GUIEngine
static unsigned int id_counter_2 = 1000; // for items that can't be reached with keyboard navigation but can be clicked {
static unsigned int id_counter = 0;
/** // for items that can't be reached with keyboard navigation but can be clicked */
static unsigned int id_counter_2 = 1000;
}
int Widget::getNewID() int Widget::getNewID()
{ {
@ -134,6 +144,9 @@ int Widget::getNewNoFocusID()
{ {
return id_counter_2++; return id_counter_2++;
} }
// -----------------------------------------------------------------------------
/** When switching to a new screen, this function will be called to reset ID counters /** When switching to a new screen, this function will be called to reset ID counters
* (so we start again from ID 0, and don't grow to big numbers) */ * (so we start again from ID 0, and don't grow to big numbers) */
void Widget::resetIDCounters() void Widget::resetIDCounters()
@ -143,6 +156,7 @@ void Widget::resetIDCounters()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Widget::add() void Widget::add()
{ {
assert(m_magic_number == 0xCAFEC001); assert(m_magic_number == 0xCAFEC001);
@ -176,6 +190,8 @@ void Widget::setFocusForPlayer(const int playerID)
this->focused(playerID); this->focused(playerID);
} }
// -----------------------------------------------------------------------------
void Widget::unsetFocusForPlayer(const int playerID) void Widget::unsetFocusForPlayer(const int playerID)
{ {
assert(m_magic_number == 0xCAFEC001); assert(m_magic_number == 0xCAFEC001);
@ -184,6 +200,8 @@ void Widget::unsetFocusForPlayer(const int playerID)
m_player_focus[playerID] = false; m_player_focus[playerID] = false;
} }
// -----------------------------------------------------------------------------
/** /**
* \param playerID ID of the player you want to set/unset focus for, starting from 0 * \param playerID ID of the player you want to set/unset focus for, starting from 0
*/ */
@ -194,6 +212,7 @@ bool Widget::isFocusedForPlayer(const int playerID)
return m_player_focus[playerID]; return m_player_focus[playerID];
} }
// -----------------------------------------------------------------------------
/** /**
* Receives as string the raw property value retrieved from XML file. * Receives as string the raw property value retrieved from XML file.
@ -223,7 +242,9 @@ bool Widget::convertToCoord(std::string& x, int* absolute /* out */, int* percen
return true; return true;
} }
} }
// -----------------------------------------------------------------------------
void Widget::move(const int x, const int y, const int w, const int h) void Widget::move(const int x, const int y, const int w, const int h)
{ {
assert(m_magic_number == 0xCAFEC001); assert(m_magic_number == 0xCAFEC001);
@ -377,11 +398,11 @@ void Widget::readCoords(Widget* parent)
} }
} }
// -----------------------------------------------------------------------------
void Widget::setParent(IGUIElement* parent) void Widget::setParent(IGUIElement* parent)
{ {
assert(m_magic_number == 0xCAFEC001); assert(m_magic_number == 0xCAFEC001);
m_parent = parent; m_parent = parent;
} }
}

View File

@ -50,6 +50,12 @@ namespace GUIEngine
WTYPE_TEXTBOX WTYPE_TEXTBOX
}; };
const int LOCKED_BADGE = 0x1;
const int OK_BADGE = 0x2;
const int BAD_BADGE = 0x4;
const int TROPHY_BADGE = 0x8;
enum Property enum Property
{ {
PROP_ID = 100, PROP_ID = 100,
@ -207,14 +213,8 @@ namespace GUIEngine
/** Whether to show a bounding box around this widget (used for sections) */ /** Whether to show a bounding box around this widget (used for sections) */
bool m_show_bounding_box; bool m_show_bounding_box;
/** Show a 'locked' badge on this widget */ /** A bitmask of which badges to show, if any; choices are *_BADGE, defined above */
bool m_lock_badge; int m_badges;
/** Show a 'good' badge on this widget */
bool m_okay_badge;
/** Show a 'good' badge on this widget */
bool m_bad_badge;
/** Set to false if widget is something that should not receieve focus */ /** Set to false if widget is something that should not receieve focus */
bool m_focusable; bool m_focusable;

View File

@ -266,13 +266,13 @@ void DynamicRibbonWidget::setSubElements()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void DynamicRibbonWidget::addItem( const irr::core::stringw& user_name, const std::string& code_name, void DynamicRibbonWidget::addItem( const irr::core::stringw& user_name, const std::string& code_name,
const std::string& image_file, const bool locked ) const std::string& image_file, const unsigned int badges )
{ {
ItemDescription desc; ItemDescription desc;
desc.m_user_name = user_name; desc.m_user_name = user_name;
desc.m_code_name = code_name; desc.m_code_name = code_name;
desc.m_sshot_file = image_file; desc.m_sshot_file = image_file;
desc.m_locked = locked; desc.m_badges = badges;
m_items.push_back(desc); m_items.push_back(desc);
} }
@ -629,7 +629,7 @@ void DynamicRibbonWidget::updateItemDisplay()
icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name; icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name;
icon->setLabel(m_items[icon_id].m_user_name); icon->setLabel(m_items[icon_id].m_user_name);
icon->m_text = m_items[icon_id].m_user_name; icon->m_text = m_items[icon_id].m_user_name;
icon->m_lock_badge = m_items[icon_id].m_locked; icon->m_badges = m_items[icon_id].m_badges;
//std::wcout << L"Setting widget text '" << icon->m_text.c_str() << L"'\n"; //std::wcout << L"Setting widget text '" << icon->m_text.c_str() << L"'\n";

View File

@ -49,7 +49,7 @@ namespace GUIEngine
irr::core::stringw m_user_name; irr::core::stringw m_user_name;
std::string m_code_name; std::string m_code_name;
std::string m_sshot_file; std::string m_sshot_file;
bool m_locked; unsigned int m_badges;
}; };
/** A dynamic ribbon (builds upon RibbonWidget, adding dynamic contents creation and sizing, scrolling, multiple-row /** A dynamic ribbon (builds upon RibbonWidget, adding dynamic contents creation and sizing, scrolling, multiple-row
@ -155,9 +155,9 @@ namespace GUIEngine
* \param user_name The name that will shown to the user (may be translated) * \param user_name The name that will shown to the user (may be translated)
* \param code_name The non-translated internal name used to uniquely identify this item. * \param code_name The non-translated internal name used to uniquely identify this item.
* \param image_name A path to a texture that will the icon of this item (path relative to data dir, just like PROP_ICON) * \param image_name A path to a texture that will the icon of this item (path relative to data dir, just like PROP_ICON)
* \param locked Whether to add a lock icon to this item (does nop actual locing, only adds an icon) * \param badge Whether to add badges to this item
*/ */
void addItem( const irr::core::stringw& user_name, const std::string& code_name, const std::string& image_file, const bool locked=false ); void addItem( const irr::core::stringw& user_name, const std::string& code_name, const std::string& image_file, const unsigned int badge=0 );
/** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call /** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call
'updateItemDisplay' to update the display. */ 'updateItemDisplay' to update the display. */

View File

@ -430,7 +430,7 @@ FocusDispatcher* g_dispatcher = NULL;
player_id_w *= 2; player_id_w *= 2;
player_name_w = 0; player_name_w = 0;
modelView->m_okay_badge = true; modelView->m_badges = OK_BADGE;
/* /*
irr::video::ITexture* texture = irr_driver->getTexture( file_manager->getTextureFile("green_check.png").c_str() ) ; irr::video::ITexture* texture = irr_driver->getTexture( file_manager->getTextureFile("green_check.png").c_str() ) ;
const int check_size = 128; // TODO: reduce size on smaller resolutions? const int check_size = 128; // TODO: reduce size on smaller resolutions?
@ -1098,7 +1098,7 @@ bool KartSelectionScreen::validateIdentChoices()
const int amount = m_kart_widgets.size(); const int amount = m_kart_widgets.size();
// reset all marks, we'll re-add them n ext if errors are still there // reset all marks, we'll re-add them next if errors are still there
for (int n=0; n<amount; n++) for (int n=0; n<amount; n++)
{ {
// first check if the player name widget is still there, it won't be for those that confirmed // first check if the player name widget is still there, it won't be for those that confirmed
@ -1164,10 +1164,10 @@ bool KartSelectionScreen::validateKartChoices()
const int amount = m_kart_widgets.size(); const int amount = m_kart_widgets.size();
// reset all marks, we'll re-add them n ext if errors are still there // reset all marks, we'll re-add them next if errors are still there
for (int n=0; n<amount; n++) for (int n=0; n<amount; n++)
{ {
m_kart_widgets[n].modelView->m_bad_badge = false; m_kart_widgets[n].modelView->m_badges = 0;
} }
for (int n=0; n<amount; n++) for (int n=0; n<amount; n++)
@ -1186,13 +1186,13 @@ bool KartSelectionScreen::validateKartChoices()
{ {
std::cout << "--> Setting red badge on player " << n << std::endl; std::cout << "--> Setting red badge on player " << n << std::endl;
// player m is ready, so player n should not choose this name // player m is ready, so player n should not choose this name
m_kart_widgets[n].modelView->m_bad_badge = true; m_kart_widgets[n].modelView->m_badges = BAD_BADGE;
} }
else if (m_kart_widgets[n].isReady() && !m_kart_widgets[m].isReady()) else if (m_kart_widgets[n].isReady() && !m_kart_widgets[m].isReady())
{ {
std::cout << "--> Setting red badge on player " << m << std::endl; std::cout << "--> Setting red badge on player " << m << std::endl;
// player n is ready, so player m should not choose this name // player n is ready, so player m should not choose this name
m_kart_widgets[m].modelView->m_bad_badge = true; m_kart_widgets[m].modelView->m_badges = BAD_BADGE;
} }
else if (m_kart_widgets[n].isReady() && m_kart_widgets[m].isReady()) else if (m_kart_widgets[n].isReady() && m_kart_widgets[m].isReady())
{ {

View File

@ -61,12 +61,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -77,12 +77,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -93,12 +93,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -109,12 +109,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
@ -137,13 +137,13 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
//std::cout << "Setting bad badge!!!!\n"; //std::cout << "Setting bad badge!!!!\n";
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -154,12 +154,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -170,12 +170,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -186,12 +186,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }
{ {
@ -202,12 +202,12 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
// check if another binding already uses this key // check if another binding already uses this key
if (existing_bindings.find(binding_name) != existing_bindings.end()) if (existing_bindings.find(binding_name) != existing_bindings.end())
{ {
btn->m_bad_badge = true; btn->m_badges = BAD_BADGE;
} }
else else
{ {
existing_bindings.insert(binding_name); existing_bindings.insert(binding_name);
btn->m_bad_badge = false; btn->m_badges = 0;
} }
} }

View File

@ -127,17 +127,33 @@ void TracksScreen::init()
std::vector<std::string> tracks = gp->getTracks(); std::vector<std::string> tracks = gp->getTracks();
// TODO: use actual screenshots std::string sshot_file = "gui/main_help.png";
for (unsigned int t=0; t<tracks.size(); t++)
{
// TODO: add cycling screenshots instead of the still of a random track
Track* curr = track_manager->getTrack(tracks[t]);
if (curr == NULL)
{
std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId() << "' refers to track '"
<< tracks[t] << "', which does not exist.\n";
}
else
{
sshot_file = curr->getScreenshotFile();
break;
}
}
if (unlock_manager->isLocked(gp->getId())) if (unlock_manager->isLocked(gp->getId()))
{ {
gps_widget->addItem( _("Locked : solve active challenges to gain access to more!"), "locked", "gui/main_help.png", true ); gps_widget->addItem( _("Locked : solve active challenges to gain access to more!"), "locked", sshot_file, TROPHY_BADGE );
} }
else else
{ {
gps_widget->addItem( gp->getName(), gp->getId(), "gui/main_help.png", false ); gps_widget->addItem( gp->getName(), gp->getId(), sshot_file, TROPHY_BADGE );
} }
} }
gps_widget->updateItemDisplay(); gps_widget->updateItemDisplay();
// Reset track list everytime (accounts for locking changes, etc.) // Reset track list everytime (accounts for locking changes, etc.)
tracks_widget->clearItems(); tracks_widget->clearItems();