Merge branch 'master' into rendermode-options
Conflicts: overviewer.py
This commit is contained in:
@@ -191,6 +191,10 @@ Options
|
||||
a short description of each. If you provide more than one mode (separated
|
||||
by commas), Overviewer will render all of them at once, and provide a
|
||||
toggle on the resulting map to switch between them.
|
||||
|
||||
If for some reason commas do not work for your shell (like if you're using
|
||||
Powershell on Windows), you can also use a colon ':' or a forward slash '/'
|
||||
to separate the modes.
|
||||
|
||||
--list-rendermodes
|
||||
List the available render modes, and a short description of each.
|
||||
|
||||
@@ -21,7 +21,7 @@ import os.path
|
||||
overviewer_dir = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0]
|
||||
sys.path.insert(0, overviewer_dir)
|
||||
|
||||
import world
|
||||
from overviewer_core import world
|
||||
from overviewer import list_worlds
|
||||
|
||||
def main():
|
||||
|
||||
@@ -51,7 +51,10 @@ def clean_render(overviewerargs, quiet):
|
||||
try:
|
||||
# check_call raises CalledProcessError when overviewer.py exits badly
|
||||
check_call(['python', 'setup.py', 'clean', 'build'], quiet=quiet)
|
||||
check_call([overviewer_script, '-d'] + overviewerargs, quiet=quiet)
|
||||
try:
|
||||
check_call([overviewer_script, '-d'] + overviewerargs, quiet=quiet)
|
||||
except CalledProcessError:
|
||||
pass
|
||||
starttime = time.time()
|
||||
check_call([overviewer_script,] + overviewerargs + [tempdir,], quiet=quiet)
|
||||
endtime = time.time()
|
||||
|
||||
@@ -104,7 +104,7 @@ def main():
|
||||
parser.add_option("-z", "--zoom", dest="zoom", helptext="Sets the zoom level manually instead of calculating it. This can be useful if you have outlier chunks that make your world too big. This value will make the highest zoom level contain (2**ZOOM)^2 tiles", action="store", type="int", advanced=True)
|
||||
parser.add_option("--regionlist", dest="regionlist", helptext="A file containing, on each line, a path to a regionlist to update. Instead of scanning the world directory for regions, it will just use this list. Normal caching rules still apply.")
|
||||
parser.add_option("--forcerender", dest="forcerender", helptext="Force re-rendering the entire map (or the given regionlist). Useful for re-rendering without deleting it.", action="store_true")
|
||||
parser.add_option("--rendermodes", dest="rendermode", helptext="Specifies the render types, separated by commas. Use --list-rendermodes to list them all.", type="choice", required=True, default=avail_rendermodes[0], listify=True)
|
||||
parser.add_option("--rendermodes", dest="rendermode", helptext="Specifies the render types, separated by ',', ':', or '/'. Use --list-rendermodes to list them all.", type="choice", required=True, default=avail_rendermodes[0], listify=True)
|
||||
parser.add_option("--list-rendermodes", dest="list_rendermodes", action="store_true", helptext="List available render modes and exit.", commandLineOnly=True)
|
||||
parser.add_option("--rendermode-options", dest="rendermode_options", default={}, advanced=True)
|
||||
parser.add_option("--custom-rendermodes", dest="custom_rendermodes", default={}, advanced=True)
|
||||
@@ -115,6 +115,7 @@ def main():
|
||||
parser.add_option("--web-assets-hook", dest="web_assets_hook", helptext="If provided, run this function after the web assets have been copied, but before actual tile rendering begins. It should accept a QuadtreeGen object as its only argument.", action="store", metavar="SCRIPT", type="function", advanced=True)
|
||||
parser.add_option("--web-assets-path", dest="web_assets_path", helptext="Specifies a non-standard web_assets directory to use. Files here will overwrite the default web assets.", metavar="PATH", type="string", advanced=True)
|
||||
parser.add_option("--textures-path", dest="textures_path", helptext="Specifies a non-standard textures path, from which terrain.png and other textures are loaded.", metavar="PATH", type="string", advanced=True)
|
||||
parser.add_option("--check-terrain", dest="check_terrain", helptext="Prints the location and hash of terrain.png, useful for debugging terrain.png problems", action="store_true", advanced=False, commandLineOnly=True)
|
||||
parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0, helptext="Print less output. You can specify this option multiple times.")
|
||||
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, helptext="Print more output. You can specify this option multiple times.")
|
||||
parser.add_option("--skip-js", dest="skipjs", action="store_true", helptext="Don't output marker.js or regions.js")
|
||||
@@ -148,6 +149,24 @@ def main():
|
||||
list_rendermodes()
|
||||
sys.exit(0)
|
||||
|
||||
if options.check_terrain:
|
||||
import hashlib
|
||||
from overviewer_core.textures import _find_file
|
||||
from overviewer_core import textures
|
||||
if options.textures_path:
|
||||
textures._find_file_local_path = options.textures_path
|
||||
|
||||
try:
|
||||
f = _find_file("terrain.png", verbose=True)
|
||||
except IOError:
|
||||
logging.error("Could not find the file terrain.png")
|
||||
sys.exit(1)
|
||||
|
||||
h = hashlib.sha1()
|
||||
h.update(f.read())
|
||||
logging.info("Hash of terrain.png file is: %s", h.hexdigest())
|
||||
sys.exit(0)
|
||||
|
||||
if options.advanced_help:
|
||||
parser.advanced_help()
|
||||
sys.exit(0)
|
||||
@@ -243,6 +262,12 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
else:
|
||||
north_direction = 'auto'
|
||||
|
||||
# Expand user dir in directories strings
|
||||
if options.textures_path:
|
||||
options.textures_path = os.path.expanduser(options.textures_path)
|
||||
if options.web_assets_path:
|
||||
options.web_assets_path = os.path.expanduser(options.web_assets_path)
|
||||
|
||||
logging.getLogger().setLevel(
|
||||
logging.getLogger().level + 10*options.quiet)
|
||||
logging.getLogger().setLevel(
|
||||
|
||||
@@ -11,6 +11,7 @@ class ConfigOptionParser(object):
|
||||
def __init__(self, **kwargs):
|
||||
self.cmdParser = optparse.OptionParser(usage=kwargs.get("usage",""))
|
||||
self.configFile = kwargs.get("config","settings.py")
|
||||
self.listifyDelimiters = kwargs.get("listdelim", ",:/")
|
||||
self.configVars = []
|
||||
self.advancedHelp = []
|
||||
# these are arguments not understood by OptionParser, so they must be removed
|
||||
@@ -154,7 +155,12 @@ class ConfigOptionParser(object):
|
||||
if 'listify' in a.keys():
|
||||
# this thing may be a list!
|
||||
if configResults.__dict__[n] != None and type(configResults.__dict__[n]) == str:
|
||||
configResults.__dict__[n] = configResults.__dict__[n].split(a.get("listdelim",","))
|
||||
delimiters = a.get("listdelim", self.listifyDelimiters)
|
||||
# replace the rest of the delimiters with the first
|
||||
for delim in delimiters[1:]:
|
||||
configResults.__dict__[n] = configResults.__dict__[n].replace(delim, delimiters[0])
|
||||
# split at each occurance of the first delimiter
|
||||
configResults.__dict__[n] = configResults.__dict__[n].split(delimiters[0])
|
||||
elif type(configResults.__dict__[n]) != list:
|
||||
configResults.__dict__[n] = [configResults.__dict__[n]]
|
||||
if 'type' in a.keys() and configResults.__dict__[n] != None:
|
||||
|
||||
@@ -223,6 +223,24 @@ do_shading_with_mask(RenderModeLighting *self, RenderState *state,
|
||||
/* this face isn't visible, so don't draw anything */
|
||||
return;
|
||||
}
|
||||
} else if ((x == -1) && (state->left_blocks != Py_None)) {
|
||||
unsigned char block = getArrayByte3D(state->left_blocks, 15, state->y, state->z);
|
||||
if (!is_transparent(block)) {
|
||||
/* the same thing but for adjacent chunks, this solves an
|
||||
ugly black doted line between chunks in night rendermode.
|
||||
This wouldn't be necessary if the textures were truly
|
||||
tessellate-able */
|
||||
return;
|
||||
}
|
||||
} else if ((y == 16) && (state->right_blocks != Py_None)) {
|
||||
unsigned char block = getArrayByte3D(state->right_blocks, state->x, 0, state->z);
|
||||
if (!is_transparent(block)) {
|
||||
/* the same thing but for adjacent chunks, this solves an
|
||||
ugly black doted line between chunks in night rendermode.
|
||||
This wouldn't be necessary if the textures were truly
|
||||
tessellate-able */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
black_coeff = get_lighting_coefficient(self, state, x, y, z);
|
||||
|
||||
@@ -23,6 +23,7 @@ import math
|
||||
from random import randint
|
||||
import numpy
|
||||
from PIL import Image, ImageEnhance, ImageOps, ImageDraw
|
||||
import logging
|
||||
|
||||
import util
|
||||
import composite
|
||||
@@ -47,13 +48,13 @@ def _find_file(filename, mode="rb", verbose=False):
|
||||
if _find_file_local_path:
|
||||
path = os.path.join(_find_file_local_path, filename)
|
||||
if os.path.exists(path):
|
||||
if verbose: print "Found %s in '%s'" % (filename, path)
|
||||
if verbose: logging.info("Found %s in '%s'", filename, path)
|
||||
return open(path, mode)
|
||||
|
||||
programdir = util.get_program_path()
|
||||
path = os.path.join(programdir, filename)
|
||||
if os.path.exists(path):
|
||||
if verbose: print "Found %s in '%s'" % (filename, path)
|
||||
if verbose: logging.info("Found %s in '%s'", filename, path)
|
||||
return open(path, mode)
|
||||
|
||||
path = os.path.join(programdir, "overviewer_core", "data", "textures", filename)
|
||||
@@ -63,13 +64,13 @@ def _find_file(filename, mode="rb", verbose=False):
|
||||
# windows special case, when the package dir doesn't exist
|
||||
path = os.path.join(programdir, "textures", filename)
|
||||
if os.path.exists(path):
|
||||
if verbose: print "Found %s in '%s'" % (filename, path)
|
||||
if verbose: logging.info("Found %s in '%s'", filename, path)
|
||||
return open(path, mode)
|
||||
|
||||
if sys.platform == "darwin":
|
||||
path = os.path.join("/Applications/Minecraft", filename)
|
||||
if os.path.exists(path):
|
||||
if verbose: print "Found %s in '%s'" % (filename, path)
|
||||
if verbose: logging.info("Found %s in '%s'", filename, path)
|
||||
return open(path, mode)
|
||||
|
||||
# Find minecraft.jar.
|
||||
@@ -82,14 +83,16 @@ def _find_file(filename, mode="rb", verbose=False):
|
||||
"Application Support", "minecraft","bin","minecraft.jar"))
|
||||
jarpaths.append(os.path.join(os.environ['HOME'], ".minecraft", "bin",
|
||||
"minecraft.jar"))
|
||||
jarpaths.append(programdir)
|
||||
jarpaths.append(os.getcwd())
|
||||
jarpaths.append(os.path.join(programdir,"minecraft.jar"))
|
||||
jarpaths.append(os.path.join(os.getcwd(), "minecraft.jar"))
|
||||
if _find_file_local_path:
|
||||
jarpaths.append(os.path.join(_find_file_local_path, "minecraft.jar"))
|
||||
|
||||
for jarpath in jarpaths:
|
||||
if os.path.exists(jarpath):
|
||||
try:
|
||||
jar = zipfile.ZipFile(jarpath)
|
||||
if verbose: print "Found %s in '%s'" % (filename, jarpath)
|
||||
if verbose: logging.info("Found %s in '%s'", filename, jarpath)
|
||||
return jar.open(filename)
|
||||
except (KeyError, IOError):
|
||||
pass
|
||||
|
||||
21
setup.py
21
setup.py
@@ -251,32 +251,11 @@ class CustomBuildExt(build_ext):
|
||||
self.inplace = True
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
class CheckTerrain(Command):
|
||||
user_options=[]
|
||||
def initialize_options(self):
|
||||
pass
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
from overviewer_core.textures import _find_file
|
||||
import hashlib
|
||||
import zipfile
|
||||
print "checking..."
|
||||
try:
|
||||
f = _find_file("terrain.png", verbose=True)
|
||||
except IOError:
|
||||
log.error("Could not find the file terrain.png")
|
||||
return
|
||||
|
||||
h = hashlib.sha1()
|
||||
h.update(f.read())
|
||||
log.info("Hash of terrain.png file is: %s", h.hexdigest())
|
||||
|
||||
setup_kwargs['cmdclass']['clean'] = CustomClean
|
||||
setup_kwargs['cmdclass']['sdist'] = CustomSDist
|
||||
setup_kwargs['cmdclass']['build'] = CustomBuild
|
||||
setup_kwargs['cmdclass']['build_ext'] = CustomBuildExt
|
||||
setup_kwargs['cmdclass']['check_terrain'] = CheckTerrain
|
||||
###
|
||||
|
||||
setup(**setup_kwargs)
|
||||
|
||||
Reference in New Issue
Block a user