mirror of
https://github.com/ihhub/fheroes2.git
synced 2026-10-12 02:16:11 +00:00
Properly setup application cursor (#10926)
This commit is contained in:
@@ -1603,10 +1603,15 @@ namespace fheroes2
|
||||
|
||||
void Display::release()
|
||||
{
|
||||
_engine->clear();
|
||||
_preprocessing = nullptr;
|
||||
_postprocessing = nullptr;
|
||||
|
||||
_cursor.reset();
|
||||
_engine->clear();
|
||||
_engine.reset();
|
||||
clear();
|
||||
|
||||
_renderSurface = nullptr;
|
||||
_prevRoi = {};
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wswitch-default"
|
||||
#endif
|
||||
|
||||
#include <SDL_error.h>
|
||||
#include <SDL_events.h>
|
||||
#include <SDL_main.h> // IWYU pragma: keep
|
||||
#include <SDL_mouse.h>
|
||||
|
||||
// Managing compiler warnings for SDL headers
|
||||
#if defined( __GNUC__ )
|
||||
@@ -154,11 +151,9 @@ namespace
|
||||
|
||||
fheroes2::engine().setTitle( GetCaption() );
|
||||
|
||||
// Hide system cursor.
|
||||
const int returnValue = SDL_ShowCursor( SDL_DISABLE );
|
||||
if ( returnValue < 0 ) {
|
||||
ERROR_LOG( "Failed to hide system cursor. Error description: " << SDL_GetError() )
|
||||
}
|
||||
auto & cursor = fheroes2::cursor();
|
||||
cursor.enableSoftwareEmulation( conf.isSoftwareEmulationEnabled() );
|
||||
cursor.show( false );
|
||||
|
||||
fheroes2::RenderProcessor & renderProcessor = fheroes2::RenderProcessor::instance();
|
||||
|
||||
@@ -173,7 +168,7 @@ namespace
|
||||
renderProcessor.startColorCycling();
|
||||
|
||||
// Update mouse cursor when switching between software emulation and OS mouse modes.
|
||||
fheroes2::cursor().registerUpdater( Cursor::Refresh );
|
||||
cursor.registerUpdater( Cursor::Refresh );
|
||||
|
||||
#if !defined( MACOS_APP_BUNDLE )
|
||||
const fheroes2::Image & appIcon = Compression::CreateImageFromZlib( 32, 32, iconImage, sizeof( iconImage ), true );
|
||||
@@ -187,10 +182,7 @@ namespace
|
||||
~DisplayInitializer()
|
||||
{
|
||||
fheroes2::RenderProcessor::instance().unregisterRenderers();
|
||||
|
||||
fheroes2::Display & display = fheroes2::Display::instance();
|
||||
display.subscribe( {}, {} );
|
||||
display.release();
|
||||
fheroes2::Display::instance().release();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -266,7 +258,7 @@ int main( int argc, char ** argv )
|
||||
|
||||
const System::CoreInitializer coreInitializer;
|
||||
|
||||
DEBUG_LOG( DBG_GAME, DBG_INFO, conf.String() )
|
||||
DEBUG_LOG( DBG_GAME, DBG_INFO, conf.getOptionsString() )
|
||||
|
||||
const DisplayInitializer displayInitializer;
|
||||
const DataInitializer dataInitializer;
|
||||
|
||||
@@ -358,11 +358,9 @@ bool Settings::Read( const std::string & filePath )
|
||||
if ( config.Exists( "cursor soft rendering" ) ) {
|
||||
if ( config.StrParams( "cursor soft rendering" ) == "on" ) {
|
||||
_gameOptions.SetModes( GAME_CURSOR_SOFT_EMULATION );
|
||||
fheroes2::cursor().enableSoftwareEmulation( true );
|
||||
}
|
||||
else {
|
||||
_gameOptions.ResetModes( GAME_CURSOR_SOFT_EMULATION );
|
||||
fheroes2::cursor().enableSoftwareEmulation( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,14 +399,14 @@ bool Settings::Save( const std::string_view fileName ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string data = String();
|
||||
const std::string data = getOptionsString();
|
||||
|
||||
fileStream.putRaw( data.data(), data.size() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Settings::String() const
|
||||
std::string Settings::getOptionsString() const
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
@@ -1026,6 +1024,11 @@ bool Settings::isBattleMovementAreaHighlightEnabled() const
|
||||
return _gameOptions.Modes( GAME_BATTLE_HIGHLIGHT_MOVEMENT_AREA );
|
||||
}
|
||||
|
||||
bool Settings::isSoftwareEmulationEnabled() const
|
||||
{
|
||||
return _gameOptions.Modes( GAME_CURSOR_SOFT_EMULATION );
|
||||
}
|
||||
|
||||
void Settings::switchToNextInterfaceType()
|
||||
{
|
||||
switch ( _interfaceType ) {
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
bool Read( const std::string & filePath );
|
||||
bool Save( const std::string_view fileName ) const;
|
||||
|
||||
std::string String() const;
|
||||
std::string getOptionsString() const;
|
||||
|
||||
void setCurrentMapInfo( Maps::FileInfo fi );
|
||||
|
||||
@@ -219,6 +219,7 @@ public:
|
||||
bool isScreenScalingTypeNearest() const;
|
||||
bool isEvilInterfaceEnabled() const;
|
||||
bool isBattleMovementAreaHighlightEnabled() const;
|
||||
bool isSoftwareEmulationEnabled() const;
|
||||
|
||||
void setInterfaceType( const InterfaceType type )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user