More cleanup and simplification in kart selection screen to make it less loaded
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7506 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -1485,7 +1485,7 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
|
||||
if (widget->m_badges != 0)
|
||||
{
|
||||
drawBadgeOn(widget, rect);
|
||||
drawBadgeOn(widget, rect + position2d<s32>(widget->m_badge_x_shift, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1541,6 +1541,18 @@ void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
|
||||
video::ITexture* texture = irr_driver->getTexture(file_manager->getTextureFile("cup_bronze.png"));
|
||||
doDrawBadge(texture, rect, max_icon_size, false);
|
||||
}
|
||||
if (widget->m_badges & KEYBOARD_BADGE)
|
||||
{
|
||||
float max_icon_size = 0.43f;
|
||||
video::ITexture* texture = irr_driver->getTexture(file_manager->getGUIDir() + "keyboard.png");
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
}
|
||||
if (widget->m_badges & GAMEPAD_BADGE)
|
||||
{
|
||||
float max_icon_size = 0.43f;
|
||||
video::ITexture* texture = irr_driver->getTexture(file_manager->getGUIDir() + "gamepad.png");
|
||||
doDrawBadge(texture, rect, max_icon_size, true);
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ Widget::Widget(WidgetType type, bool reserve_id)
|
||||
m_w = -1;
|
||||
m_h = -1;
|
||||
m_id = -1;
|
||||
m_badge_x_shift = 0;
|
||||
m_element = NULL;
|
||||
m_title_font = false;
|
||||
m_type = type;
|
||||
|
||||
@@ -55,13 +55,17 @@ namespace GUIEngine
|
||||
enum BadgeType
|
||||
{
|
||||
/** display a lock on the widget, to mean a certain game feature is locked */
|
||||
LOCKED_BADGE = 0x1,
|
||||
LOCKED_BADGE = 1,
|
||||
/** display a green check on a widget, useful e.g. to display confirmation */
|
||||
OK_BADGE = 0x2,
|
||||
OK_BADGE = 2,
|
||||
/** display a red mark badge on the widget, useful e.g. to warn of an invalid choice */
|
||||
BAD_BADGE = 0x4,
|
||||
BAD_BADGE = 4,
|
||||
/** display a trophy badge on the widget, useful e.g. for challenges */
|
||||
TROPHY_BADGE = 0x8
|
||||
TROPHY_BADGE = 8,
|
||||
/** A gamepad icon */
|
||||
GAMEPAD_BADGE = 16,
|
||||
/** A keyboard icon */
|
||||
KEYBOARD_BADGE = 32
|
||||
};
|
||||
|
||||
|
||||
@@ -231,8 +235,12 @@ namespace GUIEngine
|
||||
bool m_focusable;
|
||||
|
||||
bool m_bottom_bar;
|
||||
|
||||
/** If a badge wouldn't look too pretty on the very side of the widget */
|
||||
int m_badge_x_shift;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* This is set to NULL by default; set to something else in a widget to mean
|
||||
* that events happening on this widget should also be passed to m_event_handler->transmitEvent,
|
||||
|
||||
@@ -123,6 +123,8 @@ void SpinnerWidget::add()
|
||||
m_children[0].m_properties[PROP_ID] = "left";
|
||||
m_children[0].m_id = m_children[0].m_element->getID();
|
||||
|
||||
m_badge_x_shift = subsize_left_arrow.getWidth();
|
||||
|
||||
// label
|
||||
if (m_graphical)
|
||||
{
|
||||
|
||||
@@ -182,6 +182,11 @@ public:
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#pragma mark PlayerKartWidget
|
||||
#endif
|
||||
|
||||
/** A widget representing the kart selection for a player (i.e. the player's number, name, the kart view, the kart's name) */
|
||||
class PlayerKartWidget : public Widget, public SpinnerWidget::ISpinnerConfirmListener
|
||||
{
|
||||
@@ -215,14 +220,13 @@ class PlayerKartWidget : public Widget, public SpinnerWidget::ISpinnerConfirmLis
|
||||
|
||||
public:
|
||||
/** Sub-widgets created by this widget */
|
||||
LabelWidget* m_player_ID_label;
|
||||
//LabelWidget* m_player_ID_label;
|
||||
PlayerNameSpinner* m_player_ident_spinner;
|
||||
ModelViewWidget* m_model_view;
|
||||
LabelWidget* m_kart_name;
|
||||
|
||||
|
||||
|
||||
LabelWidget *getPlayerIDLabel() {return m_player_ID_label;}
|
||||
//LabelWidget *getPlayerIDLabel() {return m_player_ID_label;}
|
||||
core::stringw deviceName;
|
||||
std::string m_kartInternalName;
|
||||
|
||||
@@ -252,6 +256,7 @@ public:
|
||||
target_w = m_w;
|
||||
target_h = m_h;
|
||||
|
||||
/*
|
||||
// ---- Player ID label
|
||||
if (associatedPlayer->getDevice()->getType() == DT_KEYBOARD)
|
||||
{
|
||||
@@ -278,6 +283,7 @@ public:
|
||||
|
||||
//playerID->setParent(this);
|
||||
m_children.push_back(m_player_ID_label);
|
||||
*/
|
||||
|
||||
// ---- Player identity spinner
|
||||
m_player_ident_spinner = new PlayerNameSpinner(parent, m_playerID);
|
||||
@@ -287,6 +293,16 @@ public:
|
||||
m_player_ident_spinner->m_h = player_name_h;
|
||||
//m_player_ident_spinner->m_event_handler = this;
|
||||
|
||||
|
||||
if (associatedPlayer->getDevice()->getType() == DT_KEYBOARD)
|
||||
{
|
||||
m_player_ident_spinner->setBadge(KEYBOARD_BADGE);
|
||||
}
|
||||
else if (associatedPlayer->getDevice()->getType() == DT_GAMEPAD)
|
||||
{
|
||||
m_player_ident_spinner->setBadge(GAMEPAD_BADGE);
|
||||
}
|
||||
|
||||
if (irrlichtWidgetID == -1)
|
||||
{
|
||||
m_player_ident_spinner->m_tab_down_root = g_root_id;
|
||||
@@ -371,8 +387,8 @@ public:
|
||||
GUIEngine::focusNothingForPlayer(m_playerID);
|
||||
}
|
||||
|
||||
if (m_player_ID_label->getIrrlichtElement() != NULL)
|
||||
m_player_ID_label->getIrrlichtElement()->remove();
|
||||
//if (m_player_ID_label->getIrrlichtElement() != NULL)
|
||||
// m_player_ID_label->getIrrlichtElement()->remove();
|
||||
|
||||
if (m_player_ident_spinner != NULL && m_player_ident_spinner->getIrrlichtElement() != NULL)
|
||||
{
|
||||
@@ -418,9 +434,9 @@ public:
|
||||
if (focus != NULL) focus->setFocusForPlayer(m_playerID);
|
||||
|
||||
//I18N: In kart selection screen (Will read like 'Player 1 (foobartech gamepad)')
|
||||
irr::core::stringw newLabel = StringUtils::insertValues(_("Player %i (%s)"), m_playerID + 1, deviceName.c_str());
|
||||
m_player_ID_label->setText( newLabel );
|
||||
m_player_ID_label->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_label", m_playerID);
|
||||
//irr::core::stringw newLabel = StringUtils::insertValues(_("Player %i (%s)"), m_playerID + 1, deviceName.c_str());
|
||||
//m_player_ID_label->setText( newLabel );
|
||||
//m_player_ID_label->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_label", m_playerID);
|
||||
|
||||
if (m_player_ident_spinner != NULL) m_player_ident_spinner->setID(m_playerID);
|
||||
} // setPlayerID
|
||||
@@ -453,7 +469,7 @@ public:
|
||||
}
|
||||
assert(mineInList);
|
||||
|
||||
m_player_ID_label->add();
|
||||
//m_player_ID_label->add();
|
||||
|
||||
// the first player will have an ID of its own to allow for keyboard navigation despite this widget being added last
|
||||
if (m_irrlicht_widget_ID != -1) m_player_ident_spinner->m_reserved_id = m_irrlicht_widget_ID;
|
||||
@@ -516,7 +532,14 @@ public:
|
||||
m_ready = true;
|
||||
|
||||
stringw playerNameString = m_player_ident_spinner->getStringValue();
|
||||
m_player_ID_label->setText( StringUtils::insertValues( _("%s is ready"), playerNameString ) );
|
||||
core::rect<s32> rect(core::position2di(m_player_ident_spinner->m_x,
|
||||
m_player_ident_spinner->m_y),
|
||||
core::dimension2di(m_player_ident_spinner->m_w,
|
||||
m_player_ident_spinner->m_h));
|
||||
GUIEngine::getGUIEnv()->addStaticText(StringUtils::insertValues( _("%s is ready"), playerNameString ).c_str(),
|
||||
rect)->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_CENTER );
|
||||
|
||||
//m_player_ID_label->setText( StringUtils::insertValues( _("%s is ready"), playerNameString ) );
|
||||
|
||||
m_children.remove(m_player_ident_spinner);
|
||||
m_player_ident_spinner->getIrrlichtElement()->remove();
|
||||
@@ -599,10 +622,10 @@ public:
|
||||
|
||||
setSize(m_x, m_y, m_w, m_h);
|
||||
|
||||
m_player_ID_label->move(player_id_x,
|
||||
player_id_y,
|
||||
player_id_w,
|
||||
player_id_h);
|
||||
//m_player_ID_label->move(player_id_x,
|
||||
// player_id_y,
|
||||
// player_id_w,
|
||||
// player_id_h);
|
||||
|
||||
if (m_player_ident_spinner != NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user