1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

- improved sound support

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@65 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-09-07 22:57:07 +00:00
parent 575c8d7bde
commit c237c107a3
7 changed files with 81 additions and 65 deletions

View file

@ -1,3 +1,4 @@
# -*- mode: sh -*-
## MANIFEST.in for PySolFC
##
## code
@ -9,23 +10,42 @@ include pysollib/games/*.py pysollib/games/special/*.py
include pysollib/games/ultra/*.py pysollib/games/mahjongg/*.py
include scripts/build.bat scripts/create_iss.py scripts/mahjongg_utils.py
include scripts/all_games.py scripts/cardset_viewer.py
#graft data/plugins
##
## data
## data - docs
##
include docs/*
graft data/html
graft data/html-src
##
## data - images
##
#graft data/images
recursive-include data/images *.gif *.png
#graft data/music
#graft data/plugins
graft data/sound
graft data/tiles
include data/pysol.xbm data/pysol.xpm data/pysol.ico
##
## data - sound
##
#graft data/music
#include data/music/Astral_Dreams.COPYRIGHT
#include data/music/Astral_Dreams.it
include data/music/Bye_For_Now.COPYRIGHT
include data/music/Bye_For_Now.s3m
#include data/music/Past_and_Future.COPYRIGHT
#include data/music/Past_and_Future.it
include data/music/Ranger_Song.COPYRIGHT
include data/music/Ranger_Song.s3m
include data/music/Subsequential.COPYRIGHT
include data/music/Subsequential.mod
graft data/sound
##
## data - i18n
##
include po/*
graft locale
##
## cardsets
## data - cardsets
##
graft data/cardset-2000
graft data/cardset-crystal-mahjongg

12
README
View file

@ -7,9 +7,15 @@ Requirements.
- Python (2.3 or later)
- Tkinter
- PySol-Sound-Server: http://www.pysol.org/ (not necessarily)
- PIL (Python Image Library): http://www.pythonware.com/products/pil (not necessarily)
- Freecell Solver: http://vipe.technion.ac.il/~shlomif/freecell-solver/ (not necessarily)
** for sound support (not necessarily) **
- PySol-Sound-Server: http://www.pysol.org/
or
- PyGame: http://www.pygame.org/
** other modules (not necessarily) **
- PIL (Python Image Library): http://www.pythonware.com/products/pil
- Freecell Solver: http://vipe.technion.ac.il/~shlomif/freecell-solver/
Installation.

View file

@ -408,14 +408,14 @@ Please check your %s installation.
# init audio 2)
app.audio.connectServer(app)
if app.audio.audiodev is None:
if not app.audio.CAN_PLAY_SOUND:
app.opt.sound = 0
if not opts["nosound"] and not opts['sound-mod'] and pysolsoundserver and not app.audio.connected:
print PACKAGE + ": could not connect to pysolsoundserver, sound disabled."
warn_pysolsoundserver = 1
app.audio.updateSettings()
# start up the background music
if app.audio.audiodev:
if app.audio.CAN_PLAY_MUSIC:
music = app.music_manager.getAll()
if music:
app.music_playlist = list(music)[:]

View file

@ -56,7 +56,7 @@ except ImportError:
class AbstractAudioClient:
EXTENTIONS = r"\.((it)|(mod)|(mp3)|(pym)|(s3m)|(xm))$"
EXTENTIONS = r"\.((wav)|(it)|(mod)|(mp3)|(pym)|(s3m)|(xm))$"
CAN_PLAY_SOUND = False
CAN_PLAY_MUSIC = False
@ -72,10 +72,7 @@ class AbstractAudioClient:
self.music_loop = 0
def __del__(self):
try:
self.destroy()
except:
pass
self.destroy()
# start server - set self.server on success (may also set self.audiodev)
def startServer(self):
@ -95,7 +92,8 @@ class AbstractAudioClient:
# disconnect and stop server
def destroy(self):
self._destroy()
if self.audiodev:
self._destroy()
self.server = None
self.audiodev = None
self.connected = 0
@ -189,15 +187,15 @@ class PysolSoundServerModuleClient(AbstractAudioClient):
CAN_PLAY_MUSIC = True
def __init__(self):
import pysolsoundserver
AbstractAudioClient.__init__(self)
import pysolsoundserver
def startServer(self):
# use the module
try:
self.audiodev = pysolsoundserver
self.audiodev.init()
self.server = 1 # success - see also tk/menubar.py
self.server = 1
except:
if traceback: traceback.print_exc()
self.server = None
@ -277,18 +275,12 @@ class Win32AudioClient(AbstractAudioClient):
CAN_PLAY_MUSIC = False
def __init__(self):
import winsound
AbstractAudioClient.__init__(self)
import winsound
self.audiodev = winsound
def startServer(self):
# use the built-in winsound module
try:
import winsound
self.audiodev = winsound
self.server = 0 # success - see also tk/menubar.py
except:
self.server = None
self.audiodev = None
pass
def _playSample(self, filename, priority, loop, volume):
a = self.audiodev
@ -397,25 +389,21 @@ class OSSAudioClient(AbstractAudioClient):
CAN_PLAY_MUSIC = False
def __init__(self):
import ossaudiodev, wave
AbstractAudioClient.__init__(self)
def startServer(self):
try:
import ossaudiodev, wave
self.server = 0 # success - see also tk/menubar.py
self.audiodev = ossaudiodev
pin, pout = os.pipe()
self.pout = pout
server = OSSAudioServer(pin)
pid = os.fork()
if pid == 0:
server.mainLoop()
except:
if traceback: traceback.print_exc()
self.server = None
self.audiodev = None
raise
self.audiodev = ossaudiodev
def startServer(self):
pin, pout = os.pipe()
self.pout = pout
server = OSSAudioServer(pin)
pid = os.fork()
if pid == 0:
server.mainLoop()
def _playSample(self, filename, priority, loop, volume):
##print '_playSample:', filename, loop
@ -435,33 +423,32 @@ class OSSAudioClient(AbstractAudioClient):
class PyGameAudioClient(AbstractAudioClient):
EXTENTIONS = r'\.((ogg)|(mp3)|(it)|(mod)|(s3m)|(xm)|(mid))$'
if os.name == 'nt': # without mp3
EXTENTIONS = r'\.((ogg)|(it)|(mod)|(s3m)|(xm)|(mid))$'
EXTENTIONS = r'\.((ogg)|(mp3)|(wav)|(it)|(mod)|(s3m)|(xm)|(mid))$'
CAN_PLAY_SOUND = True
CAN_PLAY_MUSIC = True
def __init__(self):
import pygame.mixer, pygame.time
AbstractAudioClient.__init__(self)
def startServer(self):
try:
import pygame.mixer, pygame.time
self.server = 0 # success - see also tk/menubar.py
self.audiodev = pygame.mixer
if os.name == 'nt':
# for py2exe
import pygame.base, pygame.rwobject, pygame.mixer_music
self.mixer = pygame.mixer
self.mixer.init()
self.music = self.mixer.music
self.time = pygame.time
self.sound = None
self.sound_channel = None
self.sound_priority = -1
except:
if traceback: traceback.print_exc()
self.server = None
self.audiodev = None
##if traceback: traceback.print_exc()
raise
self.audiodev = self.mixer
self.sound = None
self.sound_channel = None
self.sound_priority = -1
def startServer(self):
pass
def _playSample(self, filename, priority, loop, volume):
##print '_playSample:', filename, priority, loop, volume
@ -475,10 +462,10 @@ class PyGameAudioClient(AbstractAudioClient):
self.sound = self.mixer.Sound(filename)
self.sound.set_volume(vol)
self.sound_channel = self.sound.play(loop)
self.sound_priority = priority
except:
if traceback: traceback.print_exc()
pass
self.sound_priority = priority
return 1
def _stopSamples(self):
@ -511,6 +498,11 @@ class PyGameAudioClient(AbstractAudioClient):
if traceback: traceback.print_exc()
self.time.wait(1000)
def _destroy(self):
self.mixer.stop()
self.mixer.quit()
self.music = None
def playContinuousMusic(self, music_list):
##print 'playContinuousMusic'
self.music_list = music_list
@ -521,15 +513,6 @@ class PyGameAudioClient(AbstractAudioClient):
th = Thread(target=self._playMusicLoop)
th.start()
def _destroy(self):
try:
self.mixer.stop()
self.mixer.quit()
self.music = None
except:
if traceback: traceback.print_exc()
pass
def updateSettings(self):
if not self.app.opt.sound or self.app.opt.sound_music_volume == 0:
if self.music:

View file

@ -5,6 +5,10 @@ rm -rf dist
mkdir dist
cp -r locale dist
cp fc-solve.exe dist
cp smpeg.dll dist
cp ogg.dll dist
cp vorbis.dll dist
cp vorbisfile.dll dist
python setup.py py2exe
python scripts\create_iss.py
"d:\Program Files\Inno Setup 5\ISCC.exe" setup.iss

View file

@ -6,3 +6,4 @@ force_manifest = 1
release = 1
doc_files = COPYING README
use_bzip2 = 1
group = Amusements/Games

View file

@ -21,9 +21,11 @@ datas = [
'tiles',
'toolbar',
]
for s in open('MANIFEST.in'):
for s in file('MANIFEST.in'):
if s.startswith('graft data/cardset-'):
datas.append(s[11:].strip())
elif s.startswith('include data/music/'):
datas.append(s[19:].strip())
data_files = []
for d in datas:
for root, dirs, files in os.walk(os.path.join('data', d)):