Merge branch 'master' into py-package
This commit is contained in:
@@ -20,7 +20,7 @@ import sys
|
||||
sys.path.insert(0,".")
|
||||
|
||||
import nbt
|
||||
from chunk import get_blockarray_fromfile
|
||||
from chunk import get_blockarray_fromfile, get_blockarray
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ def main():
|
||||
parser.add_option("-z", "--zoom", dest="zoom", help="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", configFileOnly=True)
|
||||
parser.add_option("-d", "--delete", dest="delete", help="Clear all caches. Next time you render your world, it will have to start completely over again. This is probably not a good idea for large worlds. Use this if you change texture packs and want to re-render everything.", action="store_true", commandLineOnly=True)
|
||||
parser.add_option("--regionlist", dest="regionlist", help="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", help="Force re-rendering the entire map (or the given regionlist). Useful for re-rendering without deleting the entire map with --delete.", action="store_true")
|
||||
parser.add_option("--rendermodes", dest="rendermode", help="Specifies the render types, separated by commas. Use --list-rendermodes to list them all.", type="choice", choices=avail_rendermodes, required=True, default=avail_rendermodes[0], listify=True)
|
||||
parser.add_option("--list-rendermodes", dest="list_rendermodes", action="store_true", help="List available render modes and exit.", commandLineOnly=True)
|
||||
parser.add_option("--imgformat", dest="imgformat", help="The image output format to use. Currently supported: png(default), jpg.", configFileOnly=True )
|
||||
@@ -231,7 +232,7 @@ def main():
|
||||
# create the quadtrees
|
||||
# TODO chunklist
|
||||
q = []
|
||||
qtree_args = {'depth' : options.zoom, 'imgformat' : imgformat, 'imgquality' : options.imgquality, 'optimizeimg' : optimizeimg, 'bgcolor' : bgcolor}
|
||||
qtree_args = {'depth' : options.zoom, 'imgformat' : imgformat, 'imgquality' : options.imgquality, 'optimizeimg' : optimizeimg, 'bgcolor' : bgcolor, 'forcerender' : options.forcerender}
|
||||
for rendermode in options.rendermode:
|
||||
if rendermode == 'normal':
|
||||
qtree = quadtree.QuadtreeGen(w, destdir, rendermode=rendermode, tiledir='tiles', **qtree_args)
|
||||
|
||||
@@ -29,13 +29,13 @@ body {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#customControl {
|
||||
.customControl {
|
||||
padding: 5px;
|
||||
height: 15px;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
#customControl > div#top {
|
||||
.customControl > div.top {
|
||||
background-color: #fff;
|
||||
border: 2px solid #000;
|
||||
text-align: center;
|
||||
@@ -45,14 +45,14 @@ body {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#customControl > div#dropDown {
|
||||
.customControl > div.dropDown {
|
||||
border: 1px solid #000;
|
||||
font-size: 12px;
|
||||
background-color: #fff;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#customControl > div#button {
|
||||
.customControl > div.button {
|
||||
border: 1px solid #000;
|
||||
font-size: 12px;
|
||||
background-color: #fff;
|
||||
|
||||
@@ -560,8 +560,8 @@ var overviewer = {
|
||||
|
||||
// Adjust for the fact that we we can't figure out what Y is given
|
||||
// only latitude and longitude, so assume Y=64.
|
||||
point.x += 64 + 1;
|
||||
point.z -= 64 + 2;
|
||||
point.x += 64;
|
||||
point.z -= 64;
|
||||
|
||||
return point;
|
||||
},
|
||||
@@ -585,7 +585,7 @@ var overviewer = {
|
||||
// Spawn button
|
||||
var homeControlDiv = document.createElement('DIV');
|
||||
var homeControl = new overviewer.classes.HomeControl(homeControlDiv);
|
||||
homeControlDiv.id = 'customControl';
|
||||
$(homeControlDiv).addClass('customControl');
|
||||
homeControlDiv.index = 1;
|
||||
if (overviewerConfig.map.controls.spawn) {
|
||||
overviewer.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
|
||||
@@ -680,18 +680,18 @@ var overviewer = {
|
||||
'createDropDown': function(title, items) {
|
||||
var control = document.createElement('DIV');
|
||||
// let's let a style sheet do most of the styling here
|
||||
control.id = 'customControl';
|
||||
$(control).addClass('customControl');
|
||||
|
||||
var controlText = document.createElement('DIV');
|
||||
controlText.innerHTML = title;
|
||||
|
||||
var controlBorder = document.createElement('DIV');
|
||||
controlBorder.id='top';
|
||||
$(controlBorder).addClass('top');
|
||||
control.appendChild(controlBorder);
|
||||
controlBorder.appendChild(controlText);
|
||||
|
||||
var dropdownDiv = document.createElement('DIV');
|
||||
dropdownDiv.id='dropDown';
|
||||
$(dropdownDiv).addClass('dropDown');
|
||||
control.appendChild(dropdownDiv);
|
||||
dropdownDiv.innerHTML='';
|
||||
|
||||
@@ -868,14 +868,14 @@ var overviewer = {
|
||||
controlDiv.style.padding = '5px';
|
||||
// Set CSS for the control border
|
||||
var control = document.createElement('DIV');
|
||||
control.id='top';
|
||||
$(control).addClass('top');
|
||||
control.title = 'Click to center the map on the Spawn';
|
||||
controlDiv.appendChild(control);
|
||||
|
||||
// Set CSS for the control interior
|
||||
var controlText = document.createElement('DIV');
|
||||
controlText.innerHTML = 'Spawn';
|
||||
controlText.id='button';
|
||||
$(controlText).addClass('button');
|
||||
control.appendChild(controlText);
|
||||
|
||||
// Setup the click event listeners: simply set the map to map center
|
||||
|
||||
@@ -45,7 +45,8 @@ def optimize_image(imgpath, imgformat, optimizeimg):
|
||||
os.rename(imgpath+".tmp", imgpath)
|
||||
|
||||
if optimizeimg >= 2:
|
||||
subprocess.Popen([optipng, imgpath], stderr=subprocess.STDOUT,
|
||||
# the "-nc" it's needed to no broke the transparency of tiles
|
||||
subprocess.Popen([optipng, "-nc", imgpath], stderr=subprocess.STDOUT,
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
subprocess.Popen([advdef, "-z4",imgpath], stderr=subprocess.STDOUT,
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
|
||||
@@ -49,7 +49,7 @@ def iterate_base4(d):
|
||||
return itertools.product(xrange(4), repeat=d)
|
||||
|
||||
class QuadtreeGen(object):
|
||||
def __init__(self, worldobj, destdir, bgcolor, depth=None, tiledir=None, imgformat=None, imgquality=95, optimizeimg=None, rendermode="normal"):
|
||||
def __init__(self, worldobj, destdir, bgcolor, depth=None, tiledir=None, forcerender=False, imgformat=None, imgquality=95, optimizeimg=None, rendermode="normal"):
|
||||
"""Generates a quadtree from the world given into the
|
||||
given dest directory
|
||||
|
||||
@@ -60,6 +60,7 @@ class QuadtreeGen(object):
|
||||
|
||||
"""
|
||||
assert(imgformat)
|
||||
self.forcerender = forcerender
|
||||
self.imgformat = imgformat
|
||||
self.imgquality = imgquality
|
||||
self.optimizeimg = optimizeimg
|
||||
@@ -425,10 +426,17 @@ class QuadtreeGen(object):
|
||||
needs_rerender = False
|
||||
get_region_mtime = world.get_region_mtime
|
||||
for col, row, chunkx, chunky, regionfile in chunks:
|
||||
# check region file mtime first.
|
||||
region,regionMtime = get_region_mtime(regionfile)
|
||||
# don't even check if it's not in the regionlist
|
||||
if self.world.regionlist and region._filename not in self.world.regionlist:
|
||||
continue
|
||||
|
||||
# bail early if forcerender is set
|
||||
if self.forcerender:
|
||||
needs_rerender = True
|
||||
break
|
||||
|
||||
# check region file mtime first.
|
||||
region,regionMtime = get_region_mtime(regionfile)
|
||||
if regionMtime <= tile_mtime:
|
||||
continue
|
||||
|
||||
|
||||
@@ -50,10 +50,13 @@ zoom = 9
|
||||
## Example: Dynamically create regionlist of only regions older than 2 days
|
||||
|
||||
import os, time
|
||||
# the following two lines are needed to the lambda to work
|
||||
globals()['os'] = os
|
||||
globals()['time'] = time
|
||||
regionDir = os.path.join(args[0], "region")
|
||||
regionFiles = filter(lambda x: x.endswith(".mcr"), os.listdir(regionDir))
|
||||
def olderThanTwoDays(f):
|
||||
return time.time() - os.stat(f).st_mtime > (60*60*24*2)
|
||||
return time.time() - os.stat(os.path.join(args[0], 'region',f)).st_mtime > (60*60*24*2)
|
||||
oldRegionFiles = filter(olderThanTwoDays, regionFiles)
|
||||
with open("regionlist.txt", "w") as f:
|
||||
f.write("\n".join(oldRegionFiles))
|
||||
@@ -148,3 +151,9 @@ if "web_assets_hook" in locals():
|
||||
skipjs = True
|
||||
|
||||
|
||||
|
||||
|
||||
### As a reminder, don't use this file verbatim, it should only be used as
|
||||
### a guide.
|
||||
import sys
|
||||
sys.exit("This sample-settings file shouldn't be used directly!")
|
||||
|
||||
Reference in New Issue
Block a user