Skip to content

Commit

Permalink
Fixed timing issues with resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
OrigamingWasTaken committed Jul 17, 2024
1 parent 4fe62e4 commit 1a42504
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 63 deletions.
81 changes: 34 additions & 47 deletions frontend/src/windows/main/App.svelte
Original file line number Diff line number Diff line change
@@ -1,68 +1,53 @@
<script lang="ts">
import Sidebar from "./Sidebar/Sidebar.svelte";
import { Skeleton } from "$lib/components/ui/skeleton/index.js";
import Integrations from "./pages/Integrations.svelte";
import { fly } from "svelte/transition";
import FastFlags from "./pages/FastFlags.svelte";
import { Toaster } from "$lib/components/ui/sonner";
import { Progress } from "$lib/components/ui/progress";
import Misc from "./pages/Misc.svelte";
import { app, os, window as w } from "@neutralinojs/lib";
import { ModeWatcher, setMode } from "mode-watcher";
import Credits from "./pages/Credits.svelte";
import { launchRoblox } from "./ts/roblox/launch";
import { loadSettings } from "./ts/settings";
import Updater from "./Updater.svelte";
import Mods from "./pages/Mods.svelte";
import Sidebar from './Sidebar/Sidebar.svelte';
import { Skeleton } from '$lib/components/ui/skeleton/index.js';
import Integrations from './pages/Integrations.svelte';
import { fly } from 'svelte/transition';
import FastFlags from './pages/FastFlags.svelte';
import { Toaster } from '$lib/components/ui/sonner';
import { Progress } from '$lib/components/ui/progress';
import Misc from './pages/Misc.svelte';
import { app, os, window as w } from '@neutralinojs/lib';
import { ModeWatcher, setMode } from 'mode-watcher';
import Credits from './pages/Credits.svelte';
import { launchRoblox } from './ts/roblox/launch';
import { loadSettings } from './ts/settings';
import Updater from './Updater.svelte';
import Mods from './pages/Mods.svelte';
let currentPage: string;
let launchInfo = {
launching: false,
progress: 1,
text: "Launching...",
text: 'Launching...',
isConnected: false,
};
// Checks if the app is opened with the --launch argument
async function checkArgs() {
if (window.NL_ARGS.includes("--launch")) {
if (window.NL_ARGS.includes('--launch')) {
console.debug("Launching Roblox from '--launch?'");
// Here we check if the Discord RPC options is enabled. If it is, then don't close the app.
const integrationSettings = await loadSettings("integrations");
if (integrationSettings && integrationSettings.rpc.enable_rpc) {
console.log("Not closing the app because RPC is enabled");
// Defines which values should be modified during the launch phase (the loading progress, text, etc...)
await launchRoblox(
(value) => (launchInfo.isConnected = value),
(value) => (launchInfo.launching = value),
(value) => (launchInfo.progress = value),
(value) => (launchInfo.text = value)
);
} else {
w.hide().catch(console.error);
await launchRoblox(
(value) => (launchInfo.isConnected = value),
(value) => (launchInfo.launching = value),
(value) => (launchInfo.progress = value),
(value) => (launchInfo.text = value)
);
await app.exit();
}
// Defines which values should be modified during the launch phase (the loading progress, text, etc...)
await launchRoblox(
(value) => (launchInfo.isConnected = value),
(value) => (launchInfo.launching = value),
(value) => (launchInfo.progress = value),
(value) => (launchInfo.text = value)
);
}
}
checkArgs();
// Sets the theme to the system's mode
setMode("system");
setMode('system');
// Handle app links
document.addEventListener("click", (event) => {
document.addEventListener('click', (event) => {
if (!event.target) return;
// @ts-expect-error
if (event.target.tagName === "A") {
if (event.target.tagName === 'A') {
// Prevent default behavior (opening link)
event.preventDefault();
Expand All @@ -72,6 +57,8 @@
console.log(`Opening link: ${url}`);
// Example: Open link in a new tab
// @ts-expect-error
if ((event.target.href as string).includes("localhost")) return;
os.open(url);
}
});
Expand Down Expand Up @@ -102,23 +89,23 @@
id="sidebar"
/>
<div class="fixed overflow-y-scroll max-h-full top-0 left-36 w-[85%]">
{#if currentPage == "integrations"}
{#if currentPage == 'integrations'}
<div in:fly={{ y: -750, duration: 1000 }} out:fly={{ y: 400, duration: 400 }}>
<Integrations />
</div>
{:else if currentPage === "fastflags"}
{:else if currentPage === 'fastflags'}
<div in:fly={{ y: -750, duration: 1000 }} out:fly={{ y: 400, duration: 400 }}>
<FastFlags />
</div>
{:else if currentPage === "misc"}
{:else if currentPage === 'misc'}
<div in:fly={{ y: -750, duration: 1000 }} out:fly={{ y: 400, duration: 400 }}>
<Misc />
</div>
{:else if currentPage === "credits"}
{:else if currentPage === 'credits'}
<div in:fly={{ y: -750, duration: 1000 }} out:fly={{ y: 400, duration: 400 }}>
<Credits />
</div>
{:else if currentPage === "mods"}
{:else if currentPage === 'mods'}
<div in:fly={{ y: -750, duration: 1000 }} out:fly={{ y: 400, duration: 400 }}>
<Mods />
</div>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/windows/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ events.on("ready", async () => {
await rpc.start({
clientId: "1257650541677383721",
details: "Currently in the launcher",
state: "using AppleBlox",
largeImage: "appleblox",
largeImageText: "AppleBlox Logo",
enableTime: true
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/windows/main/pages/Integrations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
.start({
clientId: "1257650541677383721",
details: "Currently in the launcher",
state: "using AppleBlox",
largeImage: "appleblox",
largeImageText: "AppleBlox Logo",
enableTime: true,
Expand Down Expand Up @@ -77,7 +76,7 @@
{
label: "Control RPC",
description: "Games can change your DiscordRPC",
id: "sdK_rpc",
id: "sdk_rpc",
options: {
type: "boolean",
state: false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/windows/main/pages/Mods.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
id: "spoof_res",
options: {
type: "boolean",
state: false,
state: true,
},
},
{
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/windows/main/ts/roblox/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const Entries: Entry[] = [
event: "GameJoining",
match: "[FLog::Output] ! Joining game",
},
{
event: "GameStartJoining",
match: "[FLog::SingleSurfaceApp] launchUGCGameInternal"
},
{
event: "GameJoiningPrivateServer",
match: "[FLog::GameJoinUtil] GameJoinUtil::joinGamePostPrivateServer",
Expand Down Expand Up @@ -82,7 +86,7 @@ const Patterns: Pattern[] = [
{
event: "GameCrashEntry",
regex: /\[FLog::CrashReportLog\] (.*)/g,
},
}
];

export class RobloxInstance {
Expand Down Expand Up @@ -188,7 +192,8 @@ export class RobloxInstance {
// Check if the event comes from the logs watcher, and that it is stdOut
if (!this.isWatching || !this.logsInstance || evt.detail.id !== this.logsInstance.id) return;
if (evt.detail.action === "exit") {
console.log("Logs watcher exited");
console.log("Logs watcher exited with output: ")
console.log(evt.detail.data);
console.log("Restarting logs watcher");
await os.execCommand(`pkill -f "tail -f /Users/$(whoami)/Library/Logs/Roblox/"`);
await sleep()
Expand Down Expand Up @@ -219,6 +224,8 @@ export class RobloxInstance {
}

private processLines(lines: string[]) {
for (const entry of Entries)

for (const entry of Entries) {
const includedLines = lines.filter((line) => line.includes(entry.match));
for (const line of includedLines) {
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/windows/main/ts/roblox/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ async function onGameEvent(data: GameEventInfo) {
try {
switch (data.event) {
case 'GameJoiningEntry':
// Change the resolution to support mods
if (modSettings && modSettings.general.enable_mods) {
const maxRes = (await os.execCommand(`system_profiler SPDisplaysDataType | grep Resolution | awk -F': ' '{print $2}'`)).stdOut.trim().split(' ');
Roblox.Window.setDesktopRes(maxRes[0], maxRes[2], 6);
}

const placeMatch = data.data.match(/place\s+(\d+)\s+/);
if (!placeMatch) {
console.error("Couldn't retrieve the placeId from the logs");
Expand Down Expand Up @@ -120,7 +126,7 @@ async function onGameEvent(data: GameEventInfo) {
rpcOptions = {
...rpcOptions,
buttonText2: 'Join server',
buttonUrl2: `"https://rpcdeeplinks.netlify.app?url=roblox://experiences/start?placeId=${placeId}&gameInstanceId=${jobId}"`,
buttonUrl2: `"roblox://experiences/start?placeId=${placeId}&gameInstanceId=${jobId}"`,
};
} else {
delete rpcOptions.buttonText2;
Expand All @@ -141,7 +147,6 @@ async function onGameEvent(data: GameEventInfo) {
const normalRpcOptions = {
clientId: '1257650541677383721',
details: 'Currently in the launcher',
state: 'using AppleBlox',
largeImage: 'appleblox',
largeImageText: 'AppleBlox Logo',
enableTime: true,
Expand All @@ -155,12 +160,6 @@ async function onGameEvent(data: GameEventInfo) {
console.log('Disconnected/Left game');
break;
case 'GameJoinedEntry':
// Change the resolution to support mods
if (modSettings && modSettings.general.enable_mods) {
const maxRes = (await os.execCommand(`system_profiler SPDisplaysDataType | grep Resolution | awk -F': ' '{print $2}'`)).stdOut.trim().split(' ');
Roblox.Window.setDesktopRes(maxRes[0], maxRes[2], 3);
}

// Add the join server button
const server = data.data.substring(10).split('|');
console.log(`Current server: ${server[0]}, Port: ${server[1]}`);
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/windows/main/ts/roblox/mods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,20 @@ export class RobloxMods {
title: 'Error while removing mods',
content: "The 'Resources' hasn't been found. Mods will not be removed.",
sound: true,
timeout: 6
timeout: 6,
});
return
return;
}

await shellFS.remove(resourcesFolder);
await shellFS.copy(resBackupFolder, resourcesFolder, true);
await shellFS.remove(resBackupFolder);

showNotification({
title: 'Resources restored',
content: 'Roblox has been cleaned of any Mods remnants..',
timeout: 5,
});
await sleep(100);
}
}

0 comments on commit 1a42504

Please sign in to comment.