Skip to content

Commit 7af6e92

Browse files
committed
Require pyglet 2.x
1 parent 6a4e742 commit 7af6e92

File tree

1 file changed

+10
-53
lines changed

1 file changed

+10
-53
lines changed

brainworkshop.py

Lines changed: 10 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,8 @@ def update_check():
934934
quit_with_error(_('Error: the resource folder\n%s') % res_path +
935935
_(' does not exist or is not readable. Exiting'), trace=False)
936936

937-
if pyglet.version < '1.1':
938-
quit_with_error(_('Error: pyglet 1.1 or greater is required.\n') +
937+
if pyglet.version < '2':
938+
quit_with_error(_('Error: pyglet >=2 is required.\n') +
939939
_('You probably have an older version of pyglet installed.\n') +
940940
_('Please visit %s') % WEB_PYGLET_DOWNLOAD, trace=False)
941941

@@ -946,48 +946,10 @@ def update_check():
946946
def test_music():
947947
try:
948948
import pyglet
949-
if pyglet.version >= '1.4':
950-
from pyglet.media import have_ffmpeg
951-
pyglet.media.have_avbin = have_ffmpeg()
952-
if not pyglet.media.have_avbin:
953-
cfg.USE_MUSIC = False
954-
else:
955-
try:
956-
from pyglet.media import avbin
957-
except Exception as e:
958-
debug_msg(e)
959-
pyglet.lib.load_library('avbin')
960-
if pyglet.version >= '1.2': # temporary workaround for defect in pyglet svn 2445
961-
pyglet.media.have_avbin = True
962-
963-
# On Windows with Data Execution Protection enabled (on by default on Vista),
964-
# an exception will be raised when use of avbin is attempted:
965-
# WindowsError: exception: access violation writing [ADDRESS]
966-
# The file doesn't need to be in a avbin-specific format,
967-
# since pyglet will use avbin over riff whenever it's detected.
968-
# Let's find an audio file and try to load it to see if avbin works.
969-
opj = os.path.join
970-
opj = os.path.join
971-
def look_for_music(path):
972-
files = [p for p in os.listdir(path) if not p.startswith('.') and not os.path.isdir(opj(path, p))]
973-
for f in files:
974-
ext = f.lower()[-3:]
975-
if ext in ['wav', 'ogg', 'mp3', 'aac', 'mp2', 'ac3', 'm4a'] and not ext in ('wav'):
976-
return [opj(path, f)]
977-
dirs = [opj(path, p) for p in os.listdir(path) if not p.startswith('.') and os.path.isdir(opj(path, p))]
978-
results = []
979-
for d in dirs:
980-
results.extend(look_for_music(d))
981-
if results: return results
982-
return results
983-
music_file = look_for_music(res_path)
984-
if music_file:
985-
# The first time we load a file should trigger the exception
986-
music_file = music_file[0]
987-
loaded_music = pyglet.media.load(music_file, streaming=False)
988-
del loaded_music
989-
else:
990-
cfg.USE_MUSIC = False
949+
from pyglet.media import have_ffmpeg
950+
pyglet.media.have_avbin = have_ffmpeg()
951+
if not pyglet.media.have_avbin:
952+
cfg.USE_MUSIC = False
991953

992954
except ImportError as e:
993955
debug_msg(e)
@@ -4801,22 +4763,17 @@ def pulsate(dt):
48014763
# Initialize brain sprite
48024764
brain_icon = pyglet.sprite.Sprite(pyglet.image.load(random.choice(resourcepaths['misc']['brain'])))
48034765
pos = (field.center_x - brain_icon.width//2,
4804-
field.center_y - brain_icon.height//2)
4805-
pyglet2x = pyglet.version >= "2"
4806-
if pyglet2x:
4807-
# add z component
4808-
pos += (0,)
4766+
field.center_y - brain_icon.height//2,
4767+
0)
48094768
brain_icon.position = pos
48104769

48114770
if cfg.BLACK_BACKGROUND:
48124771
brain_graphic = pyglet.sprite.Sprite(pyglet.image.load(random.choice(resourcepaths['misc']['splash-black'])))
48134772
else:
48144773
brain_graphic = pyglet.sprite.Sprite(pyglet.image.load(random.choice(resourcepaths['misc']['splash'])))
48154774
pos = (field.center_x - brain_graphic.width//2,
4816-
field.center_y - brain_graphic.height//2 + 40)
4817-
if pyglet2x:
4818-
# add z component
4819-
pos += (0,)
4775+
field.center_y - brain_graphic.height//2 + 40,
4776+
0)
48204777
brain_graphic.position = pos
48214778
def scale_brain(dt):
48224779
brain_graphic.scale = dt

0 commit comments

Comments
 (0)