Merge branch 'master' into py-package
This commit is contained in:
@@ -20,7 +20,7 @@ import sys
|
|||||||
sys.path.insert(0,".")
|
sys.path.insert(0,".")
|
||||||
|
|
||||||
import nbt
|
import nbt
|
||||||
from chunk import get_blockarray_fromfile
|
from chunk import get_blockarray_fromfile, get_blockarray
|
||||||
import os
|
import os
|
||||||
import re
|
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("-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("-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("--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("--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("--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 )
|
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
|
# create the quadtrees
|
||||||
# TODO chunklist
|
# TODO chunklist
|
||||||
q = []
|
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:
|
for rendermode in options.rendermode:
|
||||||
if rendermode == 'normal':
|
if rendermode == 'normal':
|
||||||
qtree = quadtree.QuadtreeGen(w, destdir, rendermode=rendermode, tiledir='tiles', **qtree_args)
|
qtree = quadtree.QuadtreeGen(w, destdir, rendermode=rendermode, tiledir='tiles', **qtree_args)
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ body {
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
#customControl {
|
.customControl {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
height: 15px;
|
height: 15px;
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
#customControl > div#top {
|
.customControl > div.top {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 2px solid #000;
|
border: 2px solid #000;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -45,14 +45,14 @@ body {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#customControl > div#dropDown {
|
.customControl > div.dropDown {
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#customControl > div#button {
|
.customControl > div.button {
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
|||||||
@@ -560,8 +560,8 @@ var overviewer = {
|
|||||||
|
|
||||||
// Adjust for the fact that we we can't figure out what Y is given
|
// Adjust for the fact that we we can't figure out what Y is given
|
||||||
// only latitude and longitude, so assume Y=64.
|
// only latitude and longitude, so assume Y=64.
|
||||||
point.x += 64 + 1;
|
point.x += 64;
|
||||||
point.z -= 64 + 2;
|
point.z -= 64;
|
||||||
|
|
||||||
return point;
|
return point;
|
||||||
},
|
},
|
||||||
@@ -585,7 +585,7 @@ var overviewer = {
|
|||||||
// Spawn button
|
// Spawn button
|
||||||
var homeControlDiv = document.createElement('DIV');
|
var homeControlDiv = document.createElement('DIV');
|
||||||
var homeControl = new overviewer.classes.HomeControl(homeControlDiv);
|
var homeControl = new overviewer.classes.HomeControl(homeControlDiv);
|
||||||
homeControlDiv.id = 'customControl';
|
$(homeControlDiv).addClass('customControl');
|
||||||
homeControlDiv.index = 1;
|
homeControlDiv.index = 1;
|
||||||
if (overviewerConfig.map.controls.spawn) {
|
if (overviewerConfig.map.controls.spawn) {
|
||||||
overviewer.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
|
overviewer.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
|
||||||
@@ -680,18 +680,18 @@ var overviewer = {
|
|||||||
'createDropDown': function(title, items) {
|
'createDropDown': function(title, items) {
|
||||||
var control = document.createElement('DIV');
|
var control = document.createElement('DIV');
|
||||||
// let's let a style sheet do most of the styling here
|
// let's let a style sheet do most of the styling here
|
||||||
control.id = 'customControl';
|
$(control).addClass('customControl');
|
||||||
|
|
||||||
var controlText = document.createElement('DIV');
|
var controlText = document.createElement('DIV');
|
||||||
controlText.innerHTML = title;
|
controlText.innerHTML = title;
|
||||||
|
|
||||||
var controlBorder = document.createElement('DIV');
|
var controlBorder = document.createElement('DIV');
|
||||||
controlBorder.id='top';
|
$(controlBorder).addClass('top');
|
||||||
control.appendChild(controlBorder);
|
control.appendChild(controlBorder);
|
||||||
controlBorder.appendChild(controlText);
|
controlBorder.appendChild(controlText);
|
||||||
|
|
||||||
var dropdownDiv = document.createElement('DIV');
|
var dropdownDiv = document.createElement('DIV');
|
||||||
dropdownDiv.id='dropDown';
|
$(dropdownDiv).addClass('dropDown');
|
||||||
control.appendChild(dropdownDiv);
|
control.appendChild(dropdownDiv);
|
||||||
dropdownDiv.innerHTML='';
|
dropdownDiv.innerHTML='';
|
||||||
|
|
||||||
@@ -868,14 +868,14 @@ var overviewer = {
|
|||||||
controlDiv.style.padding = '5px';
|
controlDiv.style.padding = '5px';
|
||||||
// Set CSS for the control border
|
// Set CSS for the control border
|
||||||
var control = document.createElement('DIV');
|
var control = document.createElement('DIV');
|
||||||
control.id='top';
|
$(control).addClass('top');
|
||||||
control.title = 'Click to center the map on the Spawn';
|
control.title = 'Click to center the map on the Spawn';
|
||||||
controlDiv.appendChild(control);
|
controlDiv.appendChild(control);
|
||||||
|
|
||||||
// Set CSS for the control interior
|
// Set CSS for the control interior
|
||||||
var controlText = document.createElement('DIV');
|
var controlText = document.createElement('DIV');
|
||||||
controlText.innerHTML = 'Spawn';
|
controlText.innerHTML = 'Spawn';
|
||||||
controlText.id='button';
|
$(controlText).addClass('button');
|
||||||
control.appendChild(controlText);
|
control.appendChild(controlText);
|
||||||
|
|
||||||
// Setup the click event listeners: simply set the map to map center
|
// 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)
|
os.rename(imgpath+".tmp", imgpath)
|
||||||
|
|
||||||
if optimizeimg >= 2:
|
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]
|
stdout=subprocess.PIPE).communicate()[0]
|
||||||
subprocess.Popen([advdef, "-z4",imgpath], stderr=subprocess.STDOUT,
|
subprocess.Popen([advdef, "-z4",imgpath], stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE).communicate()[0]
|
stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def iterate_base4(d):
|
|||||||
return itertools.product(xrange(4), repeat=d)
|
return itertools.product(xrange(4), repeat=d)
|
||||||
|
|
||||||
class QuadtreeGen(object):
|
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
|
"""Generates a quadtree from the world given into the
|
||||||
given dest directory
|
given dest directory
|
||||||
|
|
||||||
@@ -60,6 +60,7 @@ class QuadtreeGen(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
assert(imgformat)
|
assert(imgformat)
|
||||||
|
self.forcerender = forcerender
|
||||||
self.imgformat = imgformat
|
self.imgformat = imgformat
|
||||||
self.imgquality = imgquality
|
self.imgquality = imgquality
|
||||||
self.optimizeimg = optimizeimg
|
self.optimizeimg = optimizeimg
|
||||||
@@ -425,10 +426,17 @@ class QuadtreeGen(object):
|
|||||||
needs_rerender = False
|
needs_rerender = False
|
||||||
get_region_mtime = world.get_region_mtime
|
get_region_mtime = world.get_region_mtime
|
||||||
for col, row, chunkx, chunky, regionfile in chunks:
|
for col, row, chunkx, chunky, regionfile in chunks:
|
||||||
# check region file mtime first.
|
# don't even check if it's not in the regionlist
|
||||||
region,regionMtime = get_region_mtime(regionfile)
|
|
||||||
if self.world.regionlist and region._filename not in self.world.regionlist:
|
if self.world.regionlist and region._filename not in self.world.regionlist:
|
||||||
continue
|
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:
|
if regionMtime <= tile_mtime:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,13 @@ zoom = 9
|
|||||||
## Example: Dynamically create regionlist of only regions older than 2 days
|
## Example: Dynamically create regionlist of only regions older than 2 days
|
||||||
|
|
||||||
import os, time
|
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")
|
regionDir = os.path.join(args[0], "region")
|
||||||
regionFiles = filter(lambda x: x.endswith(".mcr"), os.listdir(regionDir))
|
regionFiles = filter(lambda x: x.endswith(".mcr"), os.listdir(regionDir))
|
||||||
def olderThanTwoDays(f):
|
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)
|
oldRegionFiles = filter(olderThanTwoDays, regionFiles)
|
||||||
with open("regionlist.txt", "w") as f:
|
with open("regionlist.txt", "w") as f:
|
||||||
f.write("\n".join(oldRegionFiles))
|
f.write("\n".join(oldRegionFiles))
|
||||||
@@ -148,3 +151,9 @@ if "web_assets_hook" in locals():
|
|||||||
skipjs = True
|
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