From fff387ad8f7d470d6bef696629a0dfa110467705 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sun, 24 Mar 2013 11:33:41 -0700 Subject: Finished wallOrientation setting --- js/mapspecs.js | 46 +++++++++++++++++++--------------------------- js/scores.js | 4 ++-- 2 files changed, 21 insertions(+), 29 deletions(-) (limited to 'js') diff --git a/js/mapspecs.js b/js/mapspecs.js index cf2450a..d8b4ed3 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -91,6 +91,16 @@ function linkEmblem(emblem, orientation) { if (orientation == 0) return url+emblem; return url+'rotate.php?r='+orientation+'&emblem='+emblem; } +function setWallStyle(playerObject) { + + if (typeof playerObject !== 'object') return; + + wallColor = playerObject.wallColor; + wallEmblem = playerObject.wallEmblem; + wallOrientation = playerObject.wallOrientation; +} + + function grid_click(obj) { @@ -136,30 +146,10 @@ function grid_click(obj) { //childdiv.removeAttribute("class"); childdiv.setAttribute("class", "child w"); - if (wallColor == false) { - if (typeof playerWallColor === 'undefined' || playerWallColor == '') { - wallColor = '#666666'; - playerWallColor = '#666666'; - } else { - wallColor = playerWallColor; - } - } - if (wallEmblem == false) { - if (typeof playerWallEmblem !== 'undefined' && playerWallEmblem !== '') { - wallEmblem = playerWallEmblem; - } - } - //TODO: Copy below - above w/ userObj - if (wallOrientation == false) { - if (typeof userObj !== 'undefined' && userObj.wallOrientation !== '') { - wallOrientation = userObj.wallOrientation; - } - } + if (wallColor == false) setWallStyle(userObj); obj.style.backgroundColor = wallColor; - if (wallEmblem !== false) { - //obj.style.backgroundImage="url(images/marks/"+wallEmblem+")"; - //obj.style.backgroundImage="url(images/marks/rotate.php?r=1&emblem="+wallEmblem+")"; + if (wallEmblem) { obj.style.backgroundImage="url("+linkEmblem(wallEmblem, wallOrientation)+")"; } @@ -774,14 +764,14 @@ function contains(a, obj) { //Shows a solution temporarly -function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem, solutionID) { +function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem, tempWallOrientation, solutionID) { $('.solutionSelected').removeClass('solutionSelected'); $('#solution_'+solutionID).addClass('solutionSelected'); solution[mapid] = inputSolution; - var animateA = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", \""+tempWallColor+"\", \""+tempWallEmblem+"\");"; - var animateB = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", false, false);"; + var animateA = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", \""+tempWallColor+"\", \""+tempWallEmblem+"\", \""+tempWallOrientation+"\");"; + var animateB = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", false, false, false);"; //TODO: Sticky colors for the placed walls by the user would be cool. //var animateC = "wallColor = false; wallEmblem = false;"; setTimeout(animateA, 50); @@ -792,7 +782,7 @@ function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem, setTimeout(animateB, 550); } //Shows a solution for temporary use, see 'RestoreSolution' -function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmblem) { +function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmblem, tempWallOrientation) { //console.log('showTempSolution', mapid, solution, moves, tempWallColor, tempWallEmblem); var savedSolution = ''; @@ -801,8 +791,10 @@ function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmb if (typeof solution[mapid] !== 'undefined') { savedSolution = solution[mapid]; } - wallEmblem = tempWallEmblem; + wallColor = tempWallColor; + wallEmblem = tempWallEmblem; + wallOrientation = tempWallOrientation; position = tempSolution.split('.'); diff --git a/js/scores.js b/js/scores.js index 3e01ca8..9bbfedf 100644 --- a/js/scores.js +++ b/js/scores.js @@ -170,8 +170,8 @@ function scoresFormatPage(JO) { if (solutionsGiven) { rowclass += ' scoreRowSolutionAvailable'; p += ""; } else { -- cgit v1.2.3