Some cleanup over previous commit
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3933 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d9707351ea
commit
916fa160b1
@ -246,11 +246,11 @@ const std::string& RibbonGridWidget::getSelectionIDString(const int playerID)
|
||||
return nothing;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
const std::string& RibbonGridWidget::getSelectionText()
|
||||
const std::string& RibbonGridWidget::getSelectionText(const int playerID)
|
||||
{
|
||||
RibbonWidget* row = (RibbonWidget*)(m_rows.size() == 1 ? m_rows.get(0) : getSelectedRibbon());
|
||||
|
||||
if(row != NULL) return row->getSelectionText();
|
||||
if(row != NULL) return row->getSelectionText(playerID);
|
||||
|
||||
static const std::string nothing = "";
|
||||
return nothing;
|
||||
@ -439,7 +439,7 @@ void RibbonGridWidget::scroll(const int x_delta)
|
||||
RibbonWidget* ribbon = m_rows.get(0); // there is a single row when we can select items
|
||||
int id = m_selected_item[n] - m_scroll_offset;
|
||||
if (id < 0) id += m_items.size();
|
||||
ribbon->setSelection(id);
|
||||
ribbon->setSelection(id, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -486,8 +486,8 @@ void RibbonGridWidget::updateLabel(RibbonWidget* from_this_ribbon)
|
||||
RibbonWidget* row = from_this_ribbon ? from_this_ribbon : (RibbonWidget*)getSelectedRibbon();
|
||||
if (row == NULL) return;
|
||||
|
||||
|
||||
std::string selection_id = row->getSelectionIDString();
|
||||
// FIXME? Don't hardcode player 0 (even though label can only work with a single player)
|
||||
std::string selection_id = row->getSelectionIDString(0);
|
||||
|
||||
const int amount = m_items.size();
|
||||
for (int n=0; n<amount; n++)
|
||||
@ -580,7 +580,7 @@ void RibbonGridWidget::setSelection(int item_id)
|
||||
RibbonWidget* ribbon = m_rows.get(0); // there is a single row when we can select items
|
||||
int id = m_selected_item[PLAYER_ID] - m_scroll_offset;
|
||||
if (id < 0) id += m_items.size();
|
||||
ribbon->setSelection(id);
|
||||
ribbon->setSelection(id, PLAYER_ID);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -164,10 +164,10 @@ namespace GUIEngine
|
||||
void updateItemDisplay();
|
||||
|
||||
/** Get the internal name (ID) of the selected item */
|
||||
const std::string& getSelectionIDString(const int playerID=0);
|
||||
const std::string& getSelectionIDString(const int playerID);
|
||||
|
||||
/** Get the user-visible text of the selected item */
|
||||
const std::string& getSelectionText();
|
||||
const std::string& getSelectionText(const int playerID);
|
||||
|
||||
/** Select an item from its numerical ID. Only for [1-row] combo ribbons.
|
||||
ID ranges from {0} to {number of items added through 'addItem' - 1} */
|
||||
|
@ -81,16 +81,16 @@ namespace GUIEngine
|
||||
int getSelection(const int playerID) const { return m_selection[playerID]; }
|
||||
|
||||
/** Returns the string ID (internal name) of the selection */
|
||||
const std::string& getSelectionIDString(const int playerID=0) { return m_children[m_selection[playerID]].m_properties[PROP_ID]; }
|
||||
const std::string& getSelectionIDString(const int playerID) { return m_children[m_selection[playerID]].m_properties[PROP_ID]; }
|
||||
|
||||
/** Returns the user-visible text of the selection */
|
||||
const std::string& getSelectionText(const int playerID=0) { return m_children[m_selection[playerID]].m_properties[PROP_TEXT]; }
|
||||
const std::string& getSelectionText(const int playerID) { return m_children[m_selection[playerID]].m_properties[PROP_TEXT]; }
|
||||
|
||||
/** Sets the ID of the selected item within the ribbon */
|
||||
void setSelection(const int i, const int playerID=0) { m_selection[playerID] = i; updateSelection(); }
|
||||
void setSelection(const int i, const int playerID) { m_selection[playerID] = i; updateSelection(); }
|
||||
|
||||
/** Select an item in the ribbon by its internal name */
|
||||
void select(std::string item, const int playerID=0);
|
||||
void select(std::string item, const int playerID);
|
||||
|
||||
/** When each item has a label, this method can be used to rename an item
|
||||
(especially used in scrolling ribbons, when scrolling occurs by renaming
|
||||
|
@ -202,7 +202,7 @@ namespace OptionsScreen
|
||||
RibbonGridWidget* w1 = getCurrentScreen()->getWidget<RibbonGridWidget>("resolutions");
|
||||
assert(w1 != NULL);
|
||||
|
||||
const std::string& res = w1->getSelectionIDString();
|
||||
const std::string& res = w1->getSelectionIDString(GUI_PLAYER_ID);
|
||||
|
||||
int w = -1, h = -1;
|
||||
if( sscanf(res.c_str(), "%ix%i", &w, &h) != 2 || w == -1 || h == -1 )
|
||||
@ -357,7 +357,7 @@ namespace OptionsScreen
|
||||
RibbonGridWidget* devices = getCurrentScreen()->getWidget<RibbonGridWidget>("devices");
|
||||
assert(devices != NULL);
|
||||
|
||||
const std::string& selection = devices->getSelectionIDString();
|
||||
const std::string& selection = devices->getSelectionIDString(GUI_PLAYER_ID);
|
||||
if( selection.find("gamepad") != std::string::npos )
|
||||
{
|
||||
int i = -1, read = 0;
|
||||
@ -428,21 +428,22 @@ namespace OptionsScreen
|
||||
|
||||
RibbonGridWidget* devices = getCurrentScreen()->getWidget<RibbonGridWidget>("devices");
|
||||
assert( devices != NULL );
|
||||
std::cout << "\n% Entering sensing mode for " << devices->getSelectionIDString().c_str() << std::endl;
|
||||
std::cout << "\n% Entering sensing mode for " << devices->getSelectionIDString(GUI_PLAYER_ID).c_str() << std::endl;
|
||||
|
||||
new PressAKeyDialog(0.4f, 0.4f);
|
||||
|
||||
if(devices->getSelectionIDString() == "keyboard")
|
||||
std::string selection = devices->getSelectionIDString(GUI_PLAYER_ID);
|
||||
if (selection == "keyboard")
|
||||
{
|
||||
input_manager->setMode(InputManager::INPUT_SENSE_KEYBOARD);
|
||||
}
|
||||
else if(devices->getSelectionIDString().find("gamepad") != std::string::npos)
|
||||
else if (selection.find("gamepad") != std::string::npos)
|
||||
{
|
||||
input_manager->setMode(InputManager::INPUT_SENSE_GAMEPAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "unknown selection device in options : " << devices->getSelectionIDString() << std::endl;
|
||||
std::cerr << "unknown selection device in options : " << selection.c_str() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -456,10 +457,12 @@ namespace OptionsScreen
|
||||
RibbonGridWidget* devices = getCurrentScreen()->getWidget<RibbonGridWidget>("devices");
|
||||
assert( devices != NULL );
|
||||
|
||||
const bool keyboard = sensedInput->type == Input::IT_KEYBOARD && devices->getSelectionIDString() == "keyboard";
|
||||
std::string deviceID = devices->getSelectionIDString(GUI_PLAYER_ID);
|
||||
|
||||
const bool keyboard = sensedInput->type == Input::IT_KEYBOARD && deviceID== "keyboard";
|
||||
const bool gamepad = (sensedInput->type == Input::IT_STICKMOTION ||
|
||||
sensedInput->type == Input::IT_STICKBUTTON) &&
|
||||
devices->getSelectionIDString().find("gamepad") != std::string::npos;
|
||||
deviceID.find("gamepad") != std::string::npos;
|
||||
|
||||
if(!keyboard && !gamepad) return;
|
||||
if(gamepad)
|
||||
@ -496,7 +499,7 @@ namespace OptionsScreen
|
||||
std::cout << "Sensed unknown gamepad event type??\n";
|
||||
|
||||
int configID = -1;
|
||||
sscanf( devices->getSelectionIDString().c_str(), "gamepad%i", &configID );
|
||||
sscanf( devices->getSelectionIDString(GUI_PLAYER_ID).c_str(), "gamepad%i", &configID );
|
||||
|
||||
/*
|
||||
if(sscanf( devices->getSelectionIDString().c_str(), "gamepad%i", &gamepadID ) != 1 ||
|
||||
@ -605,9 +608,9 @@ namespace OptionsScreen
|
||||
RibbonWidget* ribbon = getCurrentScreen()->getWidget<RibbonWidget>("options_choice");
|
||||
if(ribbon != NULL)
|
||||
{
|
||||
if(screen_name == "options_av.stkgui") ribbon->select( "audio_video" );
|
||||
else if(screen_name == "options_players.stkgui") ribbon->select( "players" );
|
||||
else if(screen_name == "options_input.stkgui") ribbon->select( "controls" );
|
||||
if (screen_name == "options_av.stkgui") ribbon->select( "audio_video", GUI_PLAYER_ID );
|
||||
else if (screen_name == "options_players.stkgui") ribbon->select( "players", GUI_PLAYER_ID );
|
||||
else if (screen_name == "options_input.stkgui") ribbon->select( "controls", GUI_PLAYER_ID );
|
||||
}
|
||||
|
||||
if(screen_name == "options_av.stkgui") initAudioVideo(widget, name);
|
||||
@ -616,7 +619,7 @@ namespace OptionsScreen
|
||||
}
|
||||
else if(name == "options_choice")
|
||||
{
|
||||
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString().c_str();
|
||||
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str();
|
||||
|
||||
if(selection == "audio_video") StateManager::get()->replaceTopMostMenu("options_av.stkgui");
|
||||
else if(selection == "players") StateManager::get()->replaceTopMostMenu("options_players.stkgui");
|
||||
|
@ -132,7 +132,7 @@ void StateManager::menuEventMain(Widget* widget, const std::string& name)
|
||||
{
|
||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||
if(ribbon == NULL) return; // only interesting stuff in main menu is the ribbons
|
||||
std::string selection = ribbon->getSelectionIDString().c_str();
|
||||
std::string selection = ribbon->getSelectionIDString(GUI_PLAYER_ID);
|
||||
|
||||
|
||||
if(selection == "new")
|
||||
@ -168,7 +168,7 @@ void StateManager::menuEventRaceSetup(Widget* widget, const std::string& name)
|
||||
{
|
||||
RibbonWidget* w = getCurrentScreen()->getWidget<RibbonWidget>("difficulty");
|
||||
assert( w != NULL );
|
||||
w->setSelection( race_manager->getDifficulty() );
|
||||
w->setSelection( race_manager->getDifficulty(), GUI_PLAYER_ID );
|
||||
|
||||
SpinnerWidget* kartamount = getCurrentScreen()->getWidget<SpinnerWidget>("aikartamount");
|
||||
kartamount->setValue( race_manager->getNumKarts() - race_manager->getNumPlayers() );
|
||||
@ -199,7 +199,7 @@ void StateManager::menuEventRaceSetup(Widget* widget, const std::string& name)
|
||||
{
|
||||
RibbonWidget* w = dynamic_cast<RibbonWidget*>(widget);
|
||||
assert(w != NULL);
|
||||
const std::string& selection = w->getSelectionIDString();
|
||||
const std::string& selection = w->getSelectionIDString(GUI_PLAYER_ID);
|
||||
|
||||
if(selection == "novice")
|
||||
{
|
||||
@ -220,7 +220,7 @@ void StateManager::menuEventRaceSetup(Widget* widget, const std::string& name)
|
||||
else if(name == "gamemode")
|
||||
{
|
||||
RibbonGridWidget* w = dynamic_cast<RibbonGridWidget*>(widget);
|
||||
const std::string selectedMode = w->getSelectionIDString();
|
||||
const std::string selectedMode = w->getSelectionIDString(GUI_PLAYER_ID);
|
||||
|
||||
if (selectedMode == "normal")
|
||||
{
|
||||
@ -348,9 +348,9 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
|
||||
RibbonGridWidget* w2 = dynamic_cast<RibbonGridWidget*>(widget);
|
||||
if(w2 != NULL)
|
||||
{
|
||||
std::cout << "Clicked on track " << w2->getSelectionIDString().c_str() << std::endl;
|
||||
std::cout << "Clicked on track " << w2->getSelectionIDString(GUI_PLAYER_ID).c_str() << std::endl;
|
||||
|
||||
Track* clickedTrack = track_manager->getTrack(w2->getSelectionIDString());
|
||||
Track* clickedTrack = track_manager->getTrack(w2->getSelectionIDString(GUI_PLAYER_ID));
|
||||
if (clickedTrack != NULL)
|
||||
{
|
||||
ITexture* screenshot = GUIEngine::getDriver()->getTexture( clickedTrack->getScreenshotFile().c_str() );
|
||||
@ -363,7 +363,7 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
|
||||
{
|
||||
RibbonWidget* w = dynamic_cast<RibbonWidget*>(widget);
|
||||
if(w != NULL)
|
||||
std::cout << "Clicked on GrandPrix " << w->getSelectionIDString().c_str() << std::endl;
|
||||
std::cout << "Clicked on GrandPrix " << w->getSelectionIDString(GUI_PLAYER_ID).c_str() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -382,15 +382,15 @@ void StateManager::menuEventHelp(Widget* widget, const std::string& name)
|
||||
if(w != NULL)
|
||||
{
|
||||
const std::string& screen_name = getCurrentScreen()->getName();
|
||||
if(screen_name == "help1.stkgui") w->select( "page1" );
|
||||
else if(screen_name == "help2.stkgui") w->select( "page2" );
|
||||
else if(screen_name == "help3.stkgui") w->select( "page3" );
|
||||
if(screen_name == "help1.stkgui") w->select( "page1", GUI_PLAYER_ID );
|
||||
else if(screen_name == "help2.stkgui") w->select( "page2", GUI_PLAYER_ID );
|
||||
else if(screen_name == "help3.stkgui") w->select( "page3", GUI_PLAYER_ID );
|
||||
}
|
||||
}
|
||||
// -- options
|
||||
else if(name == "category")
|
||||
{
|
||||
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString().c_str();
|
||||
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str();
|
||||
|
||||
if(selection == "page1") replaceTopMostMenu("help1.stkgui");
|
||||
else if(selection == "page2") replaceTopMostMenu("help2.stkgui");
|
||||
|
@ -33,6 +33,8 @@ namespace GUIEngine
|
||||
class Widget;
|
||||
}
|
||||
|
||||
const static int GUI_PLAYER_ID = 0;
|
||||
|
||||
class StateManager : public GUIEngine::AbstractStateManager
|
||||
{
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user