rearrange; clear section; remove nodeset
This commit is contained in:
parent
0092cb8911
commit
cf349bb0b1
|
@ -343,8 +343,10 @@ class Configuration(RawConfigParser):
|
|||
break_line and fp.write("\n")
|
||||
fp.write("[%s]\n" % section)
|
||||
for option in modifiable[section]:
|
||||
value = self.get(section, option)
|
||||
fp.write("%s = %s\n" % (option, self.get_raw_value(value)))
|
||||
if self.has_option(section, option):
|
||||
value = self.get(section, option)
|
||||
fp.write("%s = %s\n" % (option,
|
||||
self.get_raw_value(value)))
|
||||
break_line = True
|
||||
if use_main:
|
||||
fp.close()
|
||||
|
@ -360,6 +362,11 @@ class Configuration(RawConfigParser):
|
|||
raw = str(value)
|
||||
return raw
|
||||
|
||||
def clear_section(self, section):
|
||||
if self.has_section(section):
|
||||
for option in self.options(section):
|
||||
self.remove_option(section, option)
|
||||
|
||||
|
||||
class TypeDeclarations(dict):
|
||||
|
||||
|
|
|
@ -42,12 +42,17 @@ class Display(GameChild):
|
|||
self.fullscreen_enabled
|
||||
|
||||
def set_screen(self, flags=0, dimensions=None):
|
||||
self.dimensions_changed = dimensions is not None
|
||||
if dimensions is None:
|
||||
if display.get_surface():
|
||||
dimensions = display.get_surface().get_size()
|
||||
else:
|
||||
dimensions = self.get_configuration("display", "dimensions")
|
||||
self.screen = display.set_mode(dimensions, flags)
|
||||
if self.dimensions_changed:
|
||||
interpolator = self.get_game().interpolator
|
||||
if interpolator.gui_enabled:
|
||||
interpolator.gui.rearrange()
|
||||
|
||||
def set_caption(self):
|
||||
display.set_caption(self.caption)
|
||||
|
|
|
@ -38,6 +38,12 @@ class Interpolator(list, GameChild):
|
|||
if nodeset.name == name:
|
||||
return nodeset
|
||||
|
||||
def remove(self, outgoing):
|
||||
for ii, nodeset in enumerate(self):
|
||||
if nodeset.name == outgoing.name:
|
||||
self.pop(ii)
|
||||
break
|
||||
|
||||
|
||||
class Nodeset(list):
|
||||
|
||||
|
@ -465,6 +471,8 @@ class GUI(Animation):
|
|||
|
||||
def store_in_configuration(self):
|
||||
config = self.get_configuration()
|
||||
section = "interpolate"
|
||||
config.clear_section(section)
|
||||
for nodeset in self.parent:
|
||||
code = "L" if nodeset.interpolation_method == Nodeset.LINEAR else \
|
||||
"C"
|
||||
|
@ -473,9 +481,9 @@ class GUI(Animation):
|
|||
code += ","
|
||||
code += " {0} {1}".format(*map(self.get_formatted_measure,
|
||||
node))
|
||||
if not config.has_section("interpolate"):
|
||||
config.add_section("interpolate")
|
||||
config.set("interpolate", nodeset.name, code)
|
||||
if not config.has_section(section):
|
||||
config.add_section(section)
|
||||
config.set(section, nodeset.name, code)
|
||||
|
||||
def add_nodeset(self, name):
|
||||
nodeset = self.get_nodeset()
|
||||
|
@ -586,6 +594,15 @@ class GUI(Animation):
|
|||
fp.truncate()
|
||||
self.get_configuration().write(fp)
|
||||
|
||||
def rearrange(self):
|
||||
self.set_background()
|
||||
self.set_success_indicator()
|
||||
self.set_plot_rect()
|
||||
self.set_markers()
|
||||
self.set_nodeset_label()
|
||||
self.set_axis_labels()
|
||||
self.set_buttons()
|
||||
self.prompt.reset()
|
||||
|
||||
class Marker(Sprite):
|
||||
|
||||
|
@ -614,8 +631,7 @@ class Prompt(Sprite):
|
|||
Sprite.__init__(self, parent)
|
||||
self.load_configuration()
|
||||
self.font = Font(None, self.text_size)
|
||||
self.set_frame()
|
||||
self.location.center = self.display_surface.get_rect().center
|
||||
self.reset()
|
||||
self.deactivate()
|
||||
|
||||
def deactivate(self):
|
||||
|
@ -629,12 +645,20 @@ class Prompt(Sprite):
|
|||
self.character_limit = config["prompt-character-limit"]
|
||||
self.text_size = config["prompt-text-size"]
|
||||
|
||||
def reset(self):
|
||||
self.set_frame()
|
||||
self.place()
|
||||
|
||||
def set_frame(self):
|
||||
self.clear_frames()
|
||||
surface = Surface(self.size)
|
||||
self.add_frame(surface)
|
||||
surface.fill(self.border_color)
|
||||
width = self.border_width * 2
|
||||
surface.fill((0, 0, 0), self.location.inflate(-width, -width))
|
||||
surface.fill((0, 0, 0), surface.get_rect().inflate(-width, -width))
|
||||
|
||||
def place(self):
|
||||
self.location.center = self.display_surface.get_rect().center
|
||||
|
||||
def activate(self, text, callback, *args):
|
||||
self.active = True
|
||||
|
|
Loading…
Reference in New Issue