Revert "Hide the cursor during gameplay (#4861)" (#4862)

This reverts commit 07e22b033b566d61e99d077b2588fa1de6e5c5f8.
This commit is contained in:
Semphriss 2023-04-24 20:40:34 -04:00 committed by GitHub
parent 07e22b033b
commit fd12829e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 53 deletions

View File

@ -91,9 +91,6 @@
#include <IrrlichtDevice.h> #include <IrrlichtDevice.h>
#include <ISceneManager.h> #include <ISceneManager.h>
/** Hide the cursor after this many seconds without movement */
#define HIDE_CURSOR_STARTINGAT 1.0f
World* World::m_world[PT_COUNT]; World* World::m_world[PT_COUNT];
/** The main world class is used to handle the track and the karts. /** The main world class is used to handle the track and the karts.
@ -164,8 +161,6 @@ void World::init()
{ {
m_ended_early = false; m_ended_early = false;
m_faster_music_active = false; m_faster_music_active = false;
m_time_since_last_mouse_mvmt = HIDE_CURSOR_STARTINGAT;
m_force_show_cursor = false;
m_fastest_kart = 0; m_fastest_kart = 0;
m_eliminated_karts = 0; m_eliminated_karts = 0;
m_eliminated_players = 0; m_eliminated_players = 0;
@ -424,16 +419,6 @@ void World::reset(bool restart)
// Start music from beginning // Start music from beginning
music_manager->stopMusic(); music_manager->stopMusic();
#ifndef SERVER_ONLY
if (m_process_type == PT_MAIN)
{
m_force_show_cursor = false;
m_time_since_last_mouse_mvmt = HIDE_CURSOR_STARTINGAT;
SDL_GetMouseState(&m_last_mouse_pos_x, &m_last_mouse_pos_y);
SDL_ShowCursor(SDL_DISABLE);
}
#endif
// Enable SFX again // Enable SFX again
SFXManager::get()->resumeAll(); SFXManager::get()->resumeAll();
@ -624,11 +609,6 @@ World::~World()
{ {
if (m_process_type == PT_MAIN) if (m_process_type == PT_MAIN)
{ {
#ifndef SERVER_ONLY
// This shouldn't be necessary, but just to be sure
SDL_ShowCursor(SDL_ENABLE);
#endif
GUIEngine::getDevice()->setResizable(false); GUIEngine::getDevice()->setResizable(false);
material_manager->unloadAllTextures(); material_manager->unloadAllTextures();
} }
@ -747,8 +727,6 @@ void World::onGo()
*/ */
void World::terminateRace() void World::terminateRace()
{ {
m_force_show_cursor = true;
// In case the user opened paused dialog in network // In case the user opened paused dialog in network
if (!GUIEngine::isNoGraphics()) if (!GUIEngine::isNoGraphics())
{ {
@ -1028,6 +1006,7 @@ void World::updateWorld(int ticks)
assert(m_magic_number == 0xB01D6543); assert(m_magic_number == 0xB01D6543);
#endif #endif
if (m_schedule_pause) if (m_schedule_pause)
{ {
pause(m_scheduled_pause_phase); pause(m_scheduled_pause_phase);
@ -1143,27 +1122,6 @@ void World::scheduleTutorial()
*/ */
void World::updateGraphics(float dt) void World::updateGraphics(float dt)
{ {
#ifndef SERVER_ONLY
if (m_process_type == PT_MAIN)
{
int x, y;
SDL_GetMouseState(&x, &y);
if (m_last_mouse_pos_x != x || m_last_mouse_pos_y != y)
{
m_time_since_last_mouse_mvmt = 0;
m_last_mouse_pos_x = x;
m_last_mouse_pos_y = y;
}
else
{
m_time_since_last_mouse_mvmt += dt;
}
SDL_ShowCursor((m_time_since_last_mouse_mvmt < HIDE_CURSOR_STARTINGAT
|| m_force_show_cursor) ? SDL_ENABLE : SDL_DISABLE);
}
#endif
if (auto cl = LobbyProtocol::get<ClientLobby>()) if (auto cl = LobbyProtocol::get<ClientLobby>())
{ {
// Reset all smooth network body of rewinders so the rubber band effect // Reset all smooth network body of rewinders so the rubber band effect
@ -1521,8 +1479,6 @@ void World::getDefaultCollectibles(int *collectible_type, int *amount )
*/ */
void World::pause(Phase phase) void World::pause(Phase phase)
{ {
m_force_show_cursor = true;
if (m_stop_music_when_dialog_open) if (m_stop_music_when_dialog_open)
music_manager->pauseMusic(); music_manager->pauseMusic();
SFXManager::get()->pauseAll(); SFXManager::get()->pauseAll();
@ -1533,9 +1489,6 @@ void World::pause(Phase phase)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void World::unpause() void World::unpause()
{ {
m_force_show_cursor = false;
m_time_since_last_mouse_mvmt = HIDE_CURSOR_STARTINGAT;
if (m_stop_music_when_dialog_open) if (m_stop_music_when_dialog_open)
music_manager->resumeMusic(); music_manager->resumeMusic();
SFXManager::get()->resumeAll(); SFXManager::get()->resumeAll();

View File

@ -184,11 +184,6 @@ protected:
bool m_ended_early; bool m_ended_early;
int m_last_mouse_pos_x;
int m_last_mouse_pos_y;
float m_time_since_last_mouse_mvmt;
bool m_force_show_cursor;
virtual void onGo() OVERRIDE; virtual void onGo() OVERRIDE;
/** Returns true if the race is over. Must be defined by all modes. */ /** Returns true if the race is over. Must be defined by all modes. */
virtual bool isRaceOver() = 0; virtual bool isRaceOver() = 0;