code simplification; crash fix; checkboxes in options now work, but you need to restart STK
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3401 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5e249e0aed
commit
c1bd49c8af
@ -307,8 +307,13 @@ bool Screen::OnEvent(const SEvent& event)
|
||||
if(w == NULL) break;
|
||||
|
||||
Widget* widget_to_call = w;
|
||||
while(widget_to_call->m_event_handler != NULL) widget_to_call = widget_to_call->m_event_handler; // Find topmost parent
|
||||
|
||||
|
||||
/* 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;
|
||||
|
||||
if(widget_to_call->leftPressed())
|
||||
transmitEvent(w, w->m_properties[PROP_ID]);
|
||||
break;
|
||||
@ -322,7 +327,11 @@ bool Screen::OnEvent(const SEvent& event)
|
||||
if(w == NULL) break;
|
||||
|
||||
Widget* widget_to_call = w;
|
||||
while(widget_to_call->m_event_handler != NULL) widget_to_call = widget_to_call->m_event_handler; // Find topmost parent
|
||||
/* 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;
|
||||
|
||||
if(widget_to_call->rightPressed())
|
||||
transmitEvent(widget_to_call, w->m_properties[PROP_ID]);
|
||||
|
@ -293,6 +293,16 @@ namespace StateManager
|
||||
(GUIEngine::getCurrentScreen()->getWidget("music_volume"));
|
||||
assert(gauge != NULL);
|
||||
gauge->setValue( sound_manager->getMasterMusicVolume() );
|
||||
|
||||
|
||||
GUIEngine::CheckBoxWidget* sfx = dynamic_cast<GUIEngine::CheckBoxWidget*>
|
||||
(GUIEngine::getCurrentScreen()->getWidget("sfx_enabled"));
|
||||
|
||||
GUIEngine::CheckBoxWidget* music = dynamic_cast<GUIEngine::CheckBoxWidget*>
|
||||
(GUIEngine::getCurrentScreen()->getWidget("music_enabled"));
|
||||
|
||||
sfx->setState( user_config->doSFX() );
|
||||
music->setState( user_config->doMusic() );
|
||||
}
|
||||
}
|
||||
// -- options
|
||||
@ -306,8 +316,8 @@ namespace StateManager
|
||||
}
|
||||
else if(name == "music_volume")
|
||||
{
|
||||
GUIEngine::GaugeWidget* w = dynamic_cast<GUIEngine::GaugeWidget*>
|
||||
(GUIEngine::getCurrentScreen()->getWidget("music_volume"));
|
||||
GUIEngine::GaugeWidget* w = dynamic_cast<GUIEngine::GaugeWidget*>(widget);
|
||||
// GUIEngine::getCurrentScreen()->getWidget("music_volume")
|
||||
assert(w != NULL);
|
||||
|
||||
// TODO - save value to file, load value from file, allow fully disabling music
|
||||
@ -315,13 +325,25 @@ namespace StateManager
|
||||
}
|
||||
else if(name == "sfx_volume")
|
||||
{
|
||||
GUIEngine::GaugeWidget* w = dynamic_cast<GUIEngine::GaugeWidget*>
|
||||
(GUIEngine::getCurrentScreen()->getWidget("sfx_volume"));
|
||||
GUIEngine::GaugeWidget* w = dynamic_cast<GUIEngine::GaugeWidget*>(widget);
|
||||
// GUIEngine::getCurrentScreen()->getWidget("sfx_volume")
|
||||
assert(w != NULL);
|
||||
|
||||
// TODO - save value to file, load value from file, allow fully disabling sfx
|
||||
sfx_manager->setMasterSFXVolume( w->getValue() );
|
||||
}
|
||||
else if(name == "music_enabled")
|
||||
{
|
||||
GUIEngine::CheckBoxWidget* w = dynamic_cast<GUIEngine::CheckBoxWidget*>(widget);
|
||||
|
||||
user_config->setMusic(w->getState() ? UserConfig::UC_ENABLE : UserConfig::UC_DISABLE);
|
||||
}
|
||||
else if(name == "sfx_enabled")
|
||||
{
|
||||
GUIEngine::CheckBoxWidget* w = dynamic_cast<GUIEngine::CheckBoxWidget*>(widget);
|
||||
|
||||
user_config->setSFX(w->getState() ? UserConfig::UC_ENABLE : UserConfig::UC_DISABLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -169,6 +169,7 @@ namespace GUIEngine
|
||||
CheckBoxWidget();
|
||||
virtual ~CheckBoxWidget() {}
|
||||
bool getState() const { return m_state; }
|
||||
void setState(const bool enabled) { m_state = enabled; }
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user