This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository planetblupi.

commit 1db67ed20012839628efba65d24ba0bee6cf449d
Author: Mathieu Schroeter <math...@schroetersa.ch>
Date:   Thu Dec 14 23:07:17 2017 +0100

    Save the window zoom and fullscreen settings in the user preferences
---
 src/blupi.cxx | 16 ++++++-----
 src/blupi.h   |  1 +
 src/event.cxx | 87 ++++++++++++++++++++++++++++-------------------------------
 src/event.h   |  3 ---
 src/menu.cxx  |  3 +--
 5 files changed, 53 insertions(+), 57 deletions(-)

diff --git a/src/blupi.cxx b/src/blupi.cxx
index 515d38d..c516ff2 100644
--- a/src/blupi.cxx
+++ b/src/blupi.cxx
@@ -936,10 +936,6 @@ DoInit (int argc, char * argv[], bool & exit)
     return EXIT_FAILURE;
   }
 
-  // Load all cursors
-  g_pPixmap->LoadCursors (g_windowScale);
-  g_pPixmap->ChangeSprite (SPRITE_WAIT); // met le sablier maison
-
   // Create the sound manager.
   g_pSound = new CSound;
   if (g_pSound == nullptr)
@@ -981,10 +977,18 @@ DoInit (int argc, char * argv[], bool & exit)
     return EXIT_FAILURE;
   }
 
+  const bool zoom = g_windowScale;
+
   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_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->ChangePhase (EV_PHASE_INTRO1);
 
diff --git a/src/blupi.h b/src/blupi.h
index 49d4363..54b7bd8 100644
--- a/src/blupi.h
+++ b/src/blupi.h
@@ -29,6 +29,7 @@
 extern SDL_Window *   g_window;
 extern SDL_Renderer * g_renderer;
 extern bool           g_bFullScreen;
+extern Uint8          g_windowScale;
 extern bool           g_restoreBugs;
 extern bool           g_restoreMidi;
 extern bool           g_enableRecorder;
diff --git a/src/event.cxx b/src/event.cxx
index 959e141..f8817bd 100644
--- a/src/event.cxx
+++ b/src/event.cxx
@@ -72,8 +72,10 @@ typedef struct {
   Sint16 language;
   // v1.2
   Sint16 musicMidi;
+  Sint16 fullScreen;
+  Sint16 zoom;
 
-  Sint16 reserve2[91];
+  Sint16 reserve2[89];
 } DescInfo;
 
 // Toutes les premières lettres doivent
@@ -1539,8 +1541,6 @@ CEvent::CEvent ()
 {
   Sint32 i;
 
-  m_bFullScreen     = false;
-  m_WindowScale     = 1;
   m_exercice        = 0;
   m_mission         = 0;
   m_private         = 0;
@@ -1657,25 +1657,22 @@ CEvent::GetMousePos ()
 void
 CEvent::SetFullScreen (bool bFullScreen)
 {
-  if (bFullScreen == m_bFullScreen)
-    return;
-
   int x, y;
   SDL_GetMouseState (&x, &y);
-  x /= m_WindowScale;
-  y /= m_WindowScale;
+  x /= g_windowScale;
+  y /= g_windowScale;
 
-  m_WindowScale = 1;
+  g_windowScale = 1;
   SDL_SetWindowSize (g_window, LXIMAGE, LYIMAGE);
 
-  m_bFullScreen = bFullScreen;
+  g_bFullScreen = bFullScreen;
   SDL_SetWindowFullscreen (g_window, bFullScreen ? SDL_WINDOW_FULLSCREEN : 0);
   SDL_SetWindowBordered (g_window, bFullScreen ? SDL_FALSE : SDL_TRUE);
   SDL_SetWindowGrab (g_window, bFullScreen ? SDL_TRUE : SDL_FALSE);
   SDL_SetWindowPosition (
     g_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
 
-  m_pPixmap->LoadCursors (m_WindowScale);
+  m_pPixmap->LoadCursors (g_windowScale);
   m_pPixmap->ReloadTargetTextures ();
 
   /* Force this update before otherwise the coordinates retrieved with
@@ -1699,16 +1696,13 @@ CEvent::SetFullScreen (bool bFullScreen)
 void
 CEvent::SetWindowSize (Uint8 newScale)
 {
-  if (newScale == m_WindowScale)
-    return;
-
-  auto scale    = m_WindowScale;
-  m_WindowScale = newScale;
+  auto scale    = g_windowScale;
+  g_windowScale = newScale;
   switch (newScale)
   {
   case 1:
   case 2:
-    SetWindowSize (scale, m_WindowScale);
+    SetWindowSize (scale, g_windowScale);
     break;
 
   default:
@@ -1748,12 +1742,6 @@ CEvent::SetWindowSize (Uint8 prevScale, Uint8 newScale)
   CEvent::PushUserEvent (EV_WARPMOUSE, coord);
 }
 
-Uint8
-CEvent::GetWindowScale ()
-{
-  return m_WindowScale;
-}
-
 // Crée le gestionnaire d'événements.
 
 void
@@ -2092,11 +2080,11 @@ CEvent::DrawButtons ()
     SetEnable (EV_BUTTON1, m_Lang != m_Languages.begin ());
     SetEnable (EV_BUTTON2, m_Lang != m_Languages.end () - 1);
 
-    SetEnable (EV_BUTTON3, !m_bFullScreen);
-    SetEnable (EV_BUTTON4, m_bFullScreen);
+    SetEnable (EV_BUTTON3, !g_bFullScreen);
+    SetEnable (EV_BUTTON4, g_bFullScreen);
 
-    SetEnable (EV_BUTTON5, !m_bFullScreen && m_WindowScale > 1);
-    SetEnable (EV_BUTTON6, !m_bFullScreen && m_WindowScale < 2);
+    SetEnable (EV_BUTTON5, !g_bFullScreen && g_windowScale > 1);
+    SetEnable (EV_BUTTON6, !g_bFullScreen && g_windowScale < 2);
 
     SetEnable (EV_BUTTON7, g_restoreMidi);
     SetEnable (EV_BUTTON8, !g_restoreMidi);
@@ -2574,15 +2562,15 @@ CEvent::DrawButtons ()
     DrawText (m_pPixmap, pos, lang.c_str ());
 
     const char * text =
-      m_bFullScreen ? gettext ("Fullscreen") : gettext ("Windowed");
+      g_bFullScreen ? gettext ("Fullscreen") : gettext ("Windowed");
     lg    = GetTextWidth (text);
     pos.x = (169 + 40) - lg / 2;
     pos.y = 330 - 20;
     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);
       pos.x = (284 + 40) - lg / 2;
       pos.y = 330 - 20;
@@ -2690,7 +2678,7 @@ CEvent::MousePosToSprite (Point pos)
       pos.y <= POSMAPY + DIMMAPY)
       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)
         bLeft = true;
@@ -3591,7 +3579,7 @@ CEvent::DecorAutoShift ()
 
   m_bShift = false;
 
-  if (!byKeyboard && (!m_bFullScreen || m_scrollSpeed == 0))
+  if (!byKeyboard && (!g_bFullScreen || m_scrollSpeed == 0))
     return;
 
   max = maxLimit - m_scrollSpeed; // max <- 3..1
@@ -4126,18 +4114,18 @@ CEvent::ChangeButtons (Sint32 message)
       break;
     case EV_BUTTON5:
     {
-      auto scale = m_WindowScale;
-      if (m_WindowScale > 1)
-        --m_WindowScale;
-      SetWindowSize (scale, m_WindowScale);
+      auto scale = g_windowScale;
+      if (g_windowScale > 1)
+        --g_windowScale;
+      SetWindowSize (scale, g_windowScale);
       break;
     }
     case EV_BUTTON6:
     {
-      auto scale = m_WindowScale;
-      if (m_WindowScale < 2)
-        ++m_WindowScale;
-      SetWindowSize (scale, m_WindowScale);
+      auto scale = g_windowScale;
+      if (g_windowScale < 2)
+        ++g_windowScale;
+      SetWindowSize (scale, g_windowScale);
       break;
     }
     case EV_BUTTON7:
@@ -4720,7 +4708,9 @@ CEvent::WriteInfo ()
   info.language = static_cast<Sint16> (
     this->GetLanguage () != this->GetStartLanguage () ? this->GetLanguage ()
                                                       : 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);
   if (nb < 1)
@@ -4779,10 +4769,15 @@ CEvent::ReadInfo ()
     this->SetLanguage (static_cast<Language> (info.language));
   }
 
-  if (
-    ((info.majRev == 1 && info.minRev >= 2) || info.majRev >= 2) &&
-    !(g_settingsOverload & SETTING_MIDI))
-    g_restoreMidi = !!info.musicMidi;
+  if (((info.majRev == 1 && info.minRev >= 2) || info.majRev >= 2))
+  {
+    if (!(g_settingsOverload & SETTING_MIDI))
+      g_restoreMidi = !!info.musicMidi;
+    if (!(g_settingsOverload & SETTING_FULLSCREEN))
+      g_bFullScreen = !!info.fullScreen;
+    if (!(g_settingsOverload & SETTING_ZOOM))
+      g_windowScale = info.zoom;
+  }
 
   fclose (file);
   return true;
@@ -5160,7 +5155,7 @@ CEvent::DemoStep ()
         }
 
         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)
diff --git a/src/event.h b/src/event.h
index d54c433..9ffad9e 100644
--- a/src/event.h
+++ b/src/event.h
@@ -142,7 +142,6 @@ public:
 
   void IntroStep ();
 
-  Uint8 GetWindowScale ();
   void  SetWindowSize (Uint8 newScale);
   void  SetUpdateVersion (const std::string & version);
 
@@ -199,8 +198,6 @@ protected:
   bool                                     m_bSchool;
   bool                                     m_bPrivate;
   bool                                     m_bAccessBuild;
-  bool                                     m_bFullScreen;
-  Uint8                                    m_WindowScale;
   CPixmap *                                m_pPixmap;
   CDecor *                                 m_pDecor;
   CSound *                                 m_pSound;
diff --git a/src/menu.cxx b/src/menu.cxx
index 7b966c8..c8e492c 100644
--- a/src/menu.cxx
+++ b/src/menu.cxx
@@ -188,8 +188,7 @@ CMenu::Create (
     pos.x += DIMBUTTONX / 2;
     pos.y += DIMBUTTONY / 2;
     SDL_WarpMouseInWindow (
-      g_window, pos.x * m_pEvent->GetWindowScale (),
-      pos.y * m_pEvent->GetWindowScale ());
+      g_window, pos.x * g_windowScale, pos.y * g_windowScale);
   }
 
   m_selRank = Detect (pos);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/planetblupi.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to