Skip to content

Commit

Permalink
Basic graphics pack validation during loading of available packs (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pidgeot committed Nov 4, 2014
1 parent 53585a0 commit fdc03b6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def read_graphics():
os.path.isdir(o)]
result = []
for p in packs:
if not validate_pack(p):
continue
init_path = os.path.join(graphics_path, p, 'data', 'init', 'init.txt')
font, graphics = lnp.settings.read_values(
init_path, 'FONT', 'GRAPHICS_FONT')
Expand Down Expand Up @@ -109,6 +111,22 @@ def install_graphics(pack):
return None
df.load_params()

def validate_pack(pack):
"""Checks for presence of all required files for a pack install."""
result = True
gfx_dir = os.path.join(paths.get('graphics'), pack)
result &= os.path.isdir(gfx_dir)
result &= os.path.isdir(os.path.join(gfx_dir, 'raw', 'graphics'))
result &= os.path.isdir(os.path.join(gfx_dir, 'data', 'init'))
result &= os.path.isdir(os.path.join(gfx_dir, 'data', 'art'))
result &= os.path.isfile(os.path.join(gfx_dir, 'data', 'init', 'init.txt'))
if lnp.df_info.version >= '0.31.04':
result &= os.path.isfile(os.path.join(
gfx_dir, 'data', 'init', 'd_init.txt'))
result &= os.path.isfile(os.path.join(
gfx_dir, 'data', 'init', 'colors.txt'))
return result

def patch_inits(gfx_dir):
"""
Installs init files from a graphics pack by selectively changing
Expand Down

0 comments on commit fdc03b6

Please sign in to comment.