Author: esr
Date: Thu Oct 16 05:03:07 2008
New Revision: 30192
URL: http://svn.gna.org/viewcvs/wesnoth?rev=30192&view=rev
Log:
trackplacer: added visibility controls for editing multiple tracks.
Modified:
trunk/data/tools/trackplacer
Modified: trunk/data/tools/trackplacer
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/trackplacer?rev=30192&r1=30191&r2=30192&view=diff
==============================================================================
--- trunk/data/tools/trackplacer (original)
+++ trunk/data/tools/trackplacer Thu Oct 16 05:03:07 2008
@@ -4,10 +4,15 @@
usage: trackplacer [-vh?] [filename]
-If the filename is not specified, trackplacer will enter a loop in which it
-repeatedly pops up a file selector. Canceling the file selecct ends the
-program; Selecting a file takes you to a main screen. For command help on
-the main screen, click the Help button.
+A journey is an object containing a map file name and a (possibly
+empty) list of tracks, each with a name and each consisting of a
+sequence of track markers. This program exists to visually edit
+journeys represented as specially delimited sections in in .cfg files.
+
+If the .cfg filename is not specified, trackplacer will enter a loop
+in which it repeatedly pops up a file selector. Canceling the file
+selecct ends the program; Selecting a file takes you to a main screen.
+For command help on the main screen, click the Help button.
Can be started with a map image, in which case we are editing a new journey.
Can be started with a .cfg file, in which case iit will look for
@@ -19,18 +24,13 @@
trackplacer will not alter anything it finds outside these comments,
and will always enclose everything it writes in them.
-Special comments may appear in your journey.cfg, looking like this:
+Special comments may appear in the track section, looking like this:
# trackplacer: <property>=<value>
These set properties that trackplacer may use. At present there is
-only one such property: map, which records the name of the mapfile on
-which your track is laid. Do not remove this comment, trackplacer
-needs it.
-
-A journey is an object containing a map file name and a (possibly empty)
-track. This program exists to visually edit journeys represented in .cfg
-files.
+only one such property: "map", which records the name of the mapfile on
+which your track is laid.
Normally, trackplacer assumes it is running within a Battle for
Wesnoth source tree and changes directory to the root of the
@@ -43,20 +43,27 @@
The -d option sets the root directory to use.
The -h or -? options display this summary.
+
+For details on theediting controls, click the Help button in the trackplacer
+GUI.
'''
gui_help = '''\
-This is trackplacer, an editor for visually editing journey tracks on Battle
For Wesnoth maps.
-
-The radio buttons near the top left corner control which icon is placed by a
left click, except that the when the trashcan is selected a left click deletes
already-placed icons.
-
-The Animate button clears the icons off the map and places them with a delay
after each placement, so you can see what order they are drawn in.
+This is trackplacer, an editor for visually editing sets of journey tracks on
Battle For Wesnoth maps.
+
+You are editing or creating a set of named tracks; at any given time there
will one track that is selected for editing. For campaigns with a linear
narrative there will be only one track, always selected, and you will not have
to concern yourself about its name. If your campaign has a non-linear
structure, you will want to create one track for each segment.
+
+The radio buttons near the top left corner control which icon is placed by a
left click, except that the when the trashcan is selected a left click deletes
already-placed icons. Every time you place an icon, it is added to the
currently selected track.
+
+The rule for adding markers to the selected track is as follows: if the two
markers closest to the mouse pointer are adjacent on the track, insert the new
marker between them in the track order. Otherwise, append it to the end of the
track.
+
+The Animate button clears the icons off the map and places them with a delay
after each placement, so you can see what order they are drawn in. If you have
multiple tracks, only those currently visible will be edited.
The Save button pops up a file selector asking you to supply a filename to
which the track should be saved in .cfg format, as a series of macros suitable
for inclusion in WML. Any other extension than .cfg on the filename will raise
an error.
-The Properties button pops up a list of track properties - key/value pairs
associated with the track. All tracks have the property "map" with their
associated map name as the value. One other property is interpreted: "prefix"
is the prefix to give macro names in the generated track file.
-
-The rule for adding markers to the track is as follows: if the two markers
closest to the mouse pointer are adjacent on the track, insert the new marker
between them in the track order. Otherwise, append it to the end of the track.
+The Properties button pops up a list of track properties - key/value pairs
associated with the track. All tracks have the property "map" with their
associated map name as the value.
+
+The Tracks button pops up a list of checkboxes, one for each track. You can
shange the state of the checkboxes to control which tracks are visible.
The Help button displays this message.
@@ -307,6 +314,7 @@
self.log("Initial track is %s" % self.journey)
self.action = "JOURNEY"
self.selected = None
+ self.visible_set = self.journey.track_list[:]
# Backing pixmap for drawing area
self.pixmap = None
@@ -506,6 +514,7 @@
xs = self.map_width - x
if ys == -1:
ys = self.map_height - y
+ self.log("Refreshing map in (%d, %d, %d, %d, %d, %d}" % (x, y, x, y,
xs, ys))
self.pixmap.draw_drawable(self.default_gc, self.map, x, y, x, y, xs,
ys)
def box(self, (action, x, y)):
@@ -550,7 +559,7 @@
def draw_feature(self, widget, (action, x, y), selected):
"Draw specified icon on the map."
rect = self.box((action, x, y))
- self.log("Drawing action=%s, dest=%s" % (action, rect))
+ self.log("Drawing action=%s (%s), dest=%s" % (action, selected, rect))
if selected:
icon = self.selected_dictionary[action].icon
else:
@@ -563,15 +572,26 @@
self.refresh_map()
# Draw all unselected tracks before the selected one,
# so any icons coinciding will be drawn in the right order.
- for selected in (False, True):
- for (id, track) in self.journey.tracks.items():
- if (id == self.journey.selected_id) == selected:
- for item in self.journey.tracks[id]:
- self.draw_feature(widget, item, selected)
- if delay:
- time.sleep(delay)
- self.expose_event(widget)
+ for (id, track) in self.journey.tracks.items():
+ if id in self.visible_set and id != self.journey.selected_id:
+ for item in self.journey.tracks[id]:
+ self.draw_feature(widget, item, False)
+ if delay:
+ time.sleep(delay)
+ self.expose_event(widget)
+ while gtk.events_pending():
gtk.main_iteration(False)
+ for (id, track) in self.journey.tracks.items():
+ if id in self.visible_set and id == self.journey.selected_id:
+ for item in self.journey.tracks[id]:
+ self.draw_feature(widget, item, True)
+ if delay:
+ time.sleep(delay)
+ self.expose_event(widget)
+ while gtk.events_pending():
+ gtk.main_iteration(False)
+ while gtk.events_pending():
+ gtk.main_iteration(False)
def configure_event(self, widget, event):
"Create a new backing pixmap of the appropriate size."
@@ -723,7 +743,47 @@
def tracks_handler(self, w):
"Modify the visible set of tracks."
- pass
+ self.visibility = gtk.Dialog(title="Edit track visibility.",
+ buttons=(gtk.STOCK_OK,
+ gtk.RESPONSE_ACCEPT))
+ label = gtk.Label("Change the visibility of tracks.")
+ self.visibility.vbox.pack_start(label)
+ self.visibility_toggles = {}
+ label.show()
+ for (i, track_id) in enumerate(self.journey.track_list):
+ button = gtk.CheckButton(track_id)
+ button.set_active(track_id in self.visible_set)
+ button.connect("toggled", self.track_visibility_callback, track_id)
+ button.show()
+ self.visibility.vbox.add(button)
+ self.visibility_toggles[track_id] = lambda x: button.set_active(x)
+ self.visibility.show()
+ self.visibility.connect("response", self.track_visibility_revert)
+ #self.visibility.connect("destroy", self.track_visibility_revert)
+ def track_visibility_callback(self, w, track_id):
+ if len(self.visible_set) <= 1 and track_id in self.visible_set:
+ w = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ flags=gtk.DIALOG_DESTROY_WITH_PARENT,
+ buttons=gtk.BUTTONS_OK)
+ w.set_markup("At least one track must remain visible.")
+ self.visibility_toggles[track_id](True)
+ w.run()
+ w.destroy()
+ return
+ self.log("Toggling visibility of %s" % track_id)
+ if track_id in self.visible_set:
+ self.visible_set.remove(track_id)
+ else:
+ self.visible_set.append(track_id)
+ self.log("Visibility set is now %s" % self.visible_set)
+ if self.journey.selected_id not in self.visible_set:
+ self.journey.set_selected_track(self.visible_set[-1])
+ self.redraw(self.drawing_area, delay=0.05)
+ def track_visibility_revert(self, w, response_id):
+ "On response or window distruction, restire visibility set."
+ self.visible_set = self.journey.track_list
+ self.redraw(self.drawing_area, delay=0.05)
+ self.visibility.destroy()
def properties_handler(self, w):
"Display a dialog for editing track properties."
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits