From 89d383415464a405e5a9962660488d2559fdf279 Mon Sep 17 00:00:00 2001 From: X3F200C Date: Mon, 21 Aug 2023 10:56:01 -0400 Subject: [PATCH] Small GUI and warning in README.md --- README.md | 4 +- package.json | 15 ++++++ src/index.js | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 package.json create mode 100644 src/index.js diff --git a/README.md b/README.md index 3ed6bd4..86c5cb9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # open-plutonium-launcher -Open-source launcher for Plutonium \ No newline at end of file +Open-source launcher for Plutonium, inspired by [LanLauncher](https://github.com/JugAndDoubleTap/LanLauncher) + +Please note this launcher is not functional yet and a lot needs to be done. diff --git a/package.json b/package.json new file mode 100644 index 0000000..a7dbcaa --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "open-plutonium-launcher", + "version": "0.0.1", + "description": "Open-source Plutonium launcher", + "main": "src/index.js", + "repository": "https://gitea.x3f200c.net/X3F200C/open-plutonium-launcher", + "author": "X3F200C", + "license": "GPL-3.0", + "scripts": { + "start": "qode src/index.js" + }, + "dependencies": { + "@nodegui/nodegui": "http://master-release.nodegui.org" + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..753997c --- /dev/null +++ b/src/index.js @@ -0,0 +1,131 @@ +const path = require("node:path"); +const fs = require("node:fs"); +const nodeGUI = require("@nodegui/nodegui"); + +var configFile = path.join(process.env["APPDATA"], "open-plutonium-launcher.json"); +const defaultConfig = { + "username": "", + "directories": { + "plutonium": path.join(process.env["LOCALAPPDATA"], "Plutonium"), + "iw5": path.join(process.env["PROGRAMFILES(X86)"], "Steam", "steamapps", "common", "Call of Duty Modern Warfare 3"), + "t4": path.join(process.env["PROGRAMFILES(X86)"], "Steam", "steamapps", "common", "Call of Duty World at War"), + "t5": path.join(process.env["PROGRAMFILES(X86)"], "Steam", "steamapps", "common", "Call of Duty Black Ops"), + "t6": path.join(process.env["PROGRAMFILES(X86)"], "Steam", "steamapps", "common", "Call of Duty Black Ops II") + } +}; + +let config = {}; + +const games = [ + { + "id": "iw5", + "name": "Call of Duty Modern Warfare 3", + "modes": [ + { + "id": "mp", + "name": "Multiplayer" + }, + { + "id": "sp", + "name": "Co-Op/Zombies" + } + ] + }, + { + "id": "t4", + "name": "Call of Duty World at War", + "modes": [ + { + "id": "mp", + "name": "Multiplayer" + }, + { + "id": "sp", + "name": "Co-Op/Zombies" + } + ] + }, + { + "id": "t5", + "name": "Call of Duty Black Ops", + "modes": [ + { + "id": "mp", + "name": "Multiplayer" + }, + { + "id": "sp", + "name": "Co-Op/Zombies" + } + ] + }, + { + "id": "t6", + "name": "Call of Duty Black Ops II", + "modes": [ + { + "id": "mp", + "name": "Multiplayer" + }, + { + "id": "zm", + "name": "Co-Op/Zombies" + } + ] + } +]; + +var gameSelections = []; +var selectedGame = 0; + +function readConfig() { + config = JSON.parse(fs.readFileSync(configFile, "utf-8")); +} + +function writeConfig(asDefault = false) { + fs.writeFileSync(configFile, JSON.stringify((asDefault ? defaultConfig : config))); +} + +if (!fs.existsSync(configFile)) { + writeConfig(true); +} +readConfig(); + +var mainWindow = new nodeGUI.QMainWindow(); + +var mainWidget = new nodeGUI.QWidget(); +mainWidget.setObjectName("root"); + +var rootLayout = new nodeGUI.FlexLayout(); +mainWidget.setLayout(rootLayout); + +var gameSelectionBox = new nodeGUI.QComboBox(); +for (let g = 0; g < games.length; g++) { + var game = games[g]; + + for (let m = 0; m < game.modes.length; m++) { + var mode = game.modes[m]; + + gameSelections.push([ + game.id, + mode.id + ]); + gameSelectionBox.addItem(undefined, game.name + " " + mode.name); + } +} +gameSelectionBox.addEventListener("currentIndexChanged", function (index) { + selectedGame = index; +}); +rootLayout.addWidget(gameSelectionBox); + +mainWindow.setCentralWidget(mainWidget); +mainWindow.setStyleSheet(` + #root { + width: 100%; + height: 100%; + } +`); +mainWindow.setWindowTitle("Open Plutonium launcher"); +mainWindow.resize(854, 480); +mainWindow.show(); +global.mainWindow = mainWindow;