diff options
-rw-r--r-- | includes/maps.php | 1 | ||||
-rw-r--r-- | js/mapspecs.js | 26 | ||||
-rw-r--r-- | pages/scores.php | 2 |
3 files changed, 19 insertions, 10 deletions
diff --git a/includes/maps.php b/includes/maps.php index 6b8ba07..1dfb3a6 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -1072,6 +1072,7 @@ function routePath($mygrid, $validate = false, $traverseBackwards = false) { if ($blocked) {
$r['blocked'] = true;
$r['lastTarget'] = $t;
+ $r['path'] = $tpath;
return $r;
}
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>";
}
}
diff --git a/pages/scores.php b/pages/scores.php index fc86b4f..54ac027 100644 --- a/pages/scores.php +++ b/pages/scores.php @@ -275,7 +275,7 @@ function formatMapThumbForNav(json) { var r = '';
r += "<div class='mapThumbnail"+mapClass+"' title='"+toolTip+"'; onclick='displayMapScores("+map.ID+")'>";
- r += mapThumbnailHTML(map, 120, isActive);
+ r += mapThumbnailHTML(map, 120);
r += '</div>';
return r;
}
|