More event propagation cleanup
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4139 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
584d203aa4
commit
0f775b8a8c
@ -79,7 +79,7 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
|
||||
case EGET_LISTBOX_SELECTED_AGAIN:
|
||||
{
|
||||
Widget* w = GUIEngine::getWidget(id);
|
||||
if(w == NULL) break;
|
||||
if (w == NULL) break;
|
||||
|
||||
// FIXME: don't hardcode player 0
|
||||
return onWidgetActivated(w, 0);
|
||||
@ -157,7 +157,7 @@ EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int
|
||||
{
|
||||
if (ModalDialog::isADialogActive())
|
||||
{
|
||||
if (ModalDialog::getCurrent()->processEvent(w->m_properties[PROP_ID])) return EVENT_LET;
|
||||
if (ModalDialog::getCurrent()->processEvent(w->m_properties[PROP_ID]) == EVENT_BLOCK) return EVENT_BLOCK;
|
||||
if (w->m_event_handler == NULL) return EVENT_LET;
|
||||
}
|
||||
|
||||
@ -295,7 +295,8 @@ void EventHandler::processAction(const int action, const unsigned int value, Inp
|
||||
{
|
||||
IGUIElement* element = GUIEngine::getGUIEnv()->getFocus();
|
||||
Widget* w = GUIEngine::getWidget( element->getID() );
|
||||
if(w == NULL) break;
|
||||
if (w == NULL) break;
|
||||
// FIXME : consider returned value?
|
||||
onWidgetActivated( w, playerID );
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace GUIEngine
|
||||
* mainly through AbstractStateManager, and also to widgets (this class is some kind of bridge between
|
||||
* the base irrLicht GUI engine and the STK layer on top of it)
|
||||
*/
|
||||
class EventHandler : public irr::IEventReceiver
|
||||
class EventHandler : public irr::IEventReceiver
|
||||
{
|
||||
EventPropagation onGUIEvent(const irr::SEvent& event);
|
||||
EventPropagation onWidgetActivated(Widget* w, const int playerID);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "irrlicht.h"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "guiengine/event_handler.hpp"
|
||||
#include "guiengine/skin.hpp"
|
||||
|
||||
class PlayerProfile;
|
||||
@ -55,8 +56,8 @@ public:
|
||||
|
||||
virtual ~ModalDialog();
|
||||
|
||||
/** Returns whether to block event propagation */
|
||||
virtual bool processEvent(std::string& eventSource){ return false; }
|
||||
/** Returns whether to block event propagation (usually, you will want to block events you processed) */
|
||||
virtual EventPropagation processEvent(std::string& eventSource){ return EVENT_LET; }
|
||||
|
||||
static void dismiss();
|
||||
static void onEnterPressed();
|
||||
|
@ -81,14 +81,14 @@ EnterPlayerNameDialog::~EnterPlayerNameDialog()
|
||||
{
|
||||
textCtrl->getIrrlichtElement()->remove();
|
||||
}
|
||||
bool EnterPlayerNameDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation EnterPlayerNameDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "cancel")
|
||||
{
|
||||
dismiss();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return false;
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
~EnterPlayerNameDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
bool processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -182,7 +182,7 @@ void PlayerInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
bool PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "renameplayer")
|
||||
{
|
||||
@ -201,12 +201,12 @@ bool PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
ModalDialog::dismiss();
|
||||
|
||||
dismiss();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "removeplayer")
|
||||
{
|
||||
showConfirmDialog();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "confirmremove")
|
||||
{
|
||||
@ -218,12 +218,12 @@ bool PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(eventSource == "cancelremove")
|
||||
{
|
||||
showRegularDialog();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(eventSource == "cancel")
|
||||
{
|
||||
@ -233,7 +233,7 @@ bool PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return false;
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
PlayerInfoDialog(PlayerProfile* PlayerInfoDialog,
|
||||
const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
bool processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
|
@ -57,13 +57,13 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
||||
widget2->add();
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
bool PressAKeyDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation PressAKeyDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "cancel")
|
||||
{
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
dismiss();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return false;
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
PressAKeyDialog(const float percentWidth, const float percentHeight);
|
||||
bool processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -241,7 +241,7 @@ void RaceOverDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
|
||||
bool RaceOverDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation RaceOverDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "raceagainbtn")
|
||||
{
|
||||
@ -249,7 +249,7 @@ bool RaceOverDialog::processEvent(std::string& eventSource)
|
||||
network_manager->setState(NetworkManager::NS_MAIN_MENU);
|
||||
RaceManager::getWorld()->unpause();
|
||||
race_manager->rerunRace();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "newracebtn")
|
||||
{
|
||||
@ -258,7 +258,7 @@ bool RaceOverDialog::processEvent(std::string& eventSource)
|
||||
race_manager->exitRace();
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
StateManager::get()->pushScreen(KartSelectionScreen::getInstance());
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "backtomenu")
|
||||
{
|
||||
@ -267,16 +267,16 @@ bool RaceOverDialog::processEvent(std::string& eventSource)
|
||||
race_manager->exitRace();
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "continuegp")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
RaceManager::getWorld()->unpause();
|
||||
race_manager->next();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return false;
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
RaceOverDialog(const float percentWidth, const float percentHeight);
|
||||
|
||||
void onEnterPressedInternal();
|
||||
bool processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
|
@ -214,7 +214,7 @@ void RacePausedDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
|
||||
bool RacePausedDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation RacePausedDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
std::cout << "RacePausedDialog::processEvent(" << eventSource.c_str() << ")\n";
|
||||
|
||||
@ -222,7 +222,7 @@ bool RacePausedDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
// unpausing is done in the destructor so nothing more to do here
|
||||
ModalDialog::dismiss();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "choiceribbon")
|
||||
{
|
||||
@ -235,19 +235,19 @@ bool RacePausedDialog::processEvent(std::string& eventSource)
|
||||
race_manager->exitRace();
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "help")
|
||||
{
|
||||
dismiss();
|
||||
StateManager::get()->pushScreen(HelpScreen1::getInstance());
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "options")
|
||||
{
|
||||
dismiss();
|
||||
StateManager::get()->pushScreen(OptionsScreenAV::getInstance());
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "restart")
|
||||
{
|
||||
@ -255,14 +255,14 @@ bool RacePausedDialog::processEvent(std::string& eventSource)
|
||||
network_manager->setState(NetworkManager::NS_MAIN_MENU);
|
||||
RaceManager::getWorld()->unpause();
|
||||
race_manager->rerunRace();
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "newrace")
|
||||
{
|
||||
// TODO
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
RacePausedDialog::~RacePausedDialog()
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
virtual ~RacePausedDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
bool processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -233,13 +233,13 @@ void TrackInfoDialog::onEnterPressedInternal()
|
||||
startGame(m_track_ident, num_laps);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
bool TrackInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation TrackInfoDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "start" )
|
||||
{
|
||||
const int num_laps = m_spinner->getValue();
|
||||
startGame(m_track_ident, num_laps);
|
||||
return true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
return false;
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
TrackInfoDialog(const std::string& trackIdent, const irr::core::stringw& trackName,
|
||||
irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
bool processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user