diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-03-07 02:35:37 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-03-07 02:35:37 -0800 |
commit | 7d1ea2721d51aad05ffc1a01b510d86e9864f92a (patch) | |
tree | 819687bb6bd5498a32c6b983eeef33a7f986635b | |
parent | ee270d30697914e322dd1256e2e3e0b60df0ced5 (diff) | |
download | pathery-7d1ea2721d51aad05ffc1a01b510d86e9864f92a.tar.xz |
Click and drag for the mapeditor.
-rw-r--r-- | js/mapspecs.js | 6 | ||||
-rw-r--r-- | pages/mapeditor.php | 42 |
2 files changed, 36 insertions, 12 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js index ecc5c9d..5cc482e 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -92,12 +92,6 @@ function grid_click(obj) { y = tmp[1];
x = tmp[2];
-
- if(typeof(mapdata[mapid]) == 'Object' && mapdata[mapid].editMap == true) {
- mapClick(obj);
- return;
- }
-
//The users solution - prepare it if it's not started
if (solution[mapid] == undefined) {
getmapdata(mapid);
diff --git a/pages/mapeditor.php b/pages/mapeditor.php index 87fef32..0d6cf94 100644 --- a/pages/mapeditor.php +++ b/pages/mapeditor.php @@ -51,13 +51,28 @@ testMap.name = 'Testmap'; testMap.walls = 5; setTimeout("reloadMap();", 500); +setTimeout("start();", 500); function start() { - $('#testMapDisplay').html(mapAsHTML(testMap)); + //$('#testMapDisplay').html(mapAsHTML(testMap)); + + $(window).mousedown(function(){ + mouseIsDown = true; + + }); + + $(window).mouseup(function(){ + mouseIsDown = false; + }); + } +var mouseIsDown = false; -var grid_clickOverride = true; -function mapClick(obj) { +var mapHasChanged = false; +function mapEditOver(obj) { + if (mouseIsDown == true) mapEditClick(obj); +} +function mapEditClick(obj) { console.log("Map Click"); tmp = obj.id.split(','); @@ -69,9 +84,19 @@ function mapClick(obj) { testMap.tiles[y][x] = Array(palleteType, palleteValue); y++; $(obj).attr('class', 'mapcell '+palleteType+palleteValue); - loadPlayableMap(); + mapHasChanged = true; +} + +getMapTimer(); +function getMapTimer() { + setTimeout("getMapTimer()", 3000); + if (mapHasChanged) { + loadPlayableMap(); + mapHasChanged = false; + } } + var palleteType = 's'; var palleteValue = ''; function paletteSelect(type, value) { @@ -120,8 +145,12 @@ function reloadMap() { loadPlayableMap(); } +var isLoadingMap = false; function loadPlayableMap() { + if (isLoadingMap == true) return; + isLoadingMap = true; + var URLString = 'mapeditor?mapByMap='+JSON.stringify(testMap); $.ajax({ type: "GET", @@ -135,6 +164,7 @@ function loadPlayableMap() { playableMap.ID = -1; $('#playableMapDisplay').html(mapAsHTML(playableMap, 960)); $('#playableMapCodeDisplay').val(playableMap.code); + isLoadingMap = false; } }); } @@ -268,10 +298,10 @@ function constructTiles(width, height, baseMap) { </div></form> <div style='clear:both;'></div> - <div class="divide"></div> + <div class="divide"><strong>Playable Map</strong></div> <div style='clear:both;'></div> <div class='wrapper'> - <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/> + MapCode: <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/> </div> <div id='playableMapDisplay' style='float:left;'> Returned map goes here. |