mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-20 04:57:38 -04:00
launching the game works
This commit is contained in:
parent
46ab26487c
commit
f68dd41da1
4
main.js
4
main.js
|
@ -1,8 +1,8 @@
|
|||
import './style.css'
|
||||
import { actions, general_pane, files_pane, links_pane } from './components/settings/settings';
|
||||
import { jak1_main, jak1_sidebar } from './components/jak1/jak1';
|
||||
import { invoke } from '@tauri-apps/api/tauri'
|
||||
import { isoSeries } from './src/utils/iso';
|
||||
import { launchGame } from './src/utils/launch';
|
||||
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
|
||||
|
@ -32,7 +32,7 @@ const playBTN = document.querySelector('.play');
|
|||
const configBTN = document.querySelector('.config');
|
||||
|
||||
playBTN.onclick = () => {
|
||||
invoke('launch');
|
||||
launchGame();
|
||||
}
|
||||
|
||||
configBTN.onclick = () => {
|
||||
|
|
|
@ -66,6 +66,23 @@
|
|||
"/C",
|
||||
"decomp-jak1.bat"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "compile-windows",
|
||||
"cmd": "cmd",
|
||||
"args": [
|
||||
"/C",
|
||||
"gc-no-lt.bat",
|
||||
"(mi)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "launch-windows",
|
||||
"cmd": "cmd",
|
||||
"args": [
|
||||
"/C",
|
||||
"gk-display.bat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,76 +1,77 @@
|
|||
const { app } = require('electron');
|
||||
const path = require('path');
|
||||
const { execFile } = require('child_process');
|
||||
const stream = require('stream');
|
||||
// const userDataPath = app.getPath('userData');
|
||||
// const jakprojectPath = path.join(userDataPath, '/jak-project');
|
||||
|
||||
const userDataPath = app.getPath('userData');
|
||||
const jakprojectPath = path.join(userDataPath, '/jak-project');
|
||||
import { platform } from "@tauri-apps/api/os";
|
||||
import { appDir, join } from "@tauri-apps/api/path";
|
||||
import { Command } from "@tauri-apps/api/shell";
|
||||
|
||||
function updateStatus(status) {
|
||||
app.emit('status', status);
|
||||
}
|
||||
// export function buildGame(callback) {
|
||||
// let compilerScript = null;
|
||||
|
||||
export function buildGame(callback) {
|
||||
let compilerScript = null;
|
||||
// if (process.platform === 'win32') {
|
||||
// compilerScript = path.join(jakprojectPath, '/out/build/Release/bin/goalc.exe');
|
||||
// } else if (process.platform === 'linux') {
|
||||
// compilerScript = path.join(jakprojectPath, '/scripts/shell/gc.sh');
|
||||
// } else if (process.platform === 'darwin') {
|
||||
// console.log('No Mac support at this time');
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
compilerScript = path.join(jakprojectPath, '/out/build/Release/bin/goalc.exe');
|
||||
} else if (process.platform === 'linux') {
|
||||
compilerScript = path.join(jakprojectPath, '/scripts/shell/gc.sh');
|
||||
} else if (process.platform === 'darwin') {
|
||||
console.log('No Mac support at this time');
|
||||
return;
|
||||
}
|
||||
// if (compilerScript) {
|
||||
// updateStatus('Building the game');
|
||||
// // so its not console logging the '100%' when i run it in the series, but when i run it on its own its fine.
|
||||
// // so im going to assume its working properly and its a problem with the way the compiler is outputting the %%%
|
||||
// // for now i have a timeout that will kill the compiler process after 30 seconds because the compiler should be done by then (twice the length it takes my pc at least)
|
||||
// let build = execFile(compilerScript, ['-v', '-auto-user'], { timeout: 30000 });
|
||||
// build.stdout.on('data', data => {
|
||||
// console.log(data.toString().trim());
|
||||
// app.emit('console', data);
|
||||
// if (data.includes('[100%]')) {
|
||||
// updateStatus('Compiled game successfully!');
|
||||
// callback(null, 'Compiled game successfully!');
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
|
||||
if (compilerScript) {
|
||||
updateStatus('Building the game');
|
||||
// so its not console logging the '100%' when i run it in the series, but when i run it on its own its fine.
|
||||
// so im going to assume its working properly and its a problem with the way the compiler is outputting the %%%
|
||||
// for now i have a timeout that will kill the compiler process after 30 seconds because the compiler should be done by then (twice the length it takes my pc at least)
|
||||
let build = execFile(compilerScript, ['-v', '-auto-user'], { timeout: 30000 });
|
||||
build.stdout.on('data', data => {
|
||||
console.log(data.toString().trim());
|
||||
app.emit('console', data);
|
||||
if (data.includes('[100%]')) {
|
||||
updateStatus('Compiled game successfully!');
|
||||
callback(null, 'Compiled game successfully!');
|
||||
return;
|
||||
}
|
||||
});
|
||||
// build.on('close', () => {
|
||||
// updateStatus('Compiled game successfully!');
|
||||
// callback(null, 'Compiled game successfully!');
|
||||
// return;
|
||||
// });
|
||||
|
||||
build.on('close', () => {
|
||||
updateStatus('Compiled game successfully!');
|
||||
callback(null, 'Compiled game successfully!');
|
||||
return;
|
||||
});
|
||||
// let stdinStream = new stream.Readable();
|
||||
// stdinStream.push('(mi)');
|
||||
// stdinStream.push(null);
|
||||
// stdinStream.pipe(build.stdin);
|
||||
// }
|
||||
// }
|
||||
|
||||
let stdinStream = new stream.Readable();
|
||||
stdinStream.push('(mi)');
|
||||
stdinStream.push(null);
|
||||
stdinStream.pipe(build.stdin);
|
||||
}
|
||||
}
|
||||
|
||||
export function launchGame() {
|
||||
export async function launchGame() {
|
||||
const userPlatform = await platform();
|
||||
const jaklaunchPath = await join(await appDir(), '/jak-project/scripts/batch/');
|
||||
let launchScript = null;
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
launchScript = path.join(jakprojectPath, '/out/build/Release/bin/gk.exe');
|
||||
} else if (process.platform === 'linux') {
|
||||
launchScript = path.join(jakprojectPath, '/scripts/shell/gk.sh');
|
||||
return;
|
||||
} else if (process.platform === 'darwin') {
|
||||
updateStatus('Unsupported OS');
|
||||
return;
|
||||
if (userPlatform === 'win32') {
|
||||
launchScript = 'launch-windows';
|
||||
} else if (userPlatform === 'linux') {
|
||||
launchScript = 'launch-linux';
|
||||
} else if (userPlatform === 'darwin') {
|
||||
launchScript = 'launch-mac';
|
||||
}
|
||||
|
||||
console.log(launchScript);
|
||||
|
||||
if (launchScript) {
|
||||
let launcher = execFile(launchScript, ['-boot', '-fakeiso', '-debug', '-v'], { shell: true });
|
||||
launcher.stdout.on('data', data => {
|
||||
console.log(data);
|
||||
app.emit('console', data);
|
||||
const launch = new Command(launchScript, null, { cwd: jaklaunchPath });
|
||||
launch.on('close', data => {
|
||||
console.log(`Launch finished with code ${data.code} and signal ${data.signal}`);
|
||||
return ('Launch finished');
|
||||
});
|
||||
return;
|
||||
launch.on('error', error => {
|
||||
console.error(`Launch error: "${error}"`);
|
||||
});
|
||||
launch.stdout.on('data', line => console.log(`Launch stdout: "${line}"`));
|
||||
|
||||
const child = await launch.spawn();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue