mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added enable/disable music option.
This commit is contained in:
parent
344b637194
commit
58a31f8abb
5 changed files with 22 additions and 14 deletions
|
@ -848,7 +848,8 @@ class PysolMenubar(PysolMenubarTk):
|
|||
def mPlayNextMusic(self, *args):
|
||||
if self._cancelDrag(break_pause=False):
|
||||
return
|
||||
if self.app.audio and self.app.opt.sound_music_volume > 0:
|
||||
if (self.app.audio and self.app.music and
|
||||
self.app.opt.sound_music_volume > 0):
|
||||
self.app.audio.playNextMusic()
|
||||
if 1 and DEBUG:
|
||||
index = self.app.audio.getMusicInfo()
|
||||
|
|
|
@ -119,6 +119,7 @@ sound = boolean
|
|||
sound_mode = integer(0, 1)
|
||||
sound_sample_volume = integer(0, 128)
|
||||
sound_sample_buffer_size = integer(1, 4)
|
||||
music = boolean
|
||||
tabletile_name = string
|
||||
recent_gameid = int_list
|
||||
favorite_gameid = int_list
|
||||
|
@ -261,6 +262,7 @@ class Options:
|
|||
('sound_sample_volume', 'int'),
|
||||
('sound_music_volume', 'int'),
|
||||
('sound_sample_buffer_size', 'int'),
|
||||
('music', 'bool'),
|
||||
('tabletile_name', 'str'),
|
||||
('translate_game_names', 'bool'),
|
||||
('solver_presets', 'list'),
|
||||
|
@ -353,6 +355,7 @@ class Options:
|
|||
self.sound_sample_volume = 75
|
||||
self.sound_music_volume = 100
|
||||
self.sound_sample_buffer_size = 1 # 1 - 4 (1024 - 4096 bytes)
|
||||
self.music = True
|
||||
self.sound_samples = {
|
||||
'areyousure': True,
|
||||
'autodrop': True,
|
||||
|
|
|
@ -225,7 +225,7 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
|
|||
return -1
|
||||
|
||||
def playContinuousMusic(self, music_list):
|
||||
if self.audiodev is None or not self.app:
|
||||
if self.audiodev is None or not self.app or not self.app.opt.music:
|
||||
return
|
||||
try:
|
||||
loop = 999999
|
||||
|
@ -248,7 +248,8 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
|
|||
s, m = 0, 0
|
||||
if self.app.opt.sound:
|
||||
s = self.app.opt.sound_sample_volume
|
||||
m = self.app.opt.sound_music_volume
|
||||
if self.app.opt.music:
|
||||
m = self.app.opt.sound_music_volume
|
||||
try:
|
||||
self.cmd("setwavvol %d" % s)
|
||||
self.cmd("setmusvol %d" % m)
|
||||
|
@ -565,10 +566,10 @@ class PyGameAudioClient(AbstractAudioClient):
|
|||
if not music_list:
|
||||
return
|
||||
while True:
|
||||
if not self.music:
|
||||
if not self.music or not self.app.opt.music:
|
||||
break
|
||||
for m in music_list:
|
||||
if not self.music:
|
||||
if not self.music or not self.app.opt.music:
|
||||
break
|
||||
vol = self.app.opt.sound_music_volume/128.0
|
||||
try:
|
||||
|
@ -603,7 +604,8 @@ class PyGameAudioClient(AbstractAudioClient):
|
|||
th.start()
|
||||
|
||||
def updateSettings(self):
|
||||
if not self.app.opt.sound or self.app.opt.sound_music_volume == 0:
|
||||
if (not self.app.opt.sound or not self.app.opt.music or
|
||||
self.app.opt.sound_music_volume == 0):
|
||||
if self.music:
|
||||
self.music.stop()
|
||||
self.music = None
|
||||
|
|
|
@ -52,6 +52,8 @@ class SoundOptionsDialog(MfxDialog):
|
|||
self.sound_mode.set(app.opt.sound_mode != 0)
|
||||
self.sample_volume = tkinter.IntVar()
|
||||
self.sample_volume.set(app.opt.sound_sample_volume)
|
||||
self.music = tkinter.BooleanVar()
|
||||
self.music.set(app.opt.music != 0)
|
||||
self.music_volume = tkinter.IntVar()
|
||||
self.music_volume.set(app.opt.sound_music_volume)
|
||||
self.samples = [
|
||||
|
@ -110,6 +112,11 @@ class SoundOptionsDialog(MfxDialog):
|
|||
length="3i", # label=_('Sample volume'),
|
||||
variable=self.sample_volume)
|
||||
w.grid(row=row, column=1, sticky='w', padx=5)
|
||||
row += 1
|
||||
w = ttk.Checkbutton(frame, variable=self.music,
|
||||
text=_("Music enabled"))
|
||||
w.grid(row=row, column=0, columnspan=2, sticky='ew')
|
||||
|
||||
row += 1
|
||||
ttk.Label(frame, text=_('Music volume:'), anchor='w'
|
||||
).grid(row=row, column=0, sticky='ew')
|
||||
|
@ -159,6 +166,7 @@ class SoundOptionsDialog(MfxDialog):
|
|||
self.app.opt.sound_mode = int(self.sound_mode.get())
|
||||
self.app.opt.sound_sample_volume = self.sample_volume.get()
|
||||
self.app.opt.sound_music_volume = self.music_volume.get()
|
||||
self.app.opt.music = self.music.get()
|
||||
for n, t, v in self.samples:
|
||||
self.app.opt.sound_samples[n] = v.get()
|
||||
elif button == 2:
|
||||
|
|
|
@ -516,14 +516,8 @@ class PysolMenubarTkCommon:
|
|||
command=self.mOptShisenShowHint)
|
||||
menu.add_separator()
|
||||
label = n_("&Sound...")
|
||||
if not self.app.audio.CAN_PLAY_SOUND:
|
||||
menu.add_checkbutton(
|
||||
label=label, variable=self.tkopt.sound,
|
||||
command=self.mOptSoundDialog, state='disabled')
|
||||
else:
|
||||
menu.add_checkbutton(
|
||||
label=label, variable=self.tkopt.sound,
|
||||
command=self.mOptSoundDialog)
|
||||
menu.add_command(
|
||||
label=label, command=self.mOptSoundDialog)
|
||||
# cardsets
|
||||
if USE_PIL:
|
||||
submenu = MfxMenu(menu, label=n_("Card si&ze"))
|
||||
|
|
Loading…
Add table
Reference in a new issue