aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-07-21 23:22:44 +0200
committer0neGal <mail@0negal.com>2023-07-21 23:26:14 +0200
commitb08e4d193a2c6dea82a6f00432203cfad097e708 (patch)
tree07ef1bf47d71acdabc0e923d81e3c57eb0b0868e /src
parent928333b53e07809bef1897813a4f6588f37c677c (diff)
downloadViper-b08e4d193a2c6dea82a6f00432203cfad097e708.tar.gz
Viper-b08e4d193a2c6dea82a6f00432203cfad097e708.zip
rename mods.list() properties to use snake case
I may or may not have missed some properties or something somewhere, perhaps we'll see if something ends up broken in the future...
Diffstat (limited to 'src')
-rw-r--r--src/app/js/browser.js20
-rw-r--r--src/app/js/mods.js18
-rw-r--r--src/app/main.js13
-rw-r--r--src/index.js4
-rw-r--r--src/modules/mods.js49
-rw-r--r--src/modules/packages.js4
6 files changed, 57 insertions, 51 deletions
diff --git a/src/app/js/browser.js b/src/app/js/browser.js
index 206b80e..3c3786f 100644
--- a/src/app/js/browser.js
+++ b/src/app/js/browser.js
@@ -133,9 +133,9 @@ var Browser = {
for (let ii = 0; ii < modsobj.all.length; ii++) {
let mod = modsobj.all[ii];
- if (normalize(mod.Name) === normalized) {
- local_name = mod.Name;
- local_version = version.format(mod.Version);
+ if (normalize(mod.name) === normalized) {
+ local_name = mod.name;
+ local_version = version.format(mod.version);
if (version.is_newer(remote_version, local_version)) {
has_update = true;
}
@@ -270,13 +270,13 @@ var Browser = {
setTimeout(() => {
for (let i = 0; i < modsobj.all.length; i++) {
- let modname = normalize(modsobj.all[i].Name);
- let modfolder = normalize(modsobj.all[i].FolderName);
+ let modname = normalize(modsobj.all[i].name);
+ let modfolder = normalize(modsobj.all[i].folder_name);
if (mod.includes(modname)) {
if (! make(modname)) {
- if (modsobj.all[i].ManifestName) {
- make(normalize(modsobj.all[i].ManifestName));
+ if (modsobj.all[i].manifest_name) {
+ make(normalize(modsobj.all[i].manifest_name));
}
}
}
@@ -386,7 +386,7 @@ function BrowserEl(properties) {
let normalized_mods = [];
for (let i = 0; i < modsobj.all; i++) {
- normalized_mods.push(normalize(mods_list[i].Name));
+ normalized_mods.push(normalize(mods_list[i].name));
}
if (properties.pkg.local_version) {
@@ -445,8 +445,8 @@ function add_recent_toast(name, timeout = 3000) {
ipcRenderer.on("removed-mod", (event, mod) => {
setButtons(true);
Browser.setbutton(mod.name, lang("gui.browser.install"));
- if (mod.manifestname) {
- Browser.setbutton(mod.manifestname, lang("gui.browser.install"));
+ if (mod.manifest_name) {
+ Browser.setbutton(mod.manifest_name, lang("gui.browser.install"));
}
})
diff --git a/src/app/js/mods.js b/src/app/js/mods.js
index d4e8043..af430e5 100644
--- a/src/app/js/mods.js
+++ b/src/app/js/mods.js
@@ -6,13 +6,13 @@ mods.load = (mods_obj) => {
let normalized_names = [];
let set_mod = (mod) => {
- let normalized_name = "mod-list-" + normalize(mod.Name);
+ let normalized_name = "mod-list-" + normalize(mod.name);
normalized_names.push(normalized_name);
let el = document.getElementById(normalized_name);
if (el) {
- if (mod.Disabled) {
+ if (mod.disabled) {
el.querySelector(".switch").classList.remove("on");
} else {
el.querySelector(".switch").classList.add("on");
@@ -31,30 +31,30 @@ mods.load = (mods_obj) => {
<img class="blur" src="">
</div>
<div class="text">
- <div class="title">${mod.Name}</div>
- <div class="description">${mod.Description}</div>
+ <div class="title">${mod.name}</div>
+ <div class="description">${mod.description}</div>
<button class="switch on orange"></button>
<button class="update bg-blue">
${lang("gui.browser.update")}
</button>
- <button class="bg-red" onclick="mods.remove('${mod.Name}')">
+ <button class="bg-red" onclick="mods.remove('${mod.name}')">
${lang("gui.mods.remove")}
</button>
- <button class="visual">${version.format(mod.Version)}</button>
+ <button class="visual">${version.format(mod.version)}</button>
<button class="visual">
${lang("gui.browser.madeby")}
- ${mod.Author || lang("gui.mods.unknown_author")}
+ ${mod.author || lang("gui.mods.unknown_author")}
</button>
</div>
`;
- if (mod.Disabled) {
+ if (mod.disabled) {
div.querySelector(".switch").classList.remove("on");
}
div.querySelector(".switch").addEventListener("click", () => {
- mods.toggle(mod.Name);
+ mods.toggle(mod.name);
})
div.querySelector(".image").style.display = "none";
diff --git a/src/app/main.js b/src/app/main.js
index 1dbff40..26410cc 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -3,7 +3,12 @@ const path = require("path");
const { app, ipcRenderer, shell } = require("electron");
const lang = require("../lang");
-var modsobj = {};
+var modsobj = {
+ all: [],
+ enabled: [],
+ disabled: []
+}
+
let shouldInstallNorthstar = false;
// Base settings
@@ -212,11 +217,11 @@ function installFromURL(url, dependencies, clearqueue, author) {
function isModInstalled(modname) {
for (let i = 0; i < modsobj.all.length; i++) {
let mod = modsobj.all[i];
- if (mod.ManifestName) {
- if (mod.ManifestName.match(modname)) {
+ if (mod.manifest_name) {
+ if (mod.manifest_name.match(modname)) {
return true;
}
- } else if (mod.Name.match(modname)) {
+ } else if (mod.name.match(modname)) {
return true;
}
}
diff --git a/src/index.js b/src/index.js
index 99ed3c1..eb258a5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -239,13 +239,13 @@ ipcMain.on("getmods", () => {
log(`${lang("general.mods.installed")} ${mods.all.length}`);
log(`${lang("general.mods.enabled")} ${mods.enabled.length}`);
for (let i = 0; i < mods.enabled.length; i++) {
- log(` ${mods.enabled[i].Name} ${mods.enabled[i].Version}`);
+ log(` ${mods.enabled[i].name} ${mods.enabled[i].version}`);
}
if (mods.disabled.length > 0) {
log(`${lang("general.mods.disabled")} ${mods.disabled.length}`);
for (let i = 0; i < mods.disabled.length; i++) {
- log(` ${mods.disabled[i].Name} ${mods.disabled[i].Version}`);
+ log(` ${mods.disabled[i].name} ${mods.disabled[i].version}`);
}
}
cli.exit(0);
diff --git a/src/modules/mods.js b/src/modules/mods.js
index 62b6184..5ba1fab 100644
--- a/src/modules/mods.js
+++ b/src/modules/mods.js
@@ -72,14 +72,15 @@ mods.list = () => {
if (! mod) {return}
let obj = {
- Author: mod.Author || false,
- Version: mod.Version || "unknown",
- Name: mod.Name || "unknown",
- Description: mod.Description || "",
-
- FolderName: file,
- FolderPath: path.join(dir, file),
- Package: package_obj || false
+ author: mod.Author || false,
+ version: mod.Version || "unknown",
+ name: mod.Name || "unknown",
+ description: mod.Description || "",
+
+ folder_name: file,
+ folder_path: path.join(dir, file),
+
+ package: package_obj || false
}
// Electron's serializer for
@@ -105,20 +106,20 @@ mods.list = () => {
obj = JSON.stringify(obj);
obj = JSON.parse(obj);
- if (obj.Package) {
- obj.Author = obj.Package.author;
+ if (obj.package) {
+ obj.author = obj.package.author;
}
- obj.Disabled = ! mods.modfile.get(obj.Name);
+ obj.disabled = ! mods.modfile.get(obj.name);
// add manifest data from manifest.json, if it exists
let manifest_file = path.join(dir, file, "manifest.json");
if (fs.existsSync(manifest_file)) {
let manifest = json(manifest_file);
if (manifest != false) {
- obj.ManifestName = manifest.name;
- if (obj.Version == "unknown") {
- obj.Version = manifest.version_number;
+ obj.manifest_name = manifest.name;
+ if (obj.version == "unknown") {
+ obj.version = manifest.version_number;
}
}
}
@@ -126,11 +127,11 @@ mods.list = () => {
// add author data from author file, if it exists
let author_file = path.join(dir, file, "thunderstore_author.txt");
if (fs.existsSync(author_file)) {
- obj.Author = fs.readFileSync(author_file, "utf8");
+ obj.author = fs.readFileSync(author_file, "utf8");
}
// add mod to their respective disabled or enabled Array
- if (obj.Disabled) {
+ if (obj.disabled) {
disabled.push(obj);
} else {
enabled.push(obj);
@@ -185,7 +186,7 @@ mods.get = (mod) => {
// search for mod in list
for (let i = 0; i < list.length; i++) {
- if (list[i].Name == mod) {
+ if (list[i].name == mod) {
// found mod, return data
return list[i];
} else {continue}
@@ -225,7 +226,7 @@ mods.modfile.gen = () => {
let list = mods.list().all; // get list of all mods
for (let i = 0; i < list.length; i++) {
// add every mod to the list
- names[list[i].Name] = true
+ names[list[i].name] = true
}
// write the actual file
@@ -565,12 +566,12 @@ mods.remove = (mod) => {
if (mod == "allmods") {
let modlist = mods.list().all;
for (let i = 0; i < modlist.length; i++) {
- mods.remove(modlist[i].Name);
+ mods.remove(modlist[i].name);
}
return
}
- let mod_name = mods.get(mod).FolderName;
+ let mod_name = mods.get(mod).folder_name;
if (! mod_name) {
console.log("error: " + lang("cli.mods.cantfind"));
cli.exit(1);
@@ -584,12 +585,12 @@ mods.remove = (mod) => {
return cli.exit(1);
}
- let manifestname = null;
+ let manifest_name = null;
// if the mod has a manifest.json we want to save it now so we can
// send it later when telling the renderer about the deleted mod
if (fs.existsSync(path.join(path_to_mod, "manifest.json"))) {
- manifestname = require(path.join(path_to_mod, "manifest.json")).name;
+ manifest_name = require(path.join(path_to_mod, "manifest.json")).name;
}
// actually remove the mod itself
@@ -604,7 +605,7 @@ mods.remove = (mod) => {
// relevant info for it to properly update everything graphically
ipcMain.emit("removed-mod", "", {
name: mod.replace(/^.*(\\|\/|\:)/, ""),
- manifestname: manifestname
+ manifest_name: manifest_name
});
}
@@ -629,7 +630,7 @@ mods.toggle = (mod, fork) => {
if (mod == "allmods") {
let modlist = mods.list().all; // get list of all mods
for (let i = 0; i < modlist.length; i++) { // run through list
- mods.toggle(modlist[i].Name, true); // enable mod
+ mods.toggle(modlist[i].name, true); // enable mod
}
console.log(lang("cli.mods.toggledall"));
diff --git a/src/modules/packages.js b/src/modules/packages.js
index 62ef21e..25416c4 100644
--- a/src/modules/packages.js
+++ b/src/modules/packages.js
@@ -217,8 +217,8 @@ packages.install = async (url, author, package_name, version) => {
for (let i = 0; i < mods_list.length; i++) {
let mod = mods_list[i];
- if (mod.ManifestName == package_name) {
- mods.remove(mod.Name);
+ if (mod.manifest_name == package_name) {
+ mods.remove(mod.name);
continue;
}
}