Merge remote-tracking branch 'overviewer/rewrite' into rewrite
This commit is contained in:
@@ -125,28 +125,28 @@ else:
|
|||||||
doExit()
|
doExit()
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from overviewer_core import optimizeimages, world, quadtree
|
from overviewer_core import optimizeimages, world
|
||||||
from overviewer_core import googlemap, rendernode
|
from overviewer_core import googlemap
|
||||||
from overviewer_core import configParser, tileset, assetmanager, dispatcher
|
from overviewer_core import configParser, tileset, assetmanager, dispatcher
|
||||||
|
|
||||||
# definitions of built-in custom modes
|
# definitions of built-in custom modes
|
||||||
# usually because what used to be a mode became an option
|
# usually because what used to be a mode became an option
|
||||||
# for example, night mode
|
# for example, night mode
|
||||||
builtin_custom_rendermodes = {
|
builtin_custom_rendermodes = {}
|
||||||
'night' : {
|
# 'night' : {
|
||||||
'parent' : 'lighting',
|
# 'parent' : 'lighting',
|
||||||
'label' : 'Night',
|
# 'label' : 'Night',
|
||||||
'description' : 'like "lighting", except at night',
|
# 'description' : 'like "lighting", except at night',
|
||||||
'options' : {'night' : True}
|
# 'options' : {'night' : True}
|
||||||
},
|
# },
|
||||||
|
|
||||||
'smooth-night' : {
|
# 'smooth-night' : {
|
||||||
'parent' : 'smooth-lighting',
|
# 'parent' : 'smooth-lighting',
|
||||||
'label' : 'Smooth Night',
|
# 'label' : 'Smooth Night',
|
||||||
'description' : 'like "lighting", except smooth and at night',
|
# 'description' : 'like "lighting", except smooth and at night',
|
||||||
'options' : {'night' : True}
|
# 'options' : {'night' : True}
|
||||||
},
|
# },
|
||||||
}
|
# }
|
||||||
|
|
||||||
helptext = """
|
helptext = """
|
||||||
%prog [OPTIONS] <World # / Name / Path to World> <tiles dest dir>"""
|
%prog [OPTIONS] <World # / Name / Path to World> <tiles dest dir>"""
|
||||||
@@ -378,8 +378,8 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
# make sure that the textures can be found
|
# make sure that the textures can be found
|
||||||
try:
|
try:
|
||||||
#textures.generate(path=options.textures_path)
|
#textures.generate(path=options.textures_path)
|
||||||
# TODO(agrif): your magic goes here
|
tex = textures.Textures()
|
||||||
textures.generate(path=None)
|
tex.generate()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
doExit(code=1, consoleMsg=False)
|
doExit(code=1, consoleMsg=False)
|
||||||
@@ -402,7 +402,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
|
|
||||||
# if no dimension has been specified, just use the first one
|
# if no dimension has been specified, just use the first one
|
||||||
# TODO support the case where a different dimension is specified
|
# TODO support the case where a different dimension is specified
|
||||||
rset = w.get_regionset(2)
|
rset = w.get_regionset(0)
|
||||||
logging.debug("Using RegionSet %r", rset)
|
logging.debug("Using RegionSet %r", rset)
|
||||||
|
|
||||||
# create our TileSet from this RegionSet
|
# create our TileSet from this RegionSet
|
||||||
@@ -410,7 +410,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||||||
print "tileset_dir: %r" % tileset_dir
|
print "tileset_dir: %r" % tileset_dir
|
||||||
if not os.path.exists(tileset_dir):
|
if not os.path.exists(tileset_dir):
|
||||||
os.mkdir(tileset_dir)
|
os.mkdir(tileset_dir)
|
||||||
tset = tileset.TileSet(rset, assetMrg, render, tileset_dir)
|
tset = tileset.TileSet(rset, assetMrg, tex, render, tileset_dir)
|
||||||
tilesets.append(tset)
|
tilesets.append(tset)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import shutil
|
|||||||
import random
|
import random
|
||||||
import functools
|
import functools
|
||||||
import time
|
import time
|
||||||
|
import errno
|
||||||
|
import stat
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -378,15 +380,15 @@ class TileSet(object):
|
|||||||
self._render_rendertile(RenderTile.from_path(tilepath))
|
self._render_rendertile(RenderTile.from_path(tilepath))
|
||||||
else:
|
else:
|
||||||
# A composite-tile
|
# A composite-tile
|
||||||
if len(tileset) == 0:
|
if len(tilepath) == 0:
|
||||||
# The base tile
|
# The base tile
|
||||||
dest = self.outputdir
|
dest = self.outputdir
|
||||||
name = "base"
|
name = "base"
|
||||||
else:
|
else:
|
||||||
# All others
|
# All others
|
||||||
dest = os.path.sep.join(self.outputdir, *(str(x) for x in tilepath[:-1]))
|
dest = os.path.join(self.outputdir, *(str(x) for x in tilepath[:-1]))
|
||||||
name = str(tilepath[-1])
|
name = str(tilepath[-1])
|
||||||
self._render_compositetile(dest, base)
|
self._render_compositetile(dest, name)
|
||||||
|
|
||||||
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
|
||||||
@@ -544,7 +546,7 @@ class TileSet(object):
|
|||||||
elif rendercheck == 1:
|
elif rendercheck == 1:
|
||||||
def compare_times(chunkmtime, tileobj):
|
def compare_times(chunkmtime, tileobj):
|
||||||
# Compare chunk mtime to tile mtime on disk
|
# Compare chunk mtime to tile mtime on disk
|
||||||
tile_path = tileobj.get_filepath(self.full_tiledir, self.imgformat)
|
tile_path = tileobj.get_filepath(self.outputdir, self.imgextension)
|
||||||
try:
|
try:
|
||||||
tile_mtime = os.stat(tile_path)[stat.ST_MTIME]
|
tile_mtime = os.stat(tile_path)[stat.ST_MTIME]
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
@@ -750,28 +752,15 @@ class TileSet(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
imgpath = tile.get_filepath(self.full_tiledir, self.imgformat)
|
imgpath = tile.get_filepath(self.outputdir, self.imgextension)
|
||||||
|
|
||||||
# Calculate which chunks are relevant to this tile
|
# Calculate which chunks are relevant to this tile
|
||||||
# This is a list of (col, row, chunkx, chunkz, chunk_mtime)
|
# This is a list of (col, row, chunkx, chunkz, chunk_mtime)
|
||||||
chunks = list(self._get_chunks_for_tile(tile))
|
chunks = list(self._get_chunks_for_tile(tile))
|
||||||
|
|
||||||
region = self.regionobj
|
|
||||||
|
|
||||||
tile_mtime = None
|
|
||||||
if check_tile:
|
|
||||||
# stat the file, we need to know if it exists and its mtime
|
|
||||||
try:
|
|
||||||
tile_mtime = os.stat(imgpath)[stat.ST_MTIME]
|
|
||||||
except OSError, e:
|
|
||||||
# ignore only if the error was "file not found"
|
|
||||||
if e.errno != errno.ENOENT:
|
|
||||||
raise
|
|
||||||
|
|
||||||
if not chunks:
|
if not chunks:
|
||||||
# No chunks were found in this tile
|
# No chunks were found in this tile
|
||||||
if not check_tile:
|
logging.warning("%s was requested for render, but no chunks found! This may be a bug", tile)
|
||||||
logging.warning("%s was requested for render, but no chunks found! This may be a bug", tile)
|
|
||||||
try:
|
try:
|
||||||
os.unlink(imgpath)
|
os.unlink(imgpath)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
@@ -797,9 +786,8 @@ class TileSet(object):
|
|||||||
#logging.debug("writing out worldtile {0}".format(imgpath))
|
#logging.debug("writing out worldtile {0}".format(imgpath))
|
||||||
|
|
||||||
# Compile this image
|
# Compile this image
|
||||||
tileimg = Image.new("RGBA", (384, 384), self.bgcolor)
|
tileimg = Image.new("RGBA", (384, 384), self.options['bgcolor'])
|
||||||
|
|
||||||
rendermode = self.rendermode
|
|
||||||
colstart = tile.col
|
colstart = tile.col
|
||||||
rowstart = tile.row
|
rowstart = tile.row
|
||||||
# col colstart will get drawn on the image starting at x coordinates -(384/2)
|
# col colstart will get drawn on the image starting at x coordinates -(384/2)
|
||||||
@@ -817,13 +805,13 @@ class TileSet(object):
|
|||||||
xpos, ypos, self.options['rendermode'], self.textures)
|
xpos, ypos, self.options['rendermode'], self.textures)
|
||||||
|
|
||||||
# Save them
|
# Save them
|
||||||
if self.imgformat == 'jpg':
|
if self.imgextension == 'jpg':
|
||||||
tileimg.save(imgpath, quality=self.imgquality, subsampling=0)
|
tileimg.save(imgpath, quality=self.imgquality, subsampling=0)
|
||||||
else: # png
|
else: # png
|
||||||
tileimg.save(imgpath)
|
tileimg.save(imgpath)
|
||||||
|
|
||||||
if self.optimizeimg:
|
if self.options['optimizeimg']:
|
||||||
optimize_image(imgpath, self.imgformat, self.optimizeimg)
|
optimize_image(imgpath, self.imgextension, self.options['optimizeimg'])
|
||||||
|
|
||||||
os.utime(imgpath, (max_chunk_mtime, max_chunk_mtime))
|
os.utime(imgpath, (max_chunk_mtime, max_chunk_mtime))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user