mudlet-map-renderer 0.0.12 → 0.0.15
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/CHANGELOG.md +7 -0
- package/README.md +2 -0
- package/map-fragment/draw/renderer.js +19 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -8,7 +8,9 @@ const gridSize = 20;
|
|
|
8
8
|
const Colors = {
|
|
9
9
|
OPEN_DOOR : new paper.Color(10 / 255, 155 / 255, 10 / 255),
|
|
10
10
|
CLOSED_DOOR : new paper.Color(226 / 255, 205 / 255, 59 / 255),
|
|
11
|
-
LOCKED_DOOR : new paper.Color(155 / 255, 10 / 255, 10 / 255)
|
|
11
|
+
LOCKED_DOOR : new paper.Color(155 / 255, 10 / 255, 10 / 255),
|
|
12
|
+
DEFAULT_BACKGROUND : new paper.Color(0, 0, 0),
|
|
13
|
+
DEFAULT : new paper.Color(1, 1, 1),
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
class Settings {
|
|
@@ -23,7 +25,8 @@ class Settings {
|
|
|
23
25
|
this.showLabels = true;
|
|
24
26
|
this.uniformLevelSize = false;
|
|
25
27
|
this.fontFamily = 'sans-serif';
|
|
26
|
-
this.mapBackground =
|
|
28
|
+
this.mapBackground = Colors.DEFAULT_BACKGROUND
|
|
29
|
+
this.linesColor = Colors.DEFAULT
|
|
27
30
|
this.transparentLabels = false;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
@@ -159,7 +162,7 @@ class Renderer {
|
|
|
159
162
|
let roomColor = new paper.Color(color[0] / 255, color[1] / 255, color[2] / 255, 1);
|
|
160
163
|
roomShape.fillColor = !this.settings.frameMode ? roomColor : new paper.Color(this.settings.mapBackground);
|
|
161
164
|
roomShape.strokeWidth = this.exitFactor;
|
|
162
|
-
roomShape.strokeColor = !this.settings.borders || this.settings.frameMode ? roomColor : this.
|
|
165
|
+
roomShape.strokeColor = !this.settings.borders || this.settings.frameMode ? roomColor : this.settings.linesColor;
|
|
163
166
|
|
|
164
167
|
room.render = roomShape;
|
|
165
168
|
|
|
@@ -181,7 +184,7 @@ class Renderer {
|
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
for (let dir in room.customLines) {
|
|
184
|
-
this.renderCustomLine(room, dir);
|
|
187
|
+
this.renderCustomLine(room, dir, room.exits[dir] ?? room.specialExits[dir]);
|
|
185
188
|
}
|
|
186
189
|
|
|
187
190
|
for (let dir in room.stubs) {
|
|
@@ -214,9 +217,9 @@ class Renderer {
|
|
|
214
217
|
path.moveTo(exitPoint);
|
|
215
218
|
path.lineTo(secondPoint);
|
|
216
219
|
path.strokeWidth = this.exitFactor;
|
|
217
|
-
path.strokeColor = this.
|
|
220
|
+
path.strokeColor = this.settings.linesColor;
|
|
218
221
|
} else {
|
|
219
|
-
this.renderArrow(exitPoint, secondPoint, this.
|
|
222
|
+
this.renderArrow(exitPoint, secondPoint, this.settings.linesColor, [], this.exitFactor, this.settings.linesColor, true);
|
|
220
223
|
}
|
|
221
224
|
} else {
|
|
222
225
|
secondPoint = new paper.Point(room.x + this.roomFactor / 2, room.y + this.roomFactor / 2);
|
|
@@ -264,9 +267,10 @@ class Renderer {
|
|
|
264
267
|
} else {
|
|
265
268
|
secondPoint = new paper.Point(room.x + this.roomFactor / 2, room.y + this.roomFactor / 2);
|
|
266
269
|
path = this.renderArrow(exitPoint, secondPoint, this.defualtColor, [], this.exitFactor);
|
|
267
|
-
path.strokeColor = this.
|
|
270
|
+
path.strokeColor = this.settings.linesColor;
|
|
268
271
|
path.scale(1, exitPoint);
|
|
269
272
|
path.rotate(180, exitPoint);
|
|
273
|
+
path.registerClick(() => this.emitter.dispatchEvent(new CustomEvent("areaArrowClick", { detail: targetId })));
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
room.exitsRenders.push(path);
|
|
@@ -278,7 +282,7 @@ class Renderer {
|
|
|
278
282
|
return path;
|
|
279
283
|
}
|
|
280
284
|
|
|
281
|
-
renderCustomLine(room, dir) {
|
|
285
|
+
renderCustomLine(room, dir, targetId) {
|
|
282
286
|
if (room.customLines[dir].points !== undefined && room.customLines[dir].points.length === 0) {
|
|
283
287
|
return;
|
|
284
288
|
}
|
|
@@ -337,6 +341,12 @@ class Renderer {
|
|
|
337
341
|
path.strokeWidth = this.exitFactor;
|
|
338
342
|
path.orgStrokeColor = path.strokeColor;
|
|
339
343
|
|
|
344
|
+
let targetRoom = this.area.getRoomById(targetId);
|
|
345
|
+
if (!targetRoom) {
|
|
346
|
+
customLine.registerClick(() => this.emitter.dispatchEvent(new CustomEvent("areaArrowClick", { detail: targetId })));
|
|
347
|
+
customLine.pointerReactor(this.element);
|
|
348
|
+
}
|
|
349
|
+
|
|
340
350
|
room.exitsRenders.push(customLine);
|
|
341
351
|
|
|
342
352
|
return customLine;
|
|
@@ -385,7 +395,7 @@ class Renderer {
|
|
|
385
395
|
path.scale(2);
|
|
386
396
|
path.position = exitPoint;
|
|
387
397
|
path.strokeWidth = this.exitFactor;
|
|
388
|
-
path.strokeColor = this.
|
|
398
|
+
path.strokeColor = this.settings.linesColor;
|
|
389
399
|
}
|
|
390
400
|
return path;
|
|
391
401
|
}
|