From 36aa6ed011ce0de896c15e5106d700de00d75e94 Mon Sep 17 00:00:00 2001 From: Thomas Lake Date: Sun, 8 Apr 2012 12:51:27 +0100 Subject: [PATCH 1/5] Add 'showspawn' render option Allow users to hide the spawn marker that is normally generated for overworld levels --- docs/config.rst | 4 ++++ overviewer.py | 2 +- overviewer_core/settingsDefinition.py | 1 + overviewer_core/tileset.py | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 1884573..dac2c12 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -480,6 +480,10 @@ values. The valid configuration keys are listed below. **Default:** ``[]`` (an empty list) +``showspawn`` + This is a boolean, and defaults to ``True``. If set to ``False``, then the spawn + icon will not be displayed on the rendered map. + .. _customrendermodes: Custom Rendermodes and Rendermode Primitives diff --git a/overviewer.py b/overviewer.py index 6786c36..986d59a 100755 --- a/overviewer.py +++ b/overviewer.py @@ -401,7 +401,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces. # only pass to the TileSet the options it really cares about render['name'] = render_name # perhaps a hack. This is stored here for the asset manager - tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension", "changelist"]) + tileSetOpts = util.dict_subset(render, ["name", "imgformat", "renderchecks", "rerenderprob", "bgcolor", "imgquality", "optimizeimg", "rendermode", "worldname_orig", "title", "dimension", "changelist","showspawn"]) tileSetOpts.update({"spawn": w.find_true_spawn()}) # TODO find a better way to do this tset = tileset.TileSet(rset, assetMrg, tex, tileSetOpts, tileset_dir) tilesets.append(tset) diff --git a/overviewer_core/settingsDefinition.py b/overviewer_core/settingsDefinition.py index 7d1625f..d2e357c 100644 --- a/overviewer_core/settingsDefinition.py +++ b/overviewer_core/settingsDefinition.py @@ -79,6 +79,7 @@ renders = Setting(required=True, default=util.OrderedDict(), "crop": Setting(required=False, validator=validateCrop, default=None), "changelist": Setting(required=False, validator=validateStr, default=None), "markers": Setting(required=False, validator=validateMarkers, default=[]), + "showspawn": Setting(required=False, validator=validateBool, default=True), # Remove this eventually (once people update their configs) "worldname": Setting(required=False, default=None, diff --git a/overviewer_core/tileset.py b/overviewer_core/tileset.py index 4787c64..ab25a2a 100644 --- a/overviewer_core/tileset.py +++ b/overviewer_core/tileset.py @@ -520,8 +520,11 @@ class TileSet(object): last_rendertime = self.max_chunk_mtime, imgextension = self.imgextension, ) - if (self.regionset.get_type() == "overworld"): + if (self.regionset.get_type() == "overworld" and self.options.get("showspawn", True)): d.update({"spawn": self.options.get("spawn")}) + else: + d.update({"spawn": "false"}); + try: d['north_direction'] = self.regionset.north_dir except AttributeError: From e2b24a7a0f2bdd690bf651b36dd554454d7a3146 Mon Sep 17 00:00:00 2001 From: stoneLeaf Date: Tue, 10 Apr 2012 18:07:44 +0300 Subject: [PATCH 2/5] Added a new section entitled 'A dynamic config file'. It explains the use of environment variables in the config file to dynamically retrieve parameters. --- docs/config.rst | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/config.rst b/docs/config.rst index dac2c12..e256843 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -115,6 +115,53 @@ individual renders to apply to just those renders. See the ``sample_config.py`` file included in the repository for another example. +A dynamic config file +===================== + +It might be handy to dynamically retrieve parameters. For instance, if you +periodically render your last map backup which is located in a timestamped +directory, it is not convenient to edit the config file each time to fit the +new directory name. + +Using environment variables, you can easily retrieve a parameter which has +been set by, for instance, your map backup script. In this example, Overviewer is +called from a *bash* script, but it can be done from other shell scripts and +languages. + +:: + + ## The bash script + + # Setting up an environment variable that child processes will inherit + MYWORLD_DIR=/path/to/map/backup/$yourtimestamp/YourWorld + export MYWORLD_DIR + + # Running the Overviwer + overviewer.py --config=/path/to/yourConfig.py + +.. note:: + + The environment variable will only be local to the process and its child + processes. In this example, the Overviewer will be able to access the + variable since it becomes a child process. + +:: + + ## The config file + + # Importing the os python module + import os + + # Retrieving the environment variable + worlds["My world"] = os.environ['MYWORLD_DIR'] + + renders["normalrender"] = { + "world": "My world", + "title": "Normal Render of My World", + } + + outputdir = "/home/username/mcmap" + Config File Specifications ========================== From 4e7c83792805973950344e0b2d60ae93a202e9ab Mon Sep 17 00:00:00 2001 From: CounterPillow Date: Tue, 10 Apr 2012 21:30:26 +0200 Subject: [PATCH 3/5] Added documentation about optimizeimg. --- docs/config.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/config.rst b/docs/config.rst index dac2c12..dfd8450 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -360,6 +360,20 @@ values. The valid configuration keys are listed below. **Default:** ``95`` +``optimizeimg`` + This option specifies which additional tools overviewer should use to + optimize the filesize of png tiles. + The tools used must be placed somewhere, where overviewer can find them, for + example the "PATH" environment variable or a directory like /usr/bin. + This should be an integer between 0 and 3. + * ``1 - Use pngcrush`` + * ``2 - Use advdef`` + * ``3 - Use pngcrush and advdef (Not recommended)`` + Using this option may significantly increase render time, but will make + the resulting tiles smaller, with lossless image quality. + + **Default:** ``0`` + ``bgcolor`` This is the background color to be displayed behind the map. Its value should be either a string in the standard HTML color syntax or a 4-tuple in From b9217e28c8f28a27e639c9144656035df3651cd6 Mon Sep 17 00:00:00 2001 From: stoneLeaf Date: Wed, 11 Apr 2012 00:42:43 +0300 Subject: [PATCH 4/5] Improved the 'A dynamic config file' doc section. --- docs/config.rst | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index e256843..e9fd8a8 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -124,35 +124,39 @@ directory, it is not convenient to edit the config file each time to fit the new directory name. Using environment variables, you can easily retrieve a parameter which has -been set by, for instance, your map backup script. In this example, Overviewer is -called from a *bash* script, but it can be done from other shell scripts and -languages. +been set by, for instance, your map backup script. In this example, Overviewer +is called from a *bash* script, but it can be done from other shell scripts +and languages. :: - ## The bash script + #!/bin/bash - # Setting up an environment variable that child processes will inherit - MYWORLD_DIR=/path/to/map/backup/$yourtimestamp/YourWorld + ## Add these lines to your bash script + + # Setting up an environment variable that child processes will inherit. + # In this example, the map's path is not static and depends on the + # previously set $timestamp var. + MYWORLD_DIR=/path/to/map/backup/$timestamp/YourWorld export MYWORLD_DIR - # Running the Overviwer + # Running the Overviewer overviewer.py --config=/path/to/yourConfig.py .. note:: The environment variable will only be local to the process and its child - processes. In this example, the Overviewer will be able to access the - variable since it becomes a child process. + processes. The Overviewer, when run by the script, will be able to access + the variable since it becomes a child process. :: - ## The config file + ## A config file example # Importing the os python module import os - # Retrieving the environment variable + # Retrieving the environment variable set up by the bash script worlds["My world"] = os.environ['MYWORLD_DIR'] renders["normalrender"] = { From b7f4cc3fc9aa3e7e597e51927f61fae6d3f0bd6b Mon Sep 17 00:00:00 2001 From: Richard Pastrick Date: Fri, 13 Apr 2012 09:55:30 -0700 Subject: [PATCH 5/5] Make the built in rendermodes show up on the docs table of contents --- docs/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.rst b/docs/config.rst index dac2c12..e0aa983 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -643,7 +643,7 @@ are referencing the previously defined list, not one of the built-in rendermodes. Built-in Rendermodes --------------------- +==================== The built-in rendermodes are nothing but pre-defined lists of rendermode primitives for your convenience. Here are their definitions::