Better cursor show/hide management (esp. cursor will show in in-game dialogs)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4565 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
6705f0899a
commit
fd5730a0da
@ -54,7 +54,6 @@ IrrDriver *irr_driver = NULL;
|
||||
IrrDriver::IrrDriver()
|
||||
{
|
||||
file_manager->dropFileSystem();
|
||||
|
||||
initDevice();
|
||||
} // IrrDriver
|
||||
|
||||
@ -70,7 +69,7 @@ void IrrDriver::initDevice()
|
||||
static bool firstTime = true;
|
||||
|
||||
// ---- the first time, get a list of available video modes
|
||||
if(firstTime)
|
||||
if (firstTime)
|
||||
{
|
||||
m_device = createDevice(video::EDT_NULL);
|
||||
|
||||
@ -191,6 +190,11 @@ void IrrDriver::initDevice()
|
||||
material2D.AntiAliasing=video::EAAM_FULL_BASIC;
|
||||
//m_video_driver->enableMaterial2D();
|
||||
#endif
|
||||
|
||||
// set cursor viasible by default (what's the default is not tooclearly documented,
|
||||
// so let's decide ourselves...)
|
||||
m_device->getCursorControl()->setVisible(true);
|
||||
m_pointer_shown = true;
|
||||
}
|
||||
|
||||
|
||||
@ -244,13 +248,21 @@ video::E_DRIVER_TYPE IrrDriver::getEngineDriverType( int index )
|
||||
//-----------------------------------------------------------------------------
|
||||
void IrrDriver::showPointer()
|
||||
{
|
||||
this->getDevice()->getCursorControl()->setVisible(true);
|
||||
if (!m_pointer_shown)
|
||||
{
|
||||
m_pointer_shown = true;
|
||||
this->getDevice()->getCursorControl()->setVisible(true);
|
||||
}
|
||||
} // showPointer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void IrrDriver::hidePointer()
|
||||
{
|
||||
this->getDevice()->getCursorControl()->setVisible(false);
|
||||
if (m_pointer_shown)
|
||||
{
|
||||
m_pointer_shown = false;
|
||||
this->getDevice()->getCursorControl()->setVisible(false);
|
||||
}
|
||||
} // hidePointer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -58,6 +58,10 @@ private:
|
||||
void displayFPS();
|
||||
void setupViewports();
|
||||
video::E_DRIVER_TYPE getEngineDriverType(int index);
|
||||
|
||||
/** Whether the mouse cursor is currently shown */
|
||||
bool m_pointer_shown;
|
||||
|
||||
public:
|
||||
IrrDriver();
|
||||
~IrrDriver();
|
||||
@ -112,6 +116,7 @@ public:
|
||||
void changeResolution();
|
||||
void showPointer();
|
||||
void hidePointer();
|
||||
bool isPointerShown() const { return m_pointer_shown; }
|
||||
void printRenderStats();
|
||||
/** Returns the current real time, which might not be 0 at start of the
|
||||
* application. Value in msec.
|
||||
|
@ -56,7 +56,7 @@ void AbstractStateManager::enterGameState()
|
||||
if (getCurrentScreen() != NULL) getCurrentScreen()->tearDown();
|
||||
m_menu_stack.clear();
|
||||
m_menu_stack.push_back("race");
|
||||
m_game_mode = GAME;
|
||||
setGameState(GAME);
|
||||
cleanForGame();
|
||||
input_manager->setMode(InputManager::INGAME);
|
||||
}
|
||||
@ -84,12 +84,12 @@ void AbstractStateManager::pushMenu(std::string name)
|
||||
m_menu_stack.push_back(name);
|
||||
if (m_game_mode == GAME)
|
||||
{
|
||||
m_game_mode = INGAME_MENU;
|
||||
setGameState(INGAME_MENU);
|
||||
RaceManager::getWorld()->pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_game_mode = MENU;
|
||||
setGameState(MENU);
|
||||
}
|
||||
switchToScreen(name.c_str());
|
||||
}
|
||||
@ -157,18 +157,26 @@ void AbstractStateManager::popMenu()
|
||||
{
|
||||
RaceManager::getWorld()->unpause();
|
||||
}
|
||||
m_game_mode = GAME;
|
||||
setGameState(GAME);
|
||||
cleanForGame();
|
||||
input_manager->setMode(InputManager::INGAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_game_mode = MENU;
|
||||
setGameState(MENU);
|
||||
switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
|
||||
getCurrentScreen()->init();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractStateManager::setGameState(GameState state)
|
||||
{
|
||||
m_game_mode = state;
|
||||
|
||||
if (m_game_mode == GAME) irr_driver->hidePointer();
|
||||
else irr_driver->showPointer();
|
||||
}
|
||||
|
||||
void AbstractStateManager::resetAndGoToScreen(Screen* screen)
|
||||
{
|
||||
std::string name = screen->getName();
|
||||
@ -178,7 +186,7 @@ void AbstractStateManager::resetAndGoToScreen(Screen* screen)
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
m_menu_stack.clear();
|
||||
m_menu_stack.push_back(name);
|
||||
m_game_mode = MENU;
|
||||
setGameState(MENU);
|
||||
sound_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
||||
switchToScreen(name.c_str());
|
||||
getCurrentScreen()->init();
|
||||
|
@ -34,6 +34,8 @@ protected:
|
||||
|
||||
void pushMenu(std::string name);
|
||||
|
||||
void setGameState(GameState state);
|
||||
|
||||
public:
|
||||
AbstractStateManager();
|
||||
virtual ~AbstractStateManager() { }
|
||||
|
@ -22,11 +22,20 @@ using namespace irr;
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
// global instance of the current dialog if any
|
||||
static ModalDialog* modalWindow = NULL;
|
||||
/** global instance of the current dialog if any */
|
||||
static ModalDialog* modalWindow = NULL;
|
||||
|
||||
/** To remember and restore the previous state */
|
||||
bool pointer_was_shown;
|
||||
}
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
ModalDialog::ModalDialog(const float percentWidth, const float percentHeight)
|
||||
{
|
||||
pointer_was_shown = irr_driver->isPointerShown();
|
||||
irr_driver->showPointer();
|
||||
|
||||
const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
||||
|
||||
const int w = (int)(frame_size.Width*percentWidth);
|
||||
@ -67,6 +76,10 @@ ModalDialog::~ModalDialog()
|
||||
m_irrlicht_window->remove();
|
||||
|
||||
if (modalWindow == this) modalWindow = NULL;
|
||||
|
||||
// restore previous pointer state
|
||||
if (pointer_was_shown) irr_driver->showPointer();
|
||||
else irr_driver->hidePointer();
|
||||
}
|
||||
|
||||
void ModalDialog::clearWindow()
|
||||
@ -153,4 +166,3 @@ Widget* ModalDialog::getFirstWidget()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -102,6 +102,11 @@ void StateManager::resetActivePlayers()
|
||||
m_active_players.clearWithoutDeleting();
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#pragma mark misc stuff
|
||||
#endif
|
||||
|
||||
bool StateManager::throttleFPS()
|
||||
{
|
||||
return m_game_mode != GUIEngine::GAME && GUIEngine::getCurrentScreen()->throttleFPS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user