Dump assets and "initial" data before rendering starts
Now does preprocessing off of main() instead of in the dispatcher initializer.
This commit is contained in:
@@ -380,6 +380,12 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
tset = tileset.TileSet(rset, assetMrg, tex, tileSetOpts, tileset_dir)
|
tset = tileset.TileSet(rset, assetMrg, tex, tileSetOpts, tileset_dir)
|
||||||
tilesets.append(tset)
|
tilesets.append(tset)
|
||||||
|
|
||||||
|
# Do tileset preprocessing here, before we start dispatching jobs
|
||||||
|
for ts in tilesets:
|
||||||
|
ts.do_preprocessing()
|
||||||
|
|
||||||
|
# Output initial static data and configuration
|
||||||
|
assetMrg.initialize(tilesets)
|
||||||
|
|
||||||
# multiprocessing dispatcher
|
# multiprocessing dispatcher
|
||||||
if config['processes'] == 1:
|
if config['processes'] == 1:
|
||||||
|
|||||||
@@ -72,7 +72,23 @@ directory.
|
|||||||
# TODO based on the type, so something
|
# TODO based on the type, so something
|
||||||
POI[regionset.name].append
|
POI[regionset.name].append
|
||||||
|
|
||||||
def finalize(self, tilesets):
|
def initialize(self, tilesets):
|
||||||
|
"""Similar to finalize() but calls the tilesets' get_initial_data()
|
||||||
|
instead of get_persistent_data() to compile the generated javascript
|
||||||
|
config.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self.finalize(tilesets, True)
|
||||||
|
|
||||||
|
def finalize(self, tilesets, initial=False):
|
||||||
|
"""Called to output the generated javascript and all static files to
|
||||||
|
the output directory
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not initial:
|
||||||
|
get_data = lambda tileset: tileset.get_persistent_data()
|
||||||
|
else:
|
||||||
|
get_data = lambda tileset: tileset.get_initial_data()
|
||||||
|
|
||||||
# dictionary to hold the overviewerConfig.js settings that we will dumps
|
# dictionary to hold the overviewerConfig.js settings that we will dumps
|
||||||
dump = dict()
|
dump = dict()
|
||||||
@@ -94,7 +110,7 @@ directory.
|
|||||||
# based on the tilesets we have, group them by worlds
|
# based on the tilesets we have, group them by worlds
|
||||||
worlds = []
|
worlds = []
|
||||||
for tileset in tilesets:
|
for tileset in tilesets:
|
||||||
full_name = tileset.get_persistent_data()['world']
|
full_name = get_data(tileset)['world']
|
||||||
if full_name not in worlds:
|
if full_name not in worlds:
|
||||||
worlds.append(full_name)
|
worlds.append(full_name)
|
||||||
|
|
||||||
@@ -120,7 +136,7 @@ directory.
|
|||||||
|
|
||||||
|
|
||||||
for tileset in tilesets:
|
for tileset in tilesets:
|
||||||
dump['tilesets'].append(tileset.get_persistent_data())
|
dump['tilesets'].append(get_data(tileset))
|
||||||
|
|
||||||
# write a blank image
|
# write a blank image
|
||||||
blank = Image.new("RGBA", (1,1), tileset.options.get('bgcolor'))
|
blank = Image.new("RGBA", (1,1), tileset.options.get('bgcolor'))
|
||||||
|
|||||||
@@ -49,14 +49,9 @@ class Dispatcher(object):
|
|||||||
"""
|
"""
|
||||||
# TODO use status callback
|
# TODO use status callback
|
||||||
|
|
||||||
# preprocessing
|
|
||||||
for tileset in tilesetlist:
|
|
||||||
tileset.do_preprocessing()
|
|
||||||
|
|
||||||
# setup tilesetlist
|
# setup tilesetlist
|
||||||
self.setup_tilesets(tilesetlist)
|
self.setup_tilesets(tilesetlist)
|
||||||
|
|
||||||
|
|
||||||
# iterate through all possible phases
|
# iterate through all possible phases
|
||||||
num_phases = [tileset.get_num_phases() for tileset in tilesetlist]
|
num_phases = [tileset.get_num_phases() for tileset in tilesetlist]
|
||||||
for phase in xrange(max(num_phases)):
|
for phase in xrange(max(num_phases)):
|
||||||
|
|||||||
@@ -382,6 +382,20 @@ class TileSet(object):
|
|||||||
name = str(tilepath[-1])
|
name = str(tilepath[-1])
|
||||||
self._render_compositetile(dest, name)
|
self._render_compositetile(dest, name)
|
||||||
|
|
||||||
|
def get_initial_data(self):
|
||||||
|
"""This is called similarly to get_persistent_data, but is called after
|
||||||
|
do_preprocessing but before any work is acutally done.
|
||||||
|
|
||||||
|
"""
|
||||||
|
d = self.get_persistent_data()
|
||||||
|
# This is basically the same as get_persistent_data() with the
|
||||||
|
# following exceptions:
|
||||||
|
# * last_rendertime is not changed
|
||||||
|
# * A key "render_in_progress" is set to True
|
||||||
|
d['last_rendertime'] = self.last_rendertime
|
||||||
|
d['render_in_progress'] = True
|
||||||
|
return d
|
||||||
|
|
||||||
def get_persistent_data(self):
|
def get_persistent_data(self):
|
||||||
"""Returns a dictionary representing the persistent data of this
|
"""Returns a dictionary representing the persistent data of this
|
||||||
TileSet. Typically this is called by AssetManager
|
TileSet. Typically this is called by AssetManager
|
||||||
|
|||||||
Reference in New Issue
Block a user