From e9b067588460c0ac1d3e231c7f5196b905774490 Mon Sep 17 00:00:00 2001 From: Joe R Date: Sat, 26 Jun 2021 11:00:39 -0400 Subject: [PATCH] Added option to enable/disable other sound samples (the clock sound in Grandfather's Clock). --- pysollib/game/__init__.py | 15 +++++++++++---- pysollib/games/grandfathersclock.py | 3 ++- pysollib/kivy/menubar.py | 6 ++++++ pysollib/options.py | 3 ++- pysollib/pysolgtk/soundoptionsdialog.py | 2 ++ pysollib/tile/soundoptionsdialog.py | 2 ++ pysollib/tk/soundoptionsdialog.py | 2 ++ 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/pysollib/game/__init__.py b/pysollib/game/__init__.py index 5cade518..aa788b13 100644 --- a/pysollib/game/__init__.py +++ b/pysollib/game/__init__.py @@ -1344,8 +1344,16 @@ class Game(object): self._resizeHandlerID = self.canvas.after(250, self._resizeHandler) def playSample(self, name, priority=0, loop=0): - if name in self.app.opt.sound_samples and \ - not self.app.opt.sound_samples[name]: + + if name.startswith('deal'): + sampleopt = 'deal' + elif name not in self.app.opt.sound_samples: + sampleopt = 'extra' + else: + sampleopt = name + + if sampleopt in self.app.opt.sound_samples and \ + not self.app.opt.sound_samples[sampleopt]: return 0 if self.app.audio: return self.app.audio.playSample( @@ -1366,8 +1374,7 @@ class Game(object): a = self.app.opt.animations if a and not self.preview: self.canvas.update_idletasks() - if self.app.audio and self.app.opt.sound \ - and self.app.opt.sound_samples['deal']: + if self.app.audio and self.app.opt.sound: if a in (1, 2, 3, 10): self.playSample("deal01", priority=100, loop=loop) elif a == 4: diff --git a/pysollib/games/grandfathersclock.py b/pysollib/games/grandfathersclock.py index d6732966..6ffebbb7 100644 --- a/pysollib/games/grandfathersclock.py +++ b/pysollib/games/grandfathersclock.py @@ -115,7 +115,8 @@ class GrandfathersClock(Game): return clocks + cards def startGame(self): - self.playSample("grandfathersclock", loop=1) + self.startDealSample() + self.playSample("grandfathersclock", loop=1, priority=200) self._dealNumRows(4) self.s.talon.dealRow() self.s.talon.dealRow(rows=self.s.foundations) diff --git a/pysollib/kivy/menubar.py b/pysollib/kivy/menubar.py index 69f449ae..62005cf2 100644 --- a/pysollib/kivy/menubar.py +++ b/pysollib/kivy/menubar.py @@ -776,6 +776,12 @@ class OptionsMenuDialog(LMenuDialog): _('game won'), self.menubar.tkopt.sound_sample_vars[key], self.make_vars_command(self.menubar.mOptSoundSample, key)) + key = 'extra' + self.addCheckNode( + tv, rg1, + _('Other'), + self.menubar.tkopt.sound_sample_vars[key], + self.make_vars_command(self.menubar.mOptSoundSample, key)) # ------------------------------------------- # Cardsets and card backside options diff --git a/pysollib/options.py b/pysollib/options.py index 1d5042d6..50b1ac44 100644 --- a/pysollib/options.py +++ b/pysollib/options.py @@ -154,6 +154,7 @@ gamewon = boolean droppair = boolean redo = boolean dealwaste = boolean +extra = boolean [fonts] sans = list @@ -366,7 +367,7 @@ class Options: 'dealwaste': True, 'droppair': True, 'drop': True, - # 'extra': True, + 'extra': True, 'flip': True, 'move': True, 'nomove': True, diff --git a/pysollib/pysolgtk/soundoptionsdialog.py b/pysollib/pysolgtk/soundoptionsdialog.py index 68366e8e..8cd09785 100644 --- a/pysollib/pysolgtk/soundoptionsdialog.py +++ b/pysollib/pysolgtk/soundoptionsdialog.py @@ -70,6 +70,8 @@ class SoundOptionsDialog: ('gamelost', _('Game lost')), ('gamewon', _('Game won')), ('gameperfect', _('Perfect game')), + + ('extra', _('Other')), ] table = self.widgets_tree.get_widget('samples_table') diff --git a/pysollib/tile/soundoptionsdialog.py b/pysollib/tile/soundoptionsdialog.py index 3f4e05ca..9977955c 100644 --- a/pysollib/tile/soundoptionsdialog.py +++ b/pysollib/tile/soundoptionsdialog.py @@ -84,6 +84,8 @@ class SoundOptionsDialog(MfxDialog): ('gamelost', _('Game lost'), tkinter.BooleanVar()), ('gamewon', _('Game won'), tkinter.BooleanVar()), ('gameperfect', _('Perfect game'), tkinter.BooleanVar()), + + ('extra', _('Other'), tkinter.BooleanVar()), ] # diff --git a/pysollib/tk/soundoptionsdialog.py b/pysollib/tk/soundoptionsdialog.py index d9b0bf0d..c9081d7b 100644 --- a/pysollib/tk/soundoptionsdialog.py +++ b/pysollib/tk/soundoptionsdialog.py @@ -84,6 +84,8 @@ class SoundOptionsDialog(MfxDialog): ('gamelost', _('Game lost'), tkinter.BooleanVar()), ('gamewon', _('Game won'), tkinter.BooleanVar()), ('gameperfect', _('Perfect game'), tkinter.BooleanVar()), + + ('extra', _('Other'), tkinter.BooleanVar()), ] #