Implemented kart groups (still buggy for multiplayer kart selections)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3939 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0f0cff5842
commit
8574b97854
@ -16,6 +16,7 @@
|
||||
<tabs width="100%" height="25" id="kartgroups">
|
||||
<button id="standard" text="Standard"/>
|
||||
<button id="addons" text="Add-Ons"/>
|
||||
<button id="special" text="Special"/>
|
||||
<button id="all" text="All"/>
|
||||
</tabs>
|
||||
|
||||
|
@ -313,13 +313,18 @@ void EventHandler::processAction(const int action, const unsigned int value, Inp
|
||||
|
||||
void EventHandler::navigateUp(const int playerID, Input::InputType type, const bool pressedDown)
|
||||
{
|
||||
IGUIElement *el, *first=NULL, *closest=NULL;
|
||||
IGUIElement *el = NULL, *first=NULL, *closest=NULL;
|
||||
|
||||
// TODO : unify player 0 and players > 0 focus navigation to eliminate this kind of branching
|
||||
if (playerID == 0)
|
||||
{
|
||||
el = GUIEngine::getGUIEnv()->getFocus();
|
||||
}
|
||||
else
|
||||
el = GUIEngine::g_focus_for_player[playerID]->m_element;
|
||||
{
|
||||
Widget* widget = g_focus_for_player[playerID];
|
||||
if (widget != NULL) el = widget->m_element;
|
||||
}
|
||||
|
||||
Widget* w = (el == NULL) ? NULL : GUIEngine::getCurrentScreen()->getWidget( el->getID() );
|
||||
|
||||
@ -394,13 +399,18 @@ void EventHandler::navigateUp(const int playerID, Input::InputType type, const b
|
||||
|
||||
void EventHandler::navigateDown(const int playerID, Input::InputType type, const bool pressedDown)
|
||||
{
|
||||
IGUIElement *el, *first = NULL, *closest = NULL;
|
||||
IGUIElement *el = NULL, *first = NULL, *closest = NULL;
|
||||
|
||||
// TODO : unify player 0 and players > 0 focus navigation to eliminate this kind of branching
|
||||
if (playerID == 0)
|
||||
{
|
||||
el = GUIEngine::getGUIEnv()->getFocus();
|
||||
}
|
||||
else
|
||||
el = GUIEngine::g_focus_for_player[playerID]->m_element;
|
||||
{
|
||||
Widget* widget = GUIEngine::g_focus_for_player[playerID];
|
||||
if (widget != NULL) el = widget->m_element;
|
||||
}
|
||||
|
||||
Widget* w = (el == NULL) ? NULL : GUIEngine::getCurrentScreen()->getWidget( el->getID() );
|
||||
|
||||
|
@ -236,6 +236,11 @@ void RibbonGridWidget::addItem( std::string user_name, std::string code_name, st
|
||||
|
||||
m_items.push_back(desc);
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void RibbonGridWidget::clearItems()
|
||||
{
|
||||
m_items.clear();
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
|
@ -150,6 +150,8 @@ namespace GUIEngine
|
||||
call 'updateItemDisplay' or 'add') */
|
||||
void addItem( std::string user_name, std::string code_name, std::string image_file );
|
||||
|
||||
void clearItems();
|
||||
|
||||
/** Register a listener to be notified of selection changes within the ribbon */
|
||||
void registerHoverListener(RibbonGridHoverListener* listener);
|
||||
|
||||
|
@ -101,11 +101,11 @@ namespace KartSelectionScreen
|
||||
target_w = w;
|
||||
target_h = h;
|
||||
|
||||
if(associatedPlayer->getDevice()->getType() == DT_KEYBOARD)
|
||||
if (associatedPlayer->getDevice()->getType() == DT_KEYBOARD)
|
||||
{
|
||||
deviceName += "keyboard";
|
||||
}
|
||||
else if(associatedPlayer->getDevice()->getType() == DT_GAMEPAD)
|
||||
else if (associatedPlayer->getDevice()->getType() == DT_GAMEPAD)
|
||||
{
|
||||
deviceName += "gamepad";
|
||||
}
|
||||
@ -589,13 +589,14 @@ void menuEventKarts(Widget* widget, const std::string& name)
|
||||
if (!getCurrentScreen()->m_inited)
|
||||
{
|
||||
// Build kart list
|
||||
const int kart_amount = kart_properties_manager->getNumberOfKarts();
|
||||
std::vector<int> group = kart_properties_manager->getKartsInGroup("standard");
|
||||
const int kart_amount = group.size();
|
||||
|
||||
// add Tux (or whatever default kart) first
|
||||
std::string& default_kart = UserConfigParams::m_default_kart;
|
||||
for(int n=0; n<kart_amount; n++)
|
||||
{
|
||||
const KartProperties* prop = kart_properties_manager->getKartById(n);
|
||||
const KartProperties* prop = kart_properties_manager->getKartById(group[n]);
|
||||
if (prop->getIdent() == default_kart)
|
||||
{
|
||||
std::string icon_path = file_manager->getDataDir() ;
|
||||
@ -608,7 +609,7 @@ void menuEventKarts(Widget* widget, const std::string& name)
|
||||
// add others
|
||||
for(int n=0; n<kart_amount; n++)
|
||||
{
|
||||
const KartProperties* prop = kart_properties_manager->getKartById(n);
|
||||
const KartProperties* prop = kart_properties_manager->getKartById(group[n]);
|
||||
if (prop->getIdent() != default_kart)
|
||||
{
|
||||
std::string icon_path = file_manager->getDataDir() ;
|
||||
@ -653,8 +654,51 @@ void menuEventKarts(Widget* widget, const std::string& name)
|
||||
|
||||
getCurrentScreen()->m_inited = true;
|
||||
} // end if init
|
||||
|
||||
else if (name == "kartgroups")
|
||||
{
|
||||
RibbonWidget* tabs = getCurrentScreen()->getWidget<RibbonWidget>("kartgroups");
|
||||
assert(tabs != NULL);
|
||||
|
||||
else if(name == "karts")
|
||||
std::string selection = tabs->getSelectionIDString(GUI_PLAYER_ID);
|
||||
|
||||
RibbonGridWidget* w = getCurrentScreen()->getWidget<RibbonGridWidget>("karts");
|
||||
w->clearItems();
|
||||
|
||||
// TODO : preserve selection of karts for all players
|
||||
|
||||
if (selection == "all")
|
||||
{
|
||||
const int kart_amount = kart_properties_manager->getNumberOfKarts();
|
||||
|
||||
for(int n=0; n<kart_amount; n++)
|
||||
{
|
||||
const KartProperties* prop = kart_properties_manager->getKartById(n);
|
||||
|
||||
std::string icon_path = file_manager->getDataDir() ;
|
||||
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
|
||||
w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<int> group = kart_properties_manager->getKartsInGroup(selection);
|
||||
const int kart_amount = group.size();
|
||||
|
||||
for(int n=0; n<kart_amount; n++)
|
||||
{
|
||||
const KartProperties* prop = kart_properties_manager->getKartById(group[n]);
|
||||
|
||||
std::string icon_path = file_manager->getDataDir() ;
|
||||
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
|
||||
w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
w->updateItemDisplay();
|
||||
|
||||
}
|
||||
else if (name == "karts")
|
||||
{
|
||||
RibbonGridWidget* w = getCurrentScreen()->getWidget<RibbonGridWidget>("karts");
|
||||
assert( w != NULL );
|
||||
|
Loading…
Reference in New Issue
Block a user