From 7d1ea2721d51aad05ffc1a01b510d86e9864f92a Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Thu, 7 Mar 2013 02:35:37 -0800 Subject: Click and drag for the mapeditor. --- js/mapspecs.js | 6 ------ 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) {
-
+
Playable Map
- + MapCode:
Returned map goes here. -- cgit v1.2.3