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

odyx pushed a commit to annotated tag debian/1.12.1-22-g13a7e27-3
in repository planetblupi.

commit 3baa931c68cc55464f545163b4f8c4f6f9537f40
Author: Mathieu Schroeter <math...@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 9854f0c..ad7876b 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)
 {
diff --git a/src/event.h b/src/event.h
index 73fe2d5..d31a532 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);
   bool        ChangePhase (Uint32 phase);
   bool        MovieToStart ();

-- 
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