From 7b88927f53998da4544b481849bd72728688e282 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 23 Apr 2013 02:22:00 -0700 Subject: Map thumbnail, partial animation of blocked path. --- js/mapspecs.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'js') 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 += "
"; + mapgrid += "
"; mapgrid += "
"; } } -- cgit v1.2.3