aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-01-17 00:16:15 +0100
committer0neGal <mail@0negal.com>2022-01-17 00:16:15 +0100
commit962265ffbe3aa0a9c2084d370c914c0265ee6bd9 (patch)
treefd06350a2985aa1d63061208a4d8158d9c3781a6 /src
parent4d0ef0ca26afc9dc70fbc942dd05beca19e2f0a6 (diff)
downloadViper-962265ffbe3aa0a9c2084d370c914c0265ee6bd9.tar.gz
Viper-962265ffbe3aa0a9c2084d370c914c0265ee6bd9.zip
initial commit for implementing enabledmods.json
All the basic stuff is here, I just need to actually hook it up into the old utils calls/I need to change them to the new ones. The latter will likely be the one I'm doing.
Diffstat (limited to 'src')
-rw-r--r--src/utils.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/utils.js b/src/utils.js
index e6fa5b0..bdfa7f3 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -337,6 +337,51 @@ const mods = {
return false;
},
+ modfile: () => {
+ let file = path.join(modpath, "..", "enabledmods.json");
+
+ if (! fs.existsSync(modpath)) {
+ fs.mkdirSync(path.join(modpath), {recursive: true})
+ }
+
+ if (! fs.existsSync(file)) {
+ fs.writeFileSync(file, "{}")
+ }
+
+ return {
+ gen: () => {
+ let names = {};
+ let list = mods.list().all;
+ for (let i = 0; i < list.length; i++) {
+ names[list[i].Name] = true
+ }
+
+ fs.writeFileSync(file, JSON.stringify(names))
+ },
+ toggle: (mod) => {
+ let data = require(file);
+ data[mod] = !data[mod];
+ console.log(data)
+ },
+ get: () => {
+ let enabled = [];
+ let disabled = [];
+ let data = require(file);
+
+ for (let i in data) {
+ if (data[i]) {
+ enabled.push(data[i])
+ } else {disabled.push(data[i])}
+ }
+
+ return {
+ enabled: enabled,
+ disabled: disabled,
+ all: [...enabled, ...disabled]
+ }
+ }
+ };
+ },
install: (mod) => {
if (getNSVersion() == "unknown") {
winLog(lang("general.notinstalled"))
@@ -502,6 +547,8 @@ const mods = {
}
};
+console.log(mods.modfile().get())
+
module.exports = {
mods,
lang,