- const t = new Set;
- for (var e = this.westChunk; e < this.eastChunk; e++)
- for (var s = this.southChunk; s < this.northChunk; s++) {
- const i = [e, s],
- n = i.join("_");
- this.availableChunks.has(n) && !this.loadedChunksByName.has(n) && t.add(i)
- }
- const i = t.values();
- let n = setInterval(() => {
- let t = i.next();
- if (t.done) clearInterval(n), this.rendering = !1;
- else {
- const e = new Image(32, 32),
- s = t.value.join("_");
- e.src = s + ".png", e.alt = s, decode(e, e => {
- let [s, i] = this.chunkToScreen(t.value[0], t.value[1]);
- e.style.left = s + "px", e.style.top = i + "px";
- const n = this.zoom / 32;
- 1 != n && (chunk.style.transform = `scale(${n})`), this.map.append(e)
- }), this.loadedChunksByName.set(s, e), this.loadedChunksByCoords.set(t.value, e)
- }
- }, 4)
- }, ViewFrame.prototype.updateInfobox = function(t) {
- const e = this.availableChunks.get(t);
- this.infoboxSlots.forEach((t, s) => {
- t.innerText = e[s]
- })
- }, ViewFrame.initInfobox = function(t, e) {
- ["prettyCoord:Loc.", "chunkAge:Age", "temp:Temp.", "YMax:Y Max", "fert:Fert.", "forestDens:Forest", "rain:Rain", "shrubDens:Shrub", "airBlocks:Air", "nonAirBlocks:Non-Air"].map(t => t.split(":")).forEach(s => {
- const i = s[0],
- n = s[1],
- h = document.createElement("tr"),
- o = document.createElement("th");
- o.innerText = n;
- const r = document.createElement("td");
- r.innerText = "0", e.set(i, r), h.append(o, r), t.append(h)
- })
- }, ViewFrame.prototype.screenToChunk = function(t, e) {
- return [(t - this.width / 2) / this.zoom, (e - this.height / 2) / this.zoom]
- }, ViewFrame.prototype.chunkToScreen = function(t, e) {
- return [(t - this.west) * this.zoom, (e - this.south) * this.zoom]
- }, ViewFrame.prototype.updateEdges = function() {
- if (!this.dirty) return;
- const t = Math.ceil(this.width / this.zoom),
- e = Math.ceil(this.height / this.zoom);
- this.east = this.x + t / 2, this.eastChunk = Math.ceil(this.east), this.west = this.x - t / 2, this.westChunk = Math.floor(this.west), this.north = this.y + e / 2, this.northChunk = Math.ceil(this.north), this.south = this.y - e / 2, this.southChunk =
- Math.floor(this.south), this.dirty = !1
- }, ViewFrame.prototype.moveCenter = function(t, e) {
- let [s, i] = this.screenToChunk(t, e);
- this.x += s, this.y += i, this.dirty = !0
- }, ViewFrame.prototype.clear = function() {
- this.loadedChunksByName.clear(), this.loadedChunksByCoords.clear(), this.chunkScript && this.chunkScript.remove(), delete this.chunkScript, delete ViewFrame.chunks, this.map.innerHTML = ""
- }, Object.defineProperties(ViewFrame.prototype, {
- width: {
- get() {
- return this.map.clientWidth
- }
- },
- height: {
- get() {
- return this.map.clientHeight
- }
- },
- zoom: {
- get() {
- return this._zoom
- },
- set(t) {
- this._zoom = t, this.dirty = !0
- }
- }
+ this.loadedChunksByName.set(name, img);
+ this.loadedChunksByCoords.set(round.value, img);
+ } else {
+ clearInterval(ViewFrame.intervalRef);
+ this.rendering = false;
+ }
+ }, 4);
+};
+
+ViewFrame.prototype.place = function (img, x, y) {
+ x -= this.x;
+ y -= this.y;
+ x *= this.zoom;
+ y *= this.zoom;
+ x += this.width / 2;
+ y += this.height / 2;
+
+ this.map.drawImage(img, Math.floor(x), Math.floor(y), this.zoom, this.zoom);
+};
+
+ViewFrame.prototype.updateInfobox = function (chunkName) {
+ const chunkMeta = this.availableChunks.get(chunkName);
+ this.infoboxSlots.forEach((l, k) => {
+ l.innerText = chunkMeta ? chunkMeta[k] : '0';
+ });
+};</script></script>
+ <script type="text/javascript">ViewFrame.initInfobox = function (ibox, iboxSlots) {
+ // TODO: make faster
+ ViewFrame.chunks
+ .chunkMetadataNames.forEach((item, i) => {
+ const slot = document.createElement('tr');
+ const head = document.createElement('th');
+ head.innerText = item;
+ const row = document.createElement('td');
+ row.innerText = '0';
+ iboxSlots[i] = row;
+ slot.append(head, row);
+ ibox.append(slot);