clear framesets; preserve primary location; create config

This commit is contained in:
Frank DeMarco 2014-03-06 23:04:58 +09:00
parent 118fdfcad8
commit 0092cb8911
2 changed files with 24 additions and 15 deletions

View File

@ -174,6 +174,17 @@ class Configuration(RawConfigParser):
else:
self.print_debug("No configuration file found")
def locate_project_config_file(self):
rel_path = self.project_file_rel_path
if not rel_path:
rel_path = self.default_project_file_rel_path
if exists(rel_path) and not self.is_shared_mode():
return rel_path
if self.resource_path:
installed_path = join(self.resource_path, rel_path)
if exists(installed_path):
return installed_path
def set_order(self, fp):
self.order = order = []
for line in file(self.locate_project_config_file()):
@ -192,17 +203,6 @@ class Configuration(RawConfigParser):
if option != "__name__" and option not in modifiable[section]:
modifiable[section].append(option)
def locate_project_config_file(self):
rel_path = self.project_file_rel_path
if not rel_path:
rel_path = self.default_project_file_rel_path
if exists(rel_path) and not self.is_shared_mode():
return rel_path
if self.resource_path:
installed_path = join(self.resource_path, rel_path)
if exists(installed_path):
return installed_path
def is_shared_mode(self):
return "-s" in argv
@ -332,7 +332,11 @@ class Configuration(RawConfigParser):
modifiable = self.modifiable
use_main = fp is None
if use_main:
fp = open(self.locate_project_config_file(), "w")
path = self.locate_project_config_file()
if not path:
path = join(self.resource_path or "",
self.default_project_file_rel_path)
fp = open(path, "w")
break_line = False
for section in self.order:
if section in modifiable:
@ -342,7 +346,8 @@ class Configuration(RawConfigParser):
value = self.get(section, option)
fp.write("%s = %s\n" % (option, self.get_raw_value(value)))
break_line = True
use_main and fp.close()
if use_main:
fp.close()
def get_raw_value(self, value):
if isinstance(value, list):

View File

@ -16,7 +16,7 @@ class Sprite(Animation):
def __init__(self, parent, framerate=None):
Animation.__init__(self, parent, self.shift_frame, framerate)
self.clear_frames()
self.frames = []
self.mirrored = False
self.hidden = False
self.alpha = 255
@ -131,6 +131,10 @@ class Sprite(Animation):
def clear_frames(self):
self.frames = []
for frameset in self.framesets:
frameset.order = []
frameset.reset()
frameset.measure_rect()
def add_location(self, topleft=None, offset=(0, 0), count=1, base=0):
if topleft is not None:
@ -174,7 +178,7 @@ class Sprite(Animation):
if location:
self.locations.remove(location)
else:
self.locations = []
self.locations = self.locations[:1]
def update(self):
Animation.update(self)