Fixed compilation warnings, + warn if many keys are assigned to the same action in input settings
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4380 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9aba0daeb3
commit
7b8fc1e592
@ -93,7 +93,7 @@ namespace GUIEngine
|
||||
bool m_render_3d;
|
||||
|
||||
|
||||
int m_magic_number;
|
||||
unsigned int m_magic_number;
|
||||
public:
|
||||
bool throttleFPS;
|
||||
|
||||
|
@ -1152,8 +1152,8 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
SColor color(255, 255, 0, 0);
|
||||
GUIEngine::getFont()->draw(idstring.c_str(), rect, color, true, true);
|
||||
}
|
||||
|
||||
if (widget->m_lock_badge || widget->m_okay_badge)
|
||||
|
||||
if (widget->m_lock_badge || widget->m_okay_badge || widget->m_bad_badge)
|
||||
{
|
||||
drawBadgeOn(widget, rect);
|
||||
}
|
||||
@ -1163,6 +1163,7 @@ void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
|
||||
{
|
||||
video::ITexture* texture = NULL;
|
||||
float max_icon_size = 0.35f;
|
||||
bool badge_at_left = true;
|
||||
|
||||
if (widget->m_lock_badge)
|
||||
{
|
||||
@ -1173,6 +1174,11 @@ void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
|
||||
{
|
||||
texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png"));
|
||||
}
|
||||
else if (widget->m_bad_badge)
|
||||
{
|
||||
texture = irr_driver->getTexture(file_manager->getTextureFile("red_mark.png"));
|
||||
badge_at_left = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
@ -1180,14 +1186,20 @@ void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
|
||||
}
|
||||
const core::dimension2d<u32>& texture_size = texture->getSize();
|
||||
const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height;
|
||||
const int h = std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) );
|
||||
const int h = rect.getHeight() <= 50 ?
|
||||
rect.getHeight() :
|
||||
std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) );
|
||||
int w = (int)(aspectRatio*h);
|
||||
|
||||
const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height);
|
||||
|
||||
const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X,
|
||||
const core::rect< s32 > rect2 = core::rect< s32 >(badge_at_left ?
|
||||
rect.UpperLeftCorner.X :
|
||||
rect.LowerRightCorner.X - w,
|
||||
rect.LowerRightCorner.Y - h,
|
||||
rect.UpperLeftCorner.X + w,
|
||||
badge_at_left ?
|
||||
rect.UpperLeftCorner.X + w :
|
||||
rect.LowerRightCorner.X,
|
||||
rect.LowerRightCorner.Y);
|
||||
|
||||
GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area,
|
||||
|
@ -86,6 +86,7 @@ Widget::Widget(bool reserve_id)
|
||||
|
||||
m_lock_badge = false;
|
||||
m_okay_badge = false;
|
||||
m_bad_badge = false;
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
|
@ -93,7 +93,7 @@ namespace GUIEngine
|
||||
class Widget : public SkinWidgetContainer
|
||||
{
|
||||
protected:
|
||||
int m_magic_number;
|
||||
unsigned int m_magic_number;
|
||||
|
||||
friend class EventHandler;
|
||||
friend class RibbonWidget;
|
||||
@ -204,6 +204,9 @@ namespace GUIEngine
|
||||
/** 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 */
|
||||
bool m_focusable;
|
||||
|
||||
|
@ -617,7 +617,7 @@ class KartHoverListener : public DynamicRibbonHoverListener
|
||||
{
|
||||
KartSelectionScreen* m_parent;
|
||||
public:
|
||||
int m_magic_number;
|
||||
unsigned int m_magic_number;
|
||||
|
||||
KartHoverListener(KartSelectionScreen* parent)
|
||||
{
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <set>
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
@ -49,41 +50,165 @@ void OptionsScreenInput::updateInputButtons(DeviceConfig* config)
|
||||
abort();
|
||||
}
|
||||
|
||||
// to detect duplicate entries
|
||||
std::set<core::stringw> existing_bindings;
|
||||
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_up");
|
||||
btn->setLabel( config->getBindingAsString(PA_ACCEL) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_ACCEL);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_down");
|
||||
btn->setLabel( config->getBindingAsString(PA_BRAKE) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_BRAKE);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_left");
|
||||
btn->setLabel( config->getBindingAsString(PA_LEFT) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_LEFT);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_right");
|
||||
btn->setLabel( config->getBindingAsString(PA_RIGHT) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_RIGHT);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<core::stringw>::iterator it;
|
||||
|
||||
/*
|
||||
std::cout << "existing_bindings contains:";
|
||||
for ( it=existing_bindings.begin() ; it != existing_bindings.end(); it++ )
|
||||
{
|
||||
std::wcout << (*it).c_str() << ", ";
|
||||
}
|
||||
std::cout << "\n";
|
||||
*/
|
||||
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_fire");
|
||||
btn->setLabel( config->getBindingAsString(PA_FIRE) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_FIRE);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
//std::cout << "Setting bad badge!!!!\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_nitro");
|
||||
btn->setLabel( config->getBindingAsString(PA_NITRO) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_NITRO);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_drift");
|
||||
btn->setLabel( config->getBindingAsString(PA_DRIFT) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_DRIFT);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_rescue");
|
||||
btn->setLabel( config->getBindingAsString(PA_RESCUE) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_RESCUE);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
{
|
||||
ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_look_back");
|
||||
btn->setLabel( config->getBindingAsString(PA_LOOK_BACK) );
|
||||
core::stringw binding_name = config->getBindingAsString(PA_LOOK_BACK);
|
||||
btn->setLabel( binding_name );
|
||||
|
||||
// check if another binding already uses this key
|
||||
if (existing_bindings.find(binding_name) != existing_bindings.end())
|
||||
{
|
||||
btn->m_bad_badge = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
existing_bindings.insert(binding_name);
|
||||
btn->m_bad_badge = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user