summaryrefslogtreecommitdiff
path: root/tools/tmxcopy
diff options
context:
space:
mode:
authorSteve Cotton <steve@s.cotton.clara.co.uk>2009-07-20 23:21:09 +0100
committerSteve Cotton <steve@s.cotton.clara.co.uk>2009-07-22 11:36:20 +0100
commit8f5b3e7b0af9de35453bd8ff32a5bb287b13bc96 (patch)
treed943f5dea31797de6ca628fadb54338f909bbb79 /tools/tmxcopy
parent03fd663b2bfbd61f032c47d9aaf6661fe9a18bbe (diff)
downloadmana-client-8f5b3e7b0af9de35453bd8ff32a5bb287b13bc96.tar.gz
mana-client-8f5b3e7b0af9de35453bd8ff32a5bb287b13bc96.tar.bz2
mana-client-8f5b3e7b0af9de35453bd8ff32a5bb287b13bc96.tar.xz
mana-client-8f5b3e7b0af9de35453bd8ff32a5bb287b13bc96.zip
TMX Tools: minor tidyup
Diffstat (limited to 'tools/tmxcopy')
-rw-r--r--tools/tmxcopy/map.cpp17
-rw-r--r--tools/tmxcopy/readme.txt11
-rw-r--r--tools/tmxcopy/tmx_random_fill.cpp2
-rw-r--r--tools/tmxcopy/tmxcollide.cpp2
4 files changed, 25 insertions, 7 deletions
diff --git a/tools/tmxcopy/map.cpp b/tools/tmxcopy/map.cpp
index 0fd764b4..75bd9a45 100644
--- a/tools/tmxcopy/map.cpp
+++ b/tools/tmxcopy/map.cpp
@@ -390,7 +390,17 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName,
}
/* Now generate extra tiles.
- * TODO Need to configure this for desired density. For 2x1 trees, dW*dH/10 is very sparse, dW*dH/2 is dense */
+ *
+ * After considering ways to specify the number of objects to add, I think
+ * the best user interface (without integrating it with Tiled) is to place
+ * a small number of objects each time, and have the user run the utility
+ * several times, reloading the map in Tiled each time until it looks
+ * right. Simpler than typing magic numbers in at a command prompt.
+ *
+ * This algorithm completes after a fixed number of attempts at placing an
+ * object; regardless of how many attempts are successful.
+ * For 2x1 trees, destWidth*destHeight/10 is very sparse, dW*dH/2 is dense.
+ */
srand(time(NULL));
int patternsGenerated = 0;
int occupiedAreas = 0;
@@ -418,7 +428,6 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName,
if (areaIsClear)
{
int p = rand() % templateMap->getNumberOfLayers();
- std::cout <<"Copying pattern "<<p<<" to "<<x<<", "<<y<<std::endl;
Layer* srcLayer = templateMap->getLayer(p);
for (int loop_y=0; loop_y<templateMap->getHeight(); loop_y++)
@@ -436,11 +445,11 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName,
else
{
occupiedAreas++;
- std::cout <<"Area occupied "<<x<<", "<<y<<std::endl;
}
}
std::clog<<"Generated " << patternsGenerated << " new objects" <<std::endl;
+ (void) occupiedAreas; // Unused at the moment, but keep it without a compiler warning about unused variables
return true;
}
@@ -461,7 +470,7 @@ bool Map::translateAllLayers(Map* templateMap, const std::string& destLayerName,
}
if (!checkPassed) return false;
- //FIXME - as is, this will add tilesets that are in the template but
+ //TODO This will unnecessarily add tilesets that are in the template but
//not used in the main map
std::map<int, int> tilesetTranslation = addAndTranslateTilesets(templateMap);
diff --git a/tools/tmxcopy/readme.txt b/tools/tmxcopy/readme.txt
index 5964f31a..52af1048 100644
--- a/tools/tmxcopy/readme.txt
+++ b/tools/tmxcopy/readme.txt
@@ -1,3 +1,10 @@
+=== TMX Map Tools ===
+
+A set of tools for manipulating TMX map files.
+
+After using any of these tools, load the map in Tiled and save it again; until this is done the game may not be able to load the file (see Bugs for an explanation).
+
+
=== TMXCopy ===
Tmxcopy is a little tool that allows to copy parts of one TMX map to another map. This will make it much easier to match the border areas of maps. The program is command line based. The usage is:
@@ -61,6 +68,8 @@ The template is a map where each layer is a pattern. For example, to make a woo
It will then randomly place trees, but only in places where they won't overlap with other things on that layer. The size of the template map is the size of the area which must be empty in the destination layer.
+Running it several times (without specifying an output file) will add more objects. After considering ways to specify the number of objects to add, I think the easiest is to just reload the map in Tiled each time until it looks right (you don't need to quit Tiled while running tmx_random_fill).
+
=== TMX Collide / Translate ===
@@ -83,7 +92,7 @@ Blank tiles in the lower layer will be ignored (put a blank in the upper layer t
=== Bugs (for all these programs) ===
-The program works so far but there are still some minor problems:
+The programs work so far but there are still some minor problems:
-Only tested for TMW-compilant maps. I don't guarantee that it works with Tiled maps that are made for other games and thus use different features.
-Compressed maps (tmx.gz) can not be handled yet (but compressed or uncompressed layers work properly)
diff --git a/tools/tmxcopy/tmx_random_fill.cpp b/tools/tmxcopy/tmx_random_fill.cpp
index d55c9b58..2cc232fe 100644
--- a/tools/tmxcopy/tmx_random_fill.cpp
+++ b/tools/tmxcopy/tmx_random_fill.cpp
@@ -31,7 +31,7 @@ void printUsage()
<<" -o save results to outfile, instead of overwriting the original"<<std::endl
<<std::endl
<<"Fill a rectangular area of mapFile's layer 'destLayer' with a random selection from the templateFile"<<std::endl
- <<"TODO - more help here"<<std::endl;
+ <<"See readme.txt for full documentation"<<std::endl;
}
int main(int argc, char * argv[] )
diff --git a/tools/tmxcopy/tmxcollide.cpp b/tools/tmxcopy/tmxcollide.cpp
index 2ce6f90b..a3600f61 100644
--- a/tools/tmxcopy/tmxcollide.cpp
+++ b/tools/tmxcopy/tmxcollide.cpp
@@ -31,7 +31,7 @@ void printUsage()
<<" -o save results to outfile, instead of overwriting the original"<<std::endl
<<std::endl
<<"Using the template, translate visible layers to the collision layer"<<std::endl
- <<"TODO - more help here"<<std::endl;
+ <<"See readme.txt for full documentation"<<std::endl;
}
int main(int argc, char * argv[] )