Skip to content

Commit

Permalink
Found a solution to the routing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Feb 2, 2022
1 parent bea638a commit 3750969
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
11 changes: 11 additions & 0 deletions rootpath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let folder = __dirname;

const getRootPath = () => {
return folder;
};

const setRootPath = (newFolder) => {
folder = newFolder;
};

module.exports = { getRootPath, setRootPath };
6 changes: 3 additions & 3 deletions src/assets/ambiences.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { compose, clone, filter, propEq, reduce, uniq } = require("ramda");
const { getAssetsFolder } = require("../constants");
const { getRootPath } = require("../../rootpath");

const ambiences = {
none: {
Expand Down Expand Up @@ -28,13 +28,13 @@ const exportAmbiences = (outputDir) => {
reduce((files, ambience) => {
const filename = `${outputDir}/sfx/ambiance/${ambience.name}.amb`;

files[filename] = `${getAssetsFolder()}/sfx/ambiance/${
files[filename] = `${getRootPath()}/assets/sfx/ambiance/${
ambience.name
}.amb`;

const tracks = ambience.tracks || [];
tracks.forEach((track) => {
files[`${outputDir}/${track}`] = `${getAssetsFolder()}/${track}`;
files[`${outputDir}/${track}`] = `${getRootPath()}/assets/${track}`;
});

return files;
Expand Down
8 changes: 4 additions & 4 deletions src/assets/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const {
isEmpty,
reject,
pluck,
isNil,
uniq,
} = require("ramda");
const { padCharsStart, isFunction, isObject } = require("ramda-adjunct");
const { PLAYER_HEIGHT_ADJUSTMENT, getAssetsFolder } = require("../constants");
const { getRootPath } = require("../../rootpath");
const { PLAYER_HEIGHT_ADJUSTMENT } = require("../constants");

const items = {
marker: {
Expand Down Expand Up @@ -316,11 +316,11 @@ const exportDependencies = (outputDir) => {
const { dir: dir2, name: name2, ext: ext2 } = path.parse(source);
files[
`${outputDir}/${dir1}/${name1}${ext1}`
] = `${getAssetsFolder()}/${dir2}/${name2}${ext2}`;
] = `${getRootPath()}/assets/${dir2}/${name2}${ext2}`;
} else {
const { dir, name, ext } = path.parse(filename);
const target = `${outputDir}/${dir}/${name}${ext}`;
files[target] = `${getAssetsFolder()}/${dir}/${name}${ext}`;
files[target] = `${getRootPath()}/assets/${dir}/${name}${ext}`;
}

return files;
Expand Down
4 changes: 2 additions & 2 deletions src/assets/textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
reduce,
uniq,
} = require("ramda");
const { getAssetsFolder } = require("../constants");
const { getRootPath } = require("../../rootpath");

const textures = {
none: null,
Expand Down Expand Up @@ -137,7 +137,7 @@ const exportTextures = (outputDir) => {
return compose(
reduce((files, texture) => {
const filename = `${outputDir}/graph/obj3d/textures/${texture.src}`;
files[filename] = `${getAssetsFolder()}/graph/obj3d/textures/${
files[filename] = `${getRootPath()}/assets/graph/obj3d/textures/${
texture.src
}`;
return files;
Expand Down
11 changes: 0 additions & 11 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ const PLAYER_HEIGHT_ADJUSTMENT = -140;
const ISLAND_JOINT_LENGTH = 5;
const ISLAND_JOINT_WIDTH = 3;

let assetsFolder = path.resolve("./assets");

const getAssetsFolder = () => assetsFolder;

const setAssetsFolder = (folder) => {
assetsFolder = folder;
};

module.exports = {
POLY_NO_SHADOW,
POLY_DOUBLESIDED,
Expand Down Expand Up @@ -138,7 +130,4 @@ module.exports = {

ISLAND_JOINT_LENGTH,
ISLAND_JOINT_WIDTH,

getAssetsFolder,
setAssetsFolder,
};
3 changes: 0 additions & 3 deletions src/electron/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { app, BrowserWindow, dialog, ipcMain } = require("electron");
const path = require("path");
const { setAssetsFolder, getAssetsFolder } = require("../constants");

let win;

Expand All @@ -22,8 +21,6 @@ const createWindow = () => {
};

app.whenReady().then(() => {
setAssetsFolder(path.resolve(app.getAppPath(), "../../assets"));

createWindow();

app.on("activate", () => {
Expand Down
4 changes: 4 additions & 0 deletions src/electron/src/app.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import path from "path";
import React from "react";
import ReactDOM from "react-dom";
import { setRootPath } from "../../../rootpath.js";
import App from "./components/App.jsx";

setRootPath(path.resolve(__dirname, "../../../"));

window.addEventListener("DOMContentLoaded", () => {
ReactDOM.render(<App />, document.getElementById("app"));
});

0 comments on commit 3750969

Please sign in to comment.