mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Save the window zoom and fullscreen settings in the user preferences
This commit is contained in:
parent
f97d1c3644
commit
1db67ed200
@ -936,10 +936,6 @@ DoInit (int argc, char * argv[], bool & exit)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all cursors
|
|
||||||
g_pPixmap->LoadCursors (g_windowScale);
|
|
||||||
g_pPixmap->ChangeSprite (SPRITE_WAIT); // met le sablier maison
|
|
||||||
|
|
||||||
// Create the sound manager.
|
// Create the sound manager.
|
||||||
g_pSound = new CSound;
|
g_pSound = new CSound;
|
||||||
if (g_pSound == nullptr)
|
if (g_pSound == nullptr)
|
||||||
@ -981,10 +977,18 @@ DoInit (int argc, char * argv[], bool & exit)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool zoom = g_windowScale;
|
||||||
|
|
||||||
g_pEvent->Create (g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
g_pEvent->Create (g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
||||||
|
|
||||||
|
// Load all cursors
|
||||||
|
g_pPixmap->LoadCursors (g_windowScale);
|
||||||
|
g_pPixmap->ChangeSprite (SPRITE_WAIT); // met le sablier maison
|
||||||
|
|
||||||
g_updateThread = new std::thread (CheckForUpdates);
|
g_updateThread = new std::thread (CheckForUpdates);
|
||||||
g_pEvent->SetFullScreen (g_bFullScreen);
|
if (g_bFullScreen)
|
||||||
if (!g_bFullScreen)
|
g_pEvent->SetFullScreen (true);
|
||||||
|
if (!g_bFullScreen && zoom != g_windowScale)
|
||||||
g_pEvent->SetWindowSize (g_windowScale);
|
g_pEvent->SetWindowSize (g_windowScale);
|
||||||
g_pEvent->ChangePhase (EV_PHASE_INTRO1);
|
g_pEvent->ChangePhase (EV_PHASE_INTRO1);
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
extern SDL_Window * g_window;
|
extern SDL_Window * g_window;
|
||||||
extern SDL_Renderer * g_renderer;
|
extern SDL_Renderer * g_renderer;
|
||||||
extern bool g_bFullScreen;
|
extern bool g_bFullScreen;
|
||||||
|
extern Uint8 g_windowScale;
|
||||||
extern bool g_restoreBugs;
|
extern bool g_restoreBugs;
|
||||||
extern bool g_restoreMidi;
|
extern bool g_restoreMidi;
|
||||||
extern bool g_enableRecorder;
|
extern bool g_enableRecorder;
|
||||||
|
@ -72,8 +72,10 @@ typedef struct {
|
|||||||
Sint16 language;
|
Sint16 language;
|
||||||
// v1.2
|
// v1.2
|
||||||
Sint16 musicMidi;
|
Sint16 musicMidi;
|
||||||
|
Sint16 fullScreen;
|
||||||
|
Sint16 zoom;
|
||||||
|
|
||||||
Sint16 reserve2[91];
|
Sint16 reserve2[89];
|
||||||
} DescInfo;
|
} DescInfo;
|
||||||
|
|
||||||
// Toutes les premières lettres doivent
|
// Toutes les premières lettres doivent
|
||||||
@ -1539,8 +1541,6 @@ CEvent::CEvent ()
|
|||||||
{
|
{
|
||||||
Sint32 i;
|
Sint32 i;
|
||||||
|
|
||||||
m_bFullScreen = false;
|
|
||||||
m_WindowScale = 1;
|
|
||||||
m_exercice = 0;
|
m_exercice = 0;
|
||||||
m_mission = 0;
|
m_mission = 0;
|
||||||
m_private = 0;
|
m_private = 0;
|
||||||
@ -1657,25 +1657,22 @@ CEvent::GetMousePos ()
|
|||||||
void
|
void
|
||||||
CEvent::SetFullScreen (bool bFullScreen)
|
CEvent::SetFullScreen (bool bFullScreen)
|
||||||
{
|
{
|
||||||
if (bFullScreen == m_bFullScreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
SDL_GetMouseState (&x, &y);
|
SDL_GetMouseState (&x, &y);
|
||||||
x /= m_WindowScale;
|
x /= g_windowScale;
|
||||||
y /= m_WindowScale;
|
y /= g_windowScale;
|
||||||
|
|
||||||
m_WindowScale = 1;
|
g_windowScale = 1;
|
||||||
SDL_SetWindowSize (g_window, LXIMAGE, LYIMAGE);
|
SDL_SetWindowSize (g_window, LXIMAGE, LYIMAGE);
|
||||||
|
|
||||||
m_bFullScreen = bFullScreen;
|
g_bFullScreen = bFullScreen;
|
||||||
SDL_SetWindowFullscreen (g_window, bFullScreen ? SDL_WINDOW_FULLSCREEN : 0);
|
SDL_SetWindowFullscreen (g_window, bFullScreen ? SDL_WINDOW_FULLSCREEN : 0);
|
||||||
SDL_SetWindowBordered (g_window, bFullScreen ? SDL_FALSE : SDL_TRUE);
|
SDL_SetWindowBordered (g_window, bFullScreen ? SDL_FALSE : SDL_TRUE);
|
||||||
SDL_SetWindowGrab (g_window, bFullScreen ? SDL_TRUE : SDL_FALSE);
|
SDL_SetWindowGrab (g_window, bFullScreen ? SDL_TRUE : SDL_FALSE);
|
||||||
SDL_SetWindowPosition (
|
SDL_SetWindowPosition (
|
||||||
g_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
g_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
|
|
||||||
m_pPixmap->LoadCursors (m_WindowScale);
|
m_pPixmap->LoadCursors (g_windowScale);
|
||||||
m_pPixmap->ReloadTargetTextures ();
|
m_pPixmap->ReloadTargetTextures ();
|
||||||
|
|
||||||
/* Force this update before otherwise the coordinates retrieved with
|
/* Force this update before otherwise the coordinates retrieved with
|
||||||
@ -1699,16 +1696,13 @@ CEvent::SetFullScreen (bool bFullScreen)
|
|||||||
void
|
void
|
||||||
CEvent::SetWindowSize (Uint8 newScale)
|
CEvent::SetWindowSize (Uint8 newScale)
|
||||||
{
|
{
|
||||||
if (newScale == m_WindowScale)
|
auto scale = g_windowScale;
|
||||||
return;
|
g_windowScale = newScale;
|
||||||
|
|
||||||
auto scale = m_WindowScale;
|
|
||||||
m_WindowScale = newScale;
|
|
||||||
switch (newScale)
|
switch (newScale)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
SetWindowSize (scale, m_WindowScale);
|
SetWindowSize (scale, g_windowScale);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1748,12 +1742,6 @@ CEvent::SetWindowSize (Uint8 prevScale, Uint8 newScale)
|
|||||||
CEvent::PushUserEvent (EV_WARPMOUSE, coord);
|
CEvent::PushUserEvent (EV_WARPMOUSE, coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
|
||||||
CEvent::GetWindowScale ()
|
|
||||||
{
|
|
||||||
return m_WindowScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Crée le gestionnaire d'événements.
|
// Crée le gestionnaire d'événements.
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2092,11 +2080,11 @@ CEvent::DrawButtons ()
|
|||||||
SetEnable (EV_BUTTON1, m_Lang != m_Languages.begin ());
|
SetEnable (EV_BUTTON1, m_Lang != m_Languages.begin ());
|
||||||
SetEnable (EV_BUTTON2, m_Lang != m_Languages.end () - 1);
|
SetEnable (EV_BUTTON2, m_Lang != m_Languages.end () - 1);
|
||||||
|
|
||||||
SetEnable (EV_BUTTON3, !m_bFullScreen);
|
SetEnable (EV_BUTTON3, !g_bFullScreen);
|
||||||
SetEnable (EV_BUTTON4, m_bFullScreen);
|
SetEnable (EV_BUTTON4, g_bFullScreen);
|
||||||
|
|
||||||
SetEnable (EV_BUTTON5, !m_bFullScreen && m_WindowScale > 1);
|
SetEnable (EV_BUTTON5, !g_bFullScreen && g_windowScale > 1);
|
||||||
SetEnable (EV_BUTTON6, !m_bFullScreen && m_WindowScale < 2);
|
SetEnable (EV_BUTTON6, !g_bFullScreen && g_windowScale < 2);
|
||||||
|
|
||||||
SetEnable (EV_BUTTON7, g_restoreMidi);
|
SetEnable (EV_BUTTON7, g_restoreMidi);
|
||||||
SetEnable (EV_BUTTON8, !g_restoreMidi);
|
SetEnable (EV_BUTTON8, !g_restoreMidi);
|
||||||
@ -2574,15 +2562,15 @@ CEvent::DrawButtons ()
|
|||||||
DrawText (m_pPixmap, pos, lang.c_str ());
|
DrawText (m_pPixmap, pos, lang.c_str ());
|
||||||
|
|
||||||
const char * text =
|
const char * text =
|
||||||
m_bFullScreen ? gettext ("Fullscreen") : gettext ("Windowed");
|
g_bFullScreen ? gettext ("Fullscreen") : gettext ("Windowed");
|
||||||
lg = GetTextWidth (text);
|
lg = GetTextWidth (text);
|
||||||
pos.x = (169 + 40) - lg / 2;
|
pos.x = (169 + 40) - lg / 2;
|
||||||
pos.y = 330 - 20;
|
pos.y = 330 - 20;
|
||||||
DrawText (m_pPixmap, pos, text);
|
DrawText (m_pPixmap, pos, text);
|
||||||
|
|
||||||
if (!m_bFullScreen)
|
if (!g_bFullScreen)
|
||||||
{
|
{
|
||||||
snprintf (res, sizeof (res), "%dx", m_WindowScale);
|
snprintf (res, sizeof (res), "%dx", g_windowScale);
|
||||||
lg = GetTextWidth (res);
|
lg = GetTextWidth (res);
|
||||||
pos.x = (284 + 40) - lg / 2;
|
pos.x = (284 + 40) - lg / 2;
|
||||||
pos.y = 330 - 20;
|
pos.y = 330 - 20;
|
||||||
@ -2690,7 +2678,7 @@ CEvent::MousePosToSprite (Point pos)
|
|||||||
pos.y <= POSMAPY + DIMMAPY)
|
pos.y <= POSMAPY + DIMMAPY)
|
||||||
sprite = SPRITE_MAP;
|
sprite = SPRITE_MAP;
|
||||||
|
|
||||||
if (m_bFullScreen && !m_bDemoRec && !m_bDemoPlay && m_scrollSpeed != 0)
|
if (g_bFullScreen && !m_bDemoRec && !m_bDemoPlay && m_scrollSpeed != 0)
|
||||||
{
|
{
|
||||||
if (pos.x <= 5 && pos.x >= -2)
|
if (pos.x <= 5 && pos.x >= -2)
|
||||||
bLeft = true;
|
bLeft = true;
|
||||||
@ -3591,7 +3579,7 @@ CEvent::DecorAutoShift ()
|
|||||||
|
|
||||||
m_bShift = false;
|
m_bShift = false;
|
||||||
|
|
||||||
if (!byKeyboard && (!m_bFullScreen || m_scrollSpeed == 0))
|
if (!byKeyboard && (!g_bFullScreen || m_scrollSpeed == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
max = maxLimit - m_scrollSpeed; // max <- 3..1
|
max = maxLimit - m_scrollSpeed; // max <- 3..1
|
||||||
@ -4126,18 +4114,18 @@ CEvent::ChangeButtons (Sint32 message)
|
|||||||
break;
|
break;
|
||||||
case EV_BUTTON5:
|
case EV_BUTTON5:
|
||||||
{
|
{
|
||||||
auto scale = m_WindowScale;
|
auto scale = g_windowScale;
|
||||||
if (m_WindowScale > 1)
|
if (g_windowScale > 1)
|
||||||
--m_WindowScale;
|
--g_windowScale;
|
||||||
SetWindowSize (scale, m_WindowScale);
|
SetWindowSize (scale, g_windowScale);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EV_BUTTON6:
|
case EV_BUTTON6:
|
||||||
{
|
{
|
||||||
auto scale = m_WindowScale;
|
auto scale = g_windowScale;
|
||||||
if (m_WindowScale < 2)
|
if (g_windowScale < 2)
|
||||||
++m_WindowScale;
|
++g_windowScale;
|
||||||
SetWindowSize (scale, m_WindowScale);
|
SetWindowSize (scale, g_windowScale);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EV_BUTTON7:
|
case EV_BUTTON7:
|
||||||
@ -4720,7 +4708,9 @@ CEvent::WriteInfo ()
|
|||||||
info.language = static_cast<Sint16> (
|
info.language = static_cast<Sint16> (
|
||||||
this->GetLanguage () != this->GetStartLanguage () ? this->GetLanguage ()
|
this->GetLanguage () != this->GetStartLanguage () ? this->GetLanguage ()
|
||||||
: Language::undef);
|
: Language::undef);
|
||||||
info.musicMidi = g_restoreMidi;
|
info.musicMidi = g_restoreMidi;
|
||||||
|
info.fullScreen = g_bFullScreen;
|
||||||
|
info.zoom = g_windowScale;
|
||||||
|
|
||||||
nb = fwrite (&info, sizeof (info), 1, file);
|
nb = fwrite (&info, sizeof (info), 1, file);
|
||||||
if (nb < 1)
|
if (nb < 1)
|
||||||
@ -4779,10 +4769,15 @@ CEvent::ReadInfo ()
|
|||||||
this->SetLanguage (static_cast<Language> (info.language));
|
this->SetLanguage (static_cast<Language> (info.language));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (((info.majRev == 1 && info.minRev >= 2) || info.majRev >= 2))
|
||||||
((info.majRev == 1 && info.minRev >= 2) || info.majRev >= 2) &&
|
{
|
||||||
!(g_settingsOverload & SETTING_MIDI))
|
if (!(g_settingsOverload & SETTING_MIDI))
|
||||||
g_restoreMidi = !!info.musicMidi;
|
g_restoreMidi = !!info.musicMidi;
|
||||||
|
if (!(g_settingsOverload & SETTING_FULLSCREEN))
|
||||||
|
g_bFullScreen = !!info.fullScreen;
|
||||||
|
if (!(g_settingsOverload & SETTING_ZOOM))
|
||||||
|
g_windowScale = info.zoom;
|
||||||
|
}
|
||||||
|
|
||||||
fclose (file);
|
fclose (file);
|
||||||
return true;
|
return true;
|
||||||
@ -5160,7 +5155,7 @@ CEvent::DemoStep ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_WarpMouseInWindow (
|
SDL_WarpMouseInWindow (
|
||||||
g_window, pos.x * m_WindowScale, pos.y * m_WindowScale);
|
g_window, pos.x * g_windowScale, pos.y * g_windowScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pDemoBuffer)
|
if (m_pDemoBuffer)
|
||||||
|
@ -142,7 +142,6 @@ public:
|
|||||||
|
|
||||||
void IntroStep ();
|
void IntroStep ();
|
||||||
|
|
||||||
Uint8 GetWindowScale ();
|
|
||||||
void SetWindowSize (Uint8 newScale);
|
void SetWindowSize (Uint8 newScale);
|
||||||
void SetUpdateVersion (const std::string & version);
|
void SetUpdateVersion (const std::string & version);
|
||||||
|
|
||||||
@ -199,8 +198,6 @@ protected:
|
|||||||
bool m_bSchool;
|
bool m_bSchool;
|
||||||
bool m_bPrivate;
|
bool m_bPrivate;
|
||||||
bool m_bAccessBuild;
|
bool m_bAccessBuild;
|
||||||
bool m_bFullScreen;
|
|
||||||
Uint8 m_WindowScale;
|
|
||||||
CPixmap * m_pPixmap;
|
CPixmap * m_pPixmap;
|
||||||
CDecor * m_pDecor;
|
CDecor * m_pDecor;
|
||||||
CSound * m_pSound;
|
CSound * m_pSound;
|
||||||
|
@ -188,8 +188,7 @@ CMenu::Create (
|
|||||||
pos.x += DIMBUTTONX / 2;
|
pos.x += DIMBUTTONX / 2;
|
||||||
pos.y += DIMBUTTONY / 2;
|
pos.y += DIMBUTTONY / 2;
|
||||||
SDL_WarpMouseInWindow (
|
SDL_WarpMouseInWindow (
|
||||||
g_window, pos.x * m_pEvent->GetWindowScale (),
|
g_window, pos.x * g_windowScale, pos.y * g_windowScale);
|
||||||
pos.y * m_pEvent->GetWindowScale ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_selRank = Detect (pos);
|
m_selRank = Detect (pos);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user