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)
|
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]);
|
addWidgetsRecursively(widgets[n].m_children, &widgets[n]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -34,6 +34,8 @@ using namespace video;
|
|||||||
using namespace io;
|
using namespace io;
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
|
const bool ID_DEBUG = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Small utility to read config file info from a XML file.
|
* 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;
|
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);
|
SColor thecolor(255, w->r, w->g, w->b);
|
||||||
colorptr = new SColor[4]();
|
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[2] = thecolor;
|
||||||
colorptr[3] = 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)
|
if ((areas & BoxRenderParams::LEFT) != 0)
|
||||||
{
|
{
|
||||||
@ -962,7 +971,6 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co
|
|||||||
// list selection background
|
// list selection background
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -1047,6 +1055,14 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
|||||||
{
|
{
|
||||||
drawCheckBox(rect, widget, focused);
|
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)
|
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 Skin;
|
||||||
friend class DynamicRibbonWidget;
|
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
|
* Can be used in children to indicate whether a widget is selected or not
|
||||||
@ -273,6 +266,13 @@ namespace GUIEngine
|
|||||||
|
|
||||||
void requestFocus();
|
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
|
* 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
|
// 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;
|
if (m_irrlicht_widget_ID != -1) playerName->m_reserved_id = m_irrlicht_widget_ID;
|
||||||
|
else playerName->m_reserved_id = Widget::getNewNoFocusID();
|
||||||
playerName->add();
|
playerName->add();
|
||||||
|
playerName->getIrrlichtElement()->setTabStop(false);
|
||||||
|
|
||||||
modelView->add();
|
modelView->add();
|
||||||
kartName->add();
|
kartName->add();
|
||||||
@ -500,12 +502,16 @@ bool playerJoin(InputDevice* device, bool firstPlayer)
|
|||||||
|
|
||||||
// ---- Create player/kart widget
|
// ---- Create player/kart widget
|
||||||
PlayerKartWidget* newPlayer;
|
PlayerKartWidget* newPlayer;
|
||||||
//if (firstPlayer)
|
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);
|
newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size(), rightarea.m_reserved_id);
|
||||||
|
else
|
||||||
|
newPlayer = new PlayerKartWidget(aplayer, &rightarea, g_player_karts.size());
|
||||||
|
|
||||||
|
//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);
|
getCurrentScreen()->manualAddWidget(newPlayer);
|
||||||
newPlayer->add();
|
newPlayer->add();
|
||||||
@ -820,7 +826,7 @@ void renumberKarts()
|
|||||||
// FIXME : clean this mess, this file should not contain so many classes
|
// FIXME : clean this mess, this file should not contain so many classes
|
||||||
GUIEngine::EventPropagation PlayerNameSpinner::focused(const int playerID)
|
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
|
// since this screen is multiplayer, redirect focus to the right widget
|
||||||
if (this->playerID != playerID)
|
if (this->playerID != playerID)
|
||||||
@ -830,15 +836,15 @@ GUIEngine::EventPropagation PlayerNameSpinner::focused(const int playerID)
|
|||||||
{
|
{
|
||||||
if (g_player_karts[n].playerID == playerID)
|
if (g_player_karts[n].playerID == playerID)
|
||||||
{
|
{
|
||||||
//std::cout << "--> Redirecting focus for player " << playerID << " from spinner " << this->playerID <<
|
std::cout << "--> Redirecting focus for player " << playerID << " from spinner " << this->playerID <<
|
||||||
// " (ID " << m_element->getID() <<
|
" (ID " << m_element->getID() <<
|
||||||
// ") to spinner " << n << " (ID " << g_player_karts[n].playerName->m_element->getID() << ")" << std::endl;
|
") to spinner " << n << " (ID " << g_player_karts[n].playerName->m_element->getID() << ")" << std::endl;
|
||||||
//int IDbefore = GUIEngine::getGUIEnv()->getFocus()->getID();
|
int IDbefore = GUIEngine::getGUIEnv()->getFocus()->getID();
|
||||||
|
|
||||||
g_player_karts[n].playerName->setFocusForPlayer(playerID);
|
g_player_karts[n].playerName->setFocusForPlayer(playerID);
|
||||||
|
|
||||||
//int IDafter = GUIEngine::getGUIEnv()->getFocus()->getID();
|
int IDafter = GUIEngine::getGUIEnv()->getFocus()->getID();
|
||||||
//std::cout << "--> ID before : " << IDbefore << "; ID after : " << IDafter << std::endl;
|
std::cout << "--> ID before : " << IDbefore << "; ID after : " << IDafter << std::endl;
|
||||||
|
|
||||||
return GUIEngine::EVENT_BLOCK;
|
return GUIEngine::EVENT_BLOCK;
|
||||||
}
|
}
|
||||||
@ -847,7 +853,7 @@ GUIEngine::EventPropagation PlayerNameSpinner::focused(const int playerID)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//std::cout << "--> right spinner nothing to do\n";
|
std::cout << "--> right spinner nothing to do\n";
|
||||||
return GUIEngine::EVENT_LET;
|
return GUIEngine::EVENT_LET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user