diff --git a/electron.vite.config.js b/electron.vite.config.js
index 1094e76..664d136 100644
--- a/electron.vite.config.js
+++ b/electron.vite.config.js
@@ -18,7 +18,7 @@ import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'
import commonjsExternals from 'vite-plugin-commonjs-externals'
-const externals = ['pimi-launcher-core', 'path', 'process', 'fs']
+const externals = ['pimi-launcher-core', 'path', 'process', 'fs', 'console']
export default defineConfig({
main: {
diff --git a/package-lock.json b/package-lock.json
index af84304..941d1ea 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "pimi-launcher",
- "version": "1.1.0-alpha",
+ "version": "1.2.0-alpha",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "pimi-launcher",
- "version": "1.1.0-alpha",
+ "version": "1.2.0-alpha",
"hasInstallScript": true,
"dependencies": {
"@electron-toolkit/preload": "^2.0.0",
@@ -16,6 +16,7 @@
"pimi-launcher-core": "^1.1.1",
"react-router-dom": "^6.13.0",
"react-select": "^5.7.3",
+ "react-terminal-ui": "^1.0.5",
"vite-plugin-commonjs-externals": "^0.1.3"
},
"devDependencies": {
@@ -7530,6 +7531,15 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
},
+ "node_modules/react-terminal-ui": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/react-terminal-ui/-/react-terminal-ui-1.0.5.tgz",
+ "integrity": "sha512-yR19ej58dwU3koLiTR0m0nLbqJZoOyeThGWg1B3VrwUs+PLraqjP2C4AkRgiGNUwWMn4u6T0djY5DZXq0Zlvjg==",
+ "peerDependencies": {
+ "react": ">16.13.0",
+ "react-dom": ">16.13.0"
+ }
+ },
"node_modules/react-transition-group": {
"version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
diff --git a/package.json b/package.json
index ecd97fe..880b152 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pimi-launcher",
- "version": "1.1.1-alpha",
+ "version": "1.2.0-alpha",
"description": "Modern Minecraft Launcher",
"main": "./out/main/index.js",
"author": "artegoser",
@@ -27,6 +27,7 @@
"pimi-launcher-core": "^1.1.1",
"react-router-dom": "^6.13.0",
"react-select": "^5.7.3",
+ "react-terminal-ui": "^1.0.5",
"vite-plugin-commonjs-externals": "^0.1.3"
},
"devDependencies": {
diff --git a/src/renderer/src/assets/index.css b/src/renderer/src/assets/index.css
index b9458ed..41cd007 100644
--- a/src/renderer/src/assets/index.css
+++ b/src/renderer/src/assets/index.css
@@ -5,3 +5,7 @@
.inputs {
@apply bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500;
}
+
+::-webkit-scrollbar {
+ width: 0;
+}
diff --git a/src/renderer/src/components/MinecraftTerminal.jsx b/src/renderer/src/components/MinecraftTerminal.jsx
new file mode 100644
index 0000000..6c7aa72
--- /dev/null
+++ b/src/renderer/src/components/MinecraftTerminal.jsx
@@ -0,0 +1,21 @@
+import Terminal, { ColorMode, TerminalOutput } from 'react-terminal-ui'
+import PropTypes from 'prop-types'
+
+function MinecraftTerminal({ lines, height = '300px' }) {
+ const terminalLineData = lines.map((line, index) => (
+ {line}
+ ))
+
+ return (
+
+ {terminalLineData}
+
+ )
+}
+
+MinecraftTerminal.propTypes = {
+ lines: PropTypes.arrayOf(PropTypes.string),
+ height: PropTypes.string
+}
+
+export default MinecraftTerminal
diff --git a/src/renderer/src/components/utils.js b/src/renderer/src/components/utils.js
index 365a0e2..88887ad 100644
--- a/src/renderer/src/components/utils.js
+++ b/src/renderer/src/components/utils.js
@@ -1,7 +1,14 @@
import { Client, Authenticator } from 'pimi-launcher-core'
-
-async function launch(version, setProgress, setDownload, setGameStarted, setStarted) {
+async function launch(
+ version,
+ setProgress,
+ setDownload,
+ setGameStarted,
+ setStarted,
+ setTerminalLines
+) {
const launcher = new Client()
+ let terminalLines = []
let opts = {
authorization: Authenticator.getAuth(
@@ -23,13 +30,20 @@ async function launch(version, setProgress, setDownload, setGameStarted, setStar
launcher.on('progress', (e) => setProgress(e))
launcher.on('download', (e) => setDownload(e))
- launcher.on('debug', (e) => console.log(e))
- launcher.on('data', (e) => console.log(e))
+ launcher.on('debug', (e) => {
+ terminalLines = terminalLines.concat(e)
+ setTerminalLines(terminalLines)
+ })
+ launcher.on('data', (e) => {
+ terminalLines = terminalLines.concat(e)
+ setTerminalLines(terminalLines)
+ })
launcher.on('arguments', () => setGameStarted(true))
launcher.on('close', () => {
setGameStarted(false)
setStarted(false)
+ setTerminalLines([])
})
}
diff --git a/src/renderer/src/pages/Main.jsx b/src/renderer/src/pages/Main.jsx
index f0f186c..a406635 100644
--- a/src/renderer/src/pages/Main.jsx
+++ b/src/renderer/src/pages/Main.jsx
@@ -19,6 +19,7 @@ import { launch } from '../components/utils'
import Select from 'react-select'
import path from 'path'
import fs from 'fs'
+import MinecraftTerminal from '../components/MinecraftTerminal'
function Main() {
const [versions, setVersions] = useState(false)
const [version, setVersion] = useState(false)
@@ -27,6 +28,7 @@ function Main() {
const [started, setStarted] = useState(false)
const [gameStarted, setGameStarted] = useState(false)
const [installed_versions, setInstalledVersions] = useState(false)
+ const [terminalLines, setTerminalLines] = useState([])
useEffect(() => {
if (!versions) {
@@ -38,79 +40,86 @@ function Main() {
}
})
- console.log('hi')
-
return (
versions && (
-
-
- {
- localStorage.setItem('name', e.target.value)
- }}
- />
-
-
-
-
- {
- launch(version, setProgress, setDownload, setGameStarted, setStarted)
- setStarted(true)
- }}
- disabled={started}
- />
-
+ <>
+
+
+ {
+ localStorage.setItem('name', e.target.value)
+ }}
+ />
+
+
+
+
+ {
+ launch(
+ version,
+ setProgress,
+ setDownload,
+ setGameStarted,
+ setStarted,
+ setTerminalLines
+ )
+ setStarted(true)
+ }}
+ disabled={started}
+ />
+
- {started && gameStarted && (
- <>
-
Minecraft launches...
- >
+ {started && !gameStarted && (
+ <>
+
Downloading{'.'.repeat(progress.task % 3)}
+
+ {download || 'please wait'} {`(${progress.type})` || ''}
+
+
+ {((progress.task / progress.total) * 100 || 0).toFixed(2)}%
+
+ >
+ )}
+
+ {started && (
+
+
+
)}
- {started && !gameStarted && (
- <>
-
Downloading{'.'.repeat(progress.task % 3)}
-
- {download || 'please wait'} {`(${progress.type})` || ''}
-
-
- {((progress.task / progress.total) * 100 || 0).toFixed(2)}%
-
- >
- )}
-
+ >
)
)
}