summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/mapspecs.js26
1 files changed, 17 insertions, 9 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js
index 31370e3..446bc53 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -294,7 +294,7 @@ function request_path_done() {
if (lastTarget == 'f') lastTarget = 'finish';
alert("The path is blocked, can't reach "+lastTarget);
- return;
+ //return;
}
@@ -962,16 +962,24 @@ function mapAsHTML(map, targetWidth, mapEditor) {
return r;
}
-function mapThumbnailHTML(map, targetWidth, isActive) {
+function mapThumbnailHTML(map, targetWidth, targetHeight) {
if (!targetWidth) targetWidth = 120;
- var scale = map.width / targetWidth;
+ if (!targetHeight) targetHeight = 320;
+
+ var heightScale = map.height / targetHeight;
+ var widthScale = map.width / targetWidth;
- var width = parseInt(map.width / scale);
- var height = parseInt(map.height / scale);
- var tileWidth = parseInt(width / map.width);
+ //Size based on target width
+ var tileSize = Math.floor(map.width / widthScale / map.width);
+ //Too tall using width?
+ if (tileSize * map.height > targetHeight) {
+ //Use target height
+ tileSize = Math.floor(map.height / heightScale / map.height);
+ }
+ //console.log('tw', tileSize * map.height, targetHeight);
- width = tileWidth * map.width;
- height = tileWidth * map.height;
+ var width = tileSize * map.width;
+ var height = tileSize * map.height;
var mapgrid = '';
var r = '';
@@ -984,7 +992,7 @@ function mapThumbnailHTML(map, targetWidth, isActive) {
var value = map.tiles[y][x][1];
if (!value) value = '';
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"'>";
+ mapgrid += "<div style='float:left; width:"+tileSize+"px; height:"+tileSize+"px; ' class='mapcell "+type+value+"'>";
mapgrid += "</div>";
}
}