Improved multiplayer kart selection. Now player can select his name properly, other players too - though atm only player 1 can go back.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4053 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
893c430cfc
commit
477773e3ed
@ -262,6 +262,7 @@ void Screen::addWidgetsRecursively(ptr_vector<Widget>& widgets, Widget* parent)
|
||||
{
|
||||
if (widgets[n].m_type == WTYPE_DIV)
|
||||
{
|
||||
widgets[n].add(); // Will do nothing, but will maybe reserve an ID
|
||||
addWidgetsRecursively(widgets[n].m_children, &widgets[n]);
|
||||
}
|
||||
else
|
||||
|
@ -34,6 +34,8 @@ using namespace video;
|
||||
using namespace io;
|
||||
using namespace gui;
|
||||
|
||||
const bool ID_DEBUG = false;
|
||||
|
||||
/**
|
||||
* Small utility to read config file info from a XML file.
|
||||
*/
|
||||
@ -507,7 +509,7 @@ X##_yflip.LowerRightCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y1;}
|
||||
|
||||
SColor* colorptr = NULL;
|
||||
|
||||
if (w->r != -1 && w->g != -1 && w->b != -1)
|
||||
if (w->r != -1 && w->g != -1 && w->b != -1 || ID_DEBUG)
|
||||
{
|
||||
SColor thecolor(255, w->r, w->g, w->b);
|
||||
colorptr = new SColor[4]();
|
||||
@ -516,6 +518,13 @@ X##_yflip.LowerRightCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y1;}
|
||||
colorptr[2] = thecolor;
|
||||
colorptr[3] = thecolor;
|
||||
}
|
||||
if (ID_DEBUG)
|
||||
{
|
||||
colorptr[0].setAlpha(100);
|
||||
colorptr[1].setAlpha(100);
|
||||
colorptr[2].setAlpha(100);
|
||||
colorptr[3].setAlpha(100);
|
||||
}
|
||||
|
||||
if ((areas & BoxRenderParams::LEFT) != 0)
|
||||
{
|
||||
@ -961,8 +970,7 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co
|
||||
{
|
||||
// list selection background
|
||||
drawListSelection(rect, widget, focused);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, const bool pressed)
|
||||
{
|
||||
@ -1047,6 +1055,14 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
{
|
||||
drawCheckBox(rect, widget, focused);
|
||||
}
|
||||
|
||||
if (ID_DEBUG && id != -1)
|
||||
{
|
||||
irr::core::stringw idstring;
|
||||
idstring += id;
|
||||
SColor color(255, 255, 0, 0);
|
||||
GUIEngine::getFont()->draw(idstring.c_str(), rect, color, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
|
||||
|
@ -101,13 +101,6 @@ namespace GUIEngine
|
||||
friend class Skin;
|
||||
friend class DynamicRibbonWidget;
|
||||
|
||||
/**
|
||||
* These methods provide new unique IDs each time you call them.
|
||||
* Since IDs are used to determine tabbing order, "non-tabbable"
|
||||
* objects are being given very different IDs so that they don't interfere.
|
||||
*/
|
||||
int getNewID();
|
||||
int getNewNoFocusID();
|
||||
|
||||
/**
|
||||
* Can be used in children to indicate whether a widget is selected or not
|
||||
@ -273,6 +266,13 @@ namespace GUIEngine
|
||||
|
||||
void requestFocus();
|
||||
|
||||
/**
|
||||
* These methods provide new unique IDs each time you call them.
|
||||
* Since IDs are used to determine tabbing order, "non-tabbable"
|
||||
* objects are being given very different IDs so that they don't interfere.
|
||||
*/
|
||||
static int getNewID();
|
||||
static int getNewNoFocusID();
|
||||
|
||||
/**
|
||||
* Override in children to possibly receive updates (you may need to register to
|
||||
|
@ -234,7 +234,9 @@ namespace KartSelectionScreen
|
||||
|
||||
// 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) playerName->m_reserved_id = m_irrlicht_widget_ID;
|
||||
else playerName->m_reserved_id = Widget::getNewNoFocusID();
|
||||
playerName->add();
|
||||
playerName->getIrrlichtElement()->setTabStop(false);
|
||||
|
||||
modelView->add();
|
||||
kartName->add();
|
||||
@ -500,12 +502,16 @@ bool playerJoin(InputDevice* device, bool firstPlayer)
|
||||
|
||||
// ---- Create player/kart widget
|
||||
PlayerKartWidget* newPlayer;
|
||||
//if (firstPlayer)
|
||||
// newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size(), rightarea.m_reserved_id);
|
||||
//else
|
||||
// newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size());
|
||||
if (firstPlayer)
|
||||
newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size(), rightarea.m_reserved_id);
|
||||
else
|
||||
newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size());
|
||||
|
||||
newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size(), rightarea.m_reserved_id);
|
||||
//FIXME : currently, only player 0's spinner is focusable - and it dispatches focus to one of
|
||||
// the others as needed. But if player 0 leaves, it will be impossible for remaining players
|
||||
// to select their ident
|
||||
|
||||
//newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size(), rightarea.m_reserved_id);
|
||||
|
||||
getCurrentScreen()->manualAddWidget(newPlayer);
|
||||
newPlayer->add();
|
||||
@ -820,7 +826,7 @@ void renumberKarts()
|
||||
// FIXME : clean this mess, this file should not contain so many classes
|
||||
GUIEngine::EventPropagation PlayerNameSpinner::focused(const int playerID)
|
||||
{
|
||||
//std::cout << "Player name spinner " << this->playerID << " focused by " << playerID << std::endl;
|
||||
std::cout << "Player name spinner " << this->playerID << " focused by " << playerID << std::endl;
|
||||
|
||||
// since this screen is multiplayer, redirect focus to the right widget
|
||||
if (this->playerID != playerID)
|
||||
@ -830,15 +836,15 @@ GUIEngine::EventPropagation PlayerNameSpinner::focused(const int playerID)
|
||||
{
|
||||
if (g_player_karts[n].playerID == playerID)
|
||||
{
|
||||
//std::cout << "--> Redirecting focus for player " << playerID << " from spinner " << this->playerID <<
|
||||
// " (ID " << m_element->getID() <<
|
||||
// ") to spinner " << n << " (ID " << g_player_karts[n].playerName->m_element->getID() << ")" << std::endl;
|
||||
//int IDbefore = GUIEngine::getGUIEnv()->getFocus()->getID();
|
||||
std::cout << "--> Redirecting focus for player " << playerID << " from spinner " << this->playerID <<
|
||||
" (ID " << m_element->getID() <<
|
||||
") to spinner " << n << " (ID " << g_player_karts[n].playerName->m_element->getID() << ")" << std::endl;
|
||||
int IDbefore = GUIEngine::getGUIEnv()->getFocus()->getID();
|
||||
|
||||
g_player_karts[n].playerName->setFocusForPlayer(playerID);
|
||||
|
||||
//int IDafter = GUIEngine::getGUIEnv()->getFocus()->getID();
|
||||
//std::cout << "--> ID before : " << IDbefore << "; ID after : " << IDafter << std::endl;
|
||||
int IDafter = GUIEngine::getGUIEnv()->getFocus()->getID();
|
||||
std::cout << "--> ID before : " << IDbefore << "; ID after : " << IDafter << std::endl;
|
||||
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
@ -847,7 +853,7 @@ GUIEngine::EventPropagation PlayerNameSpinner::focused(const int playerID)
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout << "--> right spinner nothing to do\n";
|
||||
std::cout << "--> right spinner nothing to do\n";
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user