Skip to content

Commit

Permalink
Remove cycling deps check
Browse files Browse the repository at this point in the history
  • Loading branch information
OrigamingWasTaken committed Oct 13, 2024
1 parent 94496fb commit d844438
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 46 deletions.
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"css.lint.unknownAtRules": "ignore",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
}
"css.lint.unknownAtRules": "ignore"
// "editor.formatOnSave": true,
// "editor.codeActionsOnSave": {
// "source.organizeImports": "always"
// }
}
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions frontend/src/windows/main/ts/roblox/fflags.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { filesystem } from '@neutralinojs/lib';
import path from 'path-browserify';
import { toast } from 'svelte-sonner';
import Roblox from '.';
import { getAllProfiles, getSelectedProfile, type Profile } from '../../components/flag-editor';
import { getConfigPath, getValue, loadSettings } from '../../components/settings';
import type { SelectElement, SettingsOutput } from '../../components/settings/types';
import { Notification } from '../tools/notifications';
import shellFS from '../tools/shellfs';
import { curlGet } from '../utils';
import { robloxPath } from './path';

const FLAGS_WHITELIST = ['FFlagUserIsBloxstrap', 'FFlagUserAllowsWindowMovement'];

Expand Down Expand Up @@ -467,7 +467,7 @@ export class RobloxFFlags {
};
}
static async writeClientAppSettings() {
const filePath = path.join(Roblox.path, 'Contents/MacOS/ClientSettings/ClientAppSettings.json');
const filePath = path.join(robloxPath, 'Contents/MacOS/ClientSettings/ClientAppSettings.json');
if (await shellFS.exists(filePath)) {
await filesystem.remove(filePath);
}
Expand Down
13 changes: 7 additions & 6 deletions frontend/src/windows/main/ts/roblox/instance.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { filesystem, os } from '@neutralinojs/lib';
import path from 'path-browserify';
import Roblox from '.';
import { getValue } from '../../components/settings';
import { libraryPath } from '../libraries';
import { Notification } from '../tools/notifications';
import { shell, spawn, type SpawnEventEmitter } from '../tools/shell';
import { isProcessAlive, sleep } from '../utils';
import { RobloxDelegate } from './delegate';
import { robloxPath } from './path';
import { RobloxUtils } from './utils';

// Export value to be able to set it from other code
let restartWatcher = false;
export const setRestartWatcherVar = (value: boolean) => (restartWatcher = value);

type EventHandler = (data?: any) => void;
type Event = 'exit' | 'gameInfo' | 'gameEvent';
Expand Down Expand Up @@ -134,7 +135,7 @@ export class RobloxInstance {

/** Initalize class values */
public async init() {
if (!(await Roblox.Utils.hasRoblox())) return;
if (!(await RobloxUtils.hasRoblox())) return;
}

/** Starts the Roblox Instance */
Expand All @@ -152,16 +153,16 @@ export class RobloxInstance {

// Launch Roblox
if (url) {
await Roblox.Delegate.toggle(false);
await RobloxDelegate.toggle(false);
await shell('open', [url]);
} else {
await shell('open', [Roblox.path]);
await shell('open', [robloxPath]);
}

await sleep(1000); // Give time for Roblox to open
// "If block" because settings can be edited and maybe it will not be boolean
if ((await getValue<boolean>('roblox.launching.delegate')) === true) {
await Roblox.Delegate.toggle(true);
await RobloxDelegate.toggle(true);
}

// We find every roblox processes and get the RobloxPlayer one
Expand Down
51 changes: 26 additions & 25 deletions frontend/src/windows/main/ts/roblox/launch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import beautify from 'json-beautify';
import path from 'path-browserify';
import { toast } from 'svelte-sonner';
import Roblox from '.';
import { getValue } from '../../components/settings';
import { Notification } from '../tools/notifications';
import { RPCController } from '../tools/rpc';
Expand All @@ -11,6 +10,10 @@ import { sleep } from '../utils';
import { focusWindow, setWindowVisibility } from '../window';
import onGameEvent from './events';
import { RobloxInstance } from './instance';
import { RobloxFFlags } from './fflags';
import { robloxPath } from './path';
import { RobloxUtils } from './utils';
import { RobloxMods } from './mods';

let rbxInstance: RobloxInstance | null = null;

Expand Down Expand Up @@ -44,28 +47,28 @@ export async function launchRoblox(
try {
console.info('[Launch] Launching Roblox');
setLaunchingRoblox(true);
if (!(await Roblox.Utils.hasRoblox())) {
if (!(await RobloxUtils.hasRoblox())) {
console.info('[Launch] Roblox is not installed. Exiting launch process.');
setLaunchingRoblox(false);
return;
}

// Fast Flags
setLaunchProgress(20);
if (await shellFS.exists(path.join(Roblox.path, 'Contents/MacOS/ClientSettings/ClientAppSettings.json'))) {
if (await shellFS.exists(path.join(robloxPath, 'Contents/MacOS/ClientSettings/ClientAppSettings.json'))) {
console.info(
`[Launch] Removing current ClientAppSettings.json file in "${path.join(Roblox.path, 'Contents/MacOS/ClientSettings/ClientAppSettings.json"')}`
`[Launch] Removing current ClientAppSettings.json file in "${path.join(robloxPath, 'Contents/MacOS/ClientSettings/ClientAppSettings.json"')}`
);
await shellFS.remove(path.join(Roblox.path, 'Contents/MacOS/ClientSettings/'));
await shellFS.remove(path.join(robloxPath, 'Contents/MacOS/ClientSettings/'));
setLaunchText('Removing current ClientAppSettings...');
}

setLaunchProgress(30);
setLaunchText('Copying fast flags...');
console.info('[Launch] Copying fast flags...');
await shellFS.createDirectory(path.join(Roblox.path, 'Contents/MacOS/ClientSettings'));
await shellFS.createDirectory(path.join(robloxPath, 'Contents/MacOS/ClientSettings'));
console.info('[Launch] Parsing saved FFlags...');
const presetFlags = await Roblox.FFlags.parseFlags(true);
const presetFlags = await RobloxFFlags.parseFlags(true);
// Invalid presets
if (
Object.keys(presetFlags.invalidFlags).length > 0 &&
Expand All @@ -82,7 +85,7 @@ export async function launchRoblox(
return;
}
}
const editorFlags = await Roblox.FFlags.parseFlags(false);
const editorFlags = await RobloxFFlags.parseFlags(false);
// Invalid selected profile flags
if (
Object.keys(editorFlags.invalidFlags).length > 0 &&
Expand Down Expand Up @@ -126,29 +129,29 @@ export async function launchRoblox(
};
console.info('[Launch] FastFlags: ', fflags);
await shellFS.writeFile(
path.join(Roblox.path, 'Contents/MacOS/ClientSettings/ClientAppSettings.json'),
path.join(robloxPath, 'Contents/MacOS/ClientSettings/ClientAppSettings.json'),
JSON.stringify(fflags)
);
console.info(
`[Launch] Wrote FFlags to "${path.join(Roblox.path, 'Contents/MacOS/ClientSettings/ClientAppSettings.json')}"`
`[Launch] Wrote FFlags to "${path.join(robloxPath, 'Contents/MacOS/ClientSettings/ClientAppSettings.json')}"`
);

// Mods
if (constSettings.areModsEnabled) {
setLaunchProgress(40);
setLaunchText('Copying Mods...');

await Roblox.Mods.copyToFiles();
await RobloxMods.copyToFiles();
}
await Roblox.Mods.applyCustomFont();
await RobloxMods.applyCustomFont();

setLaunchProgress(60);
setTimeout(async () => {
try {
await RobloxMods.toggleHighRes(!constSettings.fixResolution);
if (constSettings.areModsEnabled && constSettings.fixResolution) {
setLaunchText('Disabling Retina resolution...');
setLaunchProgress(80);
await Roblox.Mods.toggleHighRes(false);
}
const robloxInstance = new RobloxInstance(true);
await robloxInstance.init();
Expand All @@ -170,17 +173,15 @@ export async function launchRoblox(
subtitle: 'Quitting the app may corrupt Roblox',
timeout: 5,
}).show();
Roblox.Mods.restoreRobloxFolders()
RobloxMods.restoreRobloxFolders()
.catch(console.error)
.then(async () => {
console.info(
`[Launch] Removed mod files from "${path.join(Roblox.path, 'Contents/Resources/')}"`
);
console.info(`[Launch] Removed mod files from "${path.join(robloxPath, 'Contents/Resources/')}"`);
// Use if block because checking if high resolution is enabled require file operations, so it's more optimized that way.
if (constSettings.fixResolution) {
await Roblox.Mods.toggleHighRes(true);
await RobloxMods.toggleHighRes(true);
}
await Roblox.Mods.removeCustomFont();
await RobloxMods.removeCustomFont();
});
}
RPCController.stop();
Expand All @@ -191,17 +192,17 @@ export async function launchRoblox(
});
} catch (err) {
if (constSettings.areModsEnabled) {
await Roblox.Mods.restoreRobloxFolders()
await RobloxMods.restoreRobloxFolders()
.catch(console.error)
.then(() => {
console.info(`[Launch] Removed mod files from "${path.join(Roblox.path, 'Contents/Resources/')}"`);
console.info(`[Launch] Removed mod files from "${path.join(robloxPath, 'Contents/Resources/')}"`);
});
}
console.error(err);
setLaunchingRoblox(false);
toast.error('An error occured while starting Roblox.');
await shellFS.remove(path.join(Roblox.path, 'Contents/MacOS/ClientSettings/'));
console.info(`[Launch] Deleted "${path.join(Roblox.path, 'Contents/MacOS/ClientSettings/')}"`);
await shellFS.remove(path.join(robloxPath, 'Contents/MacOS/ClientSettings/'));
console.info(`[Launch] Deleted "${path.join(robloxPath, 'Contents/MacOS/ClientSettings/')}"`);
return;
}

Expand All @@ -210,8 +211,8 @@ export async function launchRoblox(
setWindowVisibility(false);
setTimeout(() => {
setLaunchingRoblox(false);
shellFS.remove(path.join(Roblox.path, 'Contents/MacOS/ClientSettings/'));
console.info(`[Launch] Deleted "${path.join(Roblox.path, 'Contents/MacOS/ClientSettings')}"`);
shellFS.remove(path.join(robloxPath, 'Contents/MacOS/ClientSettings/'));
console.info(`[Launch] Deleted "${path.join(robloxPath, 'Contents/MacOS/ClientSettings')}"`);
}, 1000);
}, 1000);
} catch (err) {
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/windows/main/ts/roblox/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { sleep } from '@/windows/main/ts/utils';
import { filesystem, os } from '@neutralinojs/lib';
import path from 'path-browserify';
import { toast } from 'svelte-sonner';
import Roblox from '.';
import { shell } from '../tools/shell';
import shellFS from '../tools/shellfs';
import { setRestartWatcherVar } from './instance';
import { robloxPath } from './path';

export class RobloxUtils {
/** Checks if roblox is installed, and if not show a popup */
static async hasRoblox(popup = true): Promise<boolean> {
if (await shellFS.exists(path.join(Roblox.path, 'Contents/MacOS/RobloxPlayer'))) {
if (await shellFS.exists(path.join(robloxPath, 'Contents/MacOS/RobloxPlayer'))) {
return true;
}
if (!popup) return false;
Expand Down Expand Up @@ -51,7 +50,7 @@ END`,

toast.info('Opening Roblox...', { duration: 1000 });
console.info('[Roblox.Utils] Opening Roblox...');
await shellFS.open(Roblox.path);
await shellFS.open(robloxPath);

await sleep(1000);

Expand Down Expand Up @@ -133,7 +132,6 @@ END`,
}

static async killAll() {
setRestartWatcherVar(false);
await shell(`ps aux | grep -i roblox | grep -v grep | awk '{print $2}' | xargs kill -9`, [], {
completeCommand: true,
skipStderrCheck: true,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"typescript": "^5.3.3",
"vite": "4.4.9",
"vite-plugin-checker": "^0.7.2",
"vite-plugin-circular-dependency": "^0.5.0",
"vite-plugin-html": "^3.2.2"
},
"dependencies": {
Expand Down
7 changes: 5 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
import * as path from 'node:path';
import { defineConfig } from 'vite';
import checker from 'vite-plugin-checker';
import circleDependency from 'vite-plugin-circular-dependency';
import neutralino from './scripts/package/vite-plugin';

// https://vitejs.dev/config/
export default defineConfig({
root: 'frontend',
plugins: [svelte(), checker({ typescript: true }), neutralino(), circleDependency()],
plugins: [
svelte(),
checker({ typescript: true }),
neutralino(),
],
build: {
outDir: path.resolve('./frontend/dist'),
rollupOptions: {
Expand Down

0 comments on commit d844438

Please sign in to comment.