mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Added support to access everything inside shapez.io folder
This commit is contained in:
parent
a0d87be6c0
commit
373d49cc2d
@ -16,15 +16,13 @@ const roamingFolder =
|
||||
(process.platform == "darwin"
|
||||
? process.env.HOME + "/Library/Preferences"
|
||||
: process.env.HOME + "/.local/share");
|
||||
let storePath = path.join(roamingFolder, "shapez.io", "saves");
|
||||
let modsPath = path.join(roamingFolder, "shapez.io", "mods");
|
||||
const shapezIOFolder = path.join(roamingFolder, "shapez.io");
|
||||
let storePath = path.join(shapezIOFolder, "saves");
|
||||
|
||||
if (!fs.existsSync(storePath))
|
||||
// No try-catch by design
|
||||
fs.mkdirSync(storePath, { recursive: true });
|
||||
|
||||
if (!fs.existsSync(modsPath)) fs.mkdirSync(modsPath);
|
||||
|
||||
/** @type {BrowserWindow} */
|
||||
let win = null;
|
||||
let menu = null;
|
||||
@ -187,10 +185,10 @@ ipcMain.on("exit-app", (event, flag) => {
|
||||
function performFsJob(job) {
|
||||
let parent = storePath;
|
||||
|
||||
if (job.mods) parent = modsPath;
|
||||
if (job.folder) parent = path.join(shapezIOFolder, job.folder);
|
||||
|
||||
const fname = path.join(parent, job.filename);
|
||||
const relative = path.relative(parent, fname);
|
||||
const relative = path.relative(shapezIOFolder, fname);
|
||||
|
||||
//If not a child of parent
|
||||
if (!relative && !relative.startsWith("..") && !path.isAbsolute(relative))
|
||||
@ -198,6 +196,8 @@ function performFsJob(job) {
|
||||
error: "Cannot get above parent folder",
|
||||
};
|
||||
|
||||
if (!fs.existsSync(parent)) fs.mkdirSync(parent, { recursive: true });
|
||||
|
||||
switch (job.type) {
|
||||
case "readDir": {
|
||||
let contents = "";
|
||||
|
@ -71,6 +71,7 @@
|
||||
"babel-plugin-console-source": "^2.0.2",
|
||||
"babel-plugin-danger-remove-unused-import": "^1.1.2",
|
||||
"babel-plugin-shake-class-properties": "^0.2.0",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"css-mqpacker": "^7.0.0",
|
||||
"cssnano": "^4.1.10",
|
||||
"electron-packager": "^14.0.6",
|
||||
|
@ -2113,6 +2113,25 @@ babel-generator@^6.26.0:
|
||||
source-map "^0.5.7"
|
||||
trim-right "^1.0.1"
|
||||
|
||||
babel-helper-function-name@^6.24.1:
|
||||
version "6.24.1"
|
||||
resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9"
|
||||
integrity sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=
|
||||
dependencies:
|
||||
babel-helper-get-function-arity "^6.24.1"
|
||||
babel-runtime "^6.22.0"
|
||||
babel-template "^6.24.1"
|
||||
babel-traverse "^6.24.1"
|
||||
babel-types "^6.24.1"
|
||||
|
||||
babel-helper-get-function-arity@^6.24.1:
|
||||
version "6.24.1"
|
||||
resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d"
|
||||
integrity sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=
|
||||
dependencies:
|
||||
babel-runtime "^6.22.0"
|
||||
babel-types "^6.24.1"
|
||||
|
||||
babel-helpers@^6.24.1:
|
||||
version "6.24.1"
|
||||
resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2"
|
||||
@ -2166,6 +2185,21 @@ babel-plugin-shake-class-properties@^0.2.0:
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-shake-class-properties/-/babel-plugin-shake-class-properties-0.2.0.tgz#fb8346725f8418f992d5d193014c57533c404a85"
|
||||
integrity sha512-++i7B90ohCRp4t6rvuq3xO1Ugq5rf4r2+a0bU4cjSWNwJqq9m2MueiJ3epQ+CTBGUrzf4f7l+ReLcSlA1i0ckA==
|
||||
|
||||
babel-plugin-syntax-class-properties@^6.8.0:
|
||||
version "6.13.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de"
|
||||
integrity sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=
|
||||
|
||||
babel-plugin-transform-class-properties@^6.24.1:
|
||||
version "6.24.1"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz#6a79763ea61d33d36f37b611aa9def81a81b46ac"
|
||||
integrity sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=
|
||||
dependencies:
|
||||
babel-helper-function-name "^6.24.1"
|
||||
babel-plugin-syntax-class-properties "^6.8.0"
|
||||
babel-runtime "^6.22.0"
|
||||
babel-template "^6.24.1"
|
||||
|
||||
babel-register@^6.26.0:
|
||||
version "6.26.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071"
|
||||
@ -2206,7 +2240,7 @@ babel-template@^6.24.1, babel-template@^6.26.0:
|
||||
babylon "^6.18.0"
|
||||
lodash "^4.17.4"
|
||||
|
||||
babel-traverse@^6.26.0:
|
||||
babel-traverse@^6.24.1, babel-traverse@^6.26.0:
|
||||
version "6.26.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee"
|
||||
integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=
|
||||
@ -2221,7 +2255,7 @@ babel-traverse@^6.26.0:
|
||||
invariant "^2.2.2"
|
||||
lodash "^4.17.4"
|
||||
|
||||
babel-types@^6.26.0:
|
||||
babel-types@^6.24.1, babel-types@^6.26.0:
|
||||
version "6.26.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
|
||||
integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=
|
||||
|
@ -136,13 +136,13 @@ window.onload = async () => {
|
||||
let modFolderContents = [];
|
||||
if (G_IS_STANDALONE) {
|
||||
modFolderContents = getIPCRenderer().sendSync("fs-sync-job", {
|
||||
mods: true,
|
||||
folder: "mods",
|
||||
type: "readDir",
|
||||
filename: "",
|
||||
}).data;
|
||||
if (modFolderContents.includes("modpack.json")) {
|
||||
instance = getIPCRenderer().sendSync("fs-sync-job", {
|
||||
mods: true,
|
||||
folder: "mods",
|
||||
type: "read",
|
||||
filename: "modpack.json",
|
||||
});
|
||||
|
@ -93,7 +93,7 @@ export class ModManager {
|
||||
if (fromFile && G_IS_STANDALONE) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const modCode = getIPCRenderer().sendSync("fs-sync-job", {
|
||||
mods: true,
|
||||
folder: "mods",
|
||||
type: "read",
|
||||
filename: url,
|
||||
}).data;
|
||||
|
Loading…
Reference in New Issue
Block a user