More work on in-game dialogs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4004 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -170,6 +170,7 @@ bool EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int playerID)
|
||||
while (parent->m_event_handler != NULL && parent->m_event_handler != parent)
|
||||
{
|
||||
parent->transmitEvent(w, w->m_properties[PROP_ID], playerID);
|
||||
|
||||
parent = parent->m_event_handler;
|
||||
}
|
||||
|
||||
@@ -177,6 +178,12 @@ bool EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int playerID)
|
||||
parent event handler says so */
|
||||
if (parent->transmitEvent(w, w->m_properties[PROP_ID], playerID))
|
||||
{
|
||||
// notify modal dialog too
|
||||
if (ModalDialog::isADialogActive())
|
||||
{
|
||||
if (ModalDialog::getCurrent()->processEvent(parent->m_properties[PROP_ID])) return false;
|
||||
}
|
||||
|
||||
transmitEvent(parent, parent->m_properties[PROP_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
#include "config/player.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "states_screens/options_screen.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/event_handler.hpp"
|
||||
@@ -43,7 +40,9 @@
|
||||
#include "modes/world.hpp"
|
||||
#include "race/history.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
#include "states_screens/options_screen.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
InputManager *input_manager;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -316,7 +315,7 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
|
||||
}
|
||||
|
||||
// ... when in-game
|
||||
if(StateManager::get()->isGameState())
|
||||
if (StateManager::get()->isGameState() && !GUIEngine::ModalDialog::isADialogActive())
|
||||
{
|
||||
// Find the corresponding PlayerKart from our ActivePlayer instance
|
||||
PlayerKart* pk;
|
||||
@@ -341,7 +340,7 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
|
||||
else
|
||||
{
|
||||
// reset timer when released
|
||||
if( abs(value) == 0 && (/*type == Input::IT_KEYBOARD ||*/ type == Input::IT_STICKBUTTON) )
|
||||
if (abs(value) == 0 && (/*type == Input::IT_KEYBOARD ||*/ type == Input::IT_STICKBUTTON))
|
||||
{
|
||||
if(type == Input::IT_STICKBUTTON) std::cout << "resetting because type == Input::IT_STICKBUTTON\n";
|
||||
else std::cout << "resetting for another reason\n";
|
||||
@@ -351,9 +350,9 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
|
||||
}
|
||||
|
||||
// menu input
|
||||
if(!m_timer_in_use)
|
||||
if (!m_timer_in_use)
|
||||
{
|
||||
if(abs(value) > Input::MAX_VALUE*2/3)
|
||||
if (abs(value) > Input::MAX_VALUE*2/3)
|
||||
{
|
||||
m_timer_in_use = true;
|
||||
m_timer = 0.25;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
@@ -260,6 +261,7 @@ bool RaceOverDialog::processEvent(std::string& eventSource)
|
||||
RaceManager::getWorld()->unpause();
|
||||
race_manager->exitRace();
|
||||
StateManager::get()->resetAndGoToMenu("main.stkgui");
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "continuegp")
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "input/input_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@@ -218,28 +219,38 @@ bool RacePausedDialog::processEvent(std::string& eventSource)
|
||||
ModalDialog::dismiss();
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "exit")
|
||||
else if (eventSource == "choiceribbon")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
StateManager::get()->resetAndGoToMenu("main.stkgui");
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
return true;
|
||||
}
|
||||
else if (eventSource == "help")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else if (eventSource == "options")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else if (eventSource == "restart")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else if (eventSource == "newrace")
|
||||
{
|
||||
// TODO
|
||||
// FIXME : don't hardcode player 0
|
||||
const int playerId = 0;
|
||||
const std::string& selection = m_choice_ribbon->getSelectionIDString(playerId);
|
||||
if (selection == "exit")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
race_manager->exitRace();
|
||||
StateManager::get()->resetAndGoToMenu("main.stkgui");
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
return true;
|
||||
}
|
||||
else if (selection == "help")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else if (selection == "options")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
else if (selection == "restart")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
network_manager->setState(NetworkManager::NS_MAIN_MENU);
|
||||
RaceManager::getWorld()->unpause();
|
||||
race_manager->rerunRace();
|
||||
}
|
||||
else if (selection == "newrace")
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user