浏览代码

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.")



正在加载...
取消
保存