Skip to content

Commit

Permalink
Another try with assets folder generating
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Feb 1, 2022
1 parent 1c693a4 commit 2349af4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/assets/ambiences.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { compose, clone, filter, propEq, reduce, uniq } = require("ramda");
const path = require("path");
const { ASSETS_FOLDER } = require("../constants");
const { getAssetsFolder } = require("../constants");

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

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

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

return files;
Expand Down
6 changes: 3 additions & 3 deletions src/assets/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {
uniq,
} = require("ramda");
const { padCharsStart, isFunction, isObject } = require("ramda-adjunct");
const { PLAYER_HEIGHT_ADJUSTMENT, ASSETS_FOLDER } = require("../constants");
const { PLAYER_HEIGHT_ADJUSTMENT, getAssetsFolder } = 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}`
] = `${ASSETS_FOLDER}/${dir2}/${name2}${ext2}`;
] = `${getAssetsFolder()}/${dir2}/${name2}${ext2}`;
} else {
const { dir, name, ext } = path.parse(filename);
const target = `${outputDir}/${dir}/${name}${ext}`;
files[target] = `${ASSETS_FOLDER}/${dir}/${name}${ext}`;
files[target] = `${getAssetsFolder()}/${dir}/${name}${ext}`;
}

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

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

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

console.log(ASSETS_FOLDER);
const getAssetsFolder = () => assetsFolder;

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

module.exports = {
POLY_NO_SHADOW,
Expand Down Expand Up @@ -135,5 +139,6 @@ module.exports = {
ISLAND_JOINT_LENGTH,
ISLAND_JOINT_WIDTH,

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

let win;

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

// win.setMenu(null);

win.loadFile(path.join(__dirname, "./static/index.html"));

win.webContents.on("did-finish-load", () => {
Expand All @@ -23,6 +22,8 @@ const createWindow = () => {
};

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

createWindow();

app.on("activate", () => {
Expand Down

0 comments on commit 2349af4

Please sign in to comment.