mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-20 19:07:36 -04:00
decompiler working
This commit is contained in:
parent
a92a892bab
commit
46ab26487c
6
main.js
6
main.js
|
@ -2,7 +2,7 @@ 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 { isoWaterfall } from './src/utils/iso';
|
||||
import { isoSeries } from './src/utils/iso';
|
||||
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
|
||||
|
@ -32,9 +32,9 @@ const playBTN = document.querySelector('.play');
|
|||
const configBTN = document.querySelector('.config');
|
||||
|
||||
playBTN.onclick = () => {
|
||||
invoke('launch')
|
||||
invoke('launch');
|
||||
}
|
||||
|
||||
configBTN.onclick = () => {
|
||||
isoWaterfall();
|
||||
isoSeries();
|
||||
}
|
|
@ -51,7 +51,23 @@
|
|||
"allowlist": {
|
||||
"all": true,
|
||||
"fs": {
|
||||
"scope": ["$APP/", "$APP/iso/*", "$APP/*"]
|
||||
"scope": [
|
||||
"$APP/",
|
||||
"$APP/iso/*",
|
||||
"$APP/*"
|
||||
]
|
||||
},
|
||||
"shell": {
|
||||
"scope": [
|
||||
{
|
||||
"name": "decomp-windows",
|
||||
"cmd": "cmd",
|
||||
"args": [
|
||||
"/C",
|
||||
"decomp-jak1.bat"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"windows": [
|
||||
|
|
|
@ -5,13 +5,13 @@ import { platform } from '@tauri-apps/api/os';
|
|||
|
||||
// extract game files from iso -> into jak-project/iso_data/jak1 dir
|
||||
export async function extract(callback) {
|
||||
if (platform() == 'win32') {
|
||||
if (await platform() == 'win32') {
|
||||
const workingDirPath = await appDir();
|
||||
const isoFilePath = await join(workingDirPath, '/iso/jak.iso');
|
||||
const outputDirPath = await join(workingDirPath, '/jak-project/iso_data/jak1/');
|
||||
console.log("Output Directory:", outputDirPath);
|
||||
|
||||
return callback(null, 'extracted iso');
|
||||
return 'Extracted iso';
|
||||
|
||||
// x: extract with full paths
|
||||
// -y: yes to all prompts
|
||||
|
@ -39,7 +39,7 @@ export async function extract(callback) {
|
|||
// }
|
||||
// });
|
||||
} else {
|
||||
return callback('Unsupported OS');
|
||||
return 'Unsupported OS';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
import { waterfall } from 'async';
|
||||
import { series } from 'async';
|
||||
import { extract } from './extract';
|
||||
// import { buildGame } from './launch';
|
||||
import { open } from '@tauri-apps/api/dialog';
|
||||
import { platform } from '@tauri-apps/api/os';
|
||||
import { appDir, join } from '@tauri-apps/api/path';
|
||||
import { copyFile, createDir, readDir } from '@tauri-apps/api/fs';
|
||||
// import { Command } from '@tauri-apps/api/shell';
|
||||
import { message } from '@tauri-apps/api/dialog';
|
||||
import { Command } from '@tauri-apps/api/shell';
|
||||
|
||||
const userDir = await appDir();
|
||||
const userPlatform = await platform();
|
||||
let jakISOPath;
|
||||
|
||||
// refactored tauri get iso function
|
||||
async function getISO(callback) {
|
||||
const isoPath = await open({ multiple: false, directory: false, filters: [{ extensions: ['ISO'], name: 'Jak ISO File' }] });
|
||||
|
||||
if (isoPath) {
|
||||
return callback(null, isoPath);
|
||||
jakISOPath = isoPath;
|
||||
return ('Got the ISO File');
|
||||
}
|
||||
throw new Error('No ISO File Selected');
|
||||
}
|
||||
|
||||
// refactored tauri copy jak iso function
|
||||
async function copyJakISO(isoPath, callback) {
|
||||
async function copyJakISO(callback) {
|
||||
const destinationPath = await join(userDir, '/iso/');
|
||||
|
||||
try {
|
||||
const files = await readDir(destinationPath);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log(error.message);
|
||||
await createDir(destinationPath);
|
||||
}
|
||||
|
||||
const destination = await join(userDir, '/iso/jak.iso');
|
||||
console.log("Copy Destination:", destination);
|
||||
const copyout = await copyFile(isoPath, destination);
|
||||
return callback(null, 'Copied ISO to proper directory!');
|
||||
const copyout = await copyFile(jakISOPath, destination);
|
||||
return ('Copied ISO to proper directory!');
|
||||
}
|
||||
|
||||
async function runDecompiler(callback) {
|
||||
const jakprojectPath = await join(await userDir, '/jak-project');
|
||||
const jakDecompPath = await join(userDir, '/jak-project/scripts/batch/');
|
||||
let decompCommand;
|
||||
|
||||
switch (userPlatform) {
|
||||
case 'win32':
|
||||
console.log('windows');
|
||||
return callback('sad');
|
||||
decompCommand = 'decomp-windows';
|
||||
break;
|
||||
case 'darwin':
|
||||
console.log('mac');
|
||||
return callback('Unsupported OS');
|
||||
decompCommand = 'decomp-mac';
|
||||
return 'Unsupported OS';
|
||||
break;
|
||||
case 'linux':
|
||||
console.log('linux');
|
||||
return callback('Unsupported OS');
|
||||
decompCommand = 'decomp-linux';
|
||||
return 'Unsupported OS';
|
||||
break;
|
||||
default:
|
||||
return callback('Unsupported OS');
|
||||
return 'Unsupported OS';
|
||||
break;
|
||||
}
|
||||
|
||||
// new Command('')
|
||||
const decomp = new Command(decompCommand, null, { cwd: jakDecompPath });
|
||||
decomp.on('close', data => {
|
||||
console.log(`Decomp finished with code ${data.code} and signal ${data.signal}`);
|
||||
return ('Decomp finished');
|
||||
});
|
||||
decomp.on('error', error => {
|
||||
console.error(`Decomp error: "${error}"`);
|
||||
});
|
||||
decomp.stdout.on('data', line => console.log(`Decomp stdout: "${line}"`));
|
||||
|
||||
const child = await decomp.spawn();
|
||||
}
|
||||
|
||||
// function runDecompiler(callback) {
|
||||
// let decomp = exec(decompScript, { shell: true, cwd: path.join(jakprojectPath, '/scripts/batch/') });
|
||||
|
||||
// decomp.stdout.on('data', data => {
|
||||
// console.log(data);
|
||||
// });
|
||||
|
||||
// // i see people online saying to use decomp.on('exit'), but thats triggering this listener immediately upon running
|
||||
// decomp.on('close', (code => {
|
||||
// if (code === 0) {
|
||||
// callback(null, 'ISO decompiled successfully');
|
||||
// return;
|
||||
// }));
|
||||
// }
|
||||
// }
|
||||
|
||||
export function isoWaterfall() {
|
||||
waterfall([
|
||||
getISO,
|
||||
copyJakISO,
|
||||
extract,
|
||||
runDecompiler
|
||||
], function (err, result) {
|
||||
export async function isoSeries() {
|
||||
series([getISO, copyJakISO, extract, runDecompiler], (err, result) => {
|
||||
if (err) console.log(err);
|
||||
if (result) console.log(result);
|
||||
if (result) {
|
||||
console.log(result);
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue