escape and quit now work again
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3271 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "race_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "main_loop.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -63,6 +64,16 @@ namespace StateManager
|
||||
w2->addLabel("MiniBjorn");
|
||||
}
|
||||
}
|
||||
if(name == "menu_bottomrow")
|
||||
{
|
||||
std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionName().c_str();
|
||||
if(selection == "quit")
|
||||
{
|
||||
main_loop->abort();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(name == "gamemode")
|
||||
{
|
||||
GUIEngine::RibbonWidget* w = dynamic_cast<GUIEngine::RibbonWidget*>(widget);
|
||||
@@ -71,6 +82,7 @@ namespace StateManager
|
||||
showTrackSelectionScreen();
|
||||
}
|
||||
}
|
||||
|
||||
if(name == "tracks")
|
||||
{
|
||||
GUIEngine::RibbonGridWidget* w2 = dynamic_cast<GUIEngine::RibbonGridWidget*>(widget);
|
||||
@@ -167,8 +179,15 @@ namespace StateManager
|
||||
void popMenu()
|
||||
{
|
||||
g_menu_stack.pop_back();
|
||||
|
||||
if(g_menu_stack.size() == 0)
|
||||
{
|
||||
main_loop->abort();
|
||||
return;
|
||||
}
|
||||
|
||||
g_game_mode = g_menu_stack[g_menu_stack.size()-1] == "race";
|
||||
GUIEngine::switchToScreen(g_menu_stack[g_menu_stack.size()-1].c_str());
|
||||
GUIEngine::switchToScreen(g_menu_stack[g_menu_stack.size()-1].c_str());
|
||||
}
|
||||
|
||||
void resetAndGoToMenu(std::string name)
|
||||
@@ -194,4 +213,15 @@ namespace StateManager
|
||||
return g_game_mode;
|
||||
}
|
||||
|
||||
void escapePressed()
|
||||
{
|
||||
if(g_game_mode)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
popMenu();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@ namespace StateManager
|
||||
void resetAndGoToMenu(std::string name);
|
||||
void enterGameState();
|
||||
bool isGameState();
|
||||
|
||||
void escapePressed();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -309,19 +309,7 @@ SDLDriver::~SDLDriver()
|
||||
|
||||
} // ~SDLDriver
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Handles the conversion from some input to a GameAction and its distribution
|
||||
* to the currently active menu.
|
||||
* It also handles whether the game is currently sensing input. It does so by
|
||||
* suppressing the distribution of the input as a GameAction. Instead the
|
||||
* input is stored in 'm_sensed_input' and GA_SENSE_COMPLETE is distributed. If
|
||||
* however the input in question has resolved to GA_LEAVE this is treated as
|
||||
* an attempt of the user to cancel the sensing. In that case GA_SENSE_CANCEL
|
||||
* is distributed.
|
||||
*
|
||||
* Note: It is the obligation of the called menu to switch of the sense mode.
|
||||
*
|
||||
*/
|
||||
|
||||
#define MAX_VALUE 32768
|
||||
|
||||
void postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const int x, const int y)
|
||||
@@ -429,6 +417,19 @@ void handleGameAction(GameAction ga, int value)
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Handles the conversion from some input to a GameAction and its distribution
|
||||
* to the currently active menu.
|
||||
* It also handles whether the game is currently sensing input. It does so by
|
||||
* suppressing the distribution of the input as a GameAction. Instead the
|
||||
* input is stored in 'm_sensed_input' and GA_SENSE_COMPLETE is distributed. If
|
||||
* however the input in question has resolved to GA_LEAVE this is treated as
|
||||
* an attempt of the user to cancel the sensing. In that case GA_SENSE_CANCEL
|
||||
* is distributed.
|
||||
*
|
||||
* Note: It is the obligation of the called menu to switch of the sense mode.
|
||||
*
|
||||
*/
|
||||
void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
||||
int value)
|
||||
{
|
||||
@@ -439,6 +440,8 @@ void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
||||
{
|
||||
irr::SEvent::SKeyInput evt;
|
||||
|
||||
// std::cout << id0 << std::endl;
|
||||
|
||||
if(id0 == 9)
|
||||
evt.Key = irr::KEY_TAB;
|
||||
else if(id0 == 13)
|
||||
@@ -451,6 +454,8 @@ void SDLDriver::input(Input::InputType type, int id0, int id1, int id2,
|
||||
evt.Key = irr::KEY_RIGHT;
|
||||
else if(id0 == 276)
|
||||
evt.Key = irr::KEY_LEFT;
|
||||
else if(id0 == 27)
|
||||
StateManager::escapePressed();
|
||||
else
|
||||
evt.Key = (irr::EKEY_CODE) id0; // FIXME - probably won't work, need better input handling
|
||||
|
||||
|
||||
Reference in New Issue
Block a user