From 2326f5888df4381360369106eba65ec94b70cd6e Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Mon, 1 Feb 2021 21:54:34 +0100 Subject: [PATCH] refactored project + changed name --- README.md | 1 - config.forge.js | 10 +-- package-lock.json | 2 +- package.json | 6 +- .../client/assets}/Roboto-Regular.ttf | Bin {include => src/client/assets/css}/index.css | 2 +- {include => src/client/assets/css}/login.css | 2 +- .../client/assets/css}/material-icons.css | 2 +- .../client/assets/css}/menubar.css | 0 icon.png => src/client/assets/images/icon.png | Bin .../client/assets/images}/maxresdefault.jpg | Bin {include => src/client/assets/js}/index.js | 4 +- {include => src/client/assets/js}/login.js | 0 {include => src/client/assets/js}/menubar.js | 4 +- {include => src/client/assets/js}/script.js | 4 +- .../client/assets}/material-icons.woff2 | Bin index.html => src/client/index.html | 16 ++-- login.html => src/client/login.html | 14 ++-- src/server/install.js | 51 +++++++++++++ main.js => src/server/main.js | 71 +++--------------- 20 files changed, 96 insertions(+), 93 deletions(-) rename {include => src/client/assets}/Roboto-Regular.ttf (100%) rename {include => src/client/assets/css}/index.css (95%) rename {include => src/client/assets/css}/login.css (92%) rename {include => src/client/assets/css}/material-icons.css (89%) rename {include => src/client/assets/css}/menubar.css (100%) rename icon.png => src/client/assets/images/icon.png (100%) rename {include => src/client/assets/images}/maxresdefault.jpg (100%) rename {include => src/client/assets/js}/index.js (92%) rename {include => src/client/assets/js}/login.js (100%) rename {include => src/client/assets/js}/menubar.js (95%) rename {include => src/client/assets/js}/script.js (87%) rename {include => src/client/assets}/material-icons.woff2 (100%) rename index.html => src/client/index.html (73%) rename login.html => src/client/login.html (67%) create mode 100644 src/server/install.js rename main.js => src/server/main.js (60%) diff --git a/README.md b/README.md index e9f3b00..cfef71a 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,3 @@ - - -- diff --git a/config.forge.js b/config.forge.js index 212b559..9a90fbc 100644 --- a/config.forge.js +++ b/config.forge.js @@ -1,16 +1,16 @@ const path = require('path'); module.exports = { packagerConfig: { - packageName: "Launcher", - name: "Launcher", - productName: "Launcher", - icon: path.resolve(__dirname, 'icon.png') + packageName: "altarik-launcher", + name: "altarik-launcher", + productName: "altarik-launcher", + icon: path.resolve(__dirname, 'app.ico') }, makers: [ { name: "@electron-forge/maker-squirrel", config: { - name: "Launcher", + name: "altarik-launcher", iconUrl: path.resolve(__dirname, 'app.ico'), //loadingGif: path.resolve(__dirname, 'src/assets/loading.gif'), setupIcon: path.resolve(__dirname, 'app.ico') diff --git a/package-lock.json b/package-lock.json index bde2acf..648a830 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "launcher", + "name": "altarik-launcher", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index 1a2bed2..b5983e4 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "launcher", + "name": "altarik-launcher", "version": "1.0.0", - "description": "Launcher Projet Secret", - "main": "main.js", + "description": "Altarik Launcher", + "main": "src/server/main.js", "scripts": { "start": "electron-forge start", "test": "echo \"Error: no test specified\" && exit 1", diff --git a/include/Roboto-Regular.ttf b/src/client/assets/Roboto-Regular.ttf similarity index 100% rename from include/Roboto-Regular.ttf rename to src/client/assets/Roboto-Regular.ttf diff --git a/include/index.css b/src/client/assets/css/index.css similarity index 95% rename from include/index.css rename to src/client/assets/css/index.css index c95f344..64fd7c0 100644 --- a/include/index.css +++ b/src/client/assets/css/index.css @@ -4,7 +4,7 @@ @font-face { font-family: "Roboto"; - src: url("./Roboto-Regular.ttf") format("truetype"); + src: url("../Roboto-Regular.ttf") format("truetype"); } html{ diff --git a/include/login.css b/src/client/assets/css/login.css similarity index 92% rename from include/login.css rename to src/client/assets/css/login.css index efba09a..ea52f9b 100644 --- a/include/login.css +++ b/src/client/assets/css/login.css @@ -4,7 +4,7 @@ @font-face { font-family: "Roboto"; - src: url("./Roboto-Regular.ttf") format("truetype"); + src: url("../Roboto-Regular.ttf") format("truetype"); } html{ diff --git a/include/material-icons.css b/src/client/assets/css/material-icons.css similarity index 89% rename from include/material-icons.css rename to src/client/assets/css/material-icons.css index e658455..0478b8c 100644 --- a/include/material-icons.css +++ b/src/client/assets/css/material-icons.css @@ -3,7 +3,7 @@ font-family: 'Material Icons'; font-style: normal; font-weight: 400; - src: url(material-icons.woff2) format('woff2'); + src: url(../material-icons.woff2) format('woff2'); } .material-icons { diff --git a/include/menubar.css b/src/client/assets/css/menubar.css similarity index 100% rename from include/menubar.css rename to src/client/assets/css/menubar.css diff --git a/icon.png b/src/client/assets/images/icon.png similarity index 100% rename from icon.png rename to src/client/assets/images/icon.png diff --git a/include/maxresdefault.jpg b/src/client/assets/images/maxresdefault.jpg similarity index 100% rename from include/maxresdefault.jpg rename to src/client/assets/images/maxresdefault.jpg diff --git a/include/index.js b/src/client/assets/js/index.js similarity index 92% rename from include/index.js rename to src/client/assets/js/index.js index 28efd4d..c49bfaf 100644 --- a/include/index.js +++ b/src/client/assets/js/index.js @@ -13,9 +13,9 @@ const totalMem = os.totalmem() / (1.049 * Math.pow(10, 6)) document.body.onload = (e) => { minMem.max = totalMem maxMem.max = totalMem - minMem.value = localStorage.getItem("minMem") + minMem.value = localStorage.getItem("minMem") != null ? localStorage.getItem("minMem") : 1024 outputMinMem.innerHTML = minMem.value - maxMem.value = localStorage.getItem("maxMem") + maxMem.value = localStorage.getItem("maxMem") != null ? localStorage.getItem("maxMem") : 2048 outputMaxMem.innerHTML = maxMem.value } diff --git a/include/login.js b/src/client/assets/js/login.js similarity index 100% rename from include/login.js rename to src/client/assets/js/login.js diff --git a/include/menubar.js b/src/client/assets/js/menubar.js similarity index 95% rename from include/menubar.js rename to src/client/assets/js/menubar.js index c1bebce..d35a9d2 100644 --- a/include/menubar.js +++ b/src/client/assets/js/menubar.js @@ -1,4 +1,4 @@ -const {remote} = require('electron') +const { remote } = require('electron') const {Menu, BrowserWindow, MenuItem, shell} = remote function getCurrentWindow() { @@ -31,7 +31,7 @@ function closeWindow(browserWindow = getCurrentWindow()) { function isWindowMaximized(browserWindow = getCurrentWindow()) { return browserWindow.isMaximized() } - + module.exports = { getCurrentWindow, minimizeWindow, diff --git a/include/script.js b/src/client/assets/js/script.js similarity index 87% rename from include/script.js rename to src/client/assets/js/script.js index e2fd680..e2b5722 100644 --- a/include/script.js +++ b/src/client/assets/js/script.js @@ -7,7 +7,7 @@ const { maxUnmaxWindow, isWindowMaximized, closeWindow, - } = require("./include/menubar.js"); + } = require("./assets/js/menubar.js"); window.addEventListener("DOMContentLoaded", () => { window.getCurrentWindow = getCurrentWindow @@ -22,7 +22,7 @@ window.addEventListener("DOMContentLoaded", () => { minimizeButton.addEventListener("click", e => window.minimizeWindow()) - maxUnmaxButton.addEventListener("click", e => window.maxUnmaxWindow()) + // maxUnmaxButton.addEventListener("click", e => window.maxUnmaxWindow()) closeButton.addEventListener("click", e => window.closeWindow()) }) diff --git a/include/material-icons.woff2 b/src/client/assets/material-icons.woff2 similarity index 100% rename from include/material-icons.woff2 rename to src/client/assets/material-icons.woff2 diff --git a/index.html b/src/client/index.html similarity index 73% rename from index.html rename to src/client/index.html index 9ad42fc..3696168 100644 --- a/index.html +++ b/src/client/index.html @@ -4,10 +4,10 @@ Launcher Projet Secret - - - - + + + +
@@ -33,7 +33,7 @@
- +
@@ -42,7 +42,7 @@

- - + + diff --git a/login.html b/src/client/login.html similarity index 67% rename from login.html rename to src/client/login.html index b8b102e..9d29273 100644 --- a/login.html +++ b/src/client/login.html @@ -4,10 +4,10 @@ Launcher Projet Secret - - - - + + + +
@@ -32,7 +32,7 @@
- - + + diff --git a/src/server/install.js b/src/server/install.js new file mode 100644 index 0000000..4321689 --- /dev/null +++ b/src/server/install.js @@ -0,0 +1,51 @@ +function handleSquirrelEvent(app) { + if (process.argv.length === 1) { + return false; + } + + const ChildProcess = require('child_process'); + const path = require('path'); + + const appFolder = path.resolve(process.execPath, '..'); + const rootAtomFolder = path.resolve(appFolder, '..'); + const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); + const exeName = path.basename(process.execPath); + + const spawn = function(command, args) { + let spawnedProcess, error; + + try { + spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); + } catch (error) {} + + return spawnedProcess; + }; + + const spawnUpdate = function(args) { + return spawn(updateDotExe, args); + }; + + const squirrelEvent = process.argv[1]; + switch (squirrelEvent) { + case '--squirrel-install': + case '--squirrel-updated': + spawnUpdate(['--createShortcut', exeName]); + + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-uninstall': + spawnUpdate(['--removeShortcut', exeName]); + + setTimeout(app.quit, 1000); + return true; + + case '--squirrel-obsolete': + app.quit(); + return true; + } + } + +module.exports = { + handleSquirrelEvent +} \ No newline at end of file diff --git a/main.js b/src/server/main.js similarity index 60% rename from main.js rename to src/server/main.js index f3cc79f..83cc999 100644 --- a/main.js +++ b/src/server/main.js @@ -1,67 +1,18 @@ const { app, BrowserWindow, Menu, ipcMain, Notification } = require('electron') -const path = require('path') +const { join } = require('path') if (require('electron-squirrel-startup')) { - handleSquirrelEvent() + require("./install.js").handleSquirrelEvent(app) app.quit() } const { Client, Authenticator } = require('minecraft-launcher-core') const appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share") - -function handleSquirrelEvent() { - if (process.argv.length === 1) { - return false; - } - - const ChildProcess = require('child_process'); - const path = require('path'); - - const appFolder = path.resolve(process.execPath, '..'); - const rootAtomFolder = path.resolve(appFolder, '..'); - const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); - const exeName = path.basename(process.execPath); - - const spawn = function(command, args) { - let spawnedProcess, error; - - try { - spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); - } catch (error) {} - - return spawnedProcess; - }; - - const spawnUpdate = function(args) { - return spawn(updateDotExe, args); - }; - - const squirrelEvent = process.argv[1]; - switch (squirrelEvent) { - case '--squirrel-install': - case '--squirrel-updated': - spawnUpdate(['--createShortcut', exeName]); - - setTimeout(app.quit, 1000); - return true; - - case '--squirrel-uninstall': - spawnUpdate(['--removeShortcut', exeName]); - - setTimeout(app.quit, 1000); - return true; - - case '--squirrel-obsolete': - app.quit(); - return true; - } -} - const launcher = new Client(); -const iconPath = path.join(__dirname, "icon.ico"); +const iconPath = join(__dirname, "icon.ico"); let win = null let auth = null -let Minecraftpath = path.join(appdata, ".ps") +let Minecraftpath = join(appdata, ".altarik") let clientPackage = "https://www.dropbox.com/s/ww6a052nzzgojdm/modpack.zip?dl=1" let version = "1.16.4" let versionFolder = "fabric-loader-0.10.8-1.16.4" @@ -69,18 +20,20 @@ let versionFolder = "fabric-loader-0.10.8-1.16.4" function createWindow () { win = new BrowserWindow({ width: 1000, - minWidth: 900, + minWidth: 1000, + maxWidth: 1000, height: 600, minHeight: 600, + maxHeight: 600, icon: iconPath, webPreferences: { nodeIntegration: true, enableRemoteModule: true }, - frame: false + frame: false, }) Menu.setApplicationMenu(null) - win.loadFile('login.html') + win.loadFile('src/client/login.html') } app.whenReady().then(() => { @@ -102,7 +55,7 @@ app.on('activate', () => { ipcMain.on("login", (event, args) => { auth = Authenticator.getAuth(args.user, args.pass) auth.then(v => { - win.loadFile('index.html') + win.loadFile('src/client/index.html') setTimeout(() => { event.sender.send("nick", { name: v.name @@ -150,12 +103,12 @@ ipcMain.on("launch", (event, args) => { launcher.on('close', (e) => { event.sender.send("close", e) if(e !== 0){ - showNotification("Une erreur est suvenue", "Minecraft ne s'est pas fermé correctement") + showNotification("Une erreur est survenue", "Minecraft ne s'est pas fermé correctement") } }) }) ipcMain.on("disconnect", (e) => { - win.loadFile('login.html') + win.loadFile('src/client/login.html') })