Fixed const correctness issue with class ModalDialog + fixed behaviour when pressing ESC in race over dialog
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4829 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
151e4b64a6
commit
93c12ead08
@ -57,7 +57,7 @@ public:
|
||||
virtual ~ModalDialog();
|
||||
|
||||
/** Returns whether to block event propagation (usually, you will want to block events you processed) */
|
||||
virtual EventPropagation processEvent(std::string& eventSource){ return EVENT_LET; }
|
||||
virtual EventPropagation processEvent(const std::string& eventSource){ return EVENT_LET; }
|
||||
|
||||
bool isMyChild(Widget* widget) const { return m_children.contains(widget); }
|
||||
bool isMyChild(irr::gui::IGUIElement* widget) const { return m_irrlicht_window->isMyChild(widget); }
|
||||
@ -75,6 +75,9 @@ public:
|
||||
static ModalDialog* getCurrent();
|
||||
static bool isADialogActive();
|
||||
|
||||
/** Override to change what happens on escape pressed */
|
||||
virtual void escapePressed() { dismiss(); }
|
||||
|
||||
/** Override to be notified of updates */
|
||||
virtual void onUpdate(float dt) { }
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ void AddDeviceDialog::onEnterPressedInternal()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation AddDeviceDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation AddDeviceDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
|
||||
if (eventSource == "cancel")
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
*/
|
||||
AddDeviceDialog();
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ void ConfirmResolutionDialog::updateMessage()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation ConfirmResolutionDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation ConfirmResolutionDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
|
||||
if (eventSource == "cancel")
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
ConfirmResolutionDialog();
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
|
||||
virtual void onUpdate(float dt);
|
||||
};
|
||||
|
@ -90,7 +90,7 @@ EnterPlayerNameDialog::~EnterPlayerNameDialog()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation EnterPlayerNameDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation EnterPlayerNameDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "cancel")
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
~EnterPlayerNameDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -214,7 +214,7 @@ void GPInfoDialog::onEnterPressedInternal()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation GPInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation GPInfoDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "start")
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
virtual ~GPInfoDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
|
||||
virtual void onUpdate(float dt);
|
||||
|
||||
|
@ -191,7 +191,7 @@ void PlayerInfoDialog::onEnterPressedInternal()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation PlayerInfoDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "renameplayer")
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
PlayerInfoDialog(PlayerProfile* PlayerInfoDialog,
|
||||
const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation PressAKeyDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation PressAKeyDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "cancel")
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
PressAKeyDialog(const float percentWidth, const float percentHeight);
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -290,7 +290,7 @@ void RaceOverDialog::onEnterPressedInternal()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation RaceOverDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation RaceOverDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "raceagainbtn")
|
||||
{
|
||||
@ -327,80 +327,24 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(std::string& eventSourc
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This is used on the client and server to display a message while waiting
|
||||
* in a barrier for clients and server to ack the display.
|
||||
*/
|
||||
/*
|
||||
TODO : port this code back
|
||||
|
||||
void RaceResultsGUI::update(float dt)
|
||||
{
|
||||
BaseGUI::update(dt);
|
||||
// If an item is selected (for the first time), change the text
|
||||
// so that the user has feedback about his selection.
|
||||
if(m_selected_widget!=WTOK_NONE && m_first_time)
|
||||
{
|
||||
m_first_time = false;
|
||||
// User feedback on first selection: display message, and on the
|
||||
// server remove unnecessary widgets.
|
||||
widget_manager->setWgtText(WTOK_CONTINUE, _("Synchronising."));
|
||||
if(network_manager->getMode()==NetworkManager::NW_SERVER)
|
||||
{
|
||||
widget_manager->hideWgt(WTOK_RESTART_RACE);
|
||||
widget_manager->hideWgt(WTOK_SETUP_NEW_RACE);
|
||||
}
|
||||
} // m_selected_token defined and not first time
|
||||
|
||||
// Wait till the barrier is finished. On the server this is the case when
|
||||
// the state ie MAIN_MENU, on the client when it is wait_for_available_characters.
|
||||
if(network_manager->getMode() !=NetworkManager::NW_NONE &&
|
||||
network_manager->getState()!=NetworkManager::NS_MAIN_MENU &&
|
||||
network_manager->getState()!=NetworkManager::NS_RACE_RESULT_BARRIER_OVER )
|
||||
return;
|
||||
|
||||
// Send selected menu to all clients
|
||||
if(m_selected_widget!=WTOK_NONE &&
|
||||
network_manager->getMode()==NetworkManager::NW_SERVER)
|
||||
{
|
||||
network_manager->sendRaceResultAck(m_selected_widget);
|
||||
}
|
||||
|
||||
switch(m_selected_widget)
|
||||
{
|
||||
case WTOK_CONTINUE:
|
||||
// Gets called when:
|
||||
// 1) something was unlocked
|
||||
// 2) a Grand Prix is run
|
||||
// 3) "back to the main menu" otherwise
|
||||
RaceManager::getWorld()->unpause();
|
||||
widget_manager->setWgtText(WTOK_CONTINUE, _("Loading race..."));
|
||||
race_manager->next();
|
||||
break;
|
||||
case WTOK_RESTART_RACE:
|
||||
network_manager->setState(NetworkManager::NS_MAIN_MENU);
|
||||
RaceManager::getWorld()->unpause();
|
||||
menu_manager->popMenu();
|
||||
race_manager->rerunRace();
|
||||
break;
|
||||
case WTOK_SETUP_NEW_RACE:
|
||||
RaceManager::getWorld()->unpause();
|
||||
race_manager->exit_race();
|
||||
if(network_manager->getMode()==NetworkManager::NW_CLIENT)
|
||||
{
|
||||
network_manager->setState(NetworkManager::NS_WAIT_FOR_AVAILABLE_CHARACTERS);
|
||||
menu_manager->pushMenu(MENUID_CHARSEL_P1);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_manager->pushMenu(MENUID_GAMEMODE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} // update
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
*/
|
||||
void RaceOverDialog::escapePressed()
|
||||
{
|
||||
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
std::string what = "continuegp";
|
||||
processEvent(what);
|
||||
}
|
||||
else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_SINGLE)
|
||||
{
|
||||
std::string what = "backtomenu";
|
||||
processEvent(what);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -30,7 +30,9 @@ public:
|
||||
RaceOverDialog(const float percentWidth, const float percentHeight);
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
|
||||
virtual void escapePressed();
|
||||
};
|
||||
|
||||
|
||||
|
@ -155,7 +155,7 @@ void RacePausedDialog::onEnterPressedInternal()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation RacePausedDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation RacePausedDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
std::cout << "RacePausedDialog::processEvent(" << eventSource.c_str() << ")\n";
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
virtual ~RacePausedDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -310,7 +310,7 @@ void TrackInfoDialog::onEnterPressedInternal()
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation TrackInfoDialog::processEvent(std::string& eventSource)
|
||||
GUIEngine::EventPropagation TrackInfoDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "start" )
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
virtual ~TrackInfoDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -153,7 +153,7 @@ void StateManager::escapePressed()
|
||||
// when another modal dialog is visible
|
||||
else if(ModalDialog::isADialogActive())
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
ModalDialog::getCurrent()->escapePressed();
|
||||
}
|
||||
// In-game
|
||||
else if(m_game_mode == GAME)
|
||||
|
Loading…
x
Reference in New Issue
Block a user