mudlet-map-browser-script 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.min.js +1 -1
- package/index.js +34 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Translator from "@andreasremdt/simple-translator";
|
|
2
2
|
import bootstrap from "bootstrap";
|
|
3
|
-
import {MapReader,
|
|
3
|
+
import {MapReader, Settings, Renderer} from "mudlet-map-renderer";
|
|
4
4
|
import {Preview} from "./preview";
|
|
5
5
|
import {downloadTags, downloadVersion} from "./versions";
|
|
6
6
|
import convert from "color-convert";
|
|
@@ -211,10 +211,19 @@ class PageControls {
|
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
this.paths = {};
|
|
214
|
+
|
|
215
|
+
this.renderer = new Renderer(this.map, this.reader, this.reader.getColors(), this.settings);
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
init() {
|
|
217
|
-
|
|
219
|
+
// Check if version parameter is present
|
|
220
|
+
if (params.version && this.versions) {
|
|
221
|
+
this.replaceVersion(params.version);
|
|
222
|
+
history.replaceState(null, null, url);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let area = this.reader.getAreas()[0].areaId;
|
|
218
227
|
let zIndex = 0;
|
|
219
228
|
if (params.loc) {
|
|
220
229
|
this.findRoom(params.loc);
|
|
@@ -282,7 +291,7 @@ class PageControls {
|
|
|
282
291
|
if (this.renderer) {
|
|
283
292
|
this.renderer.clear();
|
|
284
293
|
}
|
|
285
|
-
this.renderer
|
|
294
|
+
this.renderer.renderArea(area)
|
|
286
295
|
this.select.value = areaId;
|
|
287
296
|
this.populateLevelButtons(area.getLevels(), zIndex);
|
|
288
297
|
this.hideRoomInfo();
|
|
@@ -846,7 +855,28 @@ class PageControls {
|
|
|
846
855
|
downloadVersion(tag, this.versions.getAttribute("data-files")).then(data => {
|
|
847
856
|
this.reader = new MapReader(data, colors);
|
|
848
857
|
this.populateSelectBox();
|
|
849
|
-
|
|
858
|
+
|
|
859
|
+
// Determine which area to render
|
|
860
|
+
let area = this.reader.getAreas()[0].areaId;
|
|
861
|
+
let zIndex = 0;
|
|
862
|
+
|
|
863
|
+
if (params.loc) {
|
|
864
|
+
this.findRoom(params.loc);
|
|
865
|
+
} else if (params.area) {
|
|
866
|
+
area = params.area;
|
|
867
|
+
this.renderArea(area, zIndex);
|
|
868
|
+
} else if (this.areaId !== undefined) {
|
|
869
|
+
// If already initialized, use current area
|
|
870
|
+
this.renderArea(this.areaId, this.zIndex, true).then(() => this.showToast(`Przeładowano wersję na ${tag}`));
|
|
871
|
+
} else {
|
|
872
|
+
// First initialization
|
|
873
|
+
if (position !== null && position.area) {
|
|
874
|
+
area = position.area;
|
|
875
|
+
zIndex = position.zIndex;
|
|
876
|
+
}
|
|
877
|
+
this.renderArea(area, zIndex);
|
|
878
|
+
}
|
|
879
|
+
|
|
850
880
|
this.versionBadge.innerHTML = `v${tag}`;
|
|
851
881
|
this.versionBadge.style.display = "initial";
|
|
852
882
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mudlet-map-browser-script",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"prepublishOnly": "browserify index.js | uglifyjs -cm > dist/bundle.min.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@andreasremdt/simple-translator": "^2.0.4",
|