From 677b7454a37a0152f50d40993460d8f5a071e181 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 5 Mar 2013 14:17:08 -0800 Subject: Map editor 0.1! --- js/mapspecs.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/mapspecs.js b/js/mapspecs.js index 2387a00..443ddfe 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -92,6 +92,12 @@ function grid_click(obj) { y = tmp[1]; x = tmp[2]; + + if(mapdata[mapid].editMap == true) { + mapClick(obj); + return; + } + //The users solution - prepare it if it's not started if (solution[mapid] == undefined) { getmapdata(mapid); @@ -838,7 +844,7 @@ var Tile = { "x" : "Single-Path-Rock"}; //Map as object. If target width is NULL or False, default width is used. -function mapAsHTML(map, targetWidth, demo) { +function mapAsHTML(map, targetWidth, mapEditor) { map.mapid = map.ID; //console.log("MapID:", map.mapid); @@ -872,9 +878,9 @@ 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 (type == 'o' || mapEditor == true) { mapgrid += "
"; mapgrid += "
"; } else { @@ -885,6 +891,8 @@ function mapAsHTML(map, targetWidth, demo) { } mapgrid += ''; + if (mapEditor == true) return mapgrid; + var r = ''; //TODO: Track down where that 1 pixel is comingfrom, width-1 is a hack. -- cgit v1.2.3 From ab36b3bfff1b0c4d6e6398b1e968e41f436373b3 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 6 Mar 2013 01:47:20 -0800 Subject: mapeditor Go button fix. --- includes/mapclass.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ js/mapspecs.js | 2 +- pages/mapeditor.php | 3 ++- 3 files changed, 71 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/includes/mapclass.php b/includes/mapclass.php index bc5a6e5..24b9108 100644 --- a/includes/mapclass.php +++ b/includes/mapclass.php @@ -253,6 +253,74 @@ class map { return $code; } + function getOldCode() { + + $code = ""; //The string to return to the database. + $index = 0; //The current number of tiles from the last tile saved. + + $code = $this->width.'x'.$this->height; + $code .= '.c'.$this->checkpoints; + $code .= '.r0'; //rocks... yeah. + $code .= '.w'.$this->walls; + $code .= '.t'.$this->teleports; + $code .= '.'.$this->name; + $code .= ".:"; + + $oldNames['o'] = 'o'; + + $oldNames['s'] = 's'; + $oldNames['s2'] = 'S'; + $oldNames['f'] = 'f'; + + $oldNames['c'] = 'a'; + $oldNames['c2'] = 'b'; + $oldNames['c3'] = 'c'; + $oldNames['c4'] = 'd'; + $oldNames['c5'] = 'e'; + + $oldNames['t'] = 't'; + $oldNames['t2'] = 'm'; + $oldNames['t3'] = 'g'; + $oldNames['t4'] = 'i'; + $oldNames['t5'] = 'k'; + + $oldNames['u'] = 'u'; + $oldNames['u2'] = 'n'; + $oldNames['u3'] = 'h'; + $oldNames['u4'] = 'j'; + $oldNames['u5'] = 'l'; + + $oldNames['x'] = 'x'; + $oldNames['x2'] = 'X'; + + $oldNames['r'] = 'r'; + $oldNames['r2'] = 'R'; + + for( $i = 0; $i < $this->height; $i++) { + for( $j = 0; $j < $this->width; $j++) { + if($this->tiles[$i][$j][0] != 'o') { + //As long as the tile is NOT open, embed it in the code. + + + $type = $this->tiles[$i][$j][0]; + $value = $this->tiles[$i][$j][1]; + if ($value <= 1) $value = ''; + + $code .= $index.$oldNames[$type.$value].'.'; + + + //$code .= $index.$mapMatrix[$i][$j].'.'; + //Start from 0 again. + $index = -1; + } + $index += 1; + } + } + + return $code; + + } + //Other "Magical" functions. public function __toString() { return $this->name; diff --git a/js/mapspecs.js b/js/mapspecs.js index 443ddfe..ecc5c9d 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -93,7 +93,7 @@ function grid_click(obj) { x = tmp[2]; - if(mapdata[mapid].editMap == true) { + if(typeof(mapdata[mapid]) == 'Object' && mapdata[mapid].editMap == true) { mapClick(obj); return; } diff --git a/pages/mapeditor.php b/pages/mapeditor.php index 402f2d6..87fef32 100644 --- a/pages/mapeditor.php +++ b/pages/mapeditor.php @@ -17,7 +17,8 @@ if ($_REQUEST['mapByMap']) { $map->$key = $value; } //Store the code in the object - $map->getCode(); + $code = $map->getOldCode(); + $map->code = $code; echo json_encode($map); exit; } -- cgit v1.2.3