[Add] <resedit> You may now add fleets to systems.
This commit is contained in:
parent
c4f0d39319
commit
9c7f862f2c
Binary file not shown.
Binary file not shown.
22
utils/resedit/fleet.py
Normal file
22
utils/resedit/fleet.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import data
|
||||||
|
|
||||||
|
class Fleets:
|
||||||
|
def __init__(self):
|
||||||
|
self.fleets = {}
|
||||||
|
self.fleetsXML = "../../dat/fleet.xml"
|
||||||
|
|
||||||
|
def loadFleets(self, xmlfile=None):
|
||||||
|
if xmlfile == None:
|
||||||
|
xmlFile = self.fleetsXML
|
||||||
|
self.fleets = data.load(xmlfile, "fleet", True)
|
||||||
|
|
||||||
|
def data(self):
|
||||||
|
return self.fleets
|
||||||
|
|
||||||
|
def debug(self):
|
||||||
|
print "---FACTIONS---"
|
||||||
|
print self.fleets
|
||||||
|
print "--------------"
|
||||||
|
|
@ -4,20 +4,24 @@ try:
|
|||||||
import gtk, gtk.glade
|
import gtk, gtk.glade
|
||||||
import gobject
|
import gobject
|
||||||
except:
|
except:
|
||||||
print "You do not have python gtk bindings, or you're missin glade libs"
|
print "You do not have python gtk bindings, or you're missing glade libs"
|
||||||
print "To use Lephisto's resedit you must install them"
|
print "To use Lephisto's resedit you must install them"
|
||||||
print "http://pygtk.org/"
|
print "http://pygtk.org/"
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
import space, faction
|
import space, faction, fleet
|
||||||
|
|
||||||
# Load the factions
|
# Load the factions
|
||||||
factions = faction.Factions()
|
factions = faction.Factions()
|
||||||
factions.loadFactions("../../dat/faction.xml")
|
factions.loadFactions("../../dat/faction.xml")
|
||||||
factions.window()
|
factions.window()
|
||||||
|
|
||||||
|
# Load the fleets.
|
||||||
|
fleets = fleet.Fleets()
|
||||||
|
fleets.loadFleets("../../dat/fleet.xml")
|
||||||
|
|
||||||
# Load the universe.
|
# Load the universe.
|
||||||
universe = space.Space(factions.data())
|
universe = space.Space(factions.data(), fleets.data())
|
||||||
universe.loadSystems("../../dat/ssys.xml")
|
universe.loadSystems("../../dat/ssys.xml")
|
||||||
universe.loadPlanets("../../dat/planet.xml")
|
universe.loadPlanets("../../dat/planet.xml")
|
||||||
universe.window()
|
universe.window()
|
||||||
|
@ -406,7 +406,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">270</property>
|
<property name="x">270</property>
|
||||||
<property name="y">460</property>
|
<property name="y">480</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -421,7 +421,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">360</property>
|
<property name="x">360</property>
|
||||||
<property name="y">460</property>
|
<property name="y">480</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -441,14 +441,14 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="comFleet">
|
<widget class="GtkComboBox" id="comFleets">
|
||||||
<property name="width_request">183</property>
|
<property name="width_request">189</property>
|
||||||
<property name="height_request">20</property>
|
<property name="height_request">25</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">270</property>
|
<property name="x">270</property>
|
||||||
<property name="y">425</property>
|
<property name="y">445</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -473,6 +473,43 @@
|
|||||||
<property name="y">556</property>
|
<property name="y">556</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label5">
|
||||||
|
<property name="width_request">72</property>
|
||||||
|
<property name="height_request">20</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Fleet</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="x">278</property>
|
||||||
|
<property name="y">421</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label6">
|
||||||
|
<property name="width_request">84</property>
|
||||||
|
<property name="height_request">23</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Chance</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="x">430</property>
|
||||||
|
<property name="y">416</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkSpinButton" id="spiFleets">
|
||||||
|
<property name="width_request">50</property>
|
||||||
|
<property name="height_request">20</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="adjustment">0 0 100 1 10 10</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="x">472</property>
|
||||||
|
<property name="y">445</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">True</property>
|
<property name="resize">True</property>
|
||||||
|
@ -21,6 +21,7 @@ class Space:
|
|||||||
self.factions = factions
|
self.factions = factions
|
||||||
if fleets==None:
|
if fleets==None:
|
||||||
self.fleets = {}
|
self.fleets = {}
|
||||||
|
else:
|
||||||
self.fleets = fleets
|
self.fleets = fleets
|
||||||
|
|
||||||
def loadSystems(self, xmlfile):
|
def loadSystems(self, xmlfile):
|
||||||
@ -92,6 +93,18 @@ class Space:
|
|||||||
area.connect("button-press-event", self.__space_down)
|
area.connect("button-press-event", self.__space_down)
|
||||||
area.connect("motion-notify-event", self.__space_drag)
|
area.connect("motion-notify-event", self.__space_drag)
|
||||||
|
|
||||||
|
# Factions.
|
||||||
|
wgt = self.__swidget("comFleets")
|
||||||
|
combo = gtk.ListStore(str)
|
||||||
|
combo.append(["None"])
|
||||||
|
for f in self.fleets.keys():
|
||||||
|
node = combo.append([f])
|
||||||
|
cell = gtk.CellRendererText()
|
||||||
|
wgt.pack_start(cell, True)
|
||||||
|
wgt.add_attribute(cell, 'text', 0)
|
||||||
|
wgt.set_model(combo)
|
||||||
|
wgt.set_active(0)
|
||||||
|
|
||||||
# Display the window and such.
|
# Display the window and such.
|
||||||
self.__swidget("winSystems").show_all()
|
self.__swidget("winSystems").show_all()
|
||||||
self.cur_system = ""
|
self.cur_system = ""
|
||||||
@ -129,6 +142,7 @@ class Space:
|
|||||||
wgt.pack_start(cell, True)
|
wgt.pack_start(cell, True)
|
||||||
wgt.add_attribute(cell, 'text', 0)
|
wgt.add_attribute(cell, 'text', 0)
|
||||||
wgt.set_model(combo)
|
wgt.set_model(combo)
|
||||||
|
wgt.set_active(0)
|
||||||
|
|
||||||
# Factions.
|
# Factions.
|
||||||
wgt = self.__pwidget("comFaction")
|
wgt = self.__pwidget("comFaction")
|
||||||
@ -140,6 +154,7 @@ class Space:
|
|||||||
wgt.pack_start(cell, True)
|
wgt.pack_start(cell, True)
|
||||||
wgt.add_attribute(cell, "text", 0)
|
wgt.add_attribute(cell, "text", 0)
|
||||||
wgt.set_model(combo)
|
wgt.set_model(combo)
|
||||||
|
wgt.set_active(0)
|
||||||
|
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
|
|
||||||
@ -599,6 +614,9 @@ class Space:
|
|||||||
# Draw the frame at the end.
|
# Draw the frame at the end.
|
||||||
area.window.draw_rectangle(sys_gc, False, 0, 0, ww-1, wh-1)
|
area.window.draw_rectangle(sys_gc, False, 0, 0, ww-1, wh-1)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Add or remove jumps from a star system.
|
||||||
|
"""
|
||||||
def __jump_add(self, wgt=None, event=None):
|
def __jump_add(self, wgt=None, event=None):
|
||||||
if self.space_sel in self.systems.keys() and self.cur_system in self.systems.keys():
|
if self.space_sel in self.systems.keys() and self.cur_system in self.systems.keys():
|
||||||
self.systems[self.cur_system]["jumps"].append(self.space_sel)
|
self.systems[self.cur_system]["jumps"].append(self.space_sel)
|
||||||
@ -611,25 +629,40 @@ class Space:
|
|||||||
|
|
||||||
def __jump_rm(self, wgt=None, event=None):
|
def __jump_rm(self, wgt=None, event=None):
|
||||||
if self.space_sel in self.systems.keys() and self.cur_system in self.systems.keys():
|
if self.space_sel in self.systems.keys() and self.cur_system in self.systems.keys():
|
||||||
i = 0
|
self.systems[self.cur_system]["jumps"].remove(self.space_sel)
|
||||||
for e in self.systems[self.cur_system]["jumps"]:
|
self.systems[self.space_sel]["jumps"].remove(self.cur_system)
|
||||||
if e == self.space_sel:
|
|
||||||
self.systems[self.cur_system]["jumps"].pop(i)
|
|
||||||
i = i + 1
|
|
||||||
i = 0
|
|
||||||
for e in self.systems[self.space_sel]["jumps"]:
|
|
||||||
if e == self.cur_system:
|
|
||||||
self.systems[self.space_sel]["jumps"].pop(i)
|
|
||||||
i = i + 1
|
|
||||||
self.__supdate()
|
self.__supdate()
|
||||||
self.__space_draw()
|
self.__space_draw()
|
||||||
|
|
||||||
|
"""
|
||||||
|
Add or remove fleets from a star system.
|
||||||
|
"""
|
||||||
|
def __fleet_sel(self):
|
||||||
|
tree = self.__swidget("treFleets")
|
||||||
|
model = tree.get_model()
|
||||||
|
try:
|
||||||
|
iter = tree.get_selection().get_selected()[1]
|
||||||
|
except:
|
||||||
|
return ""
|
||||||
|
return model.get_value(iter, 0)
|
||||||
|
|
||||||
def __fleet_add(self, wgt=None, event=None):
|
def __fleet_add(self, wgt=None, event=None):
|
||||||
return
|
fleet = self.__swidget("comFleets").get_active_text()
|
||||||
|
value = self.__swidget("spiFleets").get_value_as_int()
|
||||||
|
if fleet != "None" and value > 0:
|
||||||
|
self.systems[self.cur_system]["fleets"][fleet] = str(value)
|
||||||
|
self.__supdate()
|
||||||
|
|
||||||
def __fleet_rm(self, wgt=None, event=None):
|
def __fleet_rm(self, wgt=None, event=None):
|
||||||
reutrn
|
sel = self.__fleet_sel()
|
||||||
|
if sel is "":
|
||||||
|
return
|
||||||
|
del self.systems[self.cur_system]["fleets"][sel]
|
||||||
|
self.__supdate()
|
||||||
|
|
||||||
|
"""
|
||||||
|
Create a new star system.
|
||||||
|
"""
|
||||||
def __snew(self, wgt=None, event=None):
|
def __snew(self, wgt=None, event=None):
|
||||||
name = "new system"
|
name = "new system"
|
||||||
gen = { "asteroids":0, "interference":0, "stars":100 }
|
gen = { "asteroids":0, "interference":0, "stars":100 }
|
||||||
@ -639,6 +672,9 @@ class Space:
|
|||||||
self.__create_treSystems()
|
self.__create_treSystems()
|
||||||
self.__selSys(name)
|
self.__selSys(name)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Create a new planet.
|
||||||
|
"""
|
||||||
def __pnew(self, wgt=None, event=None):
|
def __pnew(self, wgt=None, event=None):
|
||||||
name = "new planet"
|
name = "new planet"
|
||||||
gfx = { "space":"none.png" }
|
gfx = { "space":"none.png" }
|
||||||
@ -695,6 +731,9 @@ class Space:
|
|||||||
self.__pupdate()
|
self.__pupdate()
|
||||||
|
|
||||||
def __pnewFact(self, wgt=None, event=None):
|
def __pnewFact(self, wgt=None, event=None):
|
||||||
|
if self.cur_planet == "":
|
||||||
|
return
|
||||||
|
|
||||||
combo = self.__pwidget("comFaction")
|
combo = self.__pwidget("comFaction")
|
||||||
fact = combo.get_active_text()
|
fact = combo.get_active_text()
|
||||||
planet = self.planets[self.cur_planet]
|
planet = self.planets[self.cur_planet]
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user