[planetblupi] 05/13: Enable only music choices accordingly to the available formats

Didier Raboud odyx at moszumanska.debian.org
Tue Feb 6 19:50:09 UTC 2018


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

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

commit fbfadb1eef41dfe95f66e6741f9b3c1aaf98d8ed
Author: Mathieu Schroeter <mathieu at schroetersa.ch>
Date:   Wed Jan 31 07:32:33 2018 +0100

    Enable only music choices accordingly to the available formats
    
    It fixes OdyX need #47.
---
 src/event.cxx | 19 ++++++++++++++++---
 src/event.h   |  1 +
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/event.cxx b/src/event.cxx
index e9fe135..9b43a4a 100644
--- a/src/event.cxx
+++ b/src/event.cxx
@@ -2075,6 +2075,10 @@ CEvent::DrawButtons ()
     SetEnable (EV_BUTTON10, bEnable);
   }
 
+  /* Check if both music formats are available */
+  auto ogg = this->IsBaseMusicAvailable (1, "ogg");
+  auto mid = this->IsBaseMusicAvailable (1, "mid");
+
   if (m_phase == EV_PHASE_SETTINGS)
   {
     SetEnable (EV_BUTTON1, m_Lang != m_Languages.begin ());
@@ -2086,8 +2090,8 @@ CEvent::DrawButtons ()
     SetEnable (EV_BUTTON5, !g_bFullScreen && g_zoom > 1);
     SetEnable (EV_BUTTON6, !g_bFullScreen && g_zoom < 2);
 
-    SetEnable (EV_BUTTON7, g_restoreMidi);
-    SetEnable (EV_BUTTON8, !g_restoreMidi);
+    SetEnable (EV_BUTTON7, g_restoreMidi && mid && ogg);
+    SetEnable (EV_BUTTON8, !g_restoreMidi && mid && ogg);
   }
 
   assert (m_index >= 0);
@@ -2577,7 +2581,7 @@ CEvent::DrawButtons ()
       DrawText (m_pPixmap, pos, res);
     }
 
-    text  = g_restoreMidi ? gettext ("Midi") : gettext ("Ogg");
+    text  = (g_restoreMidi && mid) || !ogg ? gettext ("Midi") : gettext ("Ogg");
     lg    = GetTextWidth (text);
     pos.x = (399 + 40) - lg / 2;
     pos.y = 330 - 20;
@@ -3065,6 +3069,15 @@ CEvent::IsHelpHide ()
   return bHide;
 }
 
+bool
+CEvent::IsBaseMusicAvailable (Sint32 music, const std::string & format)
+{
+  std::string absolute;
+  auto        filename =
+    string_format ("music/music%.3d.%s", music - 1, format.c_str ());
+  return FileExists (filename, absolute, LOCATION_BASE);
+}
+
 std::string
 CEvent::GetMusicLocation (Sint32 music, std::string & format)
 {
diff --git a/src/event.h b/src/event.h
index 3ca7b03..9f5fac0 100644
--- a/src/event.h
+++ b/src/event.h
@@ -100,6 +100,7 @@ public:
   Sint32      GetPhysicalWorld ();
   Sint32      GetImageWorld ();
   bool        IsHelpHide ();
+  bool        IsBaseMusicAvailable (Sint32 music, const std::string & format);
   std::string GetMusicLocation (Sint32 music, std::string & format);
   bool        ChangePhase (Uint32 phase);
   bool        MovieToStart ();

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



More information about the Pkg-games-commits mailing list