mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-24 06:39:50 +01:00
refactored project + changed name
This commit is contained in:
parent
cbd966a695
commit
ff7aee024b
@ -4,4 +4,3 @@
|
||||
|
||||
- <https://www.npmjs.com/package/electron>
|
||||
- <https://www.npmjs.com/package/minecraft-launcher-core>
|
||||
- <https://github.com/nwutils/create-desktop-shortcuts>
|
||||
|
@ -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')
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "launcher",
|
||||
"name": "altarik-launcher",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
|
@ -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",
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
src: url("./Roboto-Regular.ttf") format("truetype");
|
||||
src: url("../Roboto-Regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
html{
|
@ -4,7 +4,7 @@
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto";
|
||||
src: url("./Roboto-Regular.ttf") format("truetype");
|
||||
src: url("../Roboto-Regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
html{
|
@ -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 {
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 453 B |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
@ -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
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {remote} = require('electron')
|
||||
const { remote } = require('electron')
|
||||
const {Menu, BrowserWindow, MenuItem, shell} = remote
|
||||
|
||||
function getCurrentWindow() {
|
@ -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())
|
||||
})
|
@ -4,10 +4,10 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Launcher Projet Secret</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<link href="include/index.css" rel="stylesheet" />
|
||||
<link href="include/menubar.css" rel="stylesheet" />
|
||||
<link href="include/material-icons.css" rel="stylesheet" />
|
||||
<link rel="shortcut icon" type="image/png" href="icon.png"/>
|
||||
<link href="assets/css/index.css" rel="stylesheet" />
|
||||
<link href="assets/css/menubar.css" rel="stylesheet" />
|
||||
<link href="assets/css/material-icons.css" rel="stylesheet" />
|
||||
<link rel="shortcut icon" type="image/png" href="assets/images/icon.png"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="menubar">
|
||||
@ -15,7 +15,7 @@
|
||||
</ul>
|
||||
<ul class="right">
|
||||
<!-- Mettre ce code en ligne pour éviter que chrome ne met un espace automatiquement entre les éléments -->
|
||||
<li id="minimize-btn"><i class="material-icons">minimize</i></li><li id="max-unmax-btn"><i class="material-icons">crop_square</i></li><li id="close-btn"><i class="material-icons">close</i></li>
|
||||
<li id="minimize-btn"><i class="material-icons">minimize</i></li><!--<li id="max-unmax-btn"><i class="material-icons">crop_square</i></li>--><li id="close-btn"><i class="material-icons">close</i></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="content">
|
||||
@ -33,7 +33,7 @@
|
||||
<input type="range" min="1024" max="2048" step="128" value="1" class="slider" id="maxMem">
|
||||
</div>
|
||||
<div id="main">
|
||||
<img id="main-img" src="include/maxresdefault.jpg">
|
||||
<img id="main-img" src="assets/images/maxresdefault.jpg">
|
||||
<div id="launch">
|
||||
<button id="launch-btn">Lancer le jeu</button>
|
||||
<div id="loading-message" class="hidden">Téléchargement de Minecraft en cours...</div>
|
||||
@ -42,7 +42,7 @@
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
<script src="include/script.js"></script>
|
||||
<script src="include/index.js"></script>
|
||||
<script src="assets/js/script.js"></script>
|
||||
<script src="assets/js/index.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -4,10 +4,10 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Launcher Projet Secret</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<link href="include/login.css" rel="stylesheet" />
|
||||
<link href="include/menubar.css" rel="stylesheet" />
|
||||
<link href="include/material-icons.css" rel="stylesheet" />
|
||||
<link rel="shortcut icon" type="image/png" href="icon.png"/>
|
||||
<link href="assets/css/login.css" rel="stylesheet" />
|
||||
<link href="assets/css/menubar.css" rel="stylesheet" />
|
||||
<link href="assets/css/material-icons.css" rel="stylesheet" />
|
||||
<link rel="shortcut icon" type="image/png" href="assets/images/icon.png"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="menubar">
|
||||
@ -15,7 +15,7 @@
|
||||
</ul>
|
||||
<ul class="right">
|
||||
<!-- Mettre ce code en ligne pour éviter que chrome ne met un espace automatiquement entre les éléments -->
|
||||
<li id="minimize-btn"><i class="material-icons">minimize</i></li><li id="max-unmax-btn"><i class="material-icons">crop_square</i></li><li id="close-btn"><i class="material-icons">close</i></li>
|
||||
<li id="minimize-btn"><i class="material-icons">minimize</i></li><!--<li id="max-unmax-btn"><i class="material-icons">crop_square</i></li>--><li id="close-btn"><i class="material-icons">close</i></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="content">
|
||||
@ -32,7 +32,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="include/script.js"></script>
|
||||
<script src="include/login.js"></script>
|
||||
<script src="assets/js/script.js"></script>
|
||||
<script src="assets/js/login.js"></script>
|
||||
</body>
|
||||
</html>
|
51
src/server/install.js
Normal file
51
src/server/install.js
Normal file
@ -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
|
||||
}
|
@ -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')
|
||||
})
|
Loading…
Reference in New Issue
Block a user