Run 'Shrink Map Size' function from MapNormalizer editor script.

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@9175 282e977c-c81d-0410-88c4-b93c2d0d6712
master
akirschbaum 2008-05-30 06:23:54 +00:00
parent 981fa64822
commit 7af382aba0
1 changed files with 52 additions and 36 deletions

View File

@ -3,7 +3,9 @@
<name>MapNormalizer</name>
<code><![CDATA[import java.io.File;
import java.util.Iterator;
import net.sf.gridarta.CommonConstants;
import net.sf.gridarta.io.RecursiveFileIterator;
import net.sf.gridarta.map.ShrinkMapSizeUtils;
void normalizeMap(File mapFile, String mapPath) {
print(mapPath);
@ -14,6 +16,20 @@ void normalizeMap(File mapFile, String mapPath) {
return;
}
if (!mapPath.startsWith("/styles")
&& !mapPath.startsWith("/editor")) {
mapModel = map.getMapModel();
mapArchObject = mapModel.getMapArchObject();
int shrinkFlags = 0;
if (mapArchObject.getTilePath(CommonConstants.NORTH).length() <= 0 && mapArchObject.getTilePath(CommonConstants.SOUTH).length() <= 0) {
shrinkFlags |= ShrinkMapSizeUtils.SHRINK_EAST;
}
if (mapArchObject.getTilePath(CommonConstants.EAST).length() <= 0 && mapArchObject.getTilePath(CommonConstants.WEST).length() <= 0) {
shrinkFlags |= ShrinkMapSizeUtils.SHRINK_SOUTH;
}
ShrinkMapSizeUtils.shrinkMap(mapModel, shrinkFlags);
}
map.save();
}