From 7671f904c967dfe561ebb8f3ce08389963784ea9 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sat, 07 Feb 2009 09:05:07 +0000 Subject: Mix in Char/Ground with more OOP --- (limited to 'document.py') diff --git a/document.py b/document.py index fe84abb..2af457a 100644 --- a/document.py +++ b/document.py @@ -18,8 +18,8 @@ import cjson from zipfile import ZipFile import theme -from sound import Sound -from ground import Ground +from sound import * +from ground import * from utils import * from char import Frame @@ -51,8 +51,8 @@ def save(filepath): zip.writestr(arcname, value.read()) else: node['custom'] = False - node['filename'] = value.filename() node['name'] = value.name + node['id'] = value.id _save(cfg['ground'], 'ground.png', Document.ground) _save(cfg['sound'], 'sound', Document.sound) @@ -86,16 +86,15 @@ def load(filepath): zip = ZipFile(filepath, 'r') cfg = cjson.decode(zip.read('MANIFEST')) - def _load(node, klass): + def _load(node, restored_class, preinstalled_class): if node['custom']: - out = klass(node['name'], zip.read(node['filename']), - theme.RESTORED) + return restored_class(node['name'], node['id'], + zip.read(node['filename'])) else: - out = klass(node['name'], node['filename'], theme.PREINSTALLED) - return out + return preinstalled_class(node['name'], node['id']) - Document.ground = _load(cfg['ground'], Ground) - Document.sound = _load(cfg['sound'], Sound) + Document.ground = _load(cfg['ground'], RestoredGround, PreinstalledGround) + Document.sound = _load(cfg['sound'], RestoredSound, PreinstalledSound) loaded = {} for node in cfg['tape']: -- cgit v0.9.1