From e65b77ac579f9e96ccce682725265b25da0a666d Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 2 Jun 2011 00:57:43 +0200 Subject: [PATCH 1/6] Fix optimizeimg=2 transparency issue not messing with the color type in optipng. --- optimizeimages.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/optimizeimages.py b/optimizeimages.py index e1699b0..01799e4 100644 --- a/optimizeimages.py +++ b/optimizeimages.py @@ -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] From 5249aca936785e2ecbf37b20311dacbaa26d58bd Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Wed, 1 Jun 2011 23:15:45 -0400 Subject: [PATCH 2/6] Tweak fromLatLngToWorld to fix issue #381 --- web_assets/overviewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index d8673c1..94bb8cc 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -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; }, From f47e7fe4063846da2aa68e62b26027be169b11ed Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 2 Jun 2011 13:06:12 -0400 Subject: [PATCH 3/6] Fixed rerenderBlocks contrib script --- contrib/rerenderBlocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/rerenderBlocks.py b/contrib/rerenderBlocks.py index d0fa0df..eb93871 100644 --- a/contrib/rerenderBlocks.py +++ b/contrib/rerenderBlocks.py @@ -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 From 91c3e74ef213203a452cf7a3fac84bb914a84087 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Fri, 3 Jun 2011 21:56:04 -0400 Subject: [PATCH 4/6] Updated sample settings file * Causes Overviewer to exit if someone uses the sample settings file directly * Fixed up the regionlist example so it doesn't throw errors --- sample.settings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sample.settings.py b/sample.settings.py index 2872506..863b266 100644 --- a/sample.settings.py +++ b/sample.settings.py @@ -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!") From 36df63caa4a6edc7978b7e4df8f9778e681bae32 Mon Sep 17 00:00:00 2001 From: TJ09 Date: Sat, 4 Jun 2011 13:28:24 -0400 Subject: [PATCH 5/6] Change ids to classes. Fixes #387 --- web_assets/overviewer.css | 8 ++++---- web_assets/overviewer.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web_assets/overviewer.css b/web_assets/overviewer.css index 19b9b34..14585e6 100644 --- a/web_assets/overviewer.css +++ b/web_assets/overviewer.css @@ -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; diff --git a/web_assets/overviewer.js b/web_assets/overviewer.js index 94bb8cc..467affb 100644 --- a/web_assets/overviewer.js +++ b/web_assets/overviewer.js @@ -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 From ac91268c668f0ce1d0cb8b27136502fe03c9b482 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 4 Jun 2011 20:05:09 -0400 Subject: [PATCH 6/6] added --forcerender option --- overviewer.py | 3 ++- quadtree.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/overviewer.py b/overviewer.py index 5f3400c..e217949 100755 --- a/overviewer.py +++ b/overviewer.py @@ -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) diff --git a/quadtree.py b/quadtree.py index 5d240db..f1c4b1d 100644 --- a/quadtree.py +++ b/quadtree.py @@ -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