Fixed player identity not changeable by improving event handling in the GUI
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3793 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8623a4a49a
commit
1653ae14d7
@ -188,11 +188,18 @@ void EventHandler::processAction(const int action, const unsigned int value, Inp
|
||||
|
||||
/* Find topmost parent. Stop looping if a widget event handler's is itself, to not fall
|
||||
in an infinite loop (this can happen e.g. in checkboxes, where they need to be
|
||||
notified of clicks onto themselves so they can toggle their state. ) */
|
||||
while(widget_to_call->m_event_handler != NULL && widget_to_call->m_event_handler != widget_to_call)
|
||||
widget_to_call = widget_to_call->m_event_handler;
|
||||
notified of clicks onto themselves so they can toggle their state. )
|
||||
On the way, also notify everyone in the chain of the left press. */
|
||||
while (widget_to_call->m_event_handler != NULL && widget_to_call->m_event_handler != widget_to_call)
|
||||
{
|
||||
if (widget_to_call->leftPressed())
|
||||
transmitEvent(w, w->m_properties[PROP_ID]);
|
||||
|
||||
if(widget_to_call->leftPressed())
|
||||
widget_to_call = widget_to_call->m_event_handler;
|
||||
}
|
||||
|
||||
|
||||
if (widget_to_call->leftPressed())
|
||||
transmitEvent(w, w->m_properties[PROP_ID]);
|
||||
}
|
||||
break;
|
||||
@ -207,9 +214,15 @@ void EventHandler::processAction(const int action, const unsigned int value, Inp
|
||||
Widget* widget_to_call = w;
|
||||
/* Find topmost parent. Stop looping if a widget event handler's is itself, to not fall
|
||||
in an infinite loop (this can happen e.g. in checkboxes, where they need to be
|
||||
notified of clicks onto themselves so they can toggle their state. ) */
|
||||
notified of clicks onto themselves so they can toggle their state. )
|
||||
On the way, also notify everyone in the chain of the right press */
|
||||
while(widget_to_call->m_event_handler != NULL && widget_to_call->m_event_handler != widget_to_call)
|
||||
{
|
||||
if(widget_to_call->rightPressed())
|
||||
transmitEvent(widget_to_call, w->m_properties[PROP_ID]);
|
||||
|
||||
widget_to_call = widget_to_call->m_event_handler;
|
||||
}
|
||||
|
||||
if(widget_to_call->rightPressed())
|
||||
transmitEvent(widget_to_call, w->m_properties[PROP_ID]);
|
||||
|
@ -171,8 +171,6 @@ bool RibbonGridWidget::rightPressed()
|
||||
RibbonWidget* w = getSelectedRibbon();
|
||||
if(w != NULL)
|
||||
{
|
||||
w->rightPressed();
|
||||
|
||||
updateLabel();
|
||||
propagateSelection();
|
||||
}
|
||||
@ -193,8 +191,6 @@ bool RibbonGridWidget::leftPressed()
|
||||
RibbonWidget* w = getSelectedRibbon();
|
||||
if(w != NULL)
|
||||
{
|
||||
w->leftPressed();
|
||||
|
||||
updateLabel();
|
||||
propagateSelection();
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ SpinnerWidget::SpinnerWidget(const bool gauge)
|
||||
{
|
||||
m_gauge = gauge;
|
||||
m_type = WTYPE_SPINNER;
|
||||
|
||||
}
|
||||
|
||||
void SpinnerWidget::add()
|
||||
@ -100,6 +99,7 @@ void SpinnerWidget::add()
|
||||
m_children[1].m_element = subbtn;
|
||||
m_children[1].m_type = WTYPE_ICON_BUTTON;
|
||||
m_children[1].id = subbtn->getID();
|
||||
m_children[1].m_event_handler = this;
|
||||
subbtn->setUseAlphaChannel(true);
|
||||
|
||||
subbtn->setImage(texture);
|
||||
@ -113,6 +113,7 @@ void SpinnerWidget::add()
|
||||
btn, getNewNoFocusID());
|
||||
m_children[1].m_element = label;
|
||||
m_children[1].m_type = WTYPE_LABEL;
|
||||
m_children[1].m_event_handler = this;
|
||||
m_children[1].id = label->getID();
|
||||
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
label->setTabStop(false);
|
||||
@ -129,7 +130,10 @@ void SpinnerWidget::add()
|
||||
m_children[2].m_event_handler = this;
|
||||
m_children[2].m_properties[PROP_ID] = "right";
|
||||
m_children[2].id = m_children[2].m_element->getID();
|
||||
|
||||
std::cout << "Adding spinner with m_event_handler=" << m_event_handler << std::endl;
|
||||
}
|
||||
|
||||
void SpinnerWidget::move(const int x, const int y, const int w, const int h)
|
||||
{
|
||||
Widget::move(x, y, w, h);
|
||||
|
@ -295,11 +295,7 @@ namespace KartSelectionScreen
|
||||
|
||||
virtual bool transmitEvent(Widget* w, std::string& originator)
|
||||
{
|
||||
if (w->m_event_handler != NULL && w->m_event_handler != this)
|
||||
{
|
||||
if (!w->m_event_handler->transmitEvent(w, originator)) return false;
|
||||
}
|
||||
|
||||
std::cout << "= kart selection :: transmitEvent " << originator << "=\n";
|
||||
Widget* topmost = w;
|
||||
/* Find topmost parent. Stop looping if a widget event handler's is itself, to not fall
|
||||
in an infinite loop (this can happen e.g. in checkboxes, where they need to be
|
||||
@ -307,6 +303,9 @@ namespace KartSelectionScreen
|
||||
*/
|
||||
while(topmost->m_event_handler != NULL && topmost->m_event_handler != topmost)
|
||||
{
|
||||
// transmit events to all listeners in the chain
|
||||
std::cout << "transmitting event to widget " << topmost->m_type << std::endl;
|
||||
if (!topmost->transmitEvent(w, originator)) return false;
|
||||
topmost = topmost->m_event_handler;
|
||||
|
||||
std::string name = topmost->m_properties[PROP_ID];
|
||||
@ -314,6 +313,11 @@ namespace KartSelectionScreen
|
||||
if (name == spinnerID)
|
||||
{
|
||||
m_associatedPlayer->setPlayerProfile( UserConfigParams::m_all_players.get(playerName->getValue()) );
|
||||
|
||||
// transmit events to all listeners in the chain
|
||||
std::cout << "transmitting event to widget " << topmost->m_type << std::endl;
|
||||
if (!topmost->transmitEvent(w, originator)) return false;
|
||||
|
||||
return false; // do not continue propagating the event
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user