# HG changeset patch # User Simon Cross # Date 1259277304 0 # Node ID 3e4bb2c9556c1f75409f7ddf425c30313ed0b2e0 # Parent 77a3f7f1c85688db584954844d67cac5db72d634 Lazy loading of save game snapshots. diff -r 77a3f7f1c856 -r 3e4bb2c9556c gamelib/savegame.py --- a/gamelib/savegame.py Thu Nov 26 23:02:10 2009 +0000 +++ b/gamelib/savegame.py Thu Nov 26 23:15:04 2009 +0000 @@ -136,6 +136,9 @@ title = gui.Label(title_txt, cls=cls + ".title.label") gui.Dialog.__init__(self, title, body) + if games: + self.save_list.group.value = games[0] + def get_fullpath(self): """Return the fullpath of the select save game file or None.""" if self.value is None: @@ -151,7 +154,7 @@ continue if ext != ".xml": continue - self.save_games[root] = self._create_image_widget(fullpath) + self.save_games[root] = (fullpath, None) def _create_image_widget(self, fullpath): """Create an image showing the contents of a save game file.""" @@ -187,8 +190,13 @@ for w in self.image_container.widgets: self.image_container.remove(w) - image_widget = self.save_games[self.save_list.value] - self.image_container.add(image_widget, 0, 0) + name = self.save_list.value + fullpath, widget = self.save_games[name] + if widget is None: + widget = self._create_image_widget(fullpath) + self.save_games[name] = (fullpath, widget) + + self.image_container.add(widget, 0, 0) def _click_ok(self): if self.name_input: