diff options
Diffstat (limited to 'js/mapspecs.js')
-rw-r--r-- | js/mapspecs.js | 131 |
1 files changed, 92 insertions, 39 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js index 2a5bd1d..6ab7286 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -141,10 +141,7 @@ function grid_click(obj) { wallEmblem = playerWallEmblem;
}
}
- console.log('using wallcolors:', wallColor, wallEmblem);
-
obj.style.backgroundColor = wallColor;
-
if (wallEmblem !== false) {
obj.style.backgroundImage="url(images/marks/"+wallEmblem+")";
}
@@ -588,14 +585,14 @@ function doanimate(x, y, p, c, mapid, pathNumber) { rs = 84;
//How fast should we be going?
selectbox = document.getElementById(mapid+',speed');
- selected = selectbox.options[selectbox.selectedIndex].value;
- switch (selected) {
+ var selectedSpeed = selectbox.options[selectbox.selectedIndex].value;
+ switch (selectedSpeed) {
case '1':
- rs =160;
+ rs =180;
break;
case '2':
- rs =84;
+ rs =94;
break;
case '3':
@@ -634,7 +631,8 @@ function doanimate(x, y, p, c, mapid, pathNumber) { case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f':
- rs = rs + 410;
+ rs = rs + 410;
+ if (selectedSpeed <= 2) rs = rs + 200;
mapdata[mapid].pathColor[pathNumber] = targetColor(t);
break;
@@ -712,7 +710,12 @@ function targetColor(target) { function flashelement(eid, times, color, speed) {
- if (document.getElementById(eid) == undefined) return;
+
+ if (typeof(document.getElementById(eid)) == 'undefined') return;
+ var elementToFlash = document.getElementById(eid);
+ if (elementToFlash.isBeingFlashed == true) return;
+ elementToFlash.isBeingFlashed = true;
+
if (!color) {
color = "#FFFF44";
}
@@ -720,28 +723,23 @@ function flashelement(eid, times, color, speed) { speed = 220;
}
speedon = speed * .5;
- //document.getElementById(eid).setAttribute('class', 'no_transition');
- var currentclass = document.getElementById(eid).className;
- if (document.getElementById(eid).classOrigName != undefined)
- currentclass = document.getElementById(eid).classOrigName;
- var currentColor = document.getElementById(eid).style.backgroundColor;
- document.getElementById(eid).className='no_transition '+currentclass;
- document.getElementById(eid).style.backgroundColor = '#000000';
+
+ var currentclass = elementToFlash.className;
+ if (elementToFlash.classOrigName != undefined)
+ currentclass = elementToFlash.classOrigName;
+ var currentColor = elementToFlash.style.backgroundColor;
+ elementToFlash.className='no_transition '+currentclass;
+ elementToFlash.style.backgroundColor = '#000000';
for (var i=0; i<times; i++) {
//Flash bright
setTimeout("document.getElementById('"+eid+"').style.color = '#000000'", i*speed);
setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+color+"'", i*speed);
- // setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = 'bold'", i*200);
//Flash out
setTimeout("document.getElementById('"+eid+"').style.color = ''", (i*speed) + speedon);
setTimeout("document.getElementById('"+eid+"').style.backgroundColor = ''", (i*speed) + speedon);
- // setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = ''", i*200);
}
-
- //setTimeout("document.getElementById('"+eid+"').className = '"+currentclass+"'", (i*220) + 200);
setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+currentColor+"'", (i*speed) + 200);
-//document.getElementById(eid).className=currentclass;
-//document.getElementById(eid).style.backgroundColor=currentColor;
+ setTimeout("document.getElementById('"+eid+"').isBeingFlashed = false", (i*speed) + 220);
}
@@ -761,12 +759,14 @@ function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem) solution[mapid] = inputSolution;
var animateA = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", \""+tempWallColor+"\", \""+tempWallEmblem+"\");";
var animateB = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", false, false);";
+ //TODO: Sticky colors for the placed walls by the user would be cool.
+ //var animateC = "wallColor = false; wallEmblem = false;";
setTimeout(animateA, 50);
- setTimeout(animateB, 100);
- setTimeout(animateA, 150);
- setTimeout(animateB, 200);
+ setTimeout(animateB, 150);
setTimeout(animateA, 250);
- setTimeout(animateB, 450);
+ setTimeout(animateB, 350);
+ setTimeout(animateA, 450);
+ setTimeout(animateB, 550);
}
//Shows a solution for temporary use, see 'RestoreSolution'
function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmblem) {
@@ -802,30 +802,45 @@ function restoreSolution(mapid) { showTempSolution(mapid, mapdata[mapid].savedSolution, 0, false, false);
}
-function displayMap(mapid, divID, goalSize, solution, moves, challengeMap) {
+function displayMap(mapid, divID, goalSize, solution, moves, challengeMap, isThumb) {
- var stringURL = 'map/'+mapid+".js";
- if (challengeMap == true) stringURL = 'challenge/'+mapid+".js";
+ var stringURL = 'a/map/'+mapid+".js";
+ if (challengeMap == true) stringURL = 'a/challenge/'+mapid+".js";
$.ajax({
type: "GET",
- url: 'map/'+mapid+".js",
+ url: stringURL,
dataType: 'json',
cache: true,
data: '',
//TODO: Better fail option?
fail: (function() { console.log("FAIL Map Download"); }),
complete: function(data) {
- $("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).fadeIn('slow');
- mapdata[mapid].savedSolution = solution;
- restoreSolution(mapid);
+ if (isThumb) {
+ $("#"+divID).html(mapThumbnailHTML(decryptJSON(data.responseText), goalSize)).fadeIn('fast');
+ } else {
+ $("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).fadeIn('fast');
+ //$("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).show();
+ mapdata[mapid].savedSolution = solution;
+ restoreSolution(mapid);
+ }
}
});
}
+var Tile = {
+"o" : "Open",
+"s" : "Start",
+"f" : "Finish",
+"c" : "Checkpoint",
+"r" : "Rock",
+"t" : "Teleport In",
+"u" : "Teleport Out",
+"p" : "Unbuildable",
+"x" : "Single-Path-Rock"};
+
//Map as object. If target width is NULL or False, default width is used.
-function mapAsHTML(map, targetWidth, demo) {
-
- //console.log("loading MapHTML for ", map);
+function mapAsHTML(map, targetWidth, mapEditor) {
+
map.mapid = map.ID;
//console.log("MapID:", map.mapid);
//console.log("MapObj", map);
@@ -858,19 +873,24 @@ function mapAsHTML(map, targetWidth, demo) { // GOAL WOULD BE THIS LINE INSTEAD.. As it's not retarded.
//var idHandle = map.ID+','+x+','+y;
-
+
//oldy is used for Position too... for now
- if (type == 'o') {
+ if (mapEditor == true) {
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onMouseOver='mapEditOver(this)' onMouseDown='mapEditClick(this)' >";
+ mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
+ } else if (type == 'o') {
mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onClick='grid_click(this)' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
} else {
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' >";
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='"+Tile[type]+" "+value+" On: "+x+","+oldy+"' id='"+idHandle+"' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
}
}
}
mapgrid += '</div>';
+ if (mapEditor == true) return mapgrid;
+
var r = '';
//TODO: Track down where that 1 pixel is comingfrom, width-1 is a hack.
@@ -916,6 +936,39 @@ function mapAsHTML(map, targetWidth, demo) { return r;
}
+function mapThumbnailHTML(map, targetWidth, isActive) {
+ if (!targetWidth) targetWidth = 120;
+ var scale = map.width / targetWidth;
+
+ var width = parseInt(map.width / scale);
+ var height = parseInt(map.height / scale);
+ var tileWidth = parseInt(width / map.width);
+
+ width = tileWidth * map.width;
+ height = tileWidth * map.height;
+
+ var mapgrid = '';
+ var r = '';
+ r += map.name;
+
+ mapgrid += '<div class="map" style="width:'+width+'px; height:'+height+'px">';
+ for (var y in map.tiles) {
+ for (var x in map.tiles[y]) {
+ var type = map.tiles[y][x][0];
+ 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>";
+ }
+ }
+ mapgrid += '</div>';
+ r += mapgrid;
+ return r;
+}
+
+
+
var ignoreMuteChecks = false;
function setMute(value)
{
|