[Add] resedit: More work on planet editor, tree view.

This commit is contained in:
Allanis 2013-04-16 14:23:28 +01:00
parent fcd8496fa4
commit a1c18084fd
2 changed files with 31 additions and 1 deletions

View File

@ -37,6 +37,16 @@ class Space:
data.save("planet.xml", self.planets, "Planets", "planet", True,
{ "commodities":"commodity" })
def __genPlanetTree(self):
self.planetTree = {}
# Set planets to none.
for planet in self.planets.keys():
self.planetTree[planet] = None
# Set allocated planets.
for name, system in self.systems.items():
for planet in system["planets"]:
self.planetTree[planet] = name
def window(self):
"""
create the window
@ -124,7 +134,7 @@ class Space:
"""
# Store the current values.
self.__sstore();
self.__sstore()
self.cur_system = self.__curSystem()
if self.cur_system == "":
@ -159,6 +169,17 @@ class Space:
self.__space_draw()
def __pupdate(self, wgt=None, event=None):
# Store the current values
self.__pstore()
self.__genPlanetTree()
self.cur_planet = self.__curPlanet()
if self.cur_planet == "":
return
planet = self.planets[self.cur_planet]
def __sstore(self):
sys_name = self.__swidget("inpName").get_text()
if sys_name == "":
@ -220,6 +241,15 @@ class Space:
else:
return model.get_value(p, 0)
def __curPlanet(self):
tree = self.__pwidget("trePlanets")
model = tree.get_model()
try:
iter = tree.get_selection().get_selected()[1]
except:
return ""
return model.get_value(iter, 0)
def __done(self, widget=None, data=None):
"""
Window is done

Binary file not shown.