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/electron>
|
||||||
- <https://www.npmjs.com/package/minecraft-launcher-core>
|
- <https://www.npmjs.com/package/minecraft-launcher-core>
|
||||||
- <https://github.com/nwutils/create-desktop-shortcuts>
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
packagerConfig: {
|
packagerConfig: {
|
||||||
packageName: "Launcher",
|
packageName: "altarik-launcher",
|
||||||
name: "Launcher",
|
name: "altarik-launcher",
|
||||||
productName: "Launcher",
|
productName: "altarik-launcher",
|
||||||
icon: path.resolve(__dirname, 'icon.png')
|
icon: path.resolve(__dirname, 'app.ico')
|
||||||
},
|
},
|
||||||
makers: [
|
makers: [
|
||||||
{
|
{
|
||||||
name: "@electron-forge/maker-squirrel",
|
name: "@electron-forge/maker-squirrel",
|
||||||
config: {
|
config: {
|
||||||
name: "Launcher",
|
name: "altarik-launcher",
|
||||||
iconUrl: path.resolve(__dirname, 'app.ico'),
|
iconUrl: path.resolve(__dirname, 'app.ico'),
|
||||||
//loadingGif: path.resolve(__dirname, 'src/assets/loading.gif'),
|
//loadingGif: path.resolve(__dirname, 'src/assets/loading.gif'),
|
||||||
setupIcon: path.resolve(__dirname, 'app.ico')
|
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",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "launcher",
|
"name": "altarik-launcher",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Launcher Projet Secret",
|
"description": "Altarik Launcher",
|
||||||
"main": "main.js",
|
"main": "src/server/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron-forge start",
|
"start": "electron-forge start",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Roboto";
|
font-family: "Roboto";
|
||||||
src: url("./Roboto-Regular.ttf") format("truetype");
|
src: url("../Roboto-Regular.ttf") format("truetype");
|
||||||
}
|
}
|
||||||
|
|
||||||
html{
|
html{
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Roboto";
|
font-family: "Roboto";
|
||||||
src: url("./Roboto-Regular.ttf") format("truetype");
|
src: url("../Roboto-Regular.ttf") format("truetype");
|
||||||
}
|
}
|
||||||
|
|
||||||
html{
|
html{
|
@ -3,7 +3,7 @@
|
|||||||
font-family: 'Material Icons';
|
font-family: 'Material Icons';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
src: url(material-icons.woff2) format('woff2');
|
src: url(../material-icons.woff2) format('woff2');
|
||||||
}
|
}
|
||||||
|
|
||||||
.material-icons {
|
.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) => {
|
document.body.onload = (e) => {
|
||||||
minMem.max = totalMem
|
minMem.max = totalMem
|
||||||
maxMem.max = totalMem
|
maxMem.max = totalMem
|
||||||
minMem.value = localStorage.getItem("minMem")
|
minMem.value = localStorage.getItem("minMem") != null ? localStorage.getItem("minMem") : 1024
|
||||||
outputMinMem.innerHTML = minMem.value
|
outputMinMem.innerHTML = minMem.value
|
||||||
maxMem.value = localStorage.getItem("maxMem")
|
maxMem.value = localStorage.getItem("maxMem") != null ? localStorage.getItem("maxMem") : 2048
|
||||||
outputMaxMem.innerHTML = maxMem.value
|
outputMaxMem.innerHTML = maxMem.value
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
const {remote} = require('electron')
|
const { remote } = require('electron')
|
||||||
const {Menu, BrowserWindow, MenuItem, shell} = remote
|
const {Menu, BrowserWindow, MenuItem, shell} = remote
|
||||||
|
|
||||||
function getCurrentWindow() {
|
function getCurrentWindow() {
|
||||||
@ -31,7 +31,7 @@ function closeWindow(browserWindow = getCurrentWindow()) {
|
|||||||
function isWindowMaximized(browserWindow = getCurrentWindow()) {
|
function isWindowMaximized(browserWindow = getCurrentWindow()) {
|
||||||
return browserWindow.isMaximized()
|
return browserWindow.isMaximized()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCurrentWindow,
|
getCurrentWindow,
|
||||||
minimizeWindow,
|
minimizeWindow,
|
@ -7,7 +7,7 @@ const {
|
|||||||
maxUnmaxWindow,
|
maxUnmaxWindow,
|
||||||
isWindowMaximized,
|
isWindowMaximized,
|
||||||
closeWindow,
|
closeWindow,
|
||||||
} = require("./include/menubar.js");
|
} = require("./assets/js/menubar.js");
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
window.getCurrentWindow = getCurrentWindow
|
window.getCurrentWindow = getCurrentWindow
|
||||||
@ -22,7 +22,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
|
|
||||||
minimizeButton.addEventListener("click", e => window.minimizeWindow())
|
minimizeButton.addEventListener("click", e => window.minimizeWindow())
|
||||||
|
|
||||||
maxUnmaxButton.addEventListener("click", e => window.maxUnmaxWindow())
|
// maxUnmaxButton.addEventListener("click", e => window.maxUnmaxWindow())
|
||||||
|
|
||||||
closeButton.addEventListener("click", e => window.closeWindow())
|
closeButton.addEventListener("click", e => window.closeWindow())
|
||||||
})
|
})
|
@ -4,10 +4,10 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Launcher Projet Secret</title>
|
<title>Launcher Projet Secret</title>
|
||||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||||
<link href="include/index.css" rel="stylesheet" />
|
<link href="assets/css/index.css" rel="stylesheet" />
|
||||||
<link href="include/menubar.css" rel="stylesheet" />
|
<link href="assets/css/menubar.css" rel="stylesheet" />
|
||||||
<link href="include/material-icons.css" rel="stylesheet" />
|
<link href="assets/css/material-icons.css" rel="stylesheet" />
|
||||||
<link rel="shortcut icon" type="image/png" href="icon.png"/>
|
<link rel="shortcut icon" type="image/png" href="assets/images/icon.png"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="menubar">
|
<div id="menubar">
|
||||||
@ -15,7 +15,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul class="right">
|
<ul class="right">
|
||||||
<!-- Mettre ce code en ligne pour éviter que chrome ne met un espace automatiquement entre les éléments -->
|
<!-- 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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<input type="range" min="1024" max="2048" step="128" value="1" class="slider" id="maxMem">
|
<input type="range" min="1024" max="2048" step="128" value="1" class="slider" id="maxMem">
|
||||||
</div>
|
</div>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<img id="main-img" src="include/maxresdefault.jpg">
|
<img id="main-img" src="assets/images/maxresdefault.jpg">
|
||||||
<div id="launch">
|
<div id="launch">
|
||||||
<button id="launch-btn">Lancer le jeu</button>
|
<button id="launch-btn">Lancer le jeu</button>
|
||||||
<div id="loading-message" class="hidden">Téléchargement de Minecraft en cours...</div>
|
<div id="loading-message" class="hidden">Téléchargement de Minecraft en cours...</div>
|
||||||
@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<script src="include/script.js"></script>
|
<script src="assets/js/script.js"></script>
|
||||||
<script src="include/index.js"></script>
|
<script src="assets/js/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -4,10 +4,10 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Launcher Projet Secret</title>
|
<title>Launcher Projet Secret</title>
|
||||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||||
<link href="include/login.css" rel="stylesheet" />
|
<link href="assets/css/login.css" rel="stylesheet" />
|
||||||
<link href="include/menubar.css" rel="stylesheet" />
|
<link href="assets/css/menubar.css" rel="stylesheet" />
|
||||||
<link href="include/material-icons.css" rel="stylesheet" />
|
<link href="assets/css/material-icons.css" rel="stylesheet" />
|
||||||
<link rel="shortcut icon" type="image/png" href="icon.png"/>
|
<link rel="shortcut icon" type="image/png" href="assets/images/icon.png"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="menubar">
|
<div id="menubar">
|
||||||
@ -15,7 +15,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul class="right">
|
<ul class="right">
|
||||||
<!-- Mettre ce code en ligne pour éviter que chrome ne met un espace automatiquement entre les éléments -->
|
<!-- 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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="include/script.js"></script>
|
<script src="assets/js/script.js"></script>
|
||||||
<script src="include/login.js"></script>
|
<script src="assets/js/login.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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 { app, BrowserWindow, Menu, ipcMain, Notification } = require('electron')
|
||||||
const path = require('path')
|
const { join } = require('path')
|
||||||
if (require('electron-squirrel-startup')) {
|
if (require('electron-squirrel-startup')) {
|
||||||
handleSquirrelEvent()
|
require("./install.js").handleSquirrelEvent(app)
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
const { Client, Authenticator } = require('minecraft-launcher-core')
|
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")
|
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 launcher = new Client();
|
||||||
const iconPath = path.join(__dirname, "icon.ico");
|
const iconPath = join(__dirname, "icon.ico");
|
||||||
let win = null
|
let win = null
|
||||||
let auth = 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 clientPackage = "https://www.dropbox.com/s/ww6a052nzzgojdm/modpack.zip?dl=1"
|
||||||
let version = "1.16.4"
|
let version = "1.16.4"
|
||||||
let versionFolder = "fabric-loader-0.10.8-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 () {
|
function createWindow () {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 1000,
|
width: 1000,
|
||||||
minWidth: 900,
|
minWidth: 1000,
|
||||||
|
maxWidth: 1000,
|
||||||
height: 600,
|
height: 600,
|
||||||
minHeight: 600,
|
minHeight: 600,
|
||||||
|
maxHeight: 600,
|
||||||
icon: iconPath,
|
icon: iconPath,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
enableRemoteModule: true
|
enableRemoteModule: true
|
||||||
},
|
},
|
||||||
frame: false
|
frame: false,
|
||||||
})
|
})
|
||||||
Menu.setApplicationMenu(null)
|
Menu.setApplicationMenu(null)
|
||||||
win.loadFile('login.html')
|
win.loadFile('src/client/login.html')
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
@ -102,7 +55,7 @@ app.on('activate', () => {
|
|||||||
ipcMain.on("login", (event, args) => {
|
ipcMain.on("login", (event, args) => {
|
||||||
auth = Authenticator.getAuth(args.user, args.pass)
|
auth = Authenticator.getAuth(args.user, args.pass)
|
||||||
auth.then(v => {
|
auth.then(v => {
|
||||||
win.loadFile('index.html')
|
win.loadFile('src/client/index.html')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
event.sender.send("nick", {
|
event.sender.send("nick", {
|
||||||
name: v.name
|
name: v.name
|
||||||
@ -150,12 +103,12 @@ ipcMain.on("launch", (event, args) => {
|
|||||||
launcher.on('close', (e) => {
|
launcher.on('close', (e) => {
|
||||||
event.sender.send("close", e)
|
event.sender.send("close", e)
|
||||||
if(e !== 0){
|
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) => {
|
ipcMain.on("disconnect", (e) => {
|
||||||
win.loadFile('login.html')
|
win.loadFile('src/client/login.html')
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user