diff --git a/data/gui/help1.stkgui b/data/gui/help1.stkgui
index 9b84e0400..ad222c14d 100644
--- a/data/gui/help1.stkgui
+++ b/data/gui/help1.stkgui
@@ -56,6 +56,7 @@
-
+
\ No newline at end of file
diff --git a/data/gui/help2.stkgui b/data/gui/help2.stkgui
index 8b6dd70bf..106c7d4b9 100644
--- a/data/gui/help2.stkgui
+++ b/data/gui/help2.stkgui
@@ -60,6 +60,7 @@
-
+
\ No newline at end of file
diff --git a/data/gui/help3.stkgui b/data/gui/help3.stkgui
index 070e29721..3d4381fea 100644
--- a/data/gui/help3.stkgui
+++ b/data/gui/help3.stkgui
@@ -60,6 +60,7 @@
-
+
diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp
index ce8a0e81c..bbea07e19 100644
--- a/src/graphics/irr_driver.cpp
+++ b/src/graphics/irr_driver.cpp
@@ -509,7 +509,7 @@ void IrrDriver::displayFPS()
const int fps = m_device->getVideoDriver()->getFPS();
// Min and max info tracking, per mode, so user can check game vs menus
- bool current_state = StateManager::get()->isGameState();
+ bool current_state = StateManager::get()->getGameState() == GUIEngine::GAME;
static bool prev_state = false;
static int min = 999; // Absurd values for start will print first time
static int max = 0; // but no big issue, maybe even "invisible"
@@ -545,7 +545,7 @@ void IrrDriver::update(float dt)
m_device->getVideoDriver()->beginScene(false, true, video::SColor(255,100,101,140));
{ // just to mark the beding/end scene block
- if(!StateManager::get()->isGameState())
+ if (StateManager::get()->getGameState() != GUIEngine::GAME)
{
// this code needs to go outside beginScene() / endScene() since
// the model view widget will do off-screen rendering there
@@ -569,7 +569,7 @@ void IrrDriver::update(float dt)
}
// GUI is active
- if (!inRace || GUIEngine::ModalDialog::isADialogActive())
+ //if (!inRace || GUIEngine::ModalDialog::isADialogActive())
{
GUIEngine::render(dt);
}
diff --git a/src/guiengine/abstract_state_manager.cpp b/src/guiengine/abstract_state_manager.cpp
index c0d6b9d10..dafdadda0 100644
--- a/src/guiengine/abstract_state_manager.cpp
+++ b/src/guiengine/abstract_state_manager.cpp
@@ -32,6 +32,7 @@
#include "input/device_manager.hpp"
#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/options_screen.hpp"
@@ -54,7 +55,7 @@ const std::string g_teardown_event = "tearDown";
AbstractStateManager::AbstractStateManager()
{
- m_game_mode = false;
+ m_game_mode = MENU;
}
#if 0
@@ -75,12 +76,12 @@ void AbstractStateManager::enterGameState()
{
m_menu_stack.clear();
m_menu_stack.push_back("race");
- m_game_mode = true;
+ m_game_mode = GAME;
cleanForGame();
input_manager->setMode(InputManager::INGAME);
}
-bool AbstractStateManager::isGameState()
+GameState AbstractStateManager::getGameState()
{
return m_game_mode;
}
@@ -93,25 +94,38 @@ bool AbstractStateManager::isGameState()
void AbstractStateManager::pushMenu(std::string name)
{
+ // currently, only a single in-game menu is supported
+ assert(m_game_mode != INGAME_MENU);
+
// Send tear-down event to previous menu
- if (m_menu_stack.size() > 0) eventCallback(NULL, g_teardown_event);
+ if (m_menu_stack.size() > 0 && m_game_mode != GAME) eventCallback(NULL, g_teardown_event);
input_manager->setMode(InputManager::MENU);
m_menu_stack.push_back(name);
- m_game_mode = false;
+ if (m_game_mode == GAME)
+ {
+ m_game_mode = INGAME_MENU;
+ RaceManager::getWorld()->pause();
+ }
+ else
+ {
+ m_game_mode = MENU;
+ }
switchToScreen(name.c_str());
// Send init event to new menu
eventCallback(NULL, g_init_event);
}
+
void AbstractStateManager::replaceTopMostMenu(std::string name)
{
+ assert(m_game_mode != GAME);
+
// Send tear-down event to previous menu
if (m_menu_stack.size() > 0) eventCallback(NULL, g_teardown_event);
input_manager->setMode(InputManager::MENU);
m_menu_stack[m_menu_stack.size()-1] = name;
- m_game_mode = false;
switchToScreen(name.c_str());
// Send init event to new menu
@@ -120,6 +134,8 @@ void AbstractStateManager::replaceTopMostMenu(std::string name)
void AbstractStateManager::reshowTopMostMenu()
{
+ assert(m_game_mode != GAME);
+
// Send tear-down event to previous menu
if (m_menu_stack.size() > 0) eventCallback(NULL, g_teardown_event);
@@ -131,22 +147,38 @@ void AbstractStateManager::reshowTopMostMenu()
void AbstractStateManager::popMenu()
{
+ assert(m_game_mode != GAME);
+
// Send tear-down event to menu
eventCallback(NULL, g_teardown_event);
m_menu_stack.pop_back();
- if(m_menu_stack.size() == 0)
+ if (m_menu_stack.size() == 0)
{
main_loop->abort();
return;
}
-
- m_game_mode = m_menu_stack[m_menu_stack.size()-1] == "race";
-
+
std::cout << "-- switching to screen " << m_menu_stack[m_menu_stack.size()-1].c_str() << std::endl;
- switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
- input_manager->getDeviceList()->setAssignMode(NO_ASSIGN); // No assign mode on menus by default
- eventCallback(NULL, g_init_event);
+
+ if (m_menu_stack[m_menu_stack.size()-1] == "race")
+ {
+ m_menu_stack.push_back("race");
+ if (m_game_mode == INGAME_MENU)
+ {
+ RaceManager::getWorld()->unpause();
+ }
+ m_game_mode = GAME;
+ cleanForGame();
+ input_manager->setMode(InputManager::INGAME);
+ }
+ else
+ {
+ m_game_mode = MENU;
+ switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
+ input_manager->getDeviceList()->setAssignMode(NO_ASSIGN); // No assign mode on menus by default
+ eventCallback(NULL, g_init_event);
+ }
}
void AbstractStateManager::resetAndGoToMenu(std::string name)
@@ -155,7 +187,7 @@ void AbstractStateManager::resetAndGoToMenu(std::string name)
input_manager->setMode(InputManager::MENU);
m_menu_stack.clear();
m_menu_stack.push_back(name);
- m_game_mode = false;
+ m_game_mode = MENU;
sound_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
switchToScreen(name.c_str());
eventCallback(NULL, g_init_event);
diff --git a/src/guiengine/abstract_state_manager.hpp b/src/guiengine/abstract_state_manager.hpp
index ca96f9ce9..04a2178e1 100644
--- a/src/guiengine/abstract_state_manager.hpp
+++ b/src/guiengine/abstract_state_manager.hpp
@@ -8,6 +8,13 @@ namespace GUIEngine
{
class Widget;
+ enum GameState
+ {
+ MENU,
+ GAME,
+ INGAME_MENU
+ };
+
/**
* Abstract base class you must override from to use the GUI engine
*/
@@ -17,7 +24,7 @@ protected:
/**
* Whether we are in game mode
*/
- bool m_game_mode;
+ GameState m_game_mode;
/**
* This stack will contain menu names (e.g. main.stkgui), and/or 'race'.
@@ -33,7 +40,9 @@ public:
void popMenu();
void resetAndGoToMenu(std::string name);
void enterGameState();
- bool isGameState();
+
+ GameState getGameState();
+
void reshowTopMostMenu();
/* ***********************************
diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp
index c2676f862..266bdd319 100644
--- a/src/guiengine/engine.cpp
+++ b/src/guiengine/engine.cpp
@@ -191,11 +191,22 @@ void render(float elapsed_time)
GUIEngine::dt = elapsed_time;
// ---- menu drawing
+
// draw background image and sections
- const bool gui_state = !g_state_manager->isGameState();
- if (gui_state)
+
+ const GameState gamestate = g_state_manager->getGameState();
+
+ if (gamestate == MENU)
{
g_skin->drawBgImage();
+ }
+ else if (gamestate == INGAME_MENU)
+ {
+ g_skin->drawBGFadeColor();
+ }
+
+ if (gamestate != GAME)
+ {
g_skin->renderSections();
}
@@ -203,7 +214,7 @@ void render(float elapsed_time)
g_env->drawAll();
// ---- some menus may need updating
- if (!g_state_manager->isGameState())
+ if (gamestate != GAME)
{
g_state_manager->onUpdate(elapsed_time);
}
diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp
index b938abf58..74e72dd7e 100644
--- a/src/guiengine/event_handler.cpp
+++ b/src/guiengine/event_handler.cpp
@@ -43,7 +43,7 @@ EventHandler::~EventHandler()
bool EventHandler::OnEvent (const SEvent &event)
{
if(event.EventType == EET_GUI_EVENT ||
- (!GUIEngine::getStateManager()->isGameState() && event.EventType != EET_KEY_INPUT_EVENT &&
+ (GUIEngine::getStateManager()->getGameState() != GUIEngine::GAME && event.EventType != EET_KEY_INPUT_EVENT &&
event.EventType != EET_JOYSTICK_INPUT_EVENT)
)
{
diff --git a/src/guiengine/screen.cpp b/src/guiengine/screen.cpp
index f651c6efd..f49bcec8c 100644
--- a/src/guiengine/screen.cpp
+++ b/src/guiengine/screen.cpp
@@ -244,7 +244,7 @@ void Screen::calculateLayout(ptr_vector& widgets, Widget* parent)
void Screen::addWidgets()
{
- if(!m_loaded) loadFromFile();
+ if (!m_loaded) loadFromFile();
addWidgetsRecursively( m_widgets );
diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp
index b840ed99b..cb98b77e8 100644
--- a/src/guiengine/skin.cpp
+++ b/src/guiengine/skin.cpp
@@ -946,7 +946,7 @@ void Skin::renderSections(ptr_vector* within_vector)
void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{
- if(GUIEngine::getStateManager()->isGameState()) return; // ignore in game mode
+ if (GUIEngine::getStateManager()->getGameState() == GUIEngine::GAME) return; // ignore in game mode
//const bool focused = GUIEngine::getGUIEnv()->hasFocus(element);
const int id = element->getID();
@@ -1088,12 +1088,17 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool f
// GUIEngine::getDriver()->draw2DRectangle( SColor(255, 0, 150, 0), rect );
}
-core::rect< s32 > Skin::draw3DWindowBackground (IGUIElement *element, bool drawTitleBar, video::SColor titleBarColor, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
-{
+void Skin::drawBGFadeColor()
+{
// fade out background
SColor& color = SkinConfig::m_colors["dialog_background::neutral"];
GUIEngine::getDriver()->draw2DRectangle( color,
core::rect< s32 >(position2d< s32 >(0,0) , GUIEngine::getDriver()->getCurrentRenderTargetSize()) );
+}
+
+core::rect< s32 > Skin::draw3DWindowBackground (IGUIElement *element, bool drawTitleBar, video::SColor titleBarColor, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
+{
+ drawBGFadeColor();
// draw frame
drawBoxFromStretchableTexture( ModalDialog::getCurrent(), rect, SkinConfig::m_render_params["window::neutral"]);
diff --git a/src/guiengine/skin.hpp b/src/guiengine/skin.hpp
index 46f861246..405a9852a 100644
--- a/src/guiengine/skin.hpp
+++ b/src/guiengine/skin.hpp
@@ -244,6 +244,7 @@ namespace GUIEngine
void renderSections(ptr_vector* within_vector=NULL);
void drawBgImage();
+ void drawBGFadeColor();
// irrlicht's callbacks
virtual void draw2DRectangle (IGUIElement *element, const video::SColor &color, const core::rect< s32 > &pos, const core::rect< s32 > *clip);
diff --git a/src/input/input_device.cpp b/src/input/input_device.cpp
index 6e5380ce7..244ac9b80 100644
--- a/src/input/input_device.cpp
+++ b/src/input/input_device.cpp
@@ -1,10 +1,11 @@
-#include "states_screens/state_manager.hpp"
#include "config/device_config.hpp"
+#include "guiengine/abstract_state_manager.hpp"
#include "input/input.hpp"
#include "input/input_device.hpp"
#include "modes/world.hpp"
#include "race/race_manager.hpp"
+#include "states_screens/state_manager.hpp"
InputDevice::InputDevice()
@@ -88,7 +89,7 @@ void GamePadDevice::setButtonPressed(const int i, bool isButtonPressed)
void GamePadDevice::resetAxisDirection(const int axis, Input::AxisDirection direction, ActivePlayer* player)
{
KeyBinding bind;
- if(!StateManager::get()->isGameState()) return; // ignore this while in menus
+ if (StateManager::get()->getGameState() != GUIEngine::GAME) return; // ignore this while in menus
PlayerKart* pk = player->getKart();
if (pk == NULL)
diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp
index 8d049f25d..2306e755c 100644
--- a/src/input/input_manager.cpp
+++ b/src/input/input_manager.cpp
@@ -246,7 +246,7 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
// in menus, some keyboard keys are standard (before each player selected his device)
// FIXME: should enter always work to accept for a player using keyboard?
- if (!StateManager::get()->isGameState() && type == Input::IT_KEYBOARD && m_mode == MENU &&
+ if (StateManager::get()->getGameState() != GUIEngine::GAME && type == Input::IT_KEYBOARD && m_mode == MENU &&
m_device_manager->playerAssignMode() == NO_ASSIGN)
{
action = PA_FIRST;
@@ -315,7 +315,7 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
}
// ... when in-game
- if (StateManager::get()->isGameState() && !GUIEngine::ModalDialog::isADialogActive())
+ if (StateManager::get()->getGameState() == GUIEngine::GAME && !GUIEngine::ModalDialog::isADialogActive())
{
// Find the corresponding PlayerKart from our ActivePlayer instance
PlayerKart* pk;
@@ -508,7 +508,7 @@ bool InputManager::input(const SEvent& event)
// block events in all modes but initial menus (except in text boxes to allow typing, and exceptm in modal dialogs in-game)
return getDeviceList()->playerAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox &&
- (!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->isGameState());
+ (!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME);
}
//-----------------------------------------------------------------------------
diff --git a/src/main_loop.cpp b/src/main_loop.cpp
index 23682f715..fd2b368e9 100644
--- a/src/main_loop.cpp
+++ b/src/main_loop.cpp
@@ -78,7 +78,7 @@ float MainLoop::getLimitedDt()
// Throttle fps if more than maximum, which can reduce
// the noise the fan on a graphics card makes.
// When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus
- const int max_fps = StateManager::get()->isGameState() ? UserConfigParams::m_max_fps : 35;
+ const int max_fps = (StateManager::get()->getGameState() == GUIEngine::GAME ? UserConfigParams::m_max_fps : 35);
const int current_fps = (int)(1000.0f/dt);
if( current_fps > max_fps )
{
diff --git a/src/states_screens/dialogs/race_paused_dialog.cpp b/src/states_screens/dialogs/race_paused_dialog.cpp
index b6a3602b0..12ddaf2be 100644
--- a/src/states_screens/dialogs/race_paused_dialog.cpp
+++ b/src/states_screens/dialogs/race_paused_dialog.cpp
@@ -235,6 +235,9 @@ bool RacePausedDialog::processEvent(std::string& eventSource)
else if (selection == "help")
{
// TODO
+ dismiss();
+ StateManager::get()->pushMenu("help1.stkgui");
+ return true;
}
else if (selection == "options")
{
diff --git a/src/states_screens/state_manager.cpp b/src/states_screens/state_manager.cpp
index 42b5ce3f3..19599956d 100644
--- a/src/states_screens/state_manager.cpp
+++ b/src/states_screens/state_manager.cpp
@@ -468,7 +468,7 @@ void StateManager::escapePressed()
ModalDialog::dismiss();
}
// In-game
- else if(m_game_mode)
+ else if(m_game_mode == GAME)
{
new RacePausedDialog(0.8f, 0.6f);
//resetAndGoToMenu("main.stkgui");