Improved vertical navigation in kart selection screen for players > 0
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3943 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
4b19a059f0
commit
f89cacbf5f
@ -116,9 +116,10 @@ bool EventHandler::onGUIEvent(const SEvent& event)
|
||||
case EGET_ELEMENT_FOCUSED:
|
||||
{
|
||||
Widget* el = GUIEngine::getCurrentScreen()->getWidget(id);
|
||||
if(el == NULL) break;
|
||||
if (el == NULL) break;
|
||||
|
||||
el->focused();
|
||||
// FIXME: don't hardcode player 0
|
||||
el->focused(0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ void Widget::setFocusForPlayer(const int playerID)
|
||||
|
||||
m_player_focus[playerID] = true;
|
||||
GUIEngine::g_focus_for_player[playerID] = this;
|
||||
|
||||
this->focused(playerID);
|
||||
}
|
||||
|
||||
void Widget::unsetFocusForPlayer(const int playerID)
|
||||
|
@ -128,7 +128,7 @@ namespace GUIEngine
|
||||
virtual bool mouseHovered(Widget* child) { return false; }
|
||||
|
||||
/** override in children if you need to know when the widget is focused */
|
||||
virtual void focused() { isWithinATextBox = false; }
|
||||
virtual void focused(const int playerID) { isWithinATextBox = false; }
|
||||
|
||||
/**
|
||||
* The XML loader stored coords in their raw string form inside this widget.
|
||||
|
@ -413,29 +413,25 @@ bool RibbonGridWidget::mouseHovered(Widget* child)
|
||||
return false;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void RibbonGridWidget::focused()
|
||||
void RibbonGridWidget::focused(const int playerID)
|
||||
{
|
||||
Widget::focused();
|
||||
Widget::focused(playerID);
|
||||
updateLabel();
|
||||
|
||||
const int listenerAmount = m_hover_listeners.size();
|
||||
for(int n=0; n<listenerAmount; n++)
|
||||
{
|
||||
// FIXME: don't hardcode player 0
|
||||
const int playerID = 0;
|
||||
m_hover_listeners[n].onSelectionChanged(this, getSelectedRibbon(playerID)->getSelectionIDString(playerID), playerID);
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void RibbonGridWidget::onRowChange(RibbonWidget* row)
|
||||
void RibbonGridWidget::onRowChange(RibbonWidget* row, const int playerID)
|
||||
{
|
||||
updateLabel(row);
|
||||
|
||||
const int listenerAmount = m_hover_listeners.size();
|
||||
for (int n=0; n<listenerAmount; n++)
|
||||
{
|
||||
// FIXME: don't hardcode player 0
|
||||
const int playerID = 0;
|
||||
m_hover_listeners[n].onSelectionChanged(this, row->getSelectionIDString(playerID), playerID);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ namespace GUIEngine
|
||||
void propagateSelection();
|
||||
|
||||
/** Callback called widget is focused */
|
||||
void focused();
|
||||
void focused(const int playerID);
|
||||
|
||||
bool transmitEvent(Widget* w, std::string& originator, const int playerID);
|
||||
|
||||
@ -135,7 +135,7 @@ namespace GUIEngine
|
||||
int m_selected_item[32]; // FIXME: 32 is arbitrary, settle for a max number of players
|
||||
|
||||
/** Callbacks */
|
||||
void onRowChange(RibbonWidget* row);
|
||||
void onRowChange(RibbonWidget* row, const int playerID);
|
||||
void add();
|
||||
bool mouseHovered(Widget* child);
|
||||
|
||||
|
@ -254,20 +254,20 @@ bool RibbonWidget::leftPressed(const int playerID)
|
||||
return m_ribbon_type != RIBBON_TOOLBAR;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void RibbonWidget::focused()
|
||||
void RibbonWidget::focused(const int playerID)
|
||||
{
|
||||
Widget::focused();
|
||||
Widget::focused(playerID);
|
||||
|
||||
if (m_children.size() < 1) return; // empty ribbon
|
||||
|
||||
if (m_focus == NULL) m_focus = m_children.get(m_selection[0]); // FIXME : don't hardcode player 0 here
|
||||
if (m_focus == NULL) m_focus = m_children.get(m_selection[playerID]);
|
||||
|
||||
if (m_event_handler != NULL)
|
||||
{
|
||||
GUIEngine::getGUIEnv()->setFocus(m_focus->m_element);
|
||||
if (playerID == 0) GUIEngine::getGUIEnv()->setFocus(m_focus->m_element);
|
||||
|
||||
// FIXME : unclean, children ribbons shouldn't need to know about their parent
|
||||
((RibbonGridWidget*)m_event_handler)->onRowChange( this );
|
||||
((RibbonGridWidget*)m_event_handler)->onRowChange( this, playerID );
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -62,7 +62,7 @@ namespace GUIEngine
|
||||
bool leftPressed(const int playerID=0);
|
||||
bool mouseHovered(Widget* child);
|
||||
bool transmitEvent(Widget* w, std::string& originator, const int playerID=0);
|
||||
void focused();
|
||||
void focused(const int playerID);
|
||||
|
||||
ptr_vector<IGUIStaticText, REF> m_labels;
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace GUIEngine
|
||||
void add();
|
||||
void addItem(const char* item);
|
||||
|
||||
virtual void focused() { isWithinATextBox = true; }
|
||||
virtual void focused(const int playerID) { isWithinATextBox = true; }
|
||||
|
||||
core::stringw getText() const;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user