From 3941fee8faa827b45fac01086745b040ce4f4448 Mon Sep 17 00:00:00 2001 From: The Grand Dog Date: Wed, 3 Jun 2020 20:18:29 -0400 Subject: [PATCH] fixed map i think --- Automap/MapSRC/build.js | 8 +- Automap/MapSRC/src/Automap.css | 2 +- Automap/MapSRC/src/ViewFrame.js | 2 +- Automap/assets/automap/config/automap.html | 435 ++++++++++++++++++++--------- 4 files changed, 314 insertions(+), 133 deletions(-) diff --git a/Automap/MapSRC/build.js b/Automap/MapSRC/build.js index c5e0fb2..7b2be77 100755 --- a/Automap/MapSRC/build.js +++ b/Automap/MapSRC/build.js @@ -8,15 +8,15 @@ fs.readFile(__dirname + '/src/Automap.html', 'utf8', (err, d) => { if (err) console.log(err); let outD = d.replace(//g, (match, name, offset, string) => { return ''; }) .replace(/'; - }) - .replace(/[\t\n]/g, ''); + }); + // .replace(/[\t\n]/g, ''); fs.writeFile(__dirname + '/../assets/automap/config/automap.html', outD, err => { if (err) console.log(err); }); diff --git a/Automap/MapSRC/src/Automap.css b/Automap/MapSRC/src/Automap.css index 44e30e5..a1e1743 100644 --- a/Automap/MapSRC/src/Automap.css +++ b/Automap/MapSRC/src/Automap.css @@ -3,7 +3,7 @@ html, body, .map { height: 100%; margin: 0; overflow: hidden; - outline: 1px dotted black; + /* outline: 1px dotted black; */ } .infobox { diff --git a/Automap/MapSRC/src/ViewFrame.js b/Automap/MapSRC/src/ViewFrame.js index 663a50f..c0b6e30 100644 --- a/Automap/MapSRC/src/ViewFrame.js +++ b/Automap/MapSRC/src/ViewFrame.js @@ -107,7 +107,7 @@ ViewFrame.prototype.render = function () { const img = new Image(32, 32); const name = round.value.join('_'); - img.src = name + '.png'; + img.src = 'Chunks/'+ name + '.png'; decode(img, loadedImage => { this.place(img, round.value[0], round.value[1]); diff --git a/Automap/assets/automap/config/automap.html b/Automap/assets/automap/config/automap.html index ad5ec0b..e1f5a7a 100644 --- a/Automap/assets/automap/config/automap.html +++ b/Automap/assets/automap/config/automap.html @@ -4,140 +4,321 @@ Automap - + -
-

Chunk Info

-
-
- + +}; + +ViewFrame.prototype.updateEdges = function () { + if (this.width != window.innerWidth || this.height != window.innerHeight) { + this.width = window.innerWidth; + this.map.canvas.width = this.width; + this.height = window.innerHeight; + this.map.canvas.height = this.height; + this.map.imageSmoothingEnabled = false; + } + const chunksWide = Math.ceil(this.width / this.zoom); + const chunksHigh = Math.ceil(this.height / this.zoom); + + this.east = this.x + chunksWide / 2; // this is fractional and is used to keep track of the edges of the window + this.eastChunk = Math.ceil(this.east); // this is not and is used to track the chunks that need to load + this.west = this.x - chunksWide / 2; + this.westChunk = Math.floor(this.west); + this.north = this.y + chunksHigh / 2; + this.northChunk = Math.ceil(this.north); + this.south = this.y - chunksHigh / 2; + this.southChunk = Math.floor(this.south); +}; + +ViewFrame.prototype.moveCenter = function (dx, dy) { + // to pan when we click on the map! + this.x += (dx - this.width / 2) / this.zoom; + this.y += (dy - this.height / 2) / this.zoom; +}; +ViewFrame.prototype.setCenter = function (x, y) { + this.x = x; + this.y = y; +}; + +ViewFrame.prototype.clear = function () { + this.loadedChunksByName.clear(); + this.loadedChunksByCoords.clear(); + if (this.chunkScript) this.chunkScript.remove(); + delete this.chunkScript; + delete ViewFrame.chunks; + this.map.clearRect(0, 0, window.innerWidth, window.innerHeight); +}; + +function decode(img, cb) { + img.decode() + .then(() => { + cb(img); + }) + .catch(() => {}); // so images arent added on error +} +
+

Chunk Info

+ +
+
+ + \ No newline at end of file -- 2.11.0