Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee0e6dec32 | ||
|
|
3b54217989 | ||
|
|
425b94fd93 | ||
|
|
e0bdcb01fb | ||
|
|
c840a49f75 | ||
|
|
c535d8b830 | ||
|
|
248a387f01 |
@@ -6,7 +6,7 @@
|
||||
|
||||
Ein Minecraft-Launcher für Windows mit getrennten Instanzen, Mod-Unterstützung und Microsoft-Anmeldung.
|
||||
|
||||
Aktueller Stand: Version 1.0.8
|
||||
Aktueller Stand: Version 1.0.9
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Generated
+222
-3
@@ -1,15 +1,18 @@
|
||||
{
|
||||
"name": "aeromc",
|
||||
"version": "1.0.7",
|
||||
"version": "1.1.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "aeromc",
|
||||
"version": "1.0.7",
|
||||
"license": "MIT",
|
||||
"version": "1.1.2",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"dependencies": {
|
||||
"@xhayper/discord-rpc": "^1.3.4",
|
||||
"archiver": "^7.0.1",
|
||||
"loopback-capture": "^3.0.2",
|
||||
"node-window-manager": "^2.2.4",
|
||||
"skinview3d": "^3.4.2",
|
||||
"undici": "^6.28.0",
|
||||
"unzipper": "^0.12.5"
|
||||
@@ -37,6 +40,56 @@
|
||||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/collection": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
|
||||
"integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/discordjs/discord.js?sponsor"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/rest": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.3.tgz",
|
||||
"integrity": "sha512-wvOylxNYJkwKjctS/Mn5GP1w9r3/rzyH+ThD1JlAca6zEdlHs8QWBBUQJpU5Q+W6DoIj/Ljh1IPlZs7hTU+UAg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@discordjs/collection": "^2.1.1",
|
||||
"@discordjs/util": "^1.2.0",
|
||||
"@sapphire/async-queue": "^1.5.3",
|
||||
"@sapphire/snowflake": "^3.5.5",
|
||||
"@vladfrangu/async_event_emitter": "^2.4.6",
|
||||
"discord-api-types": "^0.38.50",
|
||||
"magic-bytes.js": "^1.13.0",
|
||||
"tslib": "^2.6.3",
|
||||
"undici": "^6.27.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/discordjs/discord.js?sponsor"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/util": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz",
|
||||
"integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"discord-api-types": "^0.38.33"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/discordjs/discord.js?sponsor"
|
||||
}
|
||||
},
|
||||
"node_modules/@electron/asar": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz",
|
||||
@@ -494,6 +547,26 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@sapphire/async-queue": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz",
|
||||
"integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sapphire/snowflake": {
|
||||
"version": "3.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.5.tgz",
|
||||
"integrity": "sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sindresorhus/is": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz",
|
||||
@@ -662,6 +735,31 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@vladfrangu/async_event_emitter": {
|
||||
"version": "2.4.7",
|
||||
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.7.tgz",
|
||||
"integrity": "sha512-Xfe6rpCTxSxfbswi/W/Pz7zp1WWSNn4A0eW4mLkQUewCrXXtMj31lCg+iQyTkh/CkusZSq9eDflu7tjEDXUY6g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=v14.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@xhayper/discord-rpc": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@xhayper/discord-rpc/-/discord-rpc-1.3.4.tgz",
|
||||
"integrity": "sha512-ff0uEXuibh9wi+l4vOj7xInLUjtlTaQBje/SCyQkeXZ0j2V0y+Zge5PQIQFRHH9TjjGaYJkTofEcQhncM2q7/w==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^2.6.1",
|
||||
"@vladfrangu/async_event_emitter": "^2.4.7",
|
||||
"discord-api-types": "^0.38.47",
|
||||
"ws": "^8.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@xmldom/xmldom": {
|
||||
"version": "0.9.10",
|
||||
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.10.tgz",
|
||||
@@ -1128,6 +1226,15 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bl": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
||||
@@ -1799,6 +1906,15 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/discord-api-types": {
|
||||
"version": "0.38.53",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.53.tgz",
|
||||
"integrity": "sha512-HL1zz/UuZ+bbJjA/X8Kbxx9gk8v9rJAbTeWRNYKmIdjwJ7EovjlHgoJTxcLpATfNJ+AonOtMdy3Y5MVIJAAd/A==",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"scripts/actions/documentation"
|
||||
]
|
||||
},
|
||||
"node_modules/dmg-builder": {
|
||||
"version": "24.13.3",
|
||||
"resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-24.13.3.tgz",
|
||||
@@ -2493,6 +2609,22 @@
|
||||
"bare-events": "^2.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/extract-file-icon": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/extract-file-icon/-/extract-file-icon-0.3.2.tgz",
|
||||
"integrity": "sha512-We5/HaMDlioOx3c9zDjit8RtKWEvT94sJF8jTujaKVOyWL8Kkqu4QGnwDr5fID6XsbKvWT0JJNuWuV2Tmr7yiw==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"node-addon-api": "1.7.1"
|
||||
}
|
||||
},
|
||||
"node_modules/extract-file-icon/node_modules/node-addon-api": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.1.tgz",
|
||||
"integrity": "sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/extract-zip": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
|
||||
@@ -2561,6 +2693,12 @@
|
||||
"integrity": "sha512-3JyEFWGjFn7zHmoa9+zG1BmW7X2okcmAB+0Cnu9UFbVs/jCBnl2A8o065ZlXiw145K3eBM3uLuzrYXC0RK7eDg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/filelist": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz",
|
||||
@@ -3340,6 +3478,25 @@
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/loopback-capture": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/loopback-capture/-/loopback-capture-3.0.2.tgz",
|
||||
"integrity": "sha512-65qyF9L7e+InnbEZP3Ic4C4J+SszoxEq84XpIZWJYH3/IgUpTKqBzJ4wCF+ShL3bvqV7I2wOEgQv9VfpaO2AMw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"os": [
|
||||
"linux",
|
||||
"win32"
|
||||
],
|
||||
"dependencies": {
|
||||
"bindings": "^1.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lowercase-keys": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz",
|
||||
@@ -3363,6 +3520,12 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-bytes.js": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.13.1.tgz",
|
||||
"integrity": "sha512-x5sn4UX2k5gCWlcfmoFwG4TPie8+dctESyqOBdhB5p6MsgWXdBKGmt9nXPObj/JI50TTL928lc5Yt1WntMn1bw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/matcher": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz",
|
||||
@@ -3525,12 +3688,41 @@
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/node-gyp-build": {
|
||||
"version": "4.8.4",
|
||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
|
||||
"integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"node-gyp-build": "bin.js",
|
||||
"node-gyp-build-optional": "optional.js",
|
||||
"node-gyp-build-test": "build-test.js"
|
||||
}
|
||||
},
|
||||
"node_modules/node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
"integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-window-manager": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/node-window-manager/-/node-window-manager-2.2.4.tgz",
|
||||
"integrity": "sha512-Dgq9a7qx6+Gi+BifWM79leteNz76QUtwSsdiqEe7SjvoJsc8TYQsRl1IA5uxqz5iSLeHS1iA/8YI/snoq0DblA==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"extract-file-icon": "^0.3.2",
|
||||
"node-addon-api": "2.0.0",
|
||||
"node-gyp-build": "^4.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/node-window-manager/node_modules/node-addon-api": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.0.tgz",
|
||||
"integrity": "sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/normalize-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||
@@ -4318,6 +4510,12 @@
|
||||
"utf8-byte-length": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/type-fest": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",
|
||||
@@ -4517,6 +4715,27 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.21.3",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz",
|
||||
"integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xmlbuilder": {
|
||||
"version": "15.1.1",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz",
|
||||
|
||||
+8
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "aeromc",
|
||||
"productName": "AeroMC",
|
||||
"version": "1.0.8",
|
||||
"version": "1.1.2",
|
||||
"description": "AeroMC – Instanz-basierter Minecraft-Launcher (à la MultiMC/Prism)",
|
||||
"homepage": "https://m-viper.de",
|
||||
"launcherWebsite": "https://aeromc.viper.ipv64.net",
|
||||
@@ -26,6 +26,10 @@
|
||||
"package.json",
|
||||
"LICENSE"
|
||||
],
|
||||
"asarUnpack": [
|
||||
"node_modules/loopback-capture/**/*",
|
||||
"node_modules/node-window-manager/**/*"
|
||||
],
|
||||
"win": {
|
||||
"target": "nsis",
|
||||
"icon": "src/assets/icon.ico"
|
||||
@@ -40,7 +44,10 @@
|
||||
"electron-builder": "^24.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@xhayper/discord-rpc": "^1.3.4",
|
||||
"archiver": "^7.0.1",
|
||||
"loopback-capture": "^3.0.2",
|
||||
"node-window-manager": "^2.2.4",
|
||||
"skinview3d": "^3.4.2",
|
||||
"undici": "^6.28.0",
|
||||
"unzipper": "^0.12.5"
|
||||
|
||||
+451
-439
@@ -1,440 +1,452 @@
|
||||
'use strict';
|
||||
|
||||
const archiver = require('archiver');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const { pipeline } = require('stream/promises');
|
||||
const unzipper = require('unzipper');
|
||||
|
||||
function pad2(value) {
|
||||
return String(value).padStart(2, '0');
|
||||
}
|
||||
|
||||
function defaultBackupFileName(date = new Date()) {
|
||||
return 'AeroMC-Backup-' +
|
||||
date.getFullYear() + '-' +
|
||||
pad2(date.getMonth() + 1) + '-' +
|
||||
pad2(date.getDate()) + '_' +
|
||||
pad2(date.getHours()) + '-' +
|
||||
pad2(date.getMinutes()) + '-' +
|
||||
pad2(date.getSeconds()) +
|
||||
'.zip';
|
||||
}
|
||||
|
||||
function defaultBackupDir(documentsDir) {
|
||||
return path.join(documentsDir, 'AeroMC Launcher', 'Backups');
|
||||
}
|
||||
|
||||
function resolveAutoBackupPath(documentsDir, date = new Date()) {
|
||||
const dir = defaultBackupDir(documentsDir);
|
||||
ensureDir(dir);
|
||||
|
||||
const baseName = defaultBackupFileName(date);
|
||||
const ext = path.extname(baseName);
|
||||
const stem = baseName.slice(0, -ext.length);
|
||||
let attempt = 0;
|
||||
let candidate = path.join(dir, baseName);
|
||||
|
||||
while (fs.existsSync(candidate)) {
|
||||
attempt += 1;
|
||||
candidate = path.join(dir, `${stem}-${attempt}${ext}`);
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
function listGlobalBackups(documentsDir) {
|
||||
const dir = defaultBackupDir(documentsDir);
|
||||
ensureDir(dir);
|
||||
|
||||
return fs.readdirSync(dir, { withFileTypes: true })
|
||||
.filter((entry) => entry.isFile() && /\.zip$/i.test(entry.name) && !/\.partial\.zip$/i.test(entry.name))
|
||||
.map((entry) => {
|
||||
const filePath = path.join(dir, entry.name);
|
||||
const stat = fs.statSync(filePath);
|
||||
return {
|
||||
name: entry.name,
|
||||
path: filePath,
|
||||
size: stat.size,
|
||||
modifiedAt: stat.mtime.toISOString(),
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
const timeDiff = new Date(b.modifiedAt).getTime() - new Date(a.modifiedAt).getTime();
|
||||
return timeDiff || a.name.localeCompare(b.name, 'de');
|
||||
});
|
||||
}
|
||||
|
||||
function ensureDir(dir) {
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
function countInstanceDirs(instancesDir) {
|
||||
if (!fs.existsSync(instancesDir)) return 0;
|
||||
return fs.readdirSync(instancesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).length;
|
||||
}
|
||||
|
||||
function readJson(file, fallback) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJson(file, data) {
|
||||
ensureDir(path.dirname(file));
|
||||
fs.writeFileSync(file, JSON.stringify(data, null, 2), 'utf8');
|
||||
}
|
||||
|
||||
function emitProgress(cb, mode, percent, detail) {
|
||||
if (!cb) return;
|
||||
cb({ mode, percent: Math.max(0, Math.min(100, Math.round(percent))), detail: detail || '' });
|
||||
}
|
||||
|
||||
function normalizeZipEntryPath(entryPath) {
|
||||
const parts = String(entryPath || '')
|
||||
.replace(/\\/g, '/')
|
||||
.split('/')
|
||||
.filter(Boolean);
|
||||
|
||||
if (!parts.length) return '';
|
||||
if (parts.some((part) => part === '.' || part === '..')) {
|
||||
throw new Error('Das Backup-Archiv enthält ungültige Pfade.');
|
||||
}
|
||||
|
||||
return path.join(...parts);
|
||||
}
|
||||
|
||||
async function extractBackupArchive(sourcePath, destinationDir, options) {
|
||||
const opts = options || {};
|
||||
const onProgress = opts.onProgress;
|
||||
const mode = opts.mode || 'restore';
|
||||
const startPercent = opts.startPercent ?? 5;
|
||||
const endPercent = opts.endPercent ?? 18;
|
||||
const detail = opts.detail || 'Entpacke Backup';
|
||||
const directory = await unzipper.Open.file(sourcePath);
|
||||
const files = directory.files || [];
|
||||
const fileEntries = files.filter((entry) => entry.type !== 'Directory');
|
||||
const totalBytes = fileEntries.reduce((sum, entry) => sum + Number(entry.uncompressedSize || 0), 0);
|
||||
let processedBytes = 0;
|
||||
let processedEntries = 0;
|
||||
|
||||
ensureDir(destinationDir);
|
||||
if (!files.length) {
|
||||
emitProgress(onProgress, mode, endPercent, detail + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
for (const entry of files) {
|
||||
const relativePath = normalizeZipEntryPath(entry.path);
|
||||
if (!relativePath) continue;
|
||||
|
||||
const targetPath = path.join(destinationDir, relativePath);
|
||||
if (entry.type === 'Directory') {
|
||||
ensureDir(targetPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
ensureDir(path.dirname(targetPath));
|
||||
await pipeline(entry.stream(), fs.createWriteStream(targetPath));
|
||||
|
||||
processedBytes += Number(entry.uncompressedSize || 0);
|
||||
processedEntries += 1;
|
||||
const ratio = totalBytes > 0
|
||||
? Math.max(0, Math.min(1, processedBytes / totalBytes))
|
||||
: Math.max(0, Math.min(1, processedEntries / Math.max(1, fileEntries.length)));
|
||||
const percent = startPercent + ((endPercent - startPercent) * ratio);
|
||||
emitProgress(onProgress, mode, percent, detail + ' ...');
|
||||
}
|
||||
}
|
||||
|
||||
function createBackupArchive(options) {
|
||||
const opts = options || {};
|
||||
const instancesDir = opts.instancesDir;
|
||||
const settingsFile = opts.settingsFile;
|
||||
const includeSettings = opts.includeSettings !== false;
|
||||
const backupInfo = opts.backupInfo || {};
|
||||
const destinationPath = opts.destinationPath;
|
||||
const onProgress = opts.onProgress;
|
||||
const mode = opts.mode || 'create';
|
||||
const startPercent = opts.startPercent ?? 15;
|
||||
const endPercent = opts.endPercent ?? 98;
|
||||
const detail = opts.detail || 'Packe ZIP-Archiv';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ensureDir(path.dirname(destinationPath));
|
||||
|
||||
const output = fs.createWriteStream(destinationPath);
|
||||
const archive = archiver('zip', { store: true });
|
||||
let done = false;
|
||||
|
||||
const fail = (err) => {
|
||||
if (done) return;
|
||||
done = true;
|
||||
try { archive.destroy(); } catch { /* ignore */ }
|
||||
try { output.destroy(); } catch { /* ignore */ }
|
||||
reject(err);
|
||||
};
|
||||
|
||||
output.on('close', () => {
|
||||
if (done) return;
|
||||
done = true;
|
||||
resolve({ bytes: archive.pointer() });
|
||||
});
|
||||
output.on('error', fail);
|
||||
archive.on('error', fail);
|
||||
archive.on('warning', (err) => {
|
||||
if (err && err.code === 'ENOENT') return;
|
||||
fail(err);
|
||||
});
|
||||
archive.on('progress', (progress) => {
|
||||
const totalBytes = progress && progress.fs ? progress.fs.totalBytes : 0;
|
||||
const processedBytes = progress && progress.fs ? progress.fs.processedBytes : 0;
|
||||
if (!totalBytes) return;
|
||||
|
||||
const ratio = Math.max(0, Math.min(1, processedBytes / totalBytes));
|
||||
const percent = startPercent + ((endPercent - startPercent) * ratio);
|
||||
emitProgress(onProgress, mode, percent, detail + ' ...');
|
||||
});
|
||||
|
||||
archive.pipe(output);
|
||||
if (fs.existsSync(instancesDir)) archive.directory(instancesDir, 'instances');
|
||||
else archive.append('', { name: 'instances/.keep' });
|
||||
|
||||
if (includeSettings && settingsFile && fs.existsSync(settingsFile)) {
|
||||
archive.file(settingsFile, { name: 'settings.json' });
|
||||
}
|
||||
|
||||
archive.append(`${JSON.stringify(backupInfo, null, 2)}\n`, { name: 'backup-info.json' });
|
||||
|
||||
try {
|
||||
const finalizeResult = archive.finalize();
|
||||
if (finalizeResult && typeof finalizeResult.catch === 'function') finalizeResult.catch(fail);
|
||||
} catch (err) {
|
||||
fail(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function copyDirContentsTracked(sourceDir, targetDir, options) {
|
||||
const opts = options || {};
|
||||
const mode = opts.mode || 'create';
|
||||
const onProgress = opts.onProgress;
|
||||
const startPercent = opts.startPercent ?? 0;
|
||||
const endPercent = opts.endPercent ?? 100;
|
||||
const detailPrefix = opts.detailPrefix || 'Kopiere';
|
||||
|
||||
ensureDir(targetDir);
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
const entries = fs.readdirSync(sourceDir, { withFileTypes: true });
|
||||
if (!entries.length) {
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
entries.forEach((entry, index) => {
|
||||
fs.cpSync(path.join(sourceDir, entry.name), path.join(targetDir, entry.name), { recursive: true });
|
||||
const ratio = (index + 1) / entries.length;
|
||||
const percent = startPercent + ((endPercent - startPercent) * ratio);
|
||||
emitProgress(onProgress, mode, percent, `${detailPrefix}: ${entry.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
function moveDirTracked(sourceDir, targetDir, options) {
|
||||
const opts = options || {};
|
||||
const mode = opts.mode || 'restore';
|
||||
const onProgress = opts.onProgress;
|
||||
const startPercent = opts.startPercent ?? 0;
|
||||
const endPercent = opts.endPercent ?? 100;
|
||||
const detailPrefix = opts.detailPrefix || 'Verschiebe';
|
||||
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
ensureDir(path.dirname(targetDir));
|
||||
try {
|
||||
fs.renameSync(sourceDir, targetDir);
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
} catch (err) {
|
||||
if (!err || !['EXDEV', 'EPERM', 'EACCES'].includes(err.code)) throw err;
|
||||
}
|
||||
|
||||
copyDirContentsTracked(sourceDir, targetDir, opts);
|
||||
try { fs.rmSync(sourceDir, { recursive: true, force: true }); } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
function resolveExtractedBackupRoot(extractDir) {
|
||||
if (fs.existsSync(path.join(extractDir, 'instances'))) return extractDir;
|
||||
const entries = fs.readdirSync(extractDir, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
||||
if (entries.length === 1) {
|
||||
const nested = path.join(extractDir, entries[0].name);
|
||||
if (fs.existsSync(path.join(nested, 'instances'))) return nested;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function createGlobalBackup(options) {
|
||||
const instancesDir = options && options.instancesDir;
|
||||
const userDataDir = options && options.userDataDir;
|
||||
const destinationPath = options && options.destinationPath;
|
||||
const includeSettings = !options || options.includeSettings !== false;
|
||||
const onProgress = options && options.onProgress;
|
||||
if (!instancesDir || !userDataDir || !destinationPath) throw new Error('Backup-Parameter unvollständig.');
|
||||
|
||||
const settingsFile = path.join(userDataDir, 'settings.json');
|
||||
const workingArchivePath = destinationPath.replace(/\.zip$/i, '') + '.partial.zip';
|
||||
const backupInfo = {
|
||||
createdAt: new Date().toISOString(),
|
||||
instanceCount: countInstanceDirs(instancesDir),
|
||||
includeSettings,
|
||||
app: 'AeroMC',
|
||||
version: 1,
|
||||
};
|
||||
|
||||
try {
|
||||
emitProgress(onProgress, 'create', 5, 'Bereite Backup vor');
|
||||
emitProgress(onProgress, 'create', 10, 'Ermittle Backup-Inhalt');
|
||||
|
||||
if (fs.existsSync(destinationPath)) fs.unlinkSync(destinationPath);
|
||||
if (fs.existsSync(workingArchivePath)) fs.unlinkSync(workingArchivePath);
|
||||
emitProgress(onProgress, 'create', 90, 'Packe ZIP-Archiv');
|
||||
await createBackupArchive({
|
||||
instancesDir,
|
||||
settingsFile,
|
||||
includeSettings,
|
||||
backupInfo,
|
||||
destinationPath: workingArchivePath,
|
||||
mode: 'create',
|
||||
onProgress,
|
||||
startPercent: 15,
|
||||
endPercent: 98,
|
||||
detail: 'Packe ZIP-Archiv',
|
||||
});
|
||||
emitProgress(onProgress, 'create', 99, 'Finalisiere Backup');
|
||||
fs.renameSync(workingArchivePath, destinationPath);
|
||||
emitProgress(onProgress, 'create', 100, 'Backup abgeschlossen');
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
path: destinationPath,
|
||||
instanceCount: countInstanceDirs(instancesDir),
|
||||
includedSettings: includeSettings && fs.existsSync(settingsFile),
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (fs.existsSync(workingArchivePath)) fs.rmSync(workingArchivePath, { force: true });
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreGlobalBackup(options) {
|
||||
const instancesDir = options && options.instancesDir;
|
||||
const userDataDir = options && options.userDataDir;
|
||||
const sourcePath = options && options.sourcePath;
|
||||
const includeSettings = !!(options && options.includeSettings);
|
||||
const onProgress = options && options.onProgress;
|
||||
const instancesDirSetting = options && Object.prototype.hasOwnProperty.call(options, 'instancesDirSetting')
|
||||
? options.instancesDirSetting
|
||||
: null;
|
||||
if (!instancesDir || !userDataDir || !sourcePath) throw new Error('Restore-Parameter unvollständig.');
|
||||
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'aeromc-restore-'));
|
||||
const extractDir = path.join(tmp, 'extract');
|
||||
const rollbackDir = path.join(tmp, 'rollback');
|
||||
const rollbackInstances = path.join(rollbackDir, 'instances');
|
||||
const settingsFile = path.join(userDataDir, 'settings.json');
|
||||
const rollbackSettings = path.join(rollbackDir, 'settings.json');
|
||||
let settingsPreviouslyExisted = false;
|
||||
|
||||
try {
|
||||
ensureDir(extractDir);
|
||||
emitProgress(onProgress, 'restore', 5, 'Entpacke Backup');
|
||||
await extractBackupArchive(sourcePath, extractDir, {
|
||||
mode: 'restore',
|
||||
onProgress,
|
||||
startPercent: 5,
|
||||
endPercent: 18,
|
||||
detail: 'Entpacke Backup',
|
||||
});
|
||||
|
||||
const backupRoot = resolveExtractedBackupRoot(extractDir);
|
||||
if (!backupRoot) throw new Error('Das Archiv enthält kein gültiges AeroMC-Backup.');
|
||||
emitProgress(onProgress, 'restore', 18, 'Backup geprüft');
|
||||
|
||||
const sourceInstances = path.join(backupRoot, 'instances');
|
||||
const sourceSettings = path.join(backupRoot, 'settings.json');
|
||||
ensureDir(rollbackDir);
|
||||
|
||||
emitProgress(onProgress, 'restore', 25, 'Sichere aktuellen Stand');
|
||||
moveDirTracked(instancesDir, rollbackInstances, {
|
||||
mode: 'restore',
|
||||
onProgress,
|
||||
startPercent: 28,
|
||||
endPercent: 40,
|
||||
detailPrefix: 'Sichere aktuelle Instanzen',
|
||||
});
|
||||
settingsPreviouslyExisted = fs.existsSync(settingsFile);
|
||||
if (settingsPreviouslyExisted) fs.copyFileSync(settingsFile, rollbackSettings);
|
||||
|
||||
ensureDir(path.dirname(instancesDir));
|
||||
moveDirTracked(sourceInstances, instancesDir, {
|
||||
mode: 'restore',
|
||||
onProgress,
|
||||
startPercent: 45,
|
||||
endPercent: 78,
|
||||
detailPrefix: 'Stelle Instanzen wieder her',
|
||||
});
|
||||
|
||||
let restoredSettings = false;
|
||||
if (includeSettings && fs.existsSync(sourceSettings)) {
|
||||
const restored = readJson(sourceSettings, {});
|
||||
restored.instancesDir = instancesDirSetting;
|
||||
writeJson(settingsFile, restored);
|
||||
restoredSettings = true;
|
||||
emitProgress(onProgress, 'restore', 90, 'Stelle Einstellungen wieder her');
|
||||
} else {
|
||||
emitProgress(onProgress, 'restore', 90, 'Einstellungen übersprungen');
|
||||
}
|
||||
|
||||
emitProgress(onProgress, 'restore', 100, 'Wiederherstellen abgeschlossen');
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
path: sourcePath,
|
||||
instanceCount: countInstanceDirs(instancesDir),
|
||||
restoredSettings,
|
||||
};
|
||||
} catch (err) {
|
||||
try {
|
||||
if (fs.existsSync(instancesDir)) fs.rmSync(instancesDir, { recursive: true, force: true });
|
||||
if (fs.existsSync(rollbackInstances)) fs.cpSync(rollbackInstances, instancesDir, { recursive: true });
|
||||
else ensureDir(instancesDir);
|
||||
|
||||
if (includeSettings) {
|
||||
if (fs.existsSync(rollbackSettings)) fs.copyFileSync(rollbackSettings, settingsFile);
|
||||
else if (!settingsPreviouslyExisted && fs.existsSync(settingsFile)) fs.rmSync(settingsFile, { force: true });
|
||||
}
|
||||
} catch { /* ignore rollback errors */ }
|
||||
throw err;
|
||||
} finally {
|
||||
try { fs.rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createGlobalBackup,
|
||||
restoreGlobalBackup,
|
||||
defaultBackupFileName,
|
||||
defaultBackupDir,
|
||||
listGlobalBackups,
|
||||
resolveAutoBackupPath,
|
||||
'use strict';
|
||||
|
||||
const archiver = require('archiver');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const { pipeline } = require('stream/promises');
|
||||
const unzipper = require('unzipper');
|
||||
|
||||
function pad2(value) {
|
||||
return String(value).padStart(2, '0');
|
||||
}
|
||||
|
||||
function defaultBackupFileName(date = new Date()) {
|
||||
return 'AeroMC-Backup-' +
|
||||
date.getFullYear() + '-' +
|
||||
pad2(date.getMonth() + 1) + '-' +
|
||||
pad2(date.getDate()) + '_' +
|
||||
pad2(date.getHours()) + '-' +
|
||||
pad2(date.getMinutes()) + '-' +
|
||||
pad2(date.getSeconds()) +
|
||||
'.zip';
|
||||
}
|
||||
|
||||
function defaultBackupDir(documentsDir) {
|
||||
return path.join(documentsDir, 'AeroMC Launcher', 'Backups');
|
||||
}
|
||||
|
||||
function resolveAutoBackupPath(documentsDir, date = new Date()) {
|
||||
const dir = defaultBackupDir(documentsDir);
|
||||
ensureDir(dir);
|
||||
|
||||
const baseName = defaultBackupFileName(date);
|
||||
const ext = path.extname(baseName);
|
||||
const stem = baseName.slice(0, -ext.length);
|
||||
let attempt = 0;
|
||||
let candidate = path.join(dir, baseName);
|
||||
|
||||
while (fs.existsSync(candidate)) {
|
||||
attempt += 1;
|
||||
candidate = path.join(dir, `${stem}-${attempt}${ext}`);
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
function listGlobalBackups(documentsDir) {
|
||||
const dir = defaultBackupDir(documentsDir);
|
||||
ensureDir(dir);
|
||||
|
||||
return fs.readdirSync(dir, { withFileTypes: true })
|
||||
.filter((entry) => entry.isFile() && /\.zip$/i.test(entry.name) && !/\.partial\.zip$/i.test(entry.name))
|
||||
.map((entry) => {
|
||||
const filePath = path.join(dir, entry.name);
|
||||
const stat = fs.statSync(filePath);
|
||||
return {
|
||||
name: entry.name,
|
||||
path: filePath,
|
||||
size: stat.size,
|
||||
modifiedAt: stat.mtime.toISOString(),
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
const timeDiff = new Date(b.modifiedAt).getTime() - new Date(a.modifiedAt).getTime();
|
||||
return timeDiff || a.name.localeCompare(b.name, 'de');
|
||||
});
|
||||
}
|
||||
|
||||
function ensureDir(dir) {
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
function countInstanceDirs(instancesDir) {
|
||||
if (!fs.existsSync(instancesDir)) return 0;
|
||||
return fs.readdirSync(instancesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).length;
|
||||
}
|
||||
|
||||
function readJson(file, fallback) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function writeJson(file, data) {
|
||||
ensureDir(path.dirname(file));
|
||||
fs.writeFileSync(file, JSON.stringify(data, null, 2), 'utf8');
|
||||
}
|
||||
|
||||
function emitProgress(cb, mode, percent, detail) {
|
||||
if (!cb) return;
|
||||
cb({ mode, percent: Math.max(0, Math.min(100, Math.round(percent))), detail: detail || '' });
|
||||
}
|
||||
|
||||
function normalizeZipEntryPath(entryPath) {
|
||||
const parts = String(entryPath || '')
|
||||
.replace(/\\/g, '/')
|
||||
.split('/')
|
||||
.filter(Boolean);
|
||||
|
||||
if (!parts.length) return '';
|
||||
if (parts.some((part) => part === '.' || part === '..')) {
|
||||
throw new Error('Das Backup-Archiv enthält ungültige Pfade.');
|
||||
}
|
||||
|
||||
return path.join(...parts);
|
||||
}
|
||||
|
||||
async function extractBackupArchive(sourcePath, destinationDir, options) {
|
||||
const opts = options || {};
|
||||
const onProgress = opts.onProgress;
|
||||
const mode = opts.mode || 'restore';
|
||||
const startPercent = opts.startPercent ?? 5;
|
||||
const endPercent = opts.endPercent ?? 18;
|
||||
const detail = opts.detail || 'Entpacke Backup';
|
||||
const directory = await unzipper.Open.file(sourcePath);
|
||||
const files = directory.files || [];
|
||||
const fileEntries = files.filter((entry) => entry.type !== 'Directory');
|
||||
const totalBytes = fileEntries.reduce((sum, entry) => sum + Number(entry.uncompressedSize || 0), 0);
|
||||
let processedBytes = 0;
|
||||
let processedEntries = 0;
|
||||
|
||||
ensureDir(destinationDir);
|
||||
if (!files.length) {
|
||||
emitProgress(onProgress, mode, endPercent, detail + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
for (const entry of files) {
|
||||
const relativePath = normalizeZipEntryPath(entry.path);
|
||||
if (!relativePath) continue;
|
||||
|
||||
const targetPath = path.join(destinationDir, relativePath);
|
||||
if (entry.type === 'Directory') {
|
||||
ensureDir(targetPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
ensureDir(path.dirname(targetPath));
|
||||
await pipeline(entry.stream(), fs.createWriteStream(targetPath));
|
||||
|
||||
processedBytes += Number(entry.uncompressedSize || 0);
|
||||
processedEntries += 1;
|
||||
const ratio = totalBytes > 0
|
||||
? Math.max(0, Math.min(1, processedBytes / totalBytes))
|
||||
: Math.max(0, Math.min(1, processedEntries / Math.max(1, fileEntries.length)));
|
||||
const percent = startPercent + ((endPercent - startPercent) * ratio);
|
||||
emitProgress(onProgress, mode, percent, detail + ' ...');
|
||||
}
|
||||
}
|
||||
|
||||
function createBackupArchive(options) {
|
||||
const opts = options || {};
|
||||
const instancesDir = opts.instancesDir;
|
||||
const settingsFile = opts.settingsFile;
|
||||
const includeSettings = opts.includeSettings !== false;
|
||||
const backupInfo = opts.backupInfo || {};
|
||||
const destinationPath = opts.destinationPath;
|
||||
const onProgress = opts.onProgress;
|
||||
const mode = opts.mode || 'create';
|
||||
const startPercent = opts.startPercent ?? 15;
|
||||
const endPercent = opts.endPercent ?? 98;
|
||||
const detail = opts.detail || 'Packe ZIP-Archiv';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ensureDir(path.dirname(destinationPath));
|
||||
|
||||
const output = fs.createWriteStream(destinationPath);
|
||||
const archive = archiver('zip', { store: true });
|
||||
let done = false;
|
||||
|
||||
const fail = (err) => {
|
||||
if (done) return;
|
||||
done = true;
|
||||
try { archive.destroy(); } catch { /* ignore */ }
|
||||
try { output.destroy(); } catch { /* ignore */ }
|
||||
reject(err);
|
||||
};
|
||||
|
||||
output.on('close', () => {
|
||||
if (done) return;
|
||||
done = true;
|
||||
resolve({ bytes: archive.pointer() });
|
||||
});
|
||||
output.on('error', fail);
|
||||
archive.on('error', fail);
|
||||
archive.on('warning', (err) => {
|
||||
if (err && err.code === 'ENOENT') return;
|
||||
fail(err);
|
||||
});
|
||||
archive.on('progress', (progress) => {
|
||||
const totalBytes = progress && progress.fs ? progress.fs.totalBytes : 0;
|
||||
const processedBytes = progress && progress.fs ? progress.fs.processedBytes : 0;
|
||||
if (!totalBytes) return;
|
||||
|
||||
const ratio = Math.max(0, Math.min(1, processedBytes / totalBytes));
|
||||
const percent = startPercent + ((endPercent - startPercent) * ratio);
|
||||
emitProgress(onProgress, mode, percent, detail + ' ...');
|
||||
});
|
||||
|
||||
archive.pipe(output);
|
||||
if (fs.existsSync(instancesDir)) archive.directory(instancesDir, 'instances');
|
||||
else archive.append('', { name: 'instances/.keep' });
|
||||
|
||||
if (includeSettings && settingsFile && fs.existsSync(settingsFile)) {
|
||||
archive.file(settingsFile, { name: 'settings.json' });
|
||||
}
|
||||
|
||||
archive.append(`${JSON.stringify(backupInfo, null, 2)}\n`, { name: 'backup-info.json' });
|
||||
|
||||
try {
|
||||
const finalizeResult = archive.finalize();
|
||||
if (finalizeResult && typeof finalizeResult.catch === 'function') finalizeResult.catch(fail);
|
||||
} catch (err) {
|
||||
fail(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function copyDirContentsTracked(sourceDir, targetDir, options) {
|
||||
const opts = options || {};
|
||||
const mode = opts.mode || 'create';
|
||||
const onProgress = opts.onProgress;
|
||||
const startPercent = opts.startPercent ?? 0;
|
||||
const endPercent = opts.endPercent ?? 100;
|
||||
const detailPrefix = opts.detailPrefix || 'Kopiere';
|
||||
|
||||
ensureDir(targetDir);
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
const entries = fs.readdirSync(sourceDir, { withFileTypes: true });
|
||||
if (!entries.length) {
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
entries.forEach((entry, index) => {
|
||||
fs.cpSync(path.join(sourceDir, entry.name), path.join(targetDir, entry.name), { recursive: true });
|
||||
const ratio = (index + 1) / entries.length;
|
||||
const percent = startPercent + ((endPercent - startPercent) * ratio);
|
||||
emitProgress(onProgress, mode, percent, `${detailPrefix}: ${entry.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
function moveDirTracked(sourceDir, targetDir, options) {
|
||||
const opts = options || {};
|
||||
const mode = opts.mode || 'restore';
|
||||
const onProgress = opts.onProgress;
|
||||
const startPercent = opts.startPercent ?? 0;
|
||||
const endPercent = opts.endPercent ?? 100;
|
||||
const detailPrefix = opts.detailPrefix || 'Verschiebe';
|
||||
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
}
|
||||
|
||||
ensureDir(path.dirname(targetDir));
|
||||
try {
|
||||
fs.renameSync(sourceDir, targetDir);
|
||||
emitProgress(onProgress, mode, endPercent, detailPrefix + ' abgeschlossen');
|
||||
return;
|
||||
} catch (err) {
|
||||
if (!err || !['EXDEV', 'EPERM', 'EACCES'].includes(err.code)) throw err;
|
||||
}
|
||||
|
||||
copyDirContentsTracked(sourceDir, targetDir, opts);
|
||||
try { fs.rmSync(sourceDir, { recursive: true, force: true }); } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
function resolveExtractedBackupRoot(extractDir) {
|
||||
if (fs.existsSync(path.join(extractDir, 'instances'))) return extractDir;
|
||||
const entries = fs.readdirSync(extractDir, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
||||
if (entries.length === 1) {
|
||||
const nested = path.join(extractDir, entries[0].name);
|
||||
if (fs.existsSync(path.join(nested, 'instances'))) return nested;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function createGlobalBackup(options) {
|
||||
const instancesDir = options && options.instancesDir;
|
||||
const userDataDir = options && options.userDataDir;
|
||||
const destinationPath = options && options.destinationPath;
|
||||
const includeSettings = !options || options.includeSettings !== false;
|
||||
const onProgress = options && options.onProgress;
|
||||
if (!instancesDir || !userDataDir || !destinationPath) throw new Error('Backup-Parameter unvollständig.');
|
||||
|
||||
const settingsFile = path.join(userDataDir, 'settings.json');
|
||||
const workingArchivePath = destinationPath.replace(/\.zip$/i, '') + '.partial.zip';
|
||||
const backupInfo = {
|
||||
createdAt: new Date().toISOString(),
|
||||
instanceCount: countInstanceDirs(instancesDir),
|
||||
includeSettings,
|
||||
app: 'AeroMC',
|
||||
version: 1,
|
||||
};
|
||||
|
||||
try {
|
||||
emitProgress(onProgress, 'create', 5, 'Bereite Backup vor');
|
||||
emitProgress(onProgress, 'create', 10, 'Ermittle Backup-Inhalt');
|
||||
|
||||
if (fs.existsSync(destinationPath)) fs.unlinkSync(destinationPath);
|
||||
if (fs.existsSync(workingArchivePath)) fs.unlinkSync(workingArchivePath);
|
||||
emitProgress(onProgress, 'create', 90, 'Packe ZIP-Archiv');
|
||||
await createBackupArchive({
|
||||
instancesDir,
|
||||
settingsFile,
|
||||
includeSettings,
|
||||
backupInfo,
|
||||
destinationPath: workingArchivePath,
|
||||
mode: 'create',
|
||||
onProgress,
|
||||
startPercent: 15,
|
||||
endPercent: 98,
|
||||
detail: 'Packe ZIP-Archiv',
|
||||
});
|
||||
emitProgress(onProgress, 'create', 99, 'Finalisiere Backup');
|
||||
fs.renameSync(workingArchivePath, destinationPath);
|
||||
emitProgress(onProgress, 'create', 100, 'Backup abgeschlossen');
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
path: destinationPath,
|
||||
instanceCount: countInstanceDirs(instancesDir),
|
||||
includedSettings: includeSettings && fs.existsSync(settingsFile),
|
||||
};
|
||||
} finally {
|
||||
try {
|
||||
if (fs.existsSync(workingArchivePath)) fs.rmSync(workingArchivePath, { force: true });
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreGlobalBackup(options) {
|
||||
const instancesDir = options && options.instancesDir;
|
||||
const userDataDir = options && options.userDataDir;
|
||||
const sourcePath = options && options.sourcePath;
|
||||
const includeSettings = !!(options && options.includeSettings);
|
||||
const onProgress = options && options.onProgress;
|
||||
const instancesDirSetting = options && Object.prototype.hasOwnProperty.call(options, 'instancesDirSetting')
|
||||
? options.instancesDirSetting
|
||||
: null;
|
||||
if (!instancesDir || !userDataDir || !sourcePath) throw new Error('Restore-Parameter unvollständig.');
|
||||
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'aeromc-restore-'));
|
||||
const extractDir = path.join(tmp, 'extract');
|
||||
const rollbackDir = path.join(tmp, 'rollback');
|
||||
const rollbackInstances = path.join(rollbackDir, 'instances');
|
||||
const settingsFile = path.join(userDataDir, 'settings.json');
|
||||
const rollbackSettings = path.join(rollbackDir, 'settings.json');
|
||||
let settingsPreviouslyExisted = false;
|
||||
// wird erst true, sobald der aktuelle Stand tatsächlich weggesichert wurde -
|
||||
// vorher darf der Rollback nichts anfassen, sonst löscht ein früher Fehler
|
||||
// (z. B. ungültiges Archiv) den unveränderten, intakten Originalbestand
|
||||
let originalMovedAway = false;
|
||||
|
||||
try {
|
||||
ensureDir(extractDir);
|
||||
emitProgress(onProgress, 'restore', 5, 'Entpacke Backup');
|
||||
await extractBackupArchive(sourcePath, extractDir, {
|
||||
mode: 'restore',
|
||||
onProgress,
|
||||
startPercent: 5,
|
||||
endPercent: 18,
|
||||
detail: 'Entpacke Backup',
|
||||
});
|
||||
|
||||
const backupRoot = resolveExtractedBackupRoot(extractDir);
|
||||
if (!backupRoot) throw new Error('Das Archiv enthält kein gültiges AeroMC-Backup.');
|
||||
emitProgress(onProgress, 'restore', 18, 'Backup geprüft');
|
||||
|
||||
const sourceInstances = path.join(backupRoot, 'instances');
|
||||
const sourceSettings = path.join(backupRoot, 'settings.json');
|
||||
ensureDir(rollbackDir);
|
||||
|
||||
emitProgress(onProgress, 'restore', 25, 'Sichere aktuellen Stand');
|
||||
moveDirTracked(instancesDir, rollbackInstances, {
|
||||
mode: 'restore',
|
||||
onProgress,
|
||||
startPercent: 28,
|
||||
endPercent: 40,
|
||||
detailPrefix: 'Sichere aktuelle Instanzen',
|
||||
});
|
||||
originalMovedAway = true;
|
||||
settingsPreviouslyExisted = fs.existsSync(settingsFile);
|
||||
if (settingsPreviouslyExisted) fs.copyFileSync(settingsFile, rollbackSettings);
|
||||
|
||||
ensureDir(path.dirname(instancesDir));
|
||||
moveDirTracked(sourceInstances, instancesDir, {
|
||||
mode: 'restore',
|
||||
onProgress,
|
||||
startPercent: 45,
|
||||
endPercent: 78,
|
||||
detailPrefix: 'Stelle Instanzen wieder her',
|
||||
});
|
||||
|
||||
let restoredSettings = false;
|
||||
if (includeSettings && fs.existsSync(sourceSettings)) {
|
||||
const restored = readJson(sourceSettings, {});
|
||||
restored.instancesDir = instancesDirSetting;
|
||||
writeJson(settingsFile, restored);
|
||||
restoredSettings = true;
|
||||
emitProgress(onProgress, 'restore', 90, 'Stelle Einstellungen wieder her');
|
||||
} else {
|
||||
emitProgress(onProgress, 'restore', 90, 'Einstellungen übersprungen');
|
||||
}
|
||||
|
||||
emitProgress(onProgress, 'restore', 100, 'Wiederherstellen abgeschlossen');
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
path: sourcePath,
|
||||
instanceCount: countInstanceDirs(instancesDir),
|
||||
restoredSettings,
|
||||
};
|
||||
} catch (err) {
|
||||
// Nur zurückrollen, wenn wir den ursprünglichen Bestand überhaupt schon
|
||||
// angefasst haben (siehe originalMovedAway oben). Schlägt die
|
||||
// Wiederherstellung vorher fehl (ungültiges/beschädigtes Archiv o. Ä.),
|
||||
// ist instancesDir noch der unveränderte Originalbestand - den lassen wir
|
||||
// dann bewusst in Ruhe, statt ihn zu löschen.
|
||||
if (originalMovedAway) {
|
||||
try {
|
||||
if (fs.existsSync(instancesDir)) fs.rmSync(instancesDir, { recursive: true, force: true });
|
||||
if (fs.existsSync(rollbackInstances)) fs.cpSync(rollbackInstances, instancesDir, { recursive: true });
|
||||
else ensureDir(instancesDir);
|
||||
|
||||
if (includeSettings) {
|
||||
if (fs.existsSync(rollbackSettings)) fs.copyFileSync(rollbackSettings, settingsFile);
|
||||
else if (!settingsPreviouslyExisted && fs.existsSync(settingsFile)) fs.rmSync(settingsFile, { force: true });
|
||||
}
|
||||
} catch { /* ignore rollback errors */ }
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
try { fs.rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createGlobalBackup,
|
||||
restoreGlobalBackup,
|
||||
defaultBackupFileName,
|
||||
defaultBackupDir,
|
||||
listGlobalBackups,
|
||||
resolveAutoBackupPath,
|
||||
};
|
||||
+195
-195
@@ -1,196 +1,196 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* cfimport.js – Instanzen aus dem CurseForge-Launcher übernehmen
|
||||
* ---------------------------------------------------------------
|
||||
* Unterstützt sowohl den Launcher-Wurzelordner als auch direkt den
|
||||
* Instances-Ordner. Gelesen werden nach Möglichkeit minecraftinstance.json
|
||||
* und die vorhandenen Spieldaten im Profilordner.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const META_FILES = ['minecraftinstance.json', 'instance.json'];
|
||||
|
||||
function readJson(file, fallback) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function existingMetaFile(dir) {
|
||||
return META_FILES.map((name) => path.join(dir, name)).find((file) => fs.existsSync(file)) || null;
|
||||
}
|
||||
|
||||
function metaVersion(meta) {
|
||||
return String(
|
||||
(meta && (
|
||||
meta.gameVersion || meta.minecraftVersion || meta.mcVersion ||
|
||||
(meta.installedModpack && meta.installedModpack.gameVersion)
|
||||
)) || ''
|
||||
).trim();
|
||||
}
|
||||
|
||||
function resolveInstancesDir(inputPath) {
|
||||
if (!inputPath || !fs.existsSync(inputPath)) return null;
|
||||
const directNames = new Set(['instances', 'minecraftinstances']);
|
||||
if (directNames.has(path.basename(inputPath).toLowerCase())) return inputPath;
|
||||
|
||||
const candidates = [
|
||||
path.join(inputPath, 'Instances'),
|
||||
path.join(inputPath, 'instances'),
|
||||
path.join(inputPath, 'minecraftInstances'),
|
||||
path.join(inputPath, 'Minecraft', 'Instances'),
|
||||
path.join(inputPath, 'minecraft', 'Instances'),
|
||||
];
|
||||
|
||||
const looksLikeWindowsInstall =
|
||||
/curseforge windows/i.test(inputPath) ||
|
||||
(fs.existsSync(path.join(inputPath, 'CurseForge.exe')) && fs.existsSync(path.join(inputPath, 'resources')));
|
||||
if (looksLikeWindowsInstall) {
|
||||
candidates.push(
|
||||
path.join(os.homedir(), 'curseforge', 'minecraft', 'Instances'),
|
||||
path.join(os.homedir(), 'CurseForge', 'minecraft', 'Instances'),
|
||||
);
|
||||
}
|
||||
return candidates.find((candidate) => fs.existsSync(candidate)) || null;
|
||||
}
|
||||
|
||||
function normalizeLoaderVersion(loader, rawValue, mcVersion) {
|
||||
let value = String(rawValue || '').trim();
|
||||
if (!value) return '';
|
||||
|
||||
if (loader === 'forge') {
|
||||
value = value.replace(/^forge-/i, '');
|
||||
if (mcVersion && value.startsWith(mcVersion + '-')) value = value.slice(mcVersion.length + 1);
|
||||
return value;
|
||||
}
|
||||
if (loader === 'neoforge') {
|
||||
return value.replace(/^neoforge-/i, '');
|
||||
}
|
||||
if (loader === 'fabric') {
|
||||
value = value.replace(/^fabric(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
if (loader === 'quilt') {
|
||||
value = value.replace(/^quilt(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function detectLoader(meta, mcVersion) {
|
||||
const raw = meta && (
|
||||
meta.baseModLoader || meta.modLoader || meta.modloader || meta.loader || meta.modLoaderId
|
||||
);
|
||||
const value = typeof raw === 'object'
|
||||
? (raw.name || raw.id || raw.value || raw.version || '')
|
||||
: (raw || '');
|
||||
const lower = String(value).toLowerCase();
|
||||
const objectVersion = raw && typeof raw === 'object'
|
||||
? (raw.version || raw.name || raw.id || '')
|
||||
: '';
|
||||
|
||||
if (!lower) return { loader: 'vanilla', loaderVersion: '' };
|
||||
if (lower.includes('neoforge')) return { loader: 'neoforge', loaderVersion: normalizeLoaderVersion('neoforge', objectVersion || value, mcVersion) };
|
||||
if (lower.includes('fabric')) return { loader: 'fabric', loaderVersion: normalizeLoaderVersion('fabric', objectVersion || value, mcVersion) };
|
||||
if (lower.includes('quilt')) return { loader: 'quilt', loaderVersion: normalizeLoaderVersion('quilt', objectVersion || value, mcVersion) };
|
||||
if (lower.includes('forge')) return { loader: 'forge', loaderVersion: normalizeLoaderVersion('forge', objectVersion || value, mcVersion) };
|
||||
return { loader: 'vanilla', loaderVersion: '' };
|
||||
}
|
||||
|
||||
function detectVersion(meta, loaderVersion) {
|
||||
return metaVersion(meta) || (loaderVersion && loaderVersion.includes('-') ? loaderVersion.split('-')[0] : '');
|
||||
}
|
||||
|
||||
function findGameDir(dir) {
|
||||
const nested = ['minecraft', '.minecraft']
|
||||
.map((name) => path.join(dir, name))
|
||||
.find((candidate) => fs.existsSync(candidate));
|
||||
if (nested) return nested;
|
||||
|
||||
const markers = ['mods', 'config', 'resourcepacks', 'shaderpacks', 'saves', 'options.txt'];
|
||||
return markers.some((name) => fs.existsSync(path.join(dir, name))) ? dir : null;
|
||||
}
|
||||
|
||||
function scan(inputPath) {
|
||||
const instancesDir = resolveInstancesDir(inputPath);
|
||||
if (!instancesDir) return { ok: false, reason: 'not-found' };
|
||||
|
||||
const list = [];
|
||||
for (const entry of fs.readdirSync(instancesDir, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory()) continue;
|
||||
const dir = path.join(instancesDir, entry.name);
|
||||
const metaFile = existingMetaFile(dir);
|
||||
const meta = metaFile ? readJson(metaFile, {}) : {};
|
||||
const gameDir = findGameDir(dir);
|
||||
if (!metaFile && !gameDir) continue;
|
||||
|
||||
const versionHint = metaVersion(meta);
|
||||
const loaderInfo = detectLoader(meta, versionHint);
|
||||
list.push({
|
||||
folder: entry.name,
|
||||
dir,
|
||||
name: meta.name || meta.displayName || entry.name,
|
||||
group: '',
|
||||
notes: meta.notes || meta.summary || '',
|
||||
version: versionHint || detectVersion(meta, loaderInfo.loaderVersion),
|
||||
loader: loaderInfo.loader,
|
||||
loaderVersion: loaderInfo.loaderVersion,
|
||||
javaPath: String(meta.javaPath || meta.javaExecutable || '').trim(),
|
||||
minMemMb: Number(meta.minimumMemory || meta.minMemory || meta.minMemAlloc) || null,
|
||||
maxMemMb: Number(meta.maximumMemory || meta.maxMemory || meta.maxMemAlloc || meta.allocatedMemory) || null,
|
||||
gameDir: gameDir || dir,
|
||||
hasGameData: !!gameDir,
|
||||
});
|
||||
}
|
||||
list.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return { ok: true, instancesDir, count: list.length, instances: list };
|
||||
}
|
||||
|
||||
function copyInto(sourceDir, targetDir) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
for (const name of fs.readdirSync(sourceDir)) {
|
||||
if (META_FILES.includes(name)) continue;
|
||||
fs.cpSync(path.join(sourceDir, name), path.join(targetDir, name), { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
function importOne(store, entry, copyData = true) {
|
||||
const created = store.createOrReplaceImportedInstance({
|
||||
name: entry.name,
|
||||
group: entry.group,
|
||||
notes: entry.notes,
|
||||
minecraft: {
|
||||
version: entry.version,
|
||||
loader: entry.loader,
|
||||
loaderVersion: entry.loaderVersion,
|
||||
},
|
||||
});
|
||||
|
||||
const patch = {};
|
||||
if (entry.javaPath || entry.minMemMb || entry.maxMemMb) {
|
||||
patch.java = {
|
||||
path: entry.javaPath || '',
|
||||
minMemMb: entry.minMemMb || null,
|
||||
maxMemMb: entry.maxMemMb || null,
|
||||
extraArgs: '',
|
||||
};
|
||||
}
|
||||
if (Object.keys(patch).length) store.updateInstance(created.id, patch);
|
||||
|
||||
let copied = false;
|
||||
if (copyData && entry.gameDir && fs.existsSync(entry.gameDir)) {
|
||||
copyInto(entry.gameDir, store.gameDir(created.id));
|
||||
copied = true;
|
||||
}
|
||||
return { id: created.id, name: created.name, copied };
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* cfimport.js – Instanzen aus dem CurseForge-Launcher übernehmen
|
||||
* ---------------------------------------------------------------
|
||||
* Unterstützt sowohl den Launcher-Wurzelordner als auch direkt den
|
||||
* Instances-Ordner. Gelesen werden nach Möglichkeit minecraftinstance.json
|
||||
* und die vorhandenen Spieldaten im Profilordner.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const META_FILES = ['minecraftinstance.json', 'instance.json'];
|
||||
|
||||
function readJson(file, fallback) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function existingMetaFile(dir) {
|
||||
return META_FILES.map((name) => path.join(dir, name)).find((file) => fs.existsSync(file)) || null;
|
||||
}
|
||||
|
||||
function metaVersion(meta) {
|
||||
return String(
|
||||
(meta && (
|
||||
meta.gameVersion || meta.minecraftVersion || meta.mcVersion ||
|
||||
(meta.installedModpack && meta.installedModpack.gameVersion)
|
||||
)) || ''
|
||||
).trim();
|
||||
}
|
||||
|
||||
function resolveInstancesDir(inputPath) {
|
||||
if (!inputPath || !fs.existsSync(inputPath)) return null;
|
||||
const directNames = new Set(['instances', 'minecraftinstances']);
|
||||
if (directNames.has(path.basename(inputPath).toLowerCase())) return inputPath;
|
||||
|
||||
const candidates = [
|
||||
path.join(inputPath, 'Instances'),
|
||||
path.join(inputPath, 'instances'),
|
||||
path.join(inputPath, 'minecraftInstances'),
|
||||
path.join(inputPath, 'Minecraft', 'Instances'),
|
||||
path.join(inputPath, 'minecraft', 'Instances'),
|
||||
];
|
||||
|
||||
const looksLikeWindowsInstall =
|
||||
/curseforge windows/i.test(inputPath) ||
|
||||
(fs.existsSync(path.join(inputPath, 'CurseForge.exe')) && fs.existsSync(path.join(inputPath, 'resources')));
|
||||
if (looksLikeWindowsInstall) {
|
||||
candidates.push(
|
||||
path.join(os.homedir(), 'curseforge', 'minecraft', 'Instances'),
|
||||
path.join(os.homedir(), 'CurseForge', 'minecraft', 'Instances'),
|
||||
);
|
||||
}
|
||||
return candidates.find((candidate) => fs.existsSync(candidate)) || null;
|
||||
}
|
||||
|
||||
function normalizeLoaderVersion(loader, rawValue, mcVersion) {
|
||||
let value = String(rawValue || '').trim();
|
||||
if (!value) return '';
|
||||
|
||||
if (loader === 'forge') {
|
||||
value = value.replace(/^forge-/i, '');
|
||||
if (mcVersion && value.startsWith(mcVersion + '-')) value = value.slice(mcVersion.length + 1);
|
||||
return value;
|
||||
}
|
||||
if (loader === 'neoforge') {
|
||||
return value.replace(/^neoforge-/i, '');
|
||||
}
|
||||
if (loader === 'fabric') {
|
||||
value = value.replace(/^fabric(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
if (loader === 'quilt') {
|
||||
value = value.replace(/^quilt(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function detectLoader(meta, mcVersion) {
|
||||
const raw = meta && (
|
||||
meta.baseModLoader || meta.modLoader || meta.modloader || meta.loader || meta.modLoaderId
|
||||
);
|
||||
const value = typeof raw === 'object'
|
||||
? (raw.name || raw.id || raw.value || raw.version || '')
|
||||
: (raw || '');
|
||||
const lower = String(value).toLowerCase();
|
||||
const objectVersion = raw && typeof raw === 'object'
|
||||
? (raw.version || raw.name || raw.id || '')
|
||||
: '';
|
||||
|
||||
if (!lower) return { loader: 'vanilla', loaderVersion: '' };
|
||||
if (lower.includes('neoforge')) return { loader: 'neoforge', loaderVersion: normalizeLoaderVersion('neoforge', objectVersion || value, mcVersion) };
|
||||
if (lower.includes('fabric')) return { loader: 'fabric', loaderVersion: normalizeLoaderVersion('fabric', objectVersion || value, mcVersion) };
|
||||
if (lower.includes('quilt')) return { loader: 'quilt', loaderVersion: normalizeLoaderVersion('quilt', objectVersion || value, mcVersion) };
|
||||
if (lower.includes('forge')) return { loader: 'forge', loaderVersion: normalizeLoaderVersion('forge', objectVersion || value, mcVersion) };
|
||||
return { loader: 'vanilla', loaderVersion: '' };
|
||||
}
|
||||
|
||||
function detectVersion(meta, loaderVersion) {
|
||||
return metaVersion(meta) || (loaderVersion && loaderVersion.includes('-') ? loaderVersion.split('-')[0] : '');
|
||||
}
|
||||
|
||||
function findGameDir(dir) {
|
||||
const nested = ['minecraft', '.minecraft']
|
||||
.map((name) => path.join(dir, name))
|
||||
.find((candidate) => fs.existsSync(candidate));
|
||||
if (nested) return nested;
|
||||
|
||||
const markers = ['mods', 'config', 'resourcepacks', 'shaderpacks', 'saves', 'options.txt'];
|
||||
return markers.some((name) => fs.existsSync(path.join(dir, name))) ? dir : null;
|
||||
}
|
||||
|
||||
function scan(inputPath) {
|
||||
const instancesDir = resolveInstancesDir(inputPath);
|
||||
if (!instancesDir) return { ok: false, reason: 'not-found' };
|
||||
|
||||
const list = [];
|
||||
for (const entry of fs.readdirSync(instancesDir, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory()) continue;
|
||||
const dir = path.join(instancesDir, entry.name);
|
||||
const metaFile = existingMetaFile(dir);
|
||||
const meta = metaFile ? readJson(metaFile, {}) : {};
|
||||
const gameDir = findGameDir(dir);
|
||||
if (!metaFile && !gameDir) continue;
|
||||
|
||||
const versionHint = metaVersion(meta);
|
||||
const loaderInfo = detectLoader(meta, versionHint);
|
||||
list.push({
|
||||
folder: entry.name,
|
||||
dir,
|
||||
name: meta.name || meta.displayName || entry.name,
|
||||
group: '',
|
||||
notes: meta.notes || meta.summary || '',
|
||||
version: versionHint || detectVersion(meta, loaderInfo.loaderVersion),
|
||||
loader: loaderInfo.loader,
|
||||
loaderVersion: loaderInfo.loaderVersion,
|
||||
javaPath: String(meta.javaPath || meta.javaExecutable || '').trim(),
|
||||
minMemMb: Number(meta.minimumMemory || meta.minMemory || meta.minMemAlloc) || null,
|
||||
maxMemMb: Number(meta.maximumMemory || meta.maxMemory || meta.maxMemAlloc || meta.allocatedMemory) || null,
|
||||
gameDir: gameDir || dir,
|
||||
hasGameData: !!gameDir,
|
||||
});
|
||||
}
|
||||
list.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return { ok: true, instancesDir, count: list.length, instances: list };
|
||||
}
|
||||
|
||||
function copyInto(sourceDir, targetDir) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
for (const name of fs.readdirSync(sourceDir)) {
|
||||
if (META_FILES.includes(name)) continue;
|
||||
fs.cpSync(path.join(sourceDir, name), path.join(targetDir, name), { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
function importOne(store, entry, copyData = true) {
|
||||
const created = store.createOrReplaceImportedInstance({
|
||||
name: entry.name,
|
||||
group: entry.group,
|
||||
notes: entry.notes,
|
||||
minecraft: {
|
||||
version: entry.version,
|
||||
loader: entry.loader,
|
||||
loaderVersion: entry.loaderVersion,
|
||||
},
|
||||
});
|
||||
|
||||
const patch = {};
|
||||
if (entry.javaPath || entry.minMemMb || entry.maxMemMb) {
|
||||
patch.java = {
|
||||
path: entry.javaPath || '',
|
||||
minMemMb: entry.minMemMb || null,
|
||||
maxMemMb: entry.maxMemMb || null,
|
||||
extraArgs: '',
|
||||
};
|
||||
}
|
||||
if (Object.keys(patch).length) store.updateInstance(created.id, patch);
|
||||
|
||||
let copied = false;
|
||||
if (copyData && entry.gameDir && fs.existsSync(entry.gameDir)) {
|
||||
copyInto(entry.gameDir, store.gameDir(created.id));
|
||||
copied = true;
|
||||
}
|
||||
return { id: created.id, name: created.name, copied };
|
||||
}
|
||||
|
||||
module.exports = { scan, importOne, resolveInstancesDir };
|
||||
@@ -0,0 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* discordpresence.js – Discord Rich Presence ("Spielt Minecraft über AeroMC")
|
||||
* -----------------------------------------------------------------------------
|
||||
* Verbindet sich rein lokal über die IPC-Pipe des laufenden Discord-Clients.
|
||||
* SET_ACTIVITY braucht dafür bewusst KEINE Authentifizierung/OAuth (anders als
|
||||
* der Rest der RPC-API) – daher hier absichtlich client.request(...) direkt
|
||||
* statt client.user.setActivity(...), das erst nach einem Login funktioniert.
|
||||
*
|
||||
* Immer aktiv, ohne eigene Einstellung – braucht also keine Zustimmung/kein
|
||||
* Häkchen. Läuft trotzdem komplett unauffällig: ist Discord nicht installiert
|
||||
* oder nicht gestartet, bleibt es einfach inaktiv, ohne den Launcher oder den
|
||||
* Spielstart zu stören – jeder Fehler hier wird bewusst verschluckt.
|
||||
*/
|
||||
|
||||
const { Client } = require('@xhayper/discord-rpc');
|
||||
|
||||
// Von M_Viper unter discord.com/developers/applications angelegte AeroMC-App.
|
||||
// Öffentliche Anwendungs-ID, kein Geheimnis (genau wie DEFAULT_CLIENT_ID bei
|
||||
// der Microsoft-Anmeldung in auth.js) – gilt für alle AeroMC-Nutzer gleich.
|
||||
const DEFAULT_CLIENT_ID = '1538173087730630686';
|
||||
|
||||
const LAUNCHER_WEBSITE = 'https://aeromc.viper.ipv64.net/';
|
||||
|
||||
let clientId = DEFAULT_CLIENT_ID;
|
||||
let client = null;
|
||||
let connecting = null;
|
||||
|
||||
function resolveClientId() {
|
||||
return (clientId && String(clientId).trim()) || DEFAULT_CLIENT_ID;
|
||||
}
|
||||
|
||||
async function connect() {
|
||||
if (client && client.isConnected) return client;
|
||||
if (connecting) return connecting;
|
||||
|
||||
const id = resolveClientId();
|
||||
const c = new Client({ clientId: id });
|
||||
c.on('disconnected', () => { if (client === c) client = null; });
|
||||
connecting = c.connect()
|
||||
.then(() => { client = c; connecting = null; return c; })
|
||||
.catch((err) => { connecting = null; throw err; });
|
||||
return connecting;
|
||||
}
|
||||
|
||||
/*
|
||||
* activity: { details, state, startTimestamp }
|
||||
* details/state -> die beiden Zeilen unter dem Profilbild in Discord
|
||||
* startTimestamp -> Discord zeigt die Spielzeit dann selbst laufend an
|
||||
*/
|
||||
async function setActivity(activity) {
|
||||
try {
|
||||
const c = await connect();
|
||||
await c.request('SET_ACTIVITY', {
|
||||
pid: process.pid,
|
||||
activity: {
|
||||
details: activity.details,
|
||||
state: activity.state,
|
||||
timestamps: activity.startTimestamp ? { start: activity.startTimestamp } : undefined,
|
||||
assets: { large_image: 'aeromc_logo', large_text: 'AeroMC Launcher' },
|
||||
// Discord zeigt Buttons Betrachtern des Profils an (nicht sich selbst) -
|
||||
// maximal 2 sind erlaubt, hier reicht einer.
|
||||
buttons: [{ label: 'AeroMC herunterladen', url: LAUNCHER_WEBSITE }],
|
||||
instance: false,
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
// Discord nicht installiert/nicht gestartet o. Ä. - bewusst lautlos
|
||||
}
|
||||
}
|
||||
|
||||
async function clearActivity() {
|
||||
try {
|
||||
if (!client || !client.isConnected) return;
|
||||
await client.request('SET_ACTIVITY', { pid: process.pid });
|
||||
} catch { /* egal */ }
|
||||
}
|
||||
|
||||
async function shutdown() {
|
||||
const c = client;
|
||||
client = null;
|
||||
connecting = null;
|
||||
if (!c) return;
|
||||
try { await c.destroy(); } catch { /* egal */ }
|
||||
}
|
||||
|
||||
/*
|
||||
* Verbindet direkt beim Start. settings.discordClientId erlaubt weiterhin
|
||||
* (rein optional, per Hand in settings.json) eine eigene App-ID zu setzen -
|
||||
* ohne eigenes Einstellungsfeld, ohne dass es dafür einen Schalter braucht.
|
||||
*/
|
||||
function configure(settings) {
|
||||
const nextId = (settings && settings.discordClientId) || DEFAULT_CLIENT_ID;
|
||||
const idChanged = nextId !== clientId;
|
||||
clientId = nextId;
|
||||
|
||||
if (idChanged) { shutdown().then(() => connect().catch(() => {})); }
|
||||
else if (!client) { connect().catch(() => {}); }
|
||||
}
|
||||
|
||||
module.exports = { configure, setActivity, clearActivity, shutdown, DEFAULT_CLIENT_ID };
|
||||
+128
-4
@@ -51,6 +51,7 @@
|
||||
<button id="p-mods" class="sbtn">Mods anzeigen</button>
|
||||
<button id="p-worlds" class="sbtn">Welten verwalten</button>
|
||||
<button id="p-screens" class="sbtn">Bildschirmfotos verwalten</button>
|
||||
<button id="p-record" class="sbtn">Spiel aufzeichnen</button>
|
||||
<button id="p-modpack" class="sbtn hidden">Modpack aktualisieren</button>
|
||||
<button id="p-logs" class="sbtn">Logdateien ansehen</button>
|
||||
<button id="p-servers" class="sbtn">Server verwalten</button>
|
||||
@@ -709,6 +710,11 @@
|
||||
<button id="m-add-file" class="btn btn-mini" data-ic="plus">Datei hinzufügen…</button>
|
||||
<button id="m-check-updates" class="btn btn-mini">Nach Updates suchen</button>
|
||||
<button id="m-apply-updates" class="btn btn-primary btn-mini hidden">Alle aktualisieren</button>
|
||||
<select id="m-installed-sort" title="Sortierung">
|
||||
<option value="name-asc">Name (A-Z)</option>
|
||||
<option value="name-desc">Name (Z-A)</option>
|
||||
<option value="status">Status (aktiv zuerst)</option>
|
||||
</select>
|
||||
<span id="m-update-status" class="hint"></span>
|
||||
</div>
|
||||
<div id="m-installed" class="mods-list"><div class="mods-empty">Noch keine Mods.</div></div>
|
||||
@@ -800,6 +806,123 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===================== Dialog: Spielaufzeichnung ===================== -->
|
||||
<div id="modal-record" class="modal hidden">
|
||||
<div class="modal-card modal-lg">
|
||||
<div class="modal-head">
|
||||
<h3 id="record-title">Spielaufzeichnung</h3>
|
||||
<button class="modal-close" data-close>✕</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="record-search" class="record-search">
|
||||
<p id="record-search-text">Suche Spielfenster …</p>
|
||||
<button id="record-search-retry" class="btn hidden">Erneut suchen</button>
|
||||
</div>
|
||||
|
||||
<div id="record-picker" class="screens-grid hidden"></div>
|
||||
|
||||
<div id="record-stage" class="record-stage hidden">
|
||||
<video id="record-preview" class="record-video" autoplay muted></video>
|
||||
<div class="record-audio-bar">
|
||||
<span class="hint">Video: <span id="record-video-summary">Nativ · Mittel</span></span>
|
||||
<button id="record-video-edit" class="btn btn-mini">Video-Einstellungen…</button>
|
||||
</div>
|
||||
<div class="record-audio-bar">
|
||||
<span class="hint">Audio: <span id="record-audio-summary">Systemton</span></span>
|
||||
<button id="record-audio-edit" class="btn btn-mini">Audioquellen wählen…</button>
|
||||
</div>
|
||||
<div class="record-toolbar">
|
||||
<div id="record-live-badge" class="record-live-badge hidden">
|
||||
<span class="rec-dot"></span>
|
||||
<span>Aufnahme läuft · <span id="record-timer">00:00</span></span>
|
||||
</div>
|
||||
<button id="record-toggle" class="btn btn-primary">Aufnahme starten</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<button id="record-open-folder" class="btn" data-ic="folder">Ordner öffnen</button>
|
||||
<div class="spacer"></div>
|
||||
<button class="btn" data-close>Schließen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===================== Dialog: Video-Einstellungen der Aufzeichnung ===================== -->
|
||||
<div id="modal-record-video" class="modal hidden">
|
||||
<div class="modal-card modal-sm">
|
||||
<div class="modal-head">
|
||||
<h3>Video-Einstellungen</h3>
|
||||
<button class="modal-close" data-close>✕</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="field-row">
|
||||
<label class="field">
|
||||
<span>Auflösung</span>
|
||||
<select id="record-resolution">
|
||||
<option value="native">Nativ (Fenstergröße)</option>
|
||||
<option value="1080">1080p</option>
|
||||
<option value="720">720p</option>
|
||||
<option value="480">480p</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Qualität</span>
|
||||
<select id="record-quality">
|
||||
<option value="low">Niedrig (kleinere Datei)</option>
|
||||
<option value="medium" selected>Mittel</option>
|
||||
<option value="high">Hoch (größere Datei)</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Bildrate</span>
|
||||
<select id="record-fps">
|
||||
<option value="30" selected>30 fps</option>
|
||||
<option value="60">60 fps (größere Datei)</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<p id="record-video-hint" class="hint hidden">Gilt erst für die nächste Aufnahme – während einer laufenden Aufnahme nicht änderbar.</p>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<div class="spacer"></div>
|
||||
<button class="btn btn-primary" data-close>Fertig</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===================== Dialog: Audioquellen der Aufzeichnung ===================== -->
|
||||
<div id="modal-record-audio" class="modal hidden">
|
||||
<div class="modal-card modal-sm">
|
||||
<div class="modal-head">
|
||||
<h3>Audioquellen wählen</h3>
|
||||
<button class="modal-close" data-close>✕</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="hint">Mehrfachauswahl möglich – alle angehakten Quellen werden zu einer Tonspur gemischt, Lautstärke je Quelle einstellbar.</p>
|
||||
<div class="record-source-row">
|
||||
<label class="checkbox-field">
|
||||
<input id="record-src-system" type="checkbox" checked /> <span>Systemton</span>
|
||||
</label>
|
||||
<input id="record-vol-system" class="record-vol" type="range" min="0" max="100" value="100" title="Lautstärke" />
|
||||
</div>
|
||||
<div class="record-source-row">
|
||||
<label class="checkbox-field">
|
||||
<input id="record-src-game" type="checkbox" disabled /> <span>Nur Minecraft (isoliert)</span>
|
||||
</label>
|
||||
<input id="record-vol-game" class="record-vol" type="range" min="0" max="100" value="100" title="Lautstärke" />
|
||||
</div>
|
||||
<p id="record-src-game-hint" class="hint hidden">Kein laufender Minecraft-Prozess erkannt – bitte über den Launcher starten.</p>
|
||||
<div id="record-mic-list" class="record-mic-list"></div>
|
||||
<p class="hint" style="margin-top:10px">Systemton ist immer der komplette Mix (Spiel, Discord, Musik, Benachrichtigungen usw.). "Nur Minecraft" nimmt ausschließlich den Ton des Spiels auf (z. B. wenn nebenbei Musik läuft, die nicht mit rein soll) – beides lässt sich auch kombiniert mit einem Mikrofon anhaken.</p>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<div class="spacer"></div>
|
||||
<button class="btn btn-primary" data-close>Fertig</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===================== Dialog: Screenshots ===================== -->
|
||||
<div id="modal-screens" class="modal hidden">
|
||||
<div class="modal-card modal-lg">
|
||||
@@ -856,7 +979,7 @@
|
||||
<div class="field-row" style="margin-top:12px">
|
||||
<label class="field"><span>Name</span><input id="srv-name" type="text" placeholder="z. B. Mein Server" /></label>
|
||||
<label class="field"><span>Adresse</span><input id="srv-ip" type="text" placeholder="mc.example.de oder 192.168.1.50:25566" /></label>
|
||||
<button id="srv-add" class="btn btn-primary" style="align-self:flex-end">Hinzufügen</button>
|
||||
<div class="field" style="flex:0 0 auto"><span> </span><button id="srv-add" class="btn btn-primary">Hinzufügen</button></div>
|
||||
</div>
|
||||
<div id="srv-list" class="mods-list" style="margin-top:12px"></div>
|
||||
</div>
|
||||
@@ -899,19 +1022,19 @@
|
||||
<div class="skin-spalte">
|
||||
<div class="skin-label">Aktuell</div>
|
||||
<div class="skin-bild">
|
||||
<img id="skin-aktuell" alt="" class="hidden" />
|
||||
<canvas id="skin-aktuell" class="hidden"></canvas>
|
||||
<span id="skin-aktuell-leer" class="hint">wird geladen …</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="skin-spalte">
|
||||
<div class="skin-label">Neu</div>
|
||||
<div class="skin-bild">
|
||||
<img id="skin-neu" alt="" class="hidden" />
|
||||
<canvas id="skin-neu" class="hidden"></canvas>
|
||||
<span id="skin-neu-leer" class="hint">noch keine Datei gewählt</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<small class="hint">Die Vorschau zeigt die Figur so, wie sie im Spiel aussieht. Die Armform wirkt sich auf die Darstellung aus.</small>
|
||||
<small class="hint">Mit der Maus ziehen dreht die Figur, Mausrad zoomt. Die Armform wirkt sich auf die Darstellung aus.</small>
|
||||
<div class="path-row" style="margin-top:12px">
|
||||
<input id="skin-pfad" type="text" readonly placeholder="PNG mit 64×64 Pixeln" />
|
||||
<button id="skin-pick" class="btn">Datei wählen…</button>
|
||||
@@ -1275,6 +1398,7 @@
|
||||
<button class="ctx-item" data-act="p-mods">Mods anzeigen</button>
|
||||
<button class="ctx-item" data-act="p-worlds">Welten verwalten</button>
|
||||
<button class="ctx-item" data-act="p-screens">Bildschirmfotos verwalten</button>
|
||||
<button class="ctx-item" data-act="p-record">Spiel aufzeichnen</button>
|
||||
<button class="ctx-item" data-act="p-logs">Logdateien ansehen</button>
|
||||
<button class="ctx-item" data-act="p-servers">Server verwalten</button>
|
||||
<div class="ctx-sep"></div>
|
||||
|
||||
+424
-100
@@ -6,7 +6,7 @@
|
||||
* (Vanilla-Start, Microsoft-Login und Mod-Loader folgen in späteren Phasen.)
|
||||
*/
|
||||
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell, safeStorage, Notification, Tray, Menu, nativeImage, clipboard } = require('electron');
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell, safeStorage, Notification, Tray, Menu, nativeImage, clipboard, desktopCapturer, session, screen } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
@@ -32,6 +32,7 @@ const crashreports = require('./crashreports');
|
||||
const skins = require('./skins');
|
||||
const servers = require('./servers');
|
||||
const mcping = require('./mcping');
|
||||
const discordpresence = require('./discordpresence');
|
||||
|
||||
// undici als globales fetch verwenden -> ermöglicht Proxy via setGlobalDispatcher
|
||||
const undici = require('undici');
|
||||
@@ -84,6 +85,274 @@ function applyProxy(s) {
|
||||
|
||||
let mainWindow = null;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Popup-Fenster: alle großen Dialoge als eigene, frei verschiebbare Fenster
|
||||
// (native Titelleiste ersetzt durch den eigenen dunklen Kopfbereich) statt
|
||||
// als Modal im Hauptfenster. Laden dieselbe index.html mit z. B.
|
||||
// "?popout=mods&instanceId=..." – der Renderer blendet dann nur diesen einen
|
||||
// Dialog vollflächig ein.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const popoutWindows = new Map(); // modalId -> BrowserWindow
|
||||
|
||||
const POPOUT_SPEC = {
|
||||
settings: { title: 'AeroMC – Einstellungen', width: 980, height: 720, minWidth: 700, minHeight: 500 },
|
||||
console: { title: 'AeroMC – Konsole / Log', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
mods: { title: 'AeroMC – Mods', width: 900, height: 700, minWidth: 640, minHeight: 480 },
|
||||
crash: { title: 'AeroMC – Absturzbericht', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
logs: { title: 'AeroMC – Logdateien', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
content: { title: 'AeroMC – Welten & Pakete', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
screens: { title: 'AeroMC – Bildschirmfotos', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
servers: { title: 'AeroMC – Server', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
skin: { title: 'AeroMC – Skin', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
bedrock: { title: 'AeroMC – Bedrock', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
login: { title: 'AeroMC – Konten', width: 460, height: 460, minWidth: 420, minHeight: 380 },
|
||||
import: { title: 'AeroMC – Import', width: 860, height: 680, minWidth: 640, minHeight: 480 },
|
||||
instance: { title: 'AeroMC – Instanz', width: 640, height: 760, minWidth: 520, minHeight: 500 },
|
||||
update: { title: 'AeroMC – Update', width: 460, height: 460, minWidth: 420, minHeight: 380 },
|
||||
record: { title: 'AeroMC – Spielaufzeichnung', width: 960, height: 800, minWidth: 640, minHeight: 560 },
|
||||
};
|
||||
const POPOUT_DEFAULT = { title: 'AeroMC', width: 860, height: 680, minWidth: 640, minHeight: 480 };
|
||||
let pendingUpdateInfo = null; // letztes Ergebnis von update:check/checkForUpdate, für Update-Popup
|
||||
|
||||
// an Hauptfenster UND alle offenen Popup-Fenster senden (Start-Fortschritt
|
||||
// muss z. B. auch im herausgelösten Konsolen-Fenster ankommen)
|
||||
function broadcast(channel, payload) {
|
||||
for (const w of [mainWindow, ...popoutWindows.values()]) {
|
||||
if (w && !w.isDestroyed()) w.webContents.send(channel, payload);
|
||||
}
|
||||
}
|
||||
|
||||
function openPopout(modalId, params) {
|
||||
let win = popoutWindows.get(modalId);
|
||||
if (win && !win.isDestroyed()) {
|
||||
win.show();
|
||||
win.focus();
|
||||
// erneut mit (evtl. neuen) Parametern anzeigen, ohne die Seite neu zu
|
||||
// laden – sonst ginge z. B. der bisher gesammelte Konsolentext verloren
|
||||
win.webContents.send('popout:reopen', params || {});
|
||||
return;
|
||||
}
|
||||
const query = { popout: modalId };
|
||||
for (const [k, v] of Object.entries(params || {})) if (v !== undefined && v !== null) query[k] = String(v);
|
||||
const spec = POPOUT_SPEC[modalId] || POPOUT_DEFAULT;
|
||||
win = new BrowserWindow({
|
||||
width: spec.width,
|
||||
height: spec.height,
|
||||
minWidth: spec.minWidth,
|
||||
minHeight: spec.minHeight,
|
||||
title: spec.title || POPOUT_DEFAULT.title,
|
||||
backgroundColor: '#1b1e24',
|
||||
icon: windowIcon(),
|
||||
frame: false, // eigener dunkler Kopfbereich (Titel + ✕) ersetzt die native Titelleiste
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
popoutWindows.set(modalId, win);
|
||||
win.loadFile(path.join(__dirname, 'index.html'), { query });
|
||||
win.once('ready-to-show', () => win.show());
|
||||
win.webContents.on('did-fail-load', (_e, code, desc) => {
|
||||
console.error('Popup-Fenster "' + modalId + '" konnte nicht laden:', code, desc);
|
||||
});
|
||||
win.on('close', (e) => {
|
||||
if (appIsQuitting) return;
|
||||
e.preventDefault();
|
||||
// Läuft gerade eine Aufzeichnung, darf ein natives Schließen (Alt+F4,
|
||||
// Taskleiste) sie nicht stillschweigend verstecken -> der Renderer
|
||||
// entscheidet selbst (Stoppen+Speichern oder Abbrechen)
|
||||
if (modalId === 'record' && recordingGuardActive) {
|
||||
win.webContents.send('record:closeAttempt');
|
||||
return;
|
||||
}
|
||||
win.hide();
|
||||
});
|
||||
win.on('closed', () => { popoutWindows.delete(modalId); });
|
||||
}
|
||||
|
||||
let recordingGuardActive = false;
|
||||
ipcMain.on('recording:guard', (_e, active) => { recordingGuardActive = !!active; });
|
||||
|
||||
ipcMain.on('debug:rendererError', (_e, msg) => console.error('[Renderer-Fehler]', msg));
|
||||
ipcMain.on('popout:open', (_e, modalId, params) => openPopout(modalId, params));
|
||||
ipcMain.on('popout:hide', (e) => {
|
||||
const w = BrowserWindow.fromWebContents(e.sender);
|
||||
if (w && !w.isDestroyed()) w.hide();
|
||||
});
|
||||
ipcMain.handle('update:getPending', () => pendingUpdateInfo);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Spielaufzeichnung: Fenster-Erkennung per Fenstertitel (kein PID-Tracking
|
||||
// nötig dafür - funktioniert unabhängig von Konto/settings.wrapperCommand).
|
||||
// Video kommt vom Fenster, Systemton separat vom Bildschirm (Chromium erlaubt
|
||||
// keine Pro-Fenster-Tonaufnahme) - siehe renderer.js für den Aufnahme-Teil.
|
||||
// Die PID wird NUR für die optionale isolierte "Nur Minecraft"-Tonspur
|
||||
// gebraucht (per-Prozess-Aufnahme via loopback-capture, siehe unten).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const letzteQuickPlayServer = new Map(); // instanceId -> Server-Adresse
|
||||
// Minecraft schreibt diese Zeile bei JEDER Verbindung zu einem Server ins Log
|
||||
// - egal ob per Quick Play oder von Hand im Spiel verbunden, und egal ob das
|
||||
// Aufzeichnungs-Fenster dabei schon offen war. Hier (statt im Renderer)
|
||||
// verfolgt, weil das hier zentral für alle Fenster gilt, auch für ein erst
|
||||
// SPÄTER geöffnetes Aufzeichnungs-Popup, das die Zeile sonst verpasst hätte.
|
||||
const VERBINDUNGS_ZEILE = /Connecting to ([^,]+),\s*(\d+)/i;
|
||||
ipcMain.handle('recording:getServer', (_e, id) => letzteQuickPlayServer.get(id) || null);
|
||||
|
||||
const laufendePid = new Map(); // instanceId -> pid des zuletzt gestarteten Minecraft-Prozesses
|
||||
ipcMain.handle('recording:getPid', (_e, id) => laufendePid.get(id) || null);
|
||||
|
||||
// Welche Bildschirmquelle als Nächstes über getDisplayMedia erfasst werden
|
||||
// soll - vom Renderer kurz vor dem eigentlichen Aufruf gesetzt (siehe
|
||||
// setDisplayMediaRequestHandler weiter unten). Für den cursorfreien
|
||||
// Erfassungsversuch: ganzer Bildschirm ohne Mauszeiger, der Zuschnitt aufs
|
||||
// Minecraft-Fenster passiert danach per Canvas im Renderer (siehe
|
||||
// recording:getWindowBounds). Schlägt das fehl, läuft die Erfassung über die
|
||||
// alte, zuverlässige chromeMediaSource-Fenster-Methode (Mauszeiger sichtbar).
|
||||
let ausstehendeErfassungsQuelle = null;
|
||||
ipcMain.handle('recording:setCaptureTarget', (_e, sourceId) => { ausstehendeErfassungsQuelle = sourceId; });
|
||||
|
||||
// Sucht das Fenster des laufenden Minecraft-Prozesses (über die PID aus
|
||||
// laufendePid, robuster als ein Titel-Abgleich) und ermittelt daraus:
|
||||
// - die aktuellen Fenstergrenzen in Bildschirmkoordinaten
|
||||
// - den Bildschirm, auf dem das Fenster gerade sitzt (Mehrschirm-fähig)
|
||||
// - die zu diesem Bildschirm gehörende Erfassungsquelle für getDisplayMedia
|
||||
// Liefert null, wenn das Fenster nicht gefunden wird (z. B. Minecraft nicht
|
||||
// über den Launcher gestartet, oder bereits beendet) - der Renderer fällt in
|
||||
// dem Fall auf die alte Fenster-Erfassung zurück statt abzustürzen.
|
||||
async function findeFensterUndBildschirm(pid, fensterTitel) {
|
||||
let windowManager;
|
||||
try { ({ windowManager } = require('node-window-manager')); }
|
||||
catch (err) { console.log('[Aufzeichnung] node-window-manager Fehler:', err.message); return null; }
|
||||
let alleFenster;
|
||||
try { alleFenster = windowManager.getWindows(); }
|
||||
catch (err) { console.log('[Aufzeichnung] getWindows Fehler:', err.message); return null; }
|
||||
|
||||
// Die PID kennt der Launcher nur für Prozesse, die er in DIESER laufenden
|
||||
// Sitzung selbst gestartet hat - nach einem Neustart des Launchers (z. B.
|
||||
// während Minecraft weiterläuft) ist laufendePid leer, obwohl das Spiel
|
||||
// noch läuft. Dann über den EXAKTEN Fenstertitel suchen, den der Renderer
|
||||
// schon über recording:listWindows (dort per /Minecraft/i gefiltert und
|
||||
// vom Nutzer im Suchdialog bestätigt) positiv identifiziert hat - NICHT
|
||||
// erneut breit nach /Minecraft/i suchen, das kann auf einem Rechner mit
|
||||
// vielen offenen Fenstern (Editor, Browser-Tabs usw.) ein völlig falsches,
|
||||
// unbeteiligtes Fenster treffen und dessen Inhalt zeigen/aufnehmen.
|
||||
let fenster = pid ? alleFenster.find((w) => w.processId === pid) : null;
|
||||
if (!fenster && fensterTitel) {
|
||||
fenster = alleFenster.find((w) => { try { return w.getTitle() === fensterTitel; } catch { return false; } });
|
||||
}
|
||||
if (!fenster) { console.log('[Aufzeichnung] kein Minecraft-Fenster gefunden (PID', pid, ', Titel', fensterTitel, ')'); return null; }
|
||||
const fensterBounds = fenster.getBounds();
|
||||
if (!fensterBounds || !fensterBounds.width || !fensterBounds.height) {
|
||||
console.log('[Aufzeichnung] ungültige Fenstergrenzen:', JSON.stringify(fensterBounds));
|
||||
return null;
|
||||
}
|
||||
|
||||
const anzeige = screen.getDisplayMatching(fensterBounds);
|
||||
const screenSources = await desktopCapturer.getSources({ types: ['screen'] });
|
||||
const quelle = screenSources.find((s) => String(s.display_id) === String(anzeige.id)) || screenSources[0];
|
||||
if (!quelle) { console.log('[Aufzeichnung] keine Bildschirmquelle gefunden'); return null; }
|
||||
|
||||
console.log('[Aufzeichnung] gefunden:', JSON.stringify({ fensterBounds, bildschirmBounds: anzeige.bounds, screenSourceId: quelle.id }));
|
||||
return {
|
||||
fensterBounds,
|
||||
bildschirmBounds: anzeige.bounds,
|
||||
screenSourceId: quelle.id,
|
||||
};
|
||||
}
|
||||
|
||||
ipcMain.handle('recording:getWindowBounds', async (_e, instanceId, fensterTitel) => {
|
||||
const pid = laufendePid.get(instanceId);
|
||||
return findeFensterUndBildschirm(pid, fensterTitel);
|
||||
});
|
||||
|
||||
// Isolierte Ton-Aufnahme nur eines Prozesses (inkl. Kindprozesse) über
|
||||
// Windows' Process-Loopback-API. Nur eine Aufnahme gleichzeitig aktiv.
|
||||
let aktiveSpielAudioCapture = null;
|
||||
|
||||
ipcMain.handle('recording:startGameAudio', (event, pid) => {
|
||||
if (aktiveSpielAudioCapture) return { ok: false, message: 'Läuft bereits.' };
|
||||
let loopback;
|
||||
try {
|
||||
loopback = require('loopback-capture');
|
||||
} catch (err) {
|
||||
return { ok: false, message: 'Spielton-Isolierung nicht verfügbar: ' + err.message };
|
||||
}
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
try {
|
||||
const capture = new loopback.LoopbackCapture();
|
||||
capture.start(pid, true, (chunk) => {
|
||||
if (win && !win.isDestroyed()) win.webContents.send('recording:gameAudioChunk', new Uint8Array(chunk));
|
||||
});
|
||||
aktiveSpielAudioCapture = { capture };
|
||||
return { ok: true };
|
||||
} catch (err) {
|
||||
return { ok: false, message: 'Spielton-Aufnahme fehlgeschlagen (Windows 10 Version 2004+ erforderlich, oder Spiel bereits beendet): ' + err.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('recording:stopGameAudio', () => {
|
||||
if (aktiveSpielAudioCapture) {
|
||||
try { aktiveSpielAudioCapture.capture.stop(); } catch { /* egal, wird verworfen */ }
|
||||
aktiveSpielAudioCapture = null;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
ipcMain.handle('recording:listWindows', async () => {
|
||||
const sources = await desktopCapturer.getSources({
|
||||
types: ['window'],
|
||||
thumbnailSize: { width: 200, height: 120 },
|
||||
});
|
||||
return sources
|
||||
.filter((s) => /Minecraft/i.test(s.name))
|
||||
.map((s) => ({
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
thumbnail: s.thumbnail && !s.thumbnail.isEmpty() ? s.thumbnail.toDataURL() : null,
|
||||
}));
|
||||
});
|
||||
|
||||
// Für den Systemton reicht irgendeine Bildschirmquelle als Pflichtfeld für
|
||||
// getUserMedia -- der Ton ist ohnehin nicht pro Bildschirm getrennt.
|
||||
ipcMain.handle('recording:getAudioSourceId', async () => {
|
||||
const sources = await desktopCapturer.getSources({ types: ['screen'] });
|
||||
return (sources[0] && sources[0].id) || null;
|
||||
});
|
||||
|
||||
function aufzeichnungsOrdner(instanceName) {
|
||||
return path.join(app.getPath('videos'), 'AeroMC Launcher',
|
||||
String(instanceName || 'Instanz').replace(/[^\w.-]+/g, '_'));
|
||||
}
|
||||
|
||||
ipcMain.handle('recording:save', async (_e, instanceName, buffer, serverLabel) => {
|
||||
try {
|
||||
const zielOrdner = aufzeichnungsOrdner(instanceName);
|
||||
fs.mkdirSync(zielOrdner, { recursive: true });
|
||||
const zeitstempel = new Date().toISOString().replace(/[:T]/g, '-').slice(0, 16);
|
||||
const serverTeil = serverLabel ? String(serverLabel).replace(/[^\w.-]+/g, '_') + '_' : '';
|
||||
let zielDatei = path.join(zielOrdner, `${serverTeil}${zeitstempel}.webm`);
|
||||
let n = 2;
|
||||
while (fs.existsSync(zielDatei)) { zielDatei = path.join(zielOrdner, `${serverTeil}${zeitstempel}_${n}.webm`); n++; }
|
||||
fs.writeFileSync(zielDatei, Buffer.from(buffer));
|
||||
notify('Aufzeichnung gespeichert', `${instanceName}: ${path.basename(zielDatei)}`);
|
||||
return { ok: true, path: zielDatei };
|
||||
} catch (err) {
|
||||
return { ok: false, message: 'Speichern fehlgeschlagen: ' + err.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('recording:openFolder', (_e, instanceName) => {
|
||||
const dir = aufzeichnungsOrdner(instanceName);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
shell.openPath(dir);
|
||||
return true;
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Verknüpfungen: "AeroMC.exe --launch <id>" startet eine Instanz direkt
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -216,7 +485,12 @@ function createWindow(startHidden) {
|
||||
// Infobereich, statt AeroMC wirklich zu beenden – sonst wäre der
|
||||
// Autostart witzlos, weil man ihn beim ersten Wegklicken gleich wieder los ist.
|
||||
mainWindow.on('close', (e) => {
|
||||
if (appIsQuitting || !store.getSettings().autostart) return;
|
||||
if (appIsQuitting || !store.getSettings().autostart) {
|
||||
// Hauptfenster schließt wirklich -> keine nur versteckten Popup-Fenster
|
||||
// zurücklassen (die sonst window-all-closed nie erreichen ließen)
|
||||
for (const w of popoutWindows.values()) if (!w.isDestroyed()) w.destroy();
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
mainWindow.hide();
|
||||
});
|
||||
@@ -269,7 +543,16 @@ function destroyTray() {
|
||||
// Windows-Autostart-Eintrag setzen/entfernen + Tray-Symbol passend ein-/ausblenden
|
||||
function applyAutostart(enabled) {
|
||||
try {
|
||||
app.setLoginItemSettings({ openAtLogin: !!enabled, args: enabled ? ['--hidden'] : [] });
|
||||
// Gleiches Problem wie bei den Desktop-Verknüpfungen (siehe verknuepfungsArgs
|
||||
// weiter oben): im Entwicklungsmodus zeigt process.execPath nur auf die nackte
|
||||
// electron.exe, die ohne Pfadangabe ihren eigenen leeren Startbildschirm zeigt
|
||||
// statt AeroMC zu laden. Zusätzlich: bei der Portable-Fassung zeigt
|
||||
// process.execPath auf den entpackten Temp-Ordner – der wäre morgen tot,
|
||||
// deshalb wie bei den Verknüpfungen über verknuepfungsZiel() auflösen.
|
||||
const args = enabled
|
||||
? (app.isPackaged ? ['--hidden'] : [path.join(__dirname, '..'), '--hidden'])
|
||||
: [];
|
||||
app.setLoginItemSettings({ openAtLogin: !!enabled, path: verknuepfungsZiel(), args });
|
||||
} catch { /* z. B. in portabler Umgebung ohne Schreibrechte auf die Registry */ }
|
||||
if (enabled) createTray();
|
||||
else destroyTray();
|
||||
@@ -288,6 +571,7 @@ app.whenReady().then(() => {
|
||||
decrypt: (b) => safeStorage.decryptString(Buffer.from(b, 'base64')),
|
||||
});
|
||||
applyProxy(store.getSettings());
|
||||
discordpresence.configure(store.getSettings());
|
||||
const autostartAn = !!store.getSettings().autostart;
|
||||
// Autostart-Eintrag/Tray mit der Einstellung synchron halten (falls z. B.
|
||||
// von Hand an der Registry gedreht wurde oder nach einem Update)
|
||||
@@ -295,6 +579,17 @@ app.whenReady().then(() => {
|
||||
const startHidden = autostartAn && process.argv.includes('--hidden');
|
||||
createWindow(startHidden);
|
||||
|
||||
// Fenstererfassung für die Spielaufzeichnung ohne nativen Auswahldialog:
|
||||
// das vom Renderer per recording:setCaptureTarget gewählte Fenster wird
|
||||
// hier direkt zurückgegeben, statt den Nutzer nochmal wählen zu lassen
|
||||
session.defaultSession.setDisplayMediaRequestHandler((_request, callback) => {
|
||||
desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {
|
||||
const quelle = sources.find((s) => s.id === ausstehendeErfassungsQuelle) || sources[0];
|
||||
console.log('[Aufzeichnung] setDisplayMediaRequestHandler: angefordert=', ausstehendeErfassungsQuelle, 'gewählt=', quelle && quelle.id);
|
||||
callback(quelle ? { video: quelle } : {});
|
||||
});
|
||||
}, { useSystemPicker: false });
|
||||
|
||||
// Java-Suche im Hintergrund vorbereiten -> erster Spielstart ohne Verzögerung
|
||||
setTimeout(() => { try { services.scanJava(); } catch { /* egal */ } }, 800);
|
||||
|
||||
@@ -318,17 +613,14 @@ app.whenReady().then(() => {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const info = await updater.checkForUpdate(app.getVersion());
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
// Ergebnis immer melden, damit die Info-Seite auch "aktuell" anzeigen
|
||||
// kann – nicht erst wenn der Nutzer manuell auf "Suchen" klickt
|
||||
mainWindow.webContents.send('update:checked', info);
|
||||
if (info.available) mainWindow.webContents.send('update:available', info);
|
||||
}
|
||||
pendingUpdateInfo = info;
|
||||
// Ergebnis immer melden, damit die Info-Seite auch "aktuell" anzeigen
|
||||
// kann – nicht erst wenn der Nutzer manuell auf "Suchen" klickt
|
||||
broadcast('update:checked', info);
|
||||
if (info.available) broadcast('update:available', info);
|
||||
} catch (err) {
|
||||
// offline o. Ä. – kein Absturz, aber die Info-Seite darf den Fehler zeigen
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('update:checked', { error: (err && err.message) || String(err) });
|
||||
}
|
||||
broadcast('update:checked', { error: (err && err.message) || String(err) });
|
||||
}
|
||||
}, 4000);
|
||||
|
||||
@@ -340,7 +632,7 @@ app.whenReady().then(() => {
|
||||
const cid = store.getSettings().azureClientId || auth.DEFAULT_CLIENT_ID;
|
||||
auth.getValidAccount(cid)
|
||||
.then((acc) => {
|
||||
if (acc && mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('auth:refreshed');
|
||||
if (acc) broadcast('auth:refreshed');
|
||||
})
|
||||
.catch(() => { /* offline o. Ä. – Konto bleibt gespeichert */ });
|
||||
|
||||
@@ -353,7 +645,7 @@ app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
});
|
||||
|
||||
app.on('before-quit', () => { appIsQuitting = true; });
|
||||
app.on('before-quit', () => { appIsQuitting = true; discordpresence.shutdown(); });
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Java-Erkennung (für Anzeige in den Einstellungen)
|
||||
@@ -381,6 +673,16 @@ ipcMain.handle('settings:save', (_e, patch) => {
|
||||
const s = store.saveSettings(patch);
|
||||
applyProxy(s);
|
||||
if (patch && Object.prototype.hasOwnProperty.call(patch, 'autostart')) applyAutostart(s.autostart);
|
||||
if (patch && Object.prototype.hasOwnProperty.call(patch, 'discordClientId')) discordpresence.configure(s);
|
||||
// Einstellungen können jetzt auch aus dem Popup-Fenster gespeichert werden –
|
||||
// das Hauptfenster muss Theme/Sortierung/Bedrock-Sichtbarkeit/Skin-Hintergrund
|
||||
// dann selbst nachziehen. NICHT bei der beiläufigen "letzte Instanz"-Notiz
|
||||
// (die speichert bei jedem Klick auf eine Instanz mit) – sonst baut das
|
||||
// Hauptfenster bei jedem Klick seine ganze Liste neu auf und die flackert.
|
||||
const nurLetzteInstanz = patch && Object.keys(patch).every((k) => k === 'lastSelectedId');
|
||||
if (!nurLetzteInstanz && mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('settings:changed', s);
|
||||
}
|
||||
return s;
|
||||
});
|
||||
|
||||
@@ -510,14 +812,14 @@ ipcMain.handle('mods:install', async (_e, id, project, art) => {
|
||||
* per Hand zugeschickt). Die Datei taucht danach ganz normal in der
|
||||
* "Installiert"-Liste auf, weil listMods() den Ordner ohnehin mitscannt.
|
||||
*/
|
||||
ipcMain.handle('mods:addFile', async (_e, id, art) => {
|
||||
ipcMain.handle('mods:addFile', async (e, id, art) => {
|
||||
const inst = store.getInstance(id);
|
||||
if (!inst) return { ok: false, message: 'Instanz nicht gefunden.' };
|
||||
const typ = services.inhaltsArt(art || 'mod');
|
||||
const filters = (art || 'mod') === 'mod'
|
||||
? [{ name: 'Mod-Datei', extensions: ['jar', 'zip'] }]
|
||||
: [{ name: typ.label || 'Datei', extensions: ['zip'] }];
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Datei hinzufügen',
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
filters: filters.concat([{ name: 'Alle Dateien', extensions: ['*'] }]),
|
||||
@@ -617,7 +919,7 @@ ipcMain.handle('optifine:setup', async (_e, id) => {
|
||||
let prep;
|
||||
try {
|
||||
prep = await launcher.prepareAndLaunch(opts, (evt) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('launch:progress', Object.assign({ id }, evt));
|
||||
broadcast('launch:progress', Object.assign({ id }, evt));
|
||||
});
|
||||
} catch (err) {
|
||||
return { ok: false, message: 'Vorbereitung fehlgeschlagen: ' + err.message };
|
||||
@@ -784,7 +1086,7 @@ ipcMain.handle('mods:checkUpdates', async (_e, id, art) => {
|
||||
if (!gameVersion) return { ok: false, message: 'Instanz hat keine Minecraft-Version gesetzt.' };
|
||||
try {
|
||||
const res = await services.modrinthFindUpdates(store.listMods(id, art || 'mod'), gameVersion, loader, (p) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('mods:updateProgress', p);
|
||||
broadcast('mods:updateProgress', p);
|
||||
}, art || 'mod');
|
||||
return { ok: true, ...res };
|
||||
} catch (err) {
|
||||
@@ -852,8 +1154,8 @@ ipcMain.handle('skin:profile', async () => {
|
||||
catch (err) { return { ok: false, message: 'Profil konnte nicht geladen werden: ' + err.message }; }
|
||||
});
|
||||
|
||||
ipcMain.handle('skin:choose', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('skin:choose', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Skin auswählen',
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: 'PNG-Bild', extensions: ['png'] }],
|
||||
@@ -874,14 +1176,22 @@ ipcMain.handle('skin:choose', async () => {
|
||||
ipcMain.handle('skin:apply', async (_e, dateiPfad, variante) => {
|
||||
const token = await aktivesToken();
|
||||
if (!token) return { ok: false, message: 'Kein angemeldetes Konto.' };
|
||||
try { return await skins.setzeSkin(token, dateiPfad, variante); }
|
||||
try {
|
||||
const res = await skins.setzeSkin(token, dateiPfad, variante);
|
||||
if (res && res.ok) broadcast('skin:changed');
|
||||
return res;
|
||||
}
|
||||
catch (err) { return { ok: false, message: 'Skin konnte nicht gesetzt werden: ' + err.message }; }
|
||||
});
|
||||
|
||||
ipcMain.handle('skin:reset', async () => {
|
||||
const token = await aktivesToken();
|
||||
if (!token) return { ok: false, message: 'Kein angemeldetes Konto.' };
|
||||
try { return await skins.setzeSkinZurueck(token); }
|
||||
try {
|
||||
const res = await skins.setzeSkinZurueck(token);
|
||||
if (res && res.ok) broadcast('skin:changed');
|
||||
return res;
|
||||
}
|
||||
catch (err) { return { ok: false, message: 'Zurücksetzen fehlgeschlagen: ' + err.message }; }
|
||||
});
|
||||
ipcMain.handle('auth:remove', (_e, id) => auth.removeAccount(id));
|
||||
@@ -893,7 +1203,7 @@ ipcMain.handle('auth:login', async () => {
|
||||
const account = await auth.login(
|
||||
clientId,
|
||||
(code) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('auth:code', code);
|
||||
broadcast('auth:code', code);
|
||||
},
|
||||
() => {},
|
||||
);
|
||||
@@ -911,9 +1221,17 @@ ipcMain.handle('instances:list', () => store.listInstances());
|
||||
|
||||
ipcMain.handle('instances:get', (_e, id) => store.getInstance(id));
|
||||
|
||||
ipcMain.handle('instances:create', (_e, data) => store.createInstance(data));
|
||||
ipcMain.handle('instances:create', (_e, data) => {
|
||||
const res = store.createInstance(data);
|
||||
broadcast('instances:changed');
|
||||
return res;
|
||||
});
|
||||
|
||||
ipcMain.handle('instances:update', (_e, id, patch) => store.updateInstance(id, patch));
|
||||
ipcMain.handle('instances:update', (_e, id, patch) => {
|
||||
const res = store.updateInstance(id, patch);
|
||||
broadcast('instances:changed');
|
||||
return res;
|
||||
});
|
||||
|
||||
ipcMain.handle('instances:delete', (_e, id) => store.deleteInstance(id));
|
||||
|
||||
@@ -1109,9 +1427,7 @@ async function spieleMrpackEin(buf, zip, index, gameDir, { schonePlayerDaten })
|
||||
if (geschuetzt(rel)) continue;
|
||||
const dest = path.join(gameDir, rel.replace(/\//g, path.sep));
|
||||
if (!inside(dest)) continue;
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', { phase: 'modpack', current: i, total: files.length, detail: 'Modpack-Dateien' });
|
||||
}
|
||||
broadcast('launch:progress', { phase: 'modpack', current: i, total: files.length, detail: 'Modpack-Dateien' });
|
||||
try {
|
||||
const res = await fetch(url, { headers: { 'User-Agent': 'AeroMC-Launcher' } });
|
||||
if (!res.ok) continue;
|
||||
@@ -1219,9 +1535,7 @@ ipcMain.handle('modpack:update', async (_e, id, versionId) => {
|
||||
const datei = (version.files || []).find((f) => f.primary) || (version.files || [])[0];
|
||||
if (!datei || !datei.url) return { ok: false, message: 'Diese Fassung enthält keine Paketdatei.' };
|
||||
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', { id, phase: 'modpack', detail: 'Neue Fassung wird geladen …' });
|
||||
}
|
||||
broadcast('launch:progress', { id, phase: 'modpack', detail: 'Neue Fassung wird geladen …' });
|
||||
const dl = await fetch(datei.url, { headers: { 'User-Agent': 'AeroMC-Launcher' } });
|
||||
if (!dl.ok) return { ok: false, message: 'Download fehlgeschlagen (HTTP ' + dl.status + ').' };
|
||||
const buf = Buffer.from(await dl.arrayBuffer());
|
||||
@@ -1264,6 +1578,7 @@ ipcMain.handle('modpack:update', async (_e, id, versionId) => {
|
||||
}),
|
||||
});
|
||||
|
||||
broadcast('instances:changed');
|
||||
notify('Modpack aktualisiert', `${inst.name} ist auf Version ${version.version_number} aktualisiert.`);
|
||||
return {
|
||||
ok: true,
|
||||
@@ -1305,9 +1620,7 @@ async function importCurseForge(buf, zip, zugang) {
|
||||
const gameDir = store.gameDir(created.id);
|
||||
const inside = (dest) => dest.startsWith(gameDir + path.sep);
|
||||
const melde = (detail, current, total) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', { phase: 'modpack', current, total, detail });
|
||||
}
|
||||
broadcast('launch:progress', { phase: 'modpack', current, total, detail });
|
||||
};
|
||||
|
||||
// 1) Dateiliste über die CurseForge-API auflösen
|
||||
@@ -1376,11 +1689,7 @@ ipcMain.handle('modpack:installFromModrinth', async (_e, project) => {
|
||||
const projectId = project && (project.projectId || project.id);
|
||||
if (!projectId) return { ok: false, message: 'Kein Modpack gewählt.' };
|
||||
const gameVersion = (project && project.gameVersion) || '';
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', {
|
||||
phase: 'modpack', detail: 'Modpack-Version wird ermittelt …',
|
||||
});
|
||||
}
|
||||
broadcast('launch:progress', { phase: 'modpack', detail: 'Modpack-Version wird ermittelt …' });
|
||||
const file = await services.modrinthResolveModpack({ projectId, gameVersion });
|
||||
if (!file) {
|
||||
return {
|
||||
@@ -1390,12 +1699,7 @@ ipcMain.handle('modpack:installFromModrinth', async (_e, project) => {
|
||||
: 'Keine Modpack-Version gefunden.',
|
||||
};
|
||||
}
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', {
|
||||
phase: 'modpack',
|
||||
detail: 'Lade ' + (file.filename || file.name || 'Modpack') + ' …',
|
||||
});
|
||||
}
|
||||
broadcast('launch:progress', { phase: 'modpack', detail: 'Lade ' + (file.filename || file.name || 'Modpack') + ' …' });
|
||||
const buf = await services.downloadBuffer(file.url);
|
||||
const zip = forge.readZipIndex(buf);
|
||||
if (!zip['modrinth.index.json']) {
|
||||
@@ -1415,6 +1719,7 @@ ipcMain.handle('modpack:installFromModrinth', async (_e, project) => {
|
||||
result.instance = store.getInstance(inst.id);
|
||||
}
|
||||
if (result && result.ok && result.instance) {
|
||||
broadcast('instances:changed');
|
||||
notify('Modpack installiert', `${result.instance.name} ist einsatzbereit.`);
|
||||
}
|
||||
return result;
|
||||
@@ -1434,11 +1739,7 @@ ipcMain.handle('modpack:installFromCurseForge', async (_e, project) => {
|
||||
const modId = Number(rawId);
|
||||
if (!modId) return { ok: false, message: 'Kein Modpack gewählt.' };
|
||||
const gameVersion = (project && project.gameVersion) || '';
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', {
|
||||
phase: 'modpack', detail: 'Modpack-Version wird ermittelt …',
|
||||
});
|
||||
}
|
||||
broadcast('launch:progress', { phase: 'modpack', detail: 'Modpack-Version wird ermittelt …' });
|
||||
const file = await services.curseforgeResolveModpackFile(zugang, modId, gameVersion);
|
||||
if (!file || !file.url) {
|
||||
return {
|
||||
@@ -1448,11 +1749,7 @@ ipcMain.handle('modpack:installFromCurseForge', async (_e, project) => {
|
||||
: 'Keine passende Modpack-Datei gefunden.',
|
||||
};
|
||||
}
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', {
|
||||
phase: 'modpack', detail: 'Lade ' + file.filename + ' …',
|
||||
});
|
||||
}
|
||||
broadcast('launch:progress', { phase: 'modpack', detail: 'Lade ' + file.filename + ' …' });
|
||||
const dlUrl = zugang.downloadAdresse ? zugang.downloadAdresse(file.url) : file.url;
|
||||
const buf = await services.downloadBuffer(dlUrl, zugang.downloadKopfzeilen);
|
||||
const zip = forge.readZipIndex(buf);
|
||||
@@ -1461,6 +1758,7 @@ ipcMain.handle('modpack:installFromCurseForge', async (_e, project) => {
|
||||
}
|
||||
const result = await importCurseForge(buf, zip, zugang);
|
||||
if (result && result.ok && result.instance) {
|
||||
broadcast('instances:changed');
|
||||
notify('Modpack installiert', `${result.instance.name} ist einsatzbereit.`);
|
||||
}
|
||||
return result;
|
||||
@@ -1493,6 +1791,7 @@ async function importModpackFromPath(filePath) {
|
||||
return { ok: false, notModpack: true, message: 'Unbekanntes Modpack-Format (keine modrinth.index.json gefunden).' };
|
||||
}
|
||||
if (result && result.ok && result.instance) {
|
||||
broadcast('instances:changed');
|
||||
notify('Modpack installiert', `${result.instance.name} ist einsatzbereit.`);
|
||||
}
|
||||
return result;
|
||||
@@ -1501,8 +1800,8 @@ async function importModpackFromPath(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('modpack:import', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('modpack:import', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Modpack importieren',
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: 'Modpacks', extensions: ['mrpack', 'zip'] }],
|
||||
@@ -1631,14 +1930,16 @@ async function importInstanceZipFromPath(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.handle('instances:import', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('instances:import', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Instanz importieren',
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: 'ZIP-Archiv', extensions: ['zip'] }],
|
||||
});
|
||||
if (res.canceled) return { ok: false, canceled: true };
|
||||
return importInstanceZipFromPath(res.filePaths[0]);
|
||||
const result = await importInstanceZipFromPath(res.filePaths[0]);
|
||||
if (result && result.ok) broadcast('instances:changed');
|
||||
return result;
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -1684,6 +1985,7 @@ ipcMain.handle('files:drop', async (_e, filePath, targetId, targetArt) => {
|
||||
if (!modpack.notModpack || ext === '.mrpack') return Object.assign({ kind: 'modpack' }, modpack);
|
||||
// .zip ohne erkanntes Modpack-Format -> als Instanz-Export/-Import versuchen
|
||||
const instanceRes = await importInstanceZipFromPath(filePath);
|
||||
if (instanceRes && instanceRes.ok) broadcast('instances:changed');
|
||||
return Object.assign({ kind: 'instance' }, instanceRes);
|
||||
}
|
||||
|
||||
@@ -1698,7 +2000,7 @@ ipcMain.handle('files:drop', async (_e, filePath, targetId, targetArt) => {
|
||||
function notify(title, body) {
|
||||
try {
|
||||
if (store.getSettings().desktopNotifications === false) return;
|
||||
if (mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()) return;
|
||||
if (BrowserWindow.getAllWindows().some((w) => !w.isDestroyed() && w.isFocused())) return;
|
||||
if (!Notification.isSupported()) return;
|
||||
const n = new Notification({ title, body, silent: false });
|
||||
n.on('click', () => {
|
||||
@@ -1832,7 +2134,7 @@ ipcMain.handle('backup:restore', async (_e, sourcePath) => {
|
||||
const spielendeKonten = new Map();
|
||||
|
||||
function meldeKontenAenderung() {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('accounts:changed');
|
||||
broadcast('accounts:changed');
|
||||
}
|
||||
|
||||
function kontoSpieltJetzt(kontoId) {
|
||||
@@ -1850,6 +2152,12 @@ function kontoSpieltNichtMehr(kontoId) {
|
||||
}
|
||||
|
||||
ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
|
||||
// für die Spielaufzeichnung merken, mit welchem Server (Quick Play) diese
|
||||
// Instanz zuletzt gestartet wurde -- muss im Hauptprozess liegen, weil
|
||||
// Serverliste und Aufzeichnung zwei getrennte Popup-Fenster mit jeweils
|
||||
// eigenem Renderer-Speicher sind
|
||||
if (launchOpts && launchOpts.quickPlayServer) letzteQuickPlayServer.set(id, launchOpts.quickPlayServer);
|
||||
else letzteQuickPlayServer.delete(id);
|
||||
const inst = store.getInstance(id);
|
||||
if (!inst) return { ok: false, message: 'Instanz nicht gefunden.' };
|
||||
if (!inst.minecraft.version) {
|
||||
@@ -1872,9 +2180,7 @@ ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
|
||||
// die nebenher läuft, während Minecraft dieselben Dateien anfasst, wäre
|
||||
// nicht verlässlich.
|
||||
if (settings.autoBackupEnabled && settings.autoBackupBeforeLaunch) {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', { id, phase: 'backup', detail: 'Sicherung vor dem Start …' });
|
||||
}
|
||||
broadcast('launch:progress', { id, phase: 'backup', detail: 'Sicherung vor dem Start …' });
|
||||
await backupNachZeitplan('vor-dem-start').catch(() => {});
|
||||
}
|
||||
|
||||
@@ -1926,9 +2232,16 @@ ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
|
||||
if (evt.phase === 'launch') {
|
||||
launchStart = Date.now();
|
||||
if (!gezaehlt) { gezaehlt = true; kontoSpieltJetzt(kontoId); }
|
||||
discordpresence.setActivity({
|
||||
details: 'Spielt Minecraft',
|
||||
state: `${inst.name} · ${inst.minecraft.version}`,
|
||||
startTimestamp: launchStart,
|
||||
});
|
||||
}
|
||||
if (evt.phase === 'exit') {
|
||||
if (gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); }
|
||||
discordpresence.clearActivity();
|
||||
laufendePid.delete(id); // für die "Nur Minecraft"-Tonaufnahme: Prozess ist weg
|
||||
if (launchStart) {
|
||||
const secs = Math.max(0, Math.round((Date.now() - launchStart) / 1000));
|
||||
launchStart = 0; // Spielzeit nur einmal gutschreiben
|
||||
@@ -1936,17 +2249,26 @@ ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
|
||||
if (cur) store.updateInstance(id, { totalPlaySeconds: (cur.totalPlaySeconds || 0) + secs });
|
||||
}
|
||||
}
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('launch:progress', Object.assign({ id }, evt));
|
||||
if (evt.phase === 'log') {
|
||||
const m = VERBINDUNGS_ZEILE.exec(evt.line);
|
||||
if (m) {
|
||||
const server = m[2] === '25565' ? m[1] : `${m[1]}:${m[2]}`;
|
||||
letzteQuickPlayServer.set(id, server);
|
||||
// damit ein schon offenes Aufzeichnungs-Fenster den Servernamen im
|
||||
// Titel nachträgt, auch wenn es VOR dem Verbinden geöffnet wurde
|
||||
broadcast('recording:serverDetected', { id, server });
|
||||
}
|
||||
}
|
||||
broadcast('launch:progress', Object.assign({ id }, evt));
|
||||
});
|
||||
// Start fehlgeschlagen, obwohl schon gezählt -> Zählung zurücknehmen,
|
||||
// sonst bliebe das Konto für immer als "spielt" stehen
|
||||
if (!res.ok && gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); }
|
||||
if (!res.ok && gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); discordpresence.clearActivity(); }
|
||||
if (res.ok) store.updateInstance(id, { lastPlayed: new Date().toISOString() });
|
||||
if (res.ok && res.pid) laufendePid.set(id, res.pid);
|
||||
return res;
|
||||
} catch (err) {
|
||||
if (gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); }
|
||||
if (gezaehlt) { gezaehlt = false; kontoSpieltNichtMehr(kontoId); discordpresence.clearActivity(); }
|
||||
return { ok: false, message: 'Start fehlgeschlagen: ' + err.message };
|
||||
}
|
||||
});
|
||||
@@ -1955,8 +2277,8 @@ ipcMain.handle('instances:launch', async (_e, id, accountId, launchOpts) => {
|
||||
// IPC – Dialoge
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
ipcMain.handle('dialog:pickFolder', async (_e, title) => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('dialog:pickFolder', async (e, title) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: title || 'Ordner wählen',
|
||||
properties: ['openDirectory', 'createDirectory'],
|
||||
});
|
||||
@@ -1992,8 +2314,8 @@ ipcMain.handle('file:dataUri', (_e, filePath) => {
|
||||
} catch { return null; }
|
||||
});
|
||||
|
||||
ipcMain.handle('dialog:pickJava', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('dialog:pickJava', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'java.exe wählen',
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: 'Java', extensions: ['exe'] }],
|
||||
@@ -2010,8 +2332,8 @@ ipcMain.handle('app:openExternal', (_e, url) => {
|
||||
// IPC – Instanzen aus MultiMC/Prism übernehmen
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
ipcMain.handle('mmc:pickFolder', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('mmc:pickFolder', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'MultiMC-Ordner wählen (der Ordner mit MultiMC.exe)',
|
||||
properties: ['openDirectory'],
|
||||
});
|
||||
@@ -2032,15 +2354,14 @@ ipcMain.handle('mmc:import', (_e, entries, copyData) => {
|
||||
done.push(imported);
|
||||
}
|
||||
catch (err) { failed.push({ name: entry.name, message: err.message }); }
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('mmc:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
broadcast('mmc:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
if (done.length) broadcast('instances:changed');
|
||||
return { ok: true, imported: done, failed };
|
||||
});
|
||||
|
||||
ipcMain.handle('cf:pickFolder', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('cf:pickFolder', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'CurseForge-Ordner wählen (oder direkt den Instances-Ordner)',
|
||||
properties: ['openDirectory'],
|
||||
});
|
||||
@@ -2061,15 +2382,14 @@ ipcMain.handle('cf:import', (_e, entries, copyData) => {
|
||||
done.push(imported);
|
||||
}
|
||||
catch (err) { failed.push({ name: entry.name, message: err.message }); }
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('cf:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
broadcast('cf:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
if (done.length) broadcast('instances:changed');
|
||||
return { ok: true, imported: done, failed };
|
||||
});
|
||||
|
||||
ipcMain.handle('mc:pickFolder', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('mc:pickFolder', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Minecraft-Launcher-Ordner wählen (meist .minecraft)',
|
||||
properties: ['openDirectory'],
|
||||
});
|
||||
@@ -2090,15 +2410,14 @@ ipcMain.handle('mc:import', (_e, entries, copyData) => {
|
||||
done.push(imported);
|
||||
}
|
||||
catch (err) { failed.push({ name: entry.name, message: err.message }); }
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('mc:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
broadcast('mc:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
if (done.length) broadcast('instances:changed');
|
||||
return { ok: true, imported: done, failed };
|
||||
});
|
||||
|
||||
ipcMain.handle('technic:pickFolder', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('technic:pickFolder', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Technic-Ordner wählen (oder direkt den modpacks-Ordner)',
|
||||
properties: ['openDirectory'],
|
||||
});
|
||||
@@ -2119,10 +2438,9 @@ ipcMain.handle('technic:import', (_e, entries, copyData) => {
|
||||
done.push(imported);
|
||||
}
|
||||
catch (err) { failed.push({ name: entry.name, message: err.message }); }
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send('technic:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
broadcast('technic:progress', { current: done.length + failed.length, total: entries.length });
|
||||
}
|
||||
if (done.length) broadcast('instances:changed');
|
||||
return { ok: true, imported: done, failed };
|
||||
});
|
||||
|
||||
@@ -2136,9 +2454,12 @@ ipcMain.handle('technicPlatform:search', async (_e, query) => {
|
||||
ipcMain.handle('technicPlatform:install', async (_e, slug) => {
|
||||
try {
|
||||
const res = await technicdiscover.installFromPlatform(store, slug, (p) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('technicPlatform:progress', p);
|
||||
broadcast('technicPlatform:progress', p);
|
||||
});
|
||||
if (res.ok && res.instance) notify('Modpack installiert', `${res.instance.name} ist einsatzbereit.`);
|
||||
if (res.ok && res.instance) {
|
||||
broadcast('instances:changed');
|
||||
notify('Modpack installiert', `${res.instance.name} ist einsatzbereit.`);
|
||||
}
|
||||
return res;
|
||||
} catch (err) {
|
||||
return { ok: false, message: err.message };
|
||||
@@ -2161,8 +2482,8 @@ ipcMain.handle('bedrock:openFolder', (_e, kind) => {
|
||||
return true;
|
||||
});
|
||||
|
||||
ipcMain.handle('bedrock:installAddon', async () => {
|
||||
const res = await dialog.showOpenDialog(mainWindow, {
|
||||
ipcMain.handle('bedrock:installAddon', async (e) => {
|
||||
const res = await dialog.showOpenDialog(BrowserWindow.fromWebContents(e.sender) || mainWindow, {
|
||||
title: 'Add-on oder Welt importieren',
|
||||
properties: ['openFile'],
|
||||
filters: [{ name: 'Bedrock-Pakete', extensions: ['mcpack', 'mcaddon', 'mcworld', 'mctemplate'] }],
|
||||
@@ -2211,15 +2532,18 @@ ipcMain.handle('icons:extract', () => {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
ipcMain.handle('update:check', async () => {
|
||||
try { return await updater.checkForUpdate(app.getVersion()); }
|
||||
catch (err) { return { available: false, error: err.message }; }
|
||||
try {
|
||||
const info = await updater.checkForUpdate(app.getVersion());
|
||||
pendingUpdateInfo = info;
|
||||
return info;
|
||||
} catch (err) { return { available: false, error: err.message }; }
|
||||
});
|
||||
|
||||
// Ein Klick: herunterladen, prüfen, Update anwenden und Launcher beenden
|
||||
ipcMain.handle('update:install', async (_e, asset) => {
|
||||
try {
|
||||
const file = await updater.downloadAndInstall(asset, (p) => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) mainWindow.webContents.send('update:progress', p);
|
||||
broadcast('update:progress', p);
|
||||
});
|
||||
const res = updater.applyUpdate(file);
|
||||
// Portable: der Tausch klappt erst, wenn der Launcher die EXE freigibt
|
||||
|
||||
+216
-216
@@ -1,217 +1,217 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const PROFILE_FILES = [
|
||||
'launcher_profiles.json',
|
||||
'launcher_profiles_microsoft_store.json',
|
||||
'launcher_profiles_microsoft_store_2.json',
|
||||
];
|
||||
|
||||
const ROOT_COPY_DIRS = new Set([
|
||||
'config', 'defaultconfigs', 'kubejs', 'mods', 'resourcepacks', 'screenshots', 'shaderpacks', 'saves',
|
||||
]);
|
||||
|
||||
const ROOT_COPY_FILE_PATTERNS = [
|
||||
/^options.*\.(txt|of)$/i,
|
||||
/^servers\.dat(?:_old)?$/i,
|
||||
/^usercache\.json$/i,
|
||||
/^tl_skin_cape\.json$/i,
|
||||
/^journeymap.*\.(json|txt|cfg)$/i,
|
||||
];
|
||||
|
||||
function readJson(file, fallback) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveLauncherRoot(inputPath) {
|
||||
const appData = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming');
|
||||
const defaultRoot = path.join(appData, '.minecraft');
|
||||
const candidates = [];
|
||||
|
||||
if (inputPath && fs.existsSync(inputPath)) candidates.push(inputPath);
|
||||
candidates.push(defaultRoot);
|
||||
|
||||
for (const candidate of candidates) {
|
||||
for (const profileFile of PROFILE_FILES) {
|
||||
if (fs.existsSync(path.join(candidate, profileFile))) return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function resolveProfileFile(rootDir) {
|
||||
return PROFILE_FILES.map((name) => path.join(rootDir, name)).find((file) => fs.existsSync(file)) || null;
|
||||
}
|
||||
|
||||
function normalizeLoaderVersion(loader, rawValue, mcVersion) {
|
||||
let value = String(rawValue || '').trim();
|
||||
if (!value) return '';
|
||||
|
||||
if (loader === 'forge') {
|
||||
value = value.replace(/^forge-/i, '');
|
||||
if (mcVersion && value.startsWith(mcVersion + '-')) value = value.slice(mcVersion.length + 1);
|
||||
return value;
|
||||
}
|
||||
if (loader === 'neoforge') return value.replace(/^neoforge-/i, '');
|
||||
if (loader === 'fabric') {
|
||||
value = value.replace(/^fabric(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
if (loader === 'quilt') {
|
||||
value = value.replace(/^quilt(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function parseLastVersionId(lastVersionId) {
|
||||
const raw = String(lastVersionId || '').trim();
|
||||
if (!raw) return { version: '', loader: 'vanilla', loaderVersion: '' };
|
||||
|
||||
let match = raw.match(/^fabric-loader-([^-]+(?:\.[^-]+)*)-(.+)$/i);
|
||||
if (match) return { version: match[2], loader: 'fabric', loaderVersion: normalizeLoaderVersion('fabric', match[1], match[2]) };
|
||||
|
||||
match = raw.match(/^quilt-loader-([^-]+(?:\.[^-]+)*)-(.+)$/i);
|
||||
if (match) return { version: match[2], loader: 'quilt', loaderVersion: normalizeLoaderVersion('quilt', match[1], match[2]) };
|
||||
|
||||
match = raw.match(/^(.+)-forge-([\w.-]+)$/i);
|
||||
if (match) return { version: match[1], loader: 'forge', loaderVersion: normalizeLoaderVersion('forge', match[2], match[1]) };
|
||||
|
||||
match = raw.match(/^forge-(.+)-([\w.-]+)$/i);
|
||||
if (match) return { version: match[1], loader: 'forge', loaderVersion: normalizeLoaderVersion('forge', match[2], match[1]) };
|
||||
|
||||
match = raw.match(/^(.+)-neoforge-([\w.-]+)$/i);
|
||||
if (match) return { version: match[1], loader: 'neoforge', loaderVersion: normalizeLoaderVersion('neoforge', match[2], match[1]) };
|
||||
|
||||
if (/^\d+(?:\.\d+)+(?:-[\w.]+)?$/i.test(raw)) return { version: raw, loader: 'vanilla', loaderVersion: '' };
|
||||
return { version: raw, loader: 'vanilla', loaderVersion: '' };
|
||||
}
|
||||
|
||||
function parseJavaSettings(javaDir, javaArgs) {
|
||||
const args = String(javaArgs || '').trim();
|
||||
const minMatch = args.match(/(?:^|\s)-Xms(\d+)([mMgG])/);
|
||||
const maxMatch = args.match(/(?:^|\s)-Xmx(\d+)([mMgG])/);
|
||||
const toMb = (match) => {
|
||||
if (!match) return null;
|
||||
const num = Number(match[1]);
|
||||
if (!Number.isFinite(num)) return null;
|
||||
return match[2].toLowerCase() === 'g' ? num * 1024 : num;
|
||||
};
|
||||
|
||||
return {
|
||||
path: String(javaDir || '').trim(),
|
||||
minMemMb: toMb(minMatch),
|
||||
maxMemMb: toMb(maxMatch),
|
||||
extraArgs: args
|
||||
.replace(/(?:^|\s)-Xms\d+[mMgG]/g, ' ')
|
||||
.replace(/(?:^|\s)-Xmx\d+[mMgG]/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim(),
|
||||
};
|
||||
}
|
||||
|
||||
function isImportableProfile(profile) {
|
||||
const type = String((profile && profile.type) || '').trim().toLowerCase();
|
||||
if (type === 'latest-release' || type === 'latest-snapshot') return false;
|
||||
const name = String((profile && profile.name) || '').trim();
|
||||
const lastVersionId = String((profile && profile.lastVersionId) || '').trim();
|
||||
return !!(name || lastVersionId);
|
||||
}
|
||||
|
||||
function shouldCopyRootEntry(name) {
|
||||
if (ROOT_COPY_DIRS.has(name)) return true;
|
||||
return ROOT_COPY_FILE_PATTERNS.some((pattern) => pattern.test(name));
|
||||
}
|
||||
|
||||
function scan(inputPath) {
|
||||
const rootDir = resolveLauncherRoot(inputPath);
|
||||
if (!rootDir) return { ok: false, reason: 'not-found' };
|
||||
|
||||
const profileFile = resolveProfileFile(rootDir);
|
||||
const json = readJson(profileFile, {});
|
||||
const profiles = json.profiles || {};
|
||||
const list = [];
|
||||
const defaultRoot = path.normalize(rootDir).toLowerCase();
|
||||
|
||||
for (const [id, profile] of Object.entries(profiles)) {
|
||||
if (!isImportableProfile(profile)) continue;
|
||||
|
||||
const name = String(profile.name || '').trim() || String(profile.lastVersionId || '').trim() || id;
|
||||
const parsed = parseLastVersionId(profile.lastVersionId);
|
||||
const gameDir = path.normalize(String(profile.gameDir || rootDir));
|
||||
const java = parseJavaSettings(profile.javaDir, profile.javaArgs);
|
||||
|
||||
list.push({
|
||||
id,
|
||||
name,
|
||||
group: '',
|
||||
notes: 'Importiert aus dem Minecraft Launcher',
|
||||
version: parsed.version,
|
||||
loader: parsed.loader,
|
||||
loaderVersion: parsed.loaderVersion,
|
||||
javaPath: java.path,
|
||||
minMemMb: java.minMemMb,
|
||||
maxMemMb: java.maxMemMb,
|
||||
extraJavaArgs: java.extraArgs,
|
||||
gameDir,
|
||||
hasGameData: fs.existsSync(gameDir),
|
||||
usesDefaultGameDir: gameDir.toLowerCase() === defaultRoot,
|
||||
rootDir,
|
||||
});
|
||||
}
|
||||
|
||||
list.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return { ok: true, rootDir, count: list.length, instances: list };
|
||||
}
|
||||
|
||||
function copyInto(sourceDir, targetDir, usesDefaultGameDir) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
for (const name of fs.readdirSync(sourceDir)) {
|
||||
if (/^launcher_profiles.*\.json$/i.test(name)) continue;
|
||||
if (name === 'versions' || name === 'libraries' || name === 'assets' || name === 'runtime' || name === 'webcache2') continue;
|
||||
if (usesDefaultGameDir && !shouldCopyRootEntry(name)) continue;
|
||||
fs.cpSync(path.join(sourceDir, name), path.join(targetDir, name), { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
function importOne(store, entry, copyData = true) {
|
||||
const created = store.createOrReplaceImportedInstance({
|
||||
name: entry.name,
|
||||
group: entry.group,
|
||||
notes: entry.notes,
|
||||
minecraft: {
|
||||
version: entry.version,
|
||||
loader: entry.loader,
|
||||
loaderVersion: entry.loaderVersion,
|
||||
},
|
||||
});
|
||||
|
||||
const patch = {};
|
||||
if (entry.javaPath || entry.minMemMb || entry.maxMemMb || entry.extraJavaArgs) {
|
||||
patch.java = {
|
||||
path: entry.javaPath || '',
|
||||
minMemMb: entry.minMemMb || null,
|
||||
maxMemMb: entry.maxMemMb || null,
|
||||
extraArgs: entry.extraJavaArgs || '',
|
||||
};
|
||||
}
|
||||
if (Object.keys(patch).length) store.updateInstance(created.id, patch);
|
||||
|
||||
let copied = false;
|
||||
if (copyData && entry.gameDir && fs.existsSync(entry.gameDir)) {
|
||||
copyInto(entry.gameDir, store.gameDir(created.id), !!entry.usesDefaultGameDir);
|
||||
copied = true;
|
||||
}
|
||||
return { id: created.id, name: created.name, copied };
|
||||
}
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const PROFILE_FILES = [
|
||||
'launcher_profiles.json',
|
||||
'launcher_profiles_microsoft_store.json',
|
||||
'launcher_profiles_microsoft_store_2.json',
|
||||
];
|
||||
|
||||
const ROOT_COPY_DIRS = new Set([
|
||||
'config', 'defaultconfigs', 'kubejs', 'mods', 'resourcepacks', 'screenshots', 'shaderpacks', 'saves',
|
||||
]);
|
||||
|
||||
const ROOT_COPY_FILE_PATTERNS = [
|
||||
/^options.*\.(txt|of)$/i,
|
||||
/^servers\.dat(?:_old)?$/i,
|
||||
/^usercache\.json$/i,
|
||||
/^tl_skin_cape\.json$/i,
|
||||
/^journeymap.*\.(json|txt|cfg)$/i,
|
||||
];
|
||||
|
||||
function readJson(file, fallback) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveLauncherRoot(inputPath) {
|
||||
const appData = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming');
|
||||
const defaultRoot = path.join(appData, '.minecraft');
|
||||
const candidates = [];
|
||||
|
||||
if (inputPath && fs.existsSync(inputPath)) candidates.push(inputPath);
|
||||
candidates.push(defaultRoot);
|
||||
|
||||
for (const candidate of candidates) {
|
||||
for (const profileFile of PROFILE_FILES) {
|
||||
if (fs.existsSync(path.join(candidate, profileFile))) return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function resolveProfileFile(rootDir) {
|
||||
return PROFILE_FILES.map((name) => path.join(rootDir, name)).find((file) => fs.existsSync(file)) || null;
|
||||
}
|
||||
|
||||
function normalizeLoaderVersion(loader, rawValue, mcVersion) {
|
||||
let value = String(rawValue || '').trim();
|
||||
if (!value) return '';
|
||||
|
||||
if (loader === 'forge') {
|
||||
value = value.replace(/^forge-/i, '');
|
||||
if (mcVersion && value.startsWith(mcVersion + '-')) value = value.slice(mcVersion.length + 1);
|
||||
return value;
|
||||
}
|
||||
if (loader === 'neoforge') return value.replace(/^neoforge-/i, '');
|
||||
if (loader === 'fabric') {
|
||||
value = value.replace(/^fabric(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
if (loader === 'quilt') {
|
||||
value = value.replace(/^quilt(?:-loader)?-/i, '');
|
||||
if (mcVersion && value.endsWith('-' + mcVersion)) value = value.slice(0, -1 * (mcVersion.length + 1));
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function parseLastVersionId(lastVersionId) {
|
||||
const raw = String(lastVersionId || '').trim();
|
||||
if (!raw) return { version: '', loader: 'vanilla', loaderVersion: '' };
|
||||
|
||||
let match = raw.match(/^fabric-loader-([^-]+(?:\.[^-]+)*)-(.+)$/i);
|
||||
if (match) return { version: match[2], loader: 'fabric', loaderVersion: normalizeLoaderVersion('fabric', match[1], match[2]) };
|
||||
|
||||
match = raw.match(/^quilt-loader-([^-]+(?:\.[^-]+)*)-(.+)$/i);
|
||||
if (match) return { version: match[2], loader: 'quilt', loaderVersion: normalizeLoaderVersion('quilt', match[1], match[2]) };
|
||||
|
||||
match = raw.match(/^(.+)-forge-([\w.-]+)$/i);
|
||||
if (match) return { version: match[1], loader: 'forge', loaderVersion: normalizeLoaderVersion('forge', match[2], match[1]) };
|
||||
|
||||
match = raw.match(/^forge-(.+)-([\w.-]+)$/i);
|
||||
if (match) return { version: match[1], loader: 'forge', loaderVersion: normalizeLoaderVersion('forge', match[2], match[1]) };
|
||||
|
||||
match = raw.match(/^(.+)-neoforge-([\w.-]+)$/i);
|
||||
if (match) return { version: match[1], loader: 'neoforge', loaderVersion: normalizeLoaderVersion('neoforge', match[2], match[1]) };
|
||||
|
||||
if (/^\d+(?:\.\d+)+(?:-[\w.]+)?$/i.test(raw)) return { version: raw, loader: 'vanilla', loaderVersion: '' };
|
||||
return { version: raw, loader: 'vanilla', loaderVersion: '' };
|
||||
}
|
||||
|
||||
function parseJavaSettings(javaDir, javaArgs) {
|
||||
const args = String(javaArgs || '').trim();
|
||||
const minMatch = args.match(/(?:^|\s)-Xms(\d+)([mMgG])/);
|
||||
const maxMatch = args.match(/(?:^|\s)-Xmx(\d+)([mMgG])/);
|
||||
const toMb = (match) => {
|
||||
if (!match) return null;
|
||||
const num = Number(match[1]);
|
||||
if (!Number.isFinite(num)) return null;
|
||||
return match[2].toLowerCase() === 'g' ? num * 1024 : num;
|
||||
};
|
||||
|
||||
return {
|
||||
path: String(javaDir || '').trim(),
|
||||
minMemMb: toMb(minMatch),
|
||||
maxMemMb: toMb(maxMatch),
|
||||
extraArgs: args
|
||||
.replace(/(?:^|\s)-Xms\d+[mMgG]/g, ' ')
|
||||
.replace(/(?:^|\s)-Xmx\d+[mMgG]/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim(),
|
||||
};
|
||||
}
|
||||
|
||||
function isImportableProfile(profile) {
|
||||
const type = String((profile && profile.type) || '').trim().toLowerCase();
|
||||
if (type === 'latest-release' || type === 'latest-snapshot') return false;
|
||||
const name = String((profile && profile.name) || '').trim();
|
||||
const lastVersionId = String((profile && profile.lastVersionId) || '').trim();
|
||||
return !!(name || lastVersionId);
|
||||
}
|
||||
|
||||
function shouldCopyRootEntry(name) {
|
||||
if (ROOT_COPY_DIRS.has(name)) return true;
|
||||
return ROOT_COPY_FILE_PATTERNS.some((pattern) => pattern.test(name));
|
||||
}
|
||||
|
||||
function scan(inputPath) {
|
||||
const rootDir = resolveLauncherRoot(inputPath);
|
||||
if (!rootDir) return { ok: false, reason: 'not-found' };
|
||||
|
||||
const profileFile = resolveProfileFile(rootDir);
|
||||
const json = readJson(profileFile, {});
|
||||
const profiles = json.profiles || {};
|
||||
const list = [];
|
||||
const defaultRoot = path.normalize(rootDir).toLowerCase();
|
||||
|
||||
for (const [id, profile] of Object.entries(profiles)) {
|
||||
if (!isImportableProfile(profile)) continue;
|
||||
|
||||
const name = String(profile.name || '').trim() || String(profile.lastVersionId || '').trim() || id;
|
||||
const parsed = parseLastVersionId(profile.lastVersionId);
|
||||
const gameDir = path.normalize(String(profile.gameDir || rootDir));
|
||||
const java = parseJavaSettings(profile.javaDir, profile.javaArgs);
|
||||
|
||||
list.push({
|
||||
id,
|
||||
name,
|
||||
group: '',
|
||||
notes: 'Importiert aus dem Minecraft Launcher',
|
||||
version: parsed.version,
|
||||
loader: parsed.loader,
|
||||
loaderVersion: parsed.loaderVersion,
|
||||
javaPath: java.path,
|
||||
minMemMb: java.minMemMb,
|
||||
maxMemMb: java.maxMemMb,
|
||||
extraJavaArgs: java.extraArgs,
|
||||
gameDir,
|
||||
hasGameData: fs.existsSync(gameDir),
|
||||
usesDefaultGameDir: gameDir.toLowerCase() === defaultRoot,
|
||||
rootDir,
|
||||
});
|
||||
}
|
||||
|
||||
list.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return { ok: true, rootDir, count: list.length, instances: list };
|
||||
}
|
||||
|
||||
function copyInto(sourceDir, targetDir, usesDefaultGameDir) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
for (const name of fs.readdirSync(sourceDir)) {
|
||||
if (/^launcher_profiles.*\.json$/i.test(name)) continue;
|
||||
if (name === 'versions' || name === 'libraries' || name === 'assets' || name === 'runtime' || name === 'webcache2') continue;
|
||||
if (usesDefaultGameDir && !shouldCopyRootEntry(name)) continue;
|
||||
fs.cpSync(path.join(sourceDir, name), path.join(targetDir, name), { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
function importOne(store, entry, copyData = true) {
|
||||
const created = store.createOrReplaceImportedInstance({
|
||||
name: entry.name,
|
||||
group: entry.group,
|
||||
notes: entry.notes,
|
||||
minecraft: {
|
||||
version: entry.version,
|
||||
loader: entry.loader,
|
||||
loaderVersion: entry.loaderVersion,
|
||||
},
|
||||
});
|
||||
|
||||
const patch = {};
|
||||
if (entry.javaPath || entry.minMemMb || entry.maxMemMb || entry.extraJavaArgs) {
|
||||
patch.java = {
|
||||
path: entry.javaPath || '',
|
||||
minMemMb: entry.minMemMb || null,
|
||||
maxMemMb: entry.maxMemMb || null,
|
||||
extraArgs: entry.extraJavaArgs || '',
|
||||
};
|
||||
}
|
||||
if (Object.keys(patch).length) store.updateInstance(created.id, patch);
|
||||
|
||||
let copied = false;
|
||||
if (copyData && entry.gameDir && fs.existsSync(entry.gameDir)) {
|
||||
copyInto(entry.gameDir, store.gameDir(created.id), !!entry.usesDefaultGameDir);
|
||||
copied = true;
|
||||
}
|
||||
return { id: created.id, name: created.name, copied };
|
||||
}
|
||||
|
||||
module.exports = { scan, importOne, parseLastVersionId, resolveLauncherRoot };
|
||||
@@ -0,0 +1,50 @@
|
||||
// AudioWorklet-Prozessor für die isolierte "Nur Minecraft"-Tonaufnahme.
|
||||
//
|
||||
// loopback-capture liefert PCM-Häppchen unregelmäßig getaktet über IPC (mal
|
||||
// etwas früher, mal etwas später). Würde man sie direkt nacheinander als
|
||||
// einzelne AudioBufferSourceNode-Aufrufe abspielen, würde jede kleine
|
||||
// Verzögerung als hörbares Knacksen/Aussetzer auffallen. Stattdessen landen
|
||||
// ankommende Häppchen hier in einem Ringpuffer; der Audio-Rendering-Thread
|
||||
// liest in gleichmäßigem Takt (process() läuft alle 128 Samples) daraus.
|
||||
// Kleine Zeitschwankungen bei der Anlieferung werden so unhörbar
|
||||
// abgefedert. Läuft der Puffer doch mal leer, gibt es kurz Stille statt
|
||||
// eines Knacksens.
|
||||
class PcmRingBufferProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.capacity = sampleRate * 2; // 2 Sekunden Puffer je Kanal
|
||||
this.ring = [new Float32Array(this.capacity), new Float32Array(this.capacity)];
|
||||
this.writeIdx = 0;
|
||||
this.readIdx = 0;
|
||||
this.available = 0; // gepufferte Frames (nicht Samples)
|
||||
this.port.onmessage = (e) => this._enqueue(e.data);
|
||||
}
|
||||
|
||||
_enqueue([left, right]) {
|
||||
const n = left.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const idx = (this.writeIdx + i) % this.capacity;
|
||||
this.ring[0][idx] = left[i];
|
||||
this.ring[1][idx] = right[i];
|
||||
}
|
||||
this.writeIdx = (this.writeIdx + n) % this.capacity;
|
||||
this.available = Math.min(this.capacity, this.available + n);
|
||||
}
|
||||
|
||||
process(_inputs, outputs) {
|
||||
const output = outputs[0];
|
||||
const frames = output[0].length;
|
||||
const playable = Math.min(frames, this.available);
|
||||
for (let i = 0; i < playable; i++) {
|
||||
const idx = (this.readIdx + i) % this.capacity;
|
||||
output[0][i] = this.ring[0][idx];
|
||||
output[1][i] = this.ring[1][idx];
|
||||
}
|
||||
for (let i = playable; i < frames; i++) { output[0][i] = 0; output[1][i] = 0; }
|
||||
this.readIdx = (this.readIdx + playable) % this.capacity;
|
||||
this.available -= playable;
|
||||
return true; // Prozessor am Leben halten, auch wenn gerade nichts ankommt
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('pcm-player', PcmRingBufferProcessor);
|
||||
@@ -7,6 +7,15 @@
|
||||
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
// Debug-Hilfe: JS-Fehler im Renderer landen im Terminal des Hauptprozesses,
|
||||
// damit man sie auch ohne offene DevTools sieht
|
||||
window.addEventListener('error', (e) => {
|
||||
ipcRenderer.send('debug:rendererError', (e.error && e.error.stack) || e.message);
|
||||
});
|
||||
window.addEventListener('unhandledrejection', (e) => {
|
||||
ipcRenderer.send('debug:rendererError', 'unhandledrejection: ' + ((e.reason && e.reason.stack) || e.reason));
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('api', {
|
||||
// Einstellungen
|
||||
getSettings: () => ipcRenderer.invoke('settings:get'),
|
||||
@@ -241,4 +250,57 @@ contextBridge.exposeInMainWorld('api', {
|
||||
pickJava: () => ipcRenderer.invoke('dialog:pickJava'),
|
||||
appInfo: () => ipcRenderer.invoke('app:info'),
|
||||
appLicense: () => ipcRenderer.invoke('app:license'),
|
||||
|
||||
// Einstellungen/Konsole als eigenes, frei verschiebbares Fenster
|
||||
popoutOpen: (modalId, params) => ipcRenderer.send('popout:open', modalId, params),
|
||||
popoutHide: () => ipcRenderer.send('popout:hide'),
|
||||
onPopoutReopen: (cb) => {
|
||||
const l = (_e, params) => cb(params);
|
||||
ipcRenderer.on('popout:reopen', l);
|
||||
return () => ipcRenderer.removeListener('popout:reopen', l);
|
||||
},
|
||||
onSettingsChanged: (cb) => {
|
||||
const l = (_e, s) => cb(s);
|
||||
ipcRenderer.on('settings:changed', l);
|
||||
return () => ipcRenderer.removeListener('settings:changed', l);
|
||||
},
|
||||
onInstancesChanged: (cb) => {
|
||||
const l = () => cb();
|
||||
ipcRenderer.on('instances:changed', l);
|
||||
return () => ipcRenderer.removeListener('instances:changed', l);
|
||||
},
|
||||
onSkinChanged: (cb) => {
|
||||
const l = () => cb();
|
||||
ipcRenderer.on('skin:changed', l);
|
||||
return () => ipcRenderer.removeListener('skin:changed', l);
|
||||
},
|
||||
updateGetPending: () => ipcRenderer.invoke('update:getPending'),
|
||||
|
||||
// Spielaufzeichnung
|
||||
recordingListWindows: () => ipcRenderer.invoke('recording:listWindows'),
|
||||
recordingGetAudioSourceId: () => ipcRenderer.invoke('recording:getAudioSourceId'),
|
||||
recordingSave: (instanceName, buffer, serverLabel) => ipcRenderer.invoke('recording:save', instanceName, buffer, serverLabel),
|
||||
recordingOpenFolder: (instanceName) => ipcRenderer.invoke('recording:openFolder', instanceName),
|
||||
recordingGetServer: (instanceId) => ipcRenderer.invoke('recording:getServer', instanceId),
|
||||
onRecordingServerDetected: (cb) => {
|
||||
const l = (_e, payload) => cb(payload);
|
||||
ipcRenderer.on('recording:serverDetected', l);
|
||||
return () => ipcRenderer.removeListener('recording:serverDetected', l);
|
||||
},
|
||||
recordingGetPid: (instanceId) => ipcRenderer.invoke('recording:getPid', instanceId),
|
||||
recordingSetCaptureTarget: (sourceId) => ipcRenderer.invoke('recording:setCaptureTarget', sourceId),
|
||||
recordingGetWindowBounds: (instanceId, fensterTitel) => ipcRenderer.invoke('recording:getWindowBounds', instanceId, fensterTitel),
|
||||
recordingStartGameAudio: (pid) => ipcRenderer.invoke('recording:startGameAudio', pid),
|
||||
recordingStopGameAudio: () => ipcRenderer.invoke('recording:stopGameAudio'),
|
||||
onGameAudioChunk: (cb) => {
|
||||
const l = (_e, chunk) => cb(chunk);
|
||||
ipcRenderer.on('recording:gameAudioChunk', l);
|
||||
return () => ipcRenderer.removeListener('recording:gameAudioChunk', l);
|
||||
},
|
||||
recordingSetGuard: (active) => ipcRenderer.send('recording:guard', active),
|
||||
onRecordCloseAttempt: (cb) => {
|
||||
const l = () => cb();
|
||||
ipcRenderer.on('record:closeAttempt', l);
|
||||
return () => ipcRenderer.removeListener('record:closeAttempt', l);
|
||||
},
|
||||
});
|
||||
|
||||
+101
-101
@@ -1,101 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
const DEFAULT_GRACE_MS = 15000;
|
||||
|
||||
const CLEAN_SHUTDOWN = /\[(?:Render thread|Client thread)\/INFO\](?:\s+\([^)]*\))?:\s*Stopping!\s*$/;
|
||||
const FATAL_OUTPUT = [
|
||||
/---- Minecraft Crash Report ----/i,
|
||||
/\b(?:Encountered an unexpected exception|Unreported exception thrown|Reported exception thrown)\b/i,
|
||||
/\b(?:This crash report has been saved to|Saving crash report to)\b/i,
|
||||
/\bA fatal error has been detected by the Java Runtime Environment\b/i,
|
||||
/Exception in thread "(?:Render thread|Client thread|main)"/i,
|
||||
/\[(?:Render thread|Client thread|main)\/FATAL\]/i,
|
||||
];
|
||||
|
||||
function createProcessWatchdog(options) {
|
||||
const graceMs = options.graceMs || DEFAULT_GRACE_MS;
|
||||
const schedule = options.setTimer || setTimeout;
|
||||
const cancel = options.clearTimer || clearTimeout;
|
||||
const buffers = { stdout: '', stderr: '' };
|
||||
let timer = null;
|
||||
let armed = false;
|
||||
let crashed = false;
|
||||
let ended = false;
|
||||
let forced = false;
|
||||
// bleibt true, sobald einmal ein regulärer Shutdown ("Stopping!") gesehen
|
||||
// wurde – im Gegensatz zu `armed` wird das NICHT durch markCrash()
|
||||
// zurückgesetzt, damit ein später vom internen Watchdog erzwungener Halt
|
||||
// weiterhin als "war ein regulärer Shutdown" erkennbar bleibt
|
||||
let sawCleanShutdown = false;
|
||||
|
||||
function clear() {
|
||||
if (timer !== null) cancel(timer);
|
||||
timer = null;
|
||||
armed = false;
|
||||
}
|
||||
|
||||
function markCrash() {
|
||||
crashed = true;
|
||||
clear();
|
||||
}
|
||||
|
||||
function scheduleKill() {
|
||||
if (timer !== null) cancel(timer);
|
||||
timer = schedule(() => {
|
||||
timer = null;
|
||||
if (ended || crashed || !armed || !options.isRunning()) return;
|
||||
try {
|
||||
forced = options.kill() === true;
|
||||
} catch {
|
||||
forced = false;
|
||||
}
|
||||
if (forced && options.onForce) options.onForce(graceMs);
|
||||
else if (!forced && options.isRunning() && options.onError) options.onError();
|
||||
}, graceMs);
|
||||
if (timer && typeof timer.unref === 'function') timer.unref();
|
||||
}
|
||||
|
||||
function inspectLine(line) {
|
||||
const isCleanShutdown = CLEAN_SHUTDOWN.test(line);
|
||||
if (isCleanShutdown) sawCleanShutdown = true;
|
||||
if (FATAL_OUTPUT.some((pattern) => pattern.test(line))) {
|
||||
markCrash();
|
||||
return;
|
||||
}
|
||||
if (ended || crashed || armed || !isCleanShutdown) return;
|
||||
|
||||
armed = true;
|
||||
scheduleKill();
|
||||
}
|
||||
|
||||
function feed(chunk, stream) {
|
||||
if (ended) return;
|
||||
const key = stream === 'stderr' ? 'stderr' : 'stdout';
|
||||
const text = buffers[key] + String(chunk || '');
|
||||
const lines = text.split(/\r?\n/);
|
||||
buffers[key] = lines.pop() || '';
|
||||
for (const line of lines) inspectLine(line);
|
||||
if (armed && !crashed && !ended && lines.length) scheduleKill();
|
||||
}
|
||||
|
||||
function end() {
|
||||
ended = true;
|
||||
clear();
|
||||
}
|
||||
|
||||
return {
|
||||
feed,
|
||||
end,
|
||||
get armed() { return armed; },
|
||||
get crashed() { return crashed; },
|
||||
get forced() { return forced; },
|
||||
get sawCleanShutdown() { return sawCleanShutdown; },
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
DEFAULT_GRACE_MS,
|
||||
CLEAN_SHUTDOWN,
|
||||
FATAL_OUTPUT,
|
||||
createProcessWatchdog,
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const DEFAULT_GRACE_MS = 15000;
|
||||
|
||||
const CLEAN_SHUTDOWN = /\[(?:Render thread|Client thread)\/INFO\](?:\s+\([^)]*\))?:\s*Stopping!\s*$/;
|
||||
const FATAL_OUTPUT = [
|
||||
/---- Minecraft Crash Report ----/i,
|
||||
/\b(?:Encountered an unexpected exception|Unreported exception thrown|Reported exception thrown)\b/i,
|
||||
/\b(?:This crash report has been saved to|Saving crash report to)\b/i,
|
||||
/\bA fatal error has been detected by the Java Runtime Environment\b/i,
|
||||
/Exception in thread "(?:Render thread|Client thread|main)"/i,
|
||||
/\[(?:Render thread|Client thread|main)\/FATAL\]/i,
|
||||
];
|
||||
|
||||
function createProcessWatchdog(options) {
|
||||
const graceMs = options.graceMs || DEFAULT_GRACE_MS;
|
||||
const schedule = options.setTimer || setTimeout;
|
||||
const cancel = options.clearTimer || clearTimeout;
|
||||
const buffers = { stdout: '', stderr: '' };
|
||||
let timer = null;
|
||||
let armed = false;
|
||||
let crashed = false;
|
||||
let ended = false;
|
||||
let forced = false;
|
||||
// bleibt true, sobald einmal ein regulärer Shutdown ("Stopping!") gesehen
|
||||
// wurde – im Gegensatz zu `armed` wird das NICHT durch markCrash()
|
||||
// zurückgesetzt, damit ein später vom internen Watchdog erzwungener Halt
|
||||
// weiterhin als "war ein regulärer Shutdown" erkennbar bleibt
|
||||
let sawCleanShutdown = false;
|
||||
|
||||
function clear() {
|
||||
if (timer !== null) cancel(timer);
|
||||
timer = null;
|
||||
armed = false;
|
||||
}
|
||||
|
||||
function markCrash() {
|
||||
crashed = true;
|
||||
clear();
|
||||
}
|
||||
|
||||
function scheduleKill() {
|
||||
if (timer !== null) cancel(timer);
|
||||
timer = schedule(() => {
|
||||
timer = null;
|
||||
if (ended || crashed || !armed || !options.isRunning()) return;
|
||||
try {
|
||||
forced = options.kill() === true;
|
||||
} catch {
|
||||
forced = false;
|
||||
}
|
||||
if (forced && options.onForce) options.onForce(graceMs);
|
||||
else if (!forced && options.isRunning() && options.onError) options.onError();
|
||||
}, graceMs);
|
||||
if (timer && typeof timer.unref === 'function') timer.unref();
|
||||
}
|
||||
|
||||
function inspectLine(line) {
|
||||
const isCleanShutdown = CLEAN_SHUTDOWN.test(line);
|
||||
if (isCleanShutdown) sawCleanShutdown = true;
|
||||
if (FATAL_OUTPUT.some((pattern) => pattern.test(line))) {
|
||||
markCrash();
|
||||
return;
|
||||
}
|
||||
if (ended || crashed || armed || !isCleanShutdown) return;
|
||||
|
||||
armed = true;
|
||||
scheduleKill();
|
||||
}
|
||||
|
||||
function feed(chunk, stream) {
|
||||
if (ended) return;
|
||||
const key = stream === 'stderr' ? 'stderr' : 'stdout';
|
||||
const text = buffers[key] + String(chunk || '');
|
||||
const lines = text.split(/\r?\n/);
|
||||
buffers[key] = lines.pop() || '';
|
||||
for (const line of lines) inspectLine(line);
|
||||
if (armed && !crashed && !ended && lines.length) scheduleKill();
|
||||
}
|
||||
|
||||
function end() {
|
||||
ended = true;
|
||||
clear();
|
||||
}
|
||||
|
||||
return {
|
||||
feed,
|
||||
end,
|
||||
get armed() { return armed; },
|
||||
get crashed() { return crashed; },
|
||||
get forced() { return forced; },
|
||||
get sawCleanShutdown() { return sawCleanShutdown; },
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
DEFAULT_GRACE_MS,
|
||||
CLEAN_SHUTDOWN,
|
||||
FATAL_OUTPUT,
|
||||
createProcessWatchdog,
|
||||
};
|
||||
|
||||
+902
-58
File diff suppressed because it is too large
Load Diff
@@ -77,6 +77,7 @@ const DEFAULT_SETTINGS = {
|
||||
bedrockEnabled: true, // Bedrock-Bereich anzeigen (nur wenn auch installiert)
|
||||
desktopNotifications: true, // Windows-Meldung bei fertigem Hintergrund-Download/-Backup
|
||||
autostart: false, // mit Windows starten, im Infobereich statt als Fenster
|
||||
discordClientId: '', // optional, nur per Hand in settings.json; leer => eingebaute AeroMC-App-ID
|
||||
bgSkin: '', // '' = aus, 'active' = aktives Konto, sonst Konto-UUID
|
||||
bgSkinOpacity: 55, // Deckkraft des Hintergrund-Skins in %
|
||||
bgSkinPose: 'walking', // Pose des 3D-Renders (falls der Pose-Dienst erreichbar ist)
|
||||
@@ -89,6 +90,16 @@ const DEFAULT_SETTINGS = {
|
||||
proxyUser: '',
|
||||
proxyPass: '',
|
||||
theme: 'dark',
|
||||
// Spielaufzeichnung - bleibt über Neustarts erhalten (letzte Wahl je Feld)
|
||||
recordingResolution: 'native',
|
||||
recordingQuality: 'medium',
|
||||
recordingFramerate: 30,
|
||||
recordingAudioSystem: true,
|
||||
recordingAudioGame: false,
|
||||
recordingVolSystem: 100,
|
||||
recordingVolGame: 100,
|
||||
recordingMicSelected: [], // Liste gewählter Mikrofon-deviceIds
|
||||
recordingMicVolumes: {}, // deviceId -> Lautstärke (0-100)
|
||||
};
|
||||
|
||||
function settingsFile() {
|
||||
|
||||
+62
-2
@@ -32,6 +32,7 @@ body{display:grid;grid-template-rows:auto 1fr auto;height:100vh;overflow:hidden}
|
||||
:root[data-theme="dark"] .field select,
|
||||
:root[data-theme="dark"] .field textarea,
|
||||
:root[data-theme="dark"] .mods-search input,
|
||||
:root[data-theme="dark"] .path-row input,
|
||||
:root[data-theme="dark"] .login-usercode{background:#1e1e1e;color:var(--text);border-color:var(--border)}
|
||||
:root[data-theme="dark"] .modal-card{background:#2d2d30;border-color:#161618}
|
||||
:root[data-theme="dark"] .modal-head{background:#333337}
|
||||
@@ -67,7 +68,8 @@ body{display:grid;grid-template-rows:auto 1fr auto;height:100vh;overflow:hidden}
|
||||
:root[data-theme="dark"] #btn-console svg{color:#c8c8cc}
|
||||
:root[data-theme="dark"] .acct-av svg{color:#c8c8cc}
|
||||
:root[data-theme="dark"] .mods-filters select,
|
||||
:root[data-theme="dark"] .mods-search select{background:#1e1e1e;color:var(--text);border-color:var(--border)}
|
||||
:root[data-theme="dark"] .mods-search select,
|
||||
:root[data-theme="dark"] .mmc-bar select{background:#1e1e1e;color:var(--text);border-color:var(--border)}
|
||||
:root[data-theme="dark"] .upd-notes{background:#1e1e1e;color:var(--text)}
|
||||
:root[data-theme="dark"] .modal-close{color:#aaa}
|
||||
:root[data-theme="dark"] .modal-close:hover{color:#fff}
|
||||
@@ -185,6 +187,38 @@ body.file-drop-active::after{
|
||||
.modal-body{padding:16px;overflow:auto;background:#f6f6f6}
|
||||
.modal-foot{display:flex;justify-content:flex-end;gap:8px;padding:10px 14px;border-top:1px solid var(--border);background:#efefef}
|
||||
|
||||
/* Popup-Fenster (Einstellungen/Konsole): Haupt-UI ausblenden, das eine Modal
|
||||
füllt das ganze (rahmenlose) Fenster; der eigene Kopfbereich ersetzt die
|
||||
native Titelleiste – per -webkit-app-region per Maus verschiebbar */
|
||||
body.is-popout>header.toolbar,body.is-popout>main.workspace,body.is-popout>footer.statusbar{display:none}
|
||||
.popout-host{position:static;inset:auto;background:none;display:block}
|
||||
/* !important: schlägt auch die spezifischere #modal-settings-Breitenregel oben */
|
||||
.popout-host .modal-card{width:100%!important;max-width:none!important;height:100vh!important;max-height:none!important;border:none;border-radius:0;box-shadow:none;margin:0}
|
||||
/* Inhalt soll die restliche Fensterhöhe füllen (scrollen statt Leerraum unter dem Fuß) */
|
||||
.popout-host .modal-body{flex:1 1 auto;min-height:0}
|
||||
/* Konsole/Logs/Screenshots haben einen einzelnen scrollbaren Kasten mit
|
||||
fester Höhe (für den normalen Dialog gedacht) – im Popup-Fenster soll der
|
||||
stattdessen die volle verbleibende Höhe ausfüllen statt Leerraum darunter
|
||||
zu lassen */
|
||||
#modal-console.popout-host .modal-body,
|
||||
#modal-logs.popout-host .modal-body,
|
||||
#modal-screens.popout-host .modal-body,
|
||||
#modal-servers.popout-host .modal-body,
|
||||
#modal-mods.popout-host .modal-body,
|
||||
#modal-record.popout-host .modal-body{display:flex;flex-direction:column}
|
||||
.popout-host .console-out,
|
||||
#modal-logs.popout-host .crash-voll,
|
||||
.popout-host .screens-grid,
|
||||
.popout-host .mods-list,
|
||||
.popout-host .record-stage{flex:1 1 auto;height:auto;max-height:none;min-height:0}
|
||||
/* Mods-Fenster: die aktive Ansicht (Katalog/Installiert) muss selbst ein
|
||||
Flex-Container werden, damit ihre eigene Liste (.mods-list) die Regel oben
|
||||
nutzen und den restlichen Platz füllen kann */
|
||||
#modal-mods.popout-host #m-pane-catalog,
|
||||
#modal-mods.popout-host #m-pane-installed{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
|
||||
.popout-host .modal-head{-webkit-app-region:drag;cursor:default}
|
||||
.popout-host .modal-head button,.popout-host .modal-head input,.popout-host .modal-head select{-webkit-app-region:no-drag}
|
||||
|
||||
/* Formular */
|
||||
.field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px}
|
||||
.field>span{font-size:12px;color:#333}
|
||||
@@ -196,7 +230,8 @@ body.file-drop-active::after{
|
||||
.backup-select-field{margin-top:14px;margin-bottom:0}
|
||||
.backup-select-field select{width:100%}
|
||||
.hint{font-size:12px}
|
||||
.path-row{display:flex;gap:8px}.path-row input{flex:1}
|
||||
.path-row{display:flex;gap:8px}
|
||||
.path-row input{flex:1;padding:6px 8px;border:1px solid var(--border);border-radius:3px;background:#fff;color:var(--text);font-family:inherit;font-size:13px}
|
||||
.advanced{border:1px solid var(--border);border-radius:3px;padding:12px 14px 2px;margin-top:4px;background:#fbfbfb}
|
||||
.advanced legend{color:var(--dim);font-size:12px;padding:0 6px}
|
||||
.version-row{display:flex;gap:8px}.version-row #f-version-type{max-width:120px}.version-row #f-version{flex:1}
|
||||
@@ -286,6 +321,8 @@ body.file-drop-active::after{
|
||||
/* Die gerenderte Figur soll das Feld ausfüllen; eine rohe 64x64-Textur wird
|
||||
ohne Weichzeichnen vergrößert, damit sie nicht verschwommen wirkt. */
|
||||
.skin-bild img{max-width:100%;max-height:100%;image-rendering:pixelated}
|
||||
.skin-bild canvas{max-width:100%;max-height:100%;cursor:grab}
|
||||
.skin-bild canvas:active{cursor:grabbing}
|
||||
.crash-details{margin-top:12px}
|
||||
.crash-details summary{cursor:pointer;font-size:12px;color:var(--dim)}
|
||||
.crash-voll{max-height:320px;overflow:auto;margin-top:8px;padding:10px;background:rgba(0,0,0,.25);border-radius:4px;font-family:var(--mono);font-size:11px;line-height:1.45;white-space:pre-wrap;word-break:break-word}
|
||||
@@ -299,6 +336,8 @@ body.file-drop-active::after{
|
||||
|
||||
/* MultiMC-Import */
|
||||
.mmc-bar{display:flex;gap:18px;align-items:center;flex-wrap:wrap;margin-bottom:10px}
|
||||
.mmc-bar select{padding:6px 8px;border:1px solid var(--border);border-radius:3px;background:var(--input,#fff);color:var(--text);font-family:inherit;font-size:12px}
|
||||
.mmc-bar select:focus{outline:none;border-color:var(--accent)}
|
||||
.mmc-item{display:flex;gap:10px;align-items:center;padding:7px 8px;border-radius:3px}
|
||||
.mmc-item+.mmc-item{border-top:1px solid var(--border2)}
|
||||
.mmc-item:hover{background:rgba(128,128,128,.10)}
|
||||
@@ -340,6 +379,21 @@ img.account-av{object-fit:cover;image-rendering:auto}
|
||||
.screens-toolbar .hint{font-size:11px}
|
||||
.screens-empty{color:var(--dim);text-align:center;padding:30px;grid-column:1/-1}
|
||||
|
||||
/* Spielaufzeichnung */
|
||||
.record-search{display:flex;flex-direction:column;align-items:center;gap:10px;padding:48px 0;color:var(--dim)}
|
||||
.record-stage{display:flex;flex-direction:column;gap:10px}
|
||||
.record-video{width:100%;flex:1 1 auto;min-height:360px;background:#000;border-radius:4px;object-fit:contain}
|
||||
.record-toolbar{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
|
||||
.record-live-badge{display:flex;align-items:center;gap:8px;color:var(--danger);font-size:13px;font-weight:600}
|
||||
#record-timer{font-variant-numeric:tabular-nums}
|
||||
.rec-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);animation:rec-pulse 1s infinite}
|
||||
@keyframes rec-pulse{0%,100%{opacity:1}50%{opacity:.25}}
|
||||
.record-audio-bar{display:flex;align-items:center;gap:10px;padding:2px 2px}
|
||||
.record-mic-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}
|
||||
.record-source-row{display:flex;align-items:center;gap:10px;margin-bottom:8px}
|
||||
.record-source-row .checkbox-field{margin-bottom:0;flex:1;min-width:0;font-size:13px;gap:6px}
|
||||
.record-vol{width:110px}
|
||||
|
||||
/* Konsole (dunkel wie ein Log) */
|
||||
.console-out{height:440px;overflow:auto;margin:0;background:#1e1e1e;border:1px solid var(--border);border-radius:3px;padding:10px;font-family:var(--mono);font-size:12px;color:#d4d4d4;white-space:pre-wrap;word-break:break-word;line-height:1.5}
|
||||
.log-line{white-space:pre-wrap}
|
||||
@@ -413,6 +467,12 @@ img.account-av{object-fit:cover;image-rendering:auto}
|
||||
.path-row{flex-direction:column}
|
||||
}
|
||||
|
||||
/* Popup-Fenster sind eigenständige, meist schmalere Fenster -- die
|
||||
Zeilenumbruch-Regel oben ist für die (deutlich breitere) Haupt-App gedacht
|
||||
und soll hier nicht greifen (sonst z. B. Version/Icon im Instanz-Fenster
|
||||
untereinander statt nebeneinander) */
|
||||
.is-popout .field-row{flex-direction:row}
|
||||
|
||||
/* Konto-Button mit 3D-Skin-Kopf */
|
||||
.acct-btn{gap:8px}
|
||||
.acct-av{display:inline-flex;align-items:center;justify-content:center}
|
||||
|
||||
Reference in New Issue
Block a user