ソースを参照

Loader load_image() now have pygame directly load the file instead of opening it's own file object. Other minor bug fixes.

master
Bryan Miller 6年前
コミット
caba06d9e7
2個のファイルの変更8行の追加9行の削除
  1. +1
    -1
      game/gbe/resource.py
  2. +7
    -8
      game/gbe/resourceLoaders.py

+ 1
- 1
game/gbe/resource.py ファイルの表示

@@ -122,7 +122,7 @@ class ResourceManager:
try:
d["instance"] = loader(filename, params)
except Exception as e:
_l.error(e.message)
_l.error("{}".format(e))
return None
return weakref.ref(d["instance"])


+ 7
- 8
game/gbe/resourceLoaders.py ファイルの表示

@@ -21,12 +21,11 @@ def file_exists(path):
def load_image(filename, params={}):
if not os.path.isfile(filename):
raise LoadError("Failed to load '{}'. Path missing or invalid.".format(filename))
with open(filename) as f:
try:
i = pygame.image.load(f, filename)
return i.convert_alpha()
except pygame.error as e:
raise LoadError("Pygame/SDL Exception: {}".format(e.message))
try:
i = pygame.image.load(filename)
return i.convert_alpha()
except pygame.error as e:
raise LoadError("Pygame/SDL Exception: {}".format(e))


def load_audio(filename, params={}):
@@ -36,7 +35,7 @@ def load_audio(filename, params={}):
if pygame.mixer.get_init() is not None:
return pygame.mixer.Sound(filename)
except pygame.error as e:
raise LoadError("Pygame Exception: {}".format(e.message))
raise LoadError("Pygame Exception: {}".format(e))
raise LoadError("Audio subsystem not initialized before attempting to obtain resource.")

def load_font(filename, params={}):
@@ -50,7 +49,7 @@ def load_font(filename, params={}):
size = params["size"]
return pygame.font.Font(filename, size)
except pygame.error as e:
raise LoadError("Pygame Exception: {}".format(e.message))
raise LoadError("Pygame Exception: {}".format(e))
raise LoadError("Font subsystem not initialized before attempting to obtain resource.")



読み込み中…
キャンセル
保存