Making path of resources relative

This commit is contained in:
Mal 2021-09-14 20:11:01 +02:00
parent 43f2290758
commit e75db5affd
3 changed files with 9 additions and 9 deletions

View File

@ -7,7 +7,7 @@ export default class Tileset
{ {
this.setId = setId; this.setId = setId;
this.image = new Image(); this.image = new Image();
this.image.src = Setting.TILESET_LOCATION + GraphicSet[this.setId].tileset; this.image.src = '../' + Setting.TILESET_LOCATION + GraphicSet[this.setId].tileset;
this.tiles = GraphicSet[this.setId].tiles; this.tiles = GraphicSet[this.setId].tiles;
this.scale = GraphicSet[this.setId].scale; this.scale = GraphicSet[this.setId].scale;
} }
@ -31,4 +31,4 @@ export default class Tileset
{ {
return this.image.height * this.scale; return this.image.height * this.scale;
} }
} }

View File

@ -77,7 +77,7 @@ export default class Dialog
let htmlAvatarElement = document.createElement('div'); let htmlAvatarElement = document.createElement('div');
htmlAvatarElement.id = 'tileset-avatar'; htmlAvatarElement.id = 'tileset-avatar';
htmlAvatarElement.style.backgroundImage = 'url("' + Setting.TILESET_LOCATION + GraphicSet[0].tileset + '")'; htmlAvatarElement.style.backgroundImage = 'url("../' + Setting.TILESET_LOCATION + GraphicSet[0].tileset + '")';
let htmlListElement = document.createElement('div'); let htmlListElement = document.createElement('div');
htmlListElement.id = 'tileset-list'; htmlListElement.id = 'tileset-list';
@ -100,7 +100,7 @@ export default class Dialog
let htmlThumbnail = document.createElement('div'); let htmlThumbnail = document.createElement('div');
htmlThumbnail.classList.add('tileset-thumbnail'); htmlThumbnail.classList.add('tileset-thumbnail');
htmlThumbnail.style.backgroundImage = 'url("' + Setting.TILESET_LOCATION + graphicSet.tileset + '")'; htmlThumbnail.style.backgroundImage = 'url("../' + Setting.TILESET_LOCATION + graphicSet.tileset + '")';
htmlTilesetElement.appendChild(htmlThumbnail); htmlTilesetElement.appendChild(htmlThumbnail);
let htmlTitleElement = document.createElement('div'); let htmlTitleElement = document.createElement('div');
@ -112,7 +112,7 @@ export default class Dialog
'click', 'click',
() => { () => {
htmlListElement.style.display = 'none'; htmlListElement.style.display = 'none';
htmlAvatarElement.style.backgroundImage = 'url("' + Setting.TILESET_LOCATION + GraphicSet[index].tileset + '")'; htmlAvatarElement.style.backgroundImage = 'url("../' + Setting.TILESET_LOCATION + GraphicSet[index].tileset + '")';
window.dispatchEvent(new TilorswiftTilesetSelectedEvent(index)); window.dispatchEvent(new TilorswiftTilesetSelectedEvent(index));
} }
); );
@ -130,4 +130,4 @@ export default class Dialog
{ {
this.messageElement.innerText = message; this.messageElement.innerText = message;
} }
} }

View File

@ -29,11 +29,11 @@ import DialogGravity from "./dialog/DialogGravity.js";
let level = Level.createFromFile('../levels/moonbase.json'); let level = Level.createFromFile('../levels/moonbase.json');
if (GraphicSet[level.terrain.tileset.setId].backgroundImage !== null) { if (GraphicSet[level.terrain.tileset.setId].backgroundImage !== null) {
document.body.style.backgroundImage = 'url("' + Setting.GRAPHICS_LOCATION + GraphicSet[level.getTilesetId()].backgroundImage + '")'; document.body.style.backgroundImage = 'url("../' + Setting.GRAPHICS_LOCATION + GraphicSet[level.getTilesetId()].backgroundImage + '")';
} }
let image = new Image(); let image = new Image();
image.src = Setting.TILESET_LOCATION + GraphicSet[level.terrain.tileset.setId].tileset; image.src = '../' + Setting.TILESET_LOCATION + GraphicSet[level.terrain.tileset.setId].tileset;
image.onload = function () { image.onload = function () {
document.body.style.backgroundColor = GraphicSet[level.terrain.tileset.setId].backgroundColor; document.body.style.backgroundColor = GraphicSet[level.terrain.tileset.setId].backgroundColor;
@ -179,7 +179,7 @@ image.onload = function () {
level.terrain = new Terrain(tileset, event.tilesX, event.tilesY, GraphicSet[event.tilesetIndex].backgroundColor); level.terrain = new Terrain(tileset, event.tilesX, event.tilesY, GraphicSet[event.tilesetIndex].backgroundColor);
document.body.style.backgroundColor = level.getBackgroundColor(); document.body.style.backgroundColor = level.getBackgroundColor();
if (GraphicSet[event.tilesetIndex].backgroundImage !== null) { if (GraphicSet[event.tilesetIndex].backgroundImage !== null) {
document.body.style.backgroundImage = 'url("' + Setting.GRAPHICS_LOCATION + GraphicSet[event.tilesetIndex].backgroundImage + '")'; document.body.style.backgroundImage = 'url("../' + Setting.GRAPHICS_LOCATION + GraphicSet[event.tilesetIndex].backgroundImage + '")';
} else { } else {
document.body.style.backgroundImage = 'none'; document.body.style.backgroundImage = 'none';
} }