changeset 215:0a441ded8a83

Always sort widgets, so jumping through json doesn't change the order
author Neil Muller <drnlmuller@gmail.com>
date Sat, 12 May 2012 20:38:44 +0200
parents d378459567bb
children ec97f80feae0
files gamelib/gamegui.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gamegui.py	Sat May 12 20:34:34 2012 +0200
+++ b/gamelib/gamegui.py	Sat May 12 20:38:44 2012 +0200
@@ -350,7 +350,8 @@
         y = max(250, 130 + self.description.rect.height +
                 20 * len(self._inventory) // 3)
         available = self.game.get_available_equipment()
-        for equip in self.game.get_all_equipment():
+        for equip in sorted(self.game.get_all_equipment(),
+                key=lambda x: x.NAME):
             copies = self.parent.equipment.count(equip)
             widget = EquipWidget(equip, (x, y), self, copies,
                     equip in available)
@@ -502,7 +503,8 @@
         self._missions = []
         x = 0
         y = 150
-        for mission in self.game.get_available_missions():
+        for mission in sorted(self.game.get_available_missions(),
+                key=lambda x: x.NAME):
             widget = MissionWidget(mission, (x, y), self)
             self._missions.append(widget)
             self.add_child(widget)
@@ -573,7 +575,7 @@
         self._sciences = []
         x = 0
         y = 150
-        for science in self.game.lab.science:
+        for science in sorted(self.game.lab.science, key=lambda x: x.NAME):
             if science.SCIENCE_TYPE == 'schematic':
                 widget = ScienceWidget(science, (x, y), self)
                 self.add_child(widget)
@@ -643,7 +645,7 @@
         self._sciences = []
         x = 0
         y = 150
-        for science in self.game.lab.science:
+        for science in sorted(self.game.lab.science, key=lambda x: x.NAME):
             if science.SCIENCE_TYPE == 'research':
                 widget = ScienceWidget(science, (x, y), self)
                 self.add_child(widget)