Skip to content

Commit

Permalink
new features, bug fixes and optimisations
Browse files Browse the repository at this point in the history
Features:
* Updated to the latest Electron and React versions
* Reworked About page, so it loads the README from GitHub
* Linux support finished

Bug fixes:
* React effects now clean up correctly
* Immediate crash of client while launching no longer crashes the React front-end
* Better error handling and reporting for better UX
* Added proper MarkDown styling
* Fixed settings page loading twice and thus overwriting settings with defaults in some cases

Optimisations:
* Removed unused code
* Better debugging info in console
* Some code refactoring
  • Loading branch information
Davis-Software committed Dec 10, 2022
1 parent 21adae9 commit 82336f2
Show file tree
Hide file tree
Showing 17 changed files with 3,540 additions and 834 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

| Feature | Description | State |
|---------------------------|-------------------------------------------------------------|-------|
| Bundled Java | Java installation bundled with the launcher (Java 8 and 16) | |
| Bundled Java | Java installation bundled with the launcher (Java 8 and 16) | |
| Minecraft Account Support | Support for Minecraft account logins ||
| Mojang Account Support | Support for Mojang account logins ||
| Session Handling | Store and refresh Microsoft login sessions as needed ||
| Minecraft Vanilla | Launch Minecraft Vanilla ||
| Minecraft Forge | Launch Minecraft Forge (only custom SWC modpacks) ||
| Support for Windows | Support for Windows ||
| Support for Linux | Support for Linux | 🛠 |
| Support for Linux | Support for Linux | |
| Support for MacOS | Support for MacOS | 🛠 |
| Configurable | Most minecraft and java launch options are accessible ||
| Easy Account Switching | Switch between multiple accounts easily ||
Expand Down
28 changes: 23 additions & 5 deletions back/mc-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,21 @@ function launchVanilla(version) {

launcher.launch(opts).then((childProcess) => {
invoke("mc:gameLaunched")
runningClients[launcherUUID].pid = childProcess.pid
runningClients[launcherUUID].kill = () => childProcess.kill()

if(!childProcess){
invoke("mc:data", "Spawning child process failed because of an unknown error")
throw new Error("Client crashed before launch")
}

runningClients[launcherUUID].pid = childProcess.pid | null
runningClients[launcherUUID].kill = () => {
invoke("mc:data", "Killing child process...")
childProcess.kill()
}
afterLaunchCalls()
}).catch((e) => {
delete runningClients[launcherUUID]
invoke("mc:gameLaunchError", e)
invoke("mc:gameLaunchError", e.message)
})

launcher.on('arguments', (e) => invoke("mc:arguments", e))
Expand Down Expand Up @@ -232,12 +241,21 @@ function launchModded(manifest) {
launcher.launch(opts).then((childProcess) => {
if(installNeeded) fs.writeFileSync(path.join(rootPath, "manifest.json"), JSON.stringify(manifest))
invoke("mc:gameLaunched")

if(!childProcess){
invoke("mc:data", "Spawning child process failed because of an unknown error")
throw new Error("Client crashed before launch")
}

runningClients[launcherUUID].pid = childProcess.pid
runningClients[launcherUUID].kill = () => childProcess.kill()
runningClients[launcherUUID].kill = () => {
invoke("mc:data", "Killing child process...")
childProcess.kill()
}
afterLaunchCalls()
}).catch((e) => {
delete runningClients[launcherUUID]
invoke("mc:gameLaunchError", e)
invoke("mc:gameLaunchError", e.message)
})

launcher.on('arguments', (e) => invoke("mc:arguments", e))
Expand Down
27 changes: 0 additions & 27 deletions back/tools.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const fs = require("fs")
const path = require("path")
const {registerIpcListener} = require("./ipc-handler");
const MarkdownIt = require("markdown-it");
const config = require("./config");

class EventEmitter {
constructor(){
Expand Down Expand Up @@ -75,31 +73,6 @@ function sleep(x) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, x)
}

const builtMarkdown = {}
registerIpcListener("render-markdown-file", (e, file) => {
if(builtMarkdown[file] && !config.devMode){
return builtMarkdown[file]
}

try {
let data = file !== "README.md" ?
fs.readFileSync(
path.join(__dirname, "../templates/components", file),
"utf8"
) :
fs.readFileSync(
path.join(__dirname, "../README.md"),
"utf8"
)

let md = MarkdownIt({html: true, linkify: true}).render(data)
builtMarkdown[file] = md
return md
} catch (err) {
return false
}
})

registerIpcListener("open-explorer", (e, file) => {
if(fs.lstatSync(file).isDirectory()){
return require("electron").shell.openPath(file)
Expand Down
Loading

0 comments on commit 82336f2

Please sign in to comment.