Skip to content

Commit

Permalink
Cleaned some code and added a label to show the app's version
Browse files Browse the repository at this point in the history
  • Loading branch information
OrigamingWasTaken committed Jul 13, 2024
1 parent 067db91 commit 583a255
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 193 deletions.
6 changes: 4 additions & 2 deletions frontend/src/windows/main/Sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { createEventDispatcher } from "svelte";
import logo from "@/assets/favicon.png";
import { os } from "@neutralinojs/lib";
import { version } from "../../../../../package.json";
import IntegrationsIcon from "@/assets/sidebar/integrations.png";
import FastFlagsIcon from "@/assets/sidebar/fastflags.png";
Expand All @@ -14,7 +15,6 @@
import SidebarBtn from "./SidebarBtn.svelte";
import Button from "$lib/components/ui/button/button.svelte";
import { Play } from "lucide-svelte";
export let isLaunched = false;
Expand Down Expand Up @@ -66,7 +66,9 @@
{/each}
</div>
</div>
<div class="flex justify-center mb-4">
<div class="flex flex-col items-center mb-4">
<p class="text-sm text-gray-500 mb-2">v{version}</p>

<Button
class={`${isLaunched ? "bg-blue-400 hover:bg-blue-400 cursor-not-allowed" : "bg-green-600 hover:bg-green-800"} font-mono`}
on:click={() => {
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/windows/main/pages/Integrations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@
},
},
{
label: "Let games control your window",
label: "Control RPC",
description: "Games can change your DiscordRPC",
id: "sdK_rpc",
options: {
type: "boolean",
state: false,
},
},
{
label: "Control Roblox window",
description: "Games can define the size of your Roblox window",
id: "window",
options: {
Expand Down
300 changes: 150 additions & 150 deletions frontend/src/windows/main/ts/roblox/fflags.ts
Original file line number Diff line number Diff line change
@@ -1,177 +1,177 @@
import { os, filesystem } from "@neutralinojs/lib";
import { filesystem } from "@neutralinojs/lib";
import { pathExists } from "../utils";
import path from "path-browserify";
import type { FFlag } from "@/types/settings";
import { dataPath, loadSettings } from "../settings";

export class RobloxFFlags {
/** Returns every saved FFlags */
static async getFlags(): Promise<FFlag[] | undefined> {
// Read the saved fflags file inside Application Support
const filePath = path.join(await dataPath(),"fflags.json");
if (!(await pathExists(filePath))) {
await this.setFlags([]);
}
const fileContent = await filesystem.readFile(filePath);
try {
return JSON.parse(fileContent);
} catch (error) {
// There was no flags previously saved or there's a random error
return undefined;
static async getFlags(): Promise<FFlag[] | undefined> {
// Read the saved fflags file inside Application Support
const filePath = path.join(await dataPath(), "fflags.json");
if (!(await pathExists(filePath))) {
await this.setFlags([]);
}
const fileContent = await filesystem.readFile(filePath);
try {
return JSON.parse(fileContent);
} catch (error) {
// There was no flags previously saved or there's a random error
return undefined;
}
}
}

/** Saves and backup fflags */
static async setFlags(flags: FFlag[]) {
const configPath = await dataPath();
const filePath = path.join(configPath, "fflags.json");
// Check if the AppleBlox/config dir exsits
if (!(await pathExists(configPath))) {
await filesystem.createDirectory(configPath);
}
// If file exits then we remove it
if (await pathExists(filePath)) {
await filesystem.remove(filePath);
/** Saves and backup fflags */
static async setFlags(flags: FFlag[]) {
const configPath = await dataPath();
const filePath = path.join(configPath, "fflags.json");
// Check if the AppleBlox/config dir exsits
if (!(await pathExists(configPath))) {
await filesystem.createDirectory(configPath);
}
// If file exits then we remove it
if (await pathExists(filePath)) {
await filesystem.remove(filePath);
}
// Copy the new file to Application Support
await filesystem.writeFile(filePath, JSON.stringify(flags));
}
// Copy the new file to Application Support
await filesystem.writeFile(filePath, JSON.stringify(flags));
}

/** Sets a fflag to true or false */
static async setFlag(flag: string, enabled: boolean, value: string) {
const configPath = await dataPath()
const filePath = path.join(configPath, "fflags.json");
// Check if the AppleBlox/config dir exsits
if (!(await pathExists(configPath))) {
await filesystem.createDirectory(configPath);
}
/** Sets a fflag to true or false */
static async setFlag(flag: string, enabled: boolean, value: string) {
const configPath = await dataPath();
const filePath = path.join(configPath, "fflags.json");
// Check if the AppleBlox/config dir exsits
if (!(await pathExists(configPath))) {
await filesystem.createDirectory(configPath);
}

// Load the fflags from the saved file || empty array
let fflags: FFlag[] = JSON.parse(await filesystem.readFile(filePath)) || [];
// Modify the flag if it exists or create a new one
if (fflags.find((f) => f.flag === flag)) {
fflags[fflags.findIndex((f) => f.flag === flag)] = { flag, enabled, value };
} else {
fflags.push({ flag, enabled, value });
// Load the fflags from the saved file || empty array
let fflags: FFlag[] = JSON.parse(await filesystem.readFile(filePath)) || [];
// Modify the flag if it exists or create a new one
if (fflags.find((f) => f.flag === flag)) {
fflags[fflags.findIndex((f) => f.flag === flag)] = { flag, enabled, value };
} else {
fflags.push({ flag, enabled, value });
}
await this.setFlags(fflags);
}
await this.setFlags(fflags);
}

/** Append a flag to the config file. If the one provided already exists, then this will return false */
static async addFlag(flag: string, value: string): Promise<boolean> {
let flags: FFlag[] = (await this.getFlags()) || [];
if (flags.find((f) => f.flag === flag)) {
// The flag already exists
return false;
} else {
flags.push({ flag, enabled: true, value });
await this.setFlags(flags);
return true;
/** Append a flag to the config file. If the one provided already exists, then this will return false */
static async addFlag(flag: string, value: string): Promise<boolean> {
let flags: FFlag[] = (await this.getFlags()) || [];
if (flags.find((f) => f.flag === flag)) {
// The flag already exists
return false;
} else {
flags.push({ flag, enabled: true, value });
await this.setFlags(flags);
return true;
}
}
}

/** Removes the provided flag. If it's doesn't exist, returns false */
static async removeFlag(flag: string): Promise<boolean> {
let flags: FFlag[] = (await this.getFlags()) || [];
if (flags.find((f) => f.flag === flag)) {
await this.setFlags(flags.filter((f) => f.flag !== flag));
return true;
} else {
// The flag doesn't exist
return false;
/** Removes the provided flag. If it's doesn't exist, returns false */
static async removeFlag(flag: string): Promise<boolean> {
let flags: FFlag[] = (await this.getFlags()) || [];
if (flags.find((f) => f.flag === flag)) {
await this.setFlags(flags.filter((f) => f.flag !== flag));
return true;
} else {
// The flag doesn't exist
return false;
}
}
}

static async parseFlags(preset = false): Promise<Object> {
// Get the path to Application Supoort
const appPath = await dataPath();
let fflagsJson: { [key: string]: string | number } = {};
if (preset) {
if (!(await pathExists(path.join(appPath, "fastflags.json")))) {
return {};
}
const neuPath = path.join(appPath, "fastflags.json");
const ohioFinalBoss = JSON.parse(await filesystem.readFile(neuPath));
// i know this isn't efficient, but i didn't want to re-write the fastlfags saving system.
// in the future, i may change this to a dynamic system.
for (const name of Object.keys(ohioFinalBoss.presets)) {
const data = ohioFinalBoss.presets[name];
switch (name) {
case "ff_fps":
if (data[0] > 60) {
fflagsJson["FFlagDebugGraphicsDisableMetal"] = "true";
fflagsJson["FFlagDebugGraphicsPreferVulkan"] = "true";
}
fflagsJson["DFIntTaskSchedulerTargetFps"] = data[0];
break;
case "ff_lightning":
if (data.disabled) break;
switch (data.value) {
case "voxel":
fflagsJson["DFFlagDebugRenderForceTechnologyVoxel"] = "true";
break;
case "shadowmap":
fflagsJson["FFlagDebugForceFutureIsBrightPhase2"] = "true";
break;
case "future":
fflagsJson["FFlagDebugForceFutureIsBrightPhase3"] = "true";
break;
}
break;
case "ff_engine":
if (data.disabled) break;
switch (data.value) {
// don't know if disabling Metal works, need testing. For now it uses OpenGL
case "opengl":
fflagsJson["FFlagDebugGraphicsDisableMetal"] = "true";
fflagsJson["FFlagDebugGraphicsPreferOpenGL"] = "true";
break;
case "metal":
fflagsJson["FFlagDebugGraphicsPreferMetal"] = "true";
break;
case "vulkan":
static async parseFlags(preset = false): Promise<Object> {
// Get the path to Application Supoort
const appPath = await dataPath();
let fflagsJson: { [key: string]: string | number } = {};
if (preset) {
if (!(await pathExists(path.join(appPath, "fastflags.json")))) {
return {};
}
const neuPath = path.join(appPath, "fastflags.json");
const ohioFinalBoss = JSON.parse(await filesystem.readFile(neuPath));
// i know this isn't efficient, but i didn't want to re-write the fastlfags saving system.
// in the future, i may change this to a dynamic system.
for (const name of Object.keys(ohioFinalBoss.presets)) {
const data = ohioFinalBoss.presets[name];
switch (name) {
case "ff_fps":
if (data[0] > 60) {
fflagsJson["FFlagDebugGraphicsDisableMetal"] = "true";
fflagsJson["FFlagDebugGraphicsPreferVulkan"] = "true";
break;
}
break;
case "ff_gui":
if (data.length < 1) break;
fflagsJson["DFIntCanHideGuiGroupId"] = data;
break;
case "ff_display":
if (data) {
fflagsJson["DFIntDebugFRMQualityLevelOverride"] = 1;
}
break;
case "ff_graphics":
if (data) {
fflagsJson["FFlagCommitToGraphicsQualityFix"] = "true";
fflagsJson["FFlagFixGraphicsQuality"] = "true";
}
break;
}
fflagsJson["DFIntTaskSchedulerTargetFps"] = data[0];
break;
case "ff_lightning":
if (data.disabled) break;
switch (data.value) {
case "voxel":
fflagsJson["DFFlagDebugRenderForceTechnologyVoxel"] = "true";
break;
case "shadowmap":
fflagsJson["FFlagDebugForceFutureIsBrightPhase2"] = "true";
break;
case "future":
fflagsJson["FFlagDebugForceFutureIsBrightPhase3"] = "true";
break;
}
break;
case "ff_engine":
if (data.disabled) break;
switch (data.value) {
// don't know if disabling Metal works, need testing. For now it uses OpenGL
case "opengl":
fflagsJson["FFlagDebugGraphicsDisableMetal"] = "true";
fflagsJson["FFlagDebugGraphicsPreferOpenGL"] = "true";
break;
case "metal":
fflagsJson["FFlagDebugGraphicsPreferMetal"] = "true";
break;
case "vulkan":
fflagsJson["FFlagDebugGraphicsDisableMetal"] = "true";
fflagsJson["FFlagDebugGraphicsPreferVulkan"] = "true";
break;
}
break;
case "ff_gui":
if (data.length < 1) break;
fflagsJson["DFIntCanHideGuiGroupId"] = data;
break;
case "ff_display":
if (data) {
fflagsJson["DFIntDebugFRMQualityLevelOverride"] = 1;
}
break;
case "ff_graphics":
if (data) {
fflagsJson["FFlagCommitToGraphicsQualityFix"] = "true";
fflagsJson["FFlagFixGraphicsQuality"] = "true";
}
break;
}
}
}

const integrationsFlags = await loadSettings("integrations")
if (integrationsFlags && integrationsFlags.sdk.enabled) {
fflagsJson["FFlagUserIsBloxstrap"] = "true"
if (integrationsFlags.sdk.window) fflagsJson["FFlagUserAllowsWindowMovement"] = "true"
}
const integrationsFlags = await loadSettings("integrations");
if (integrationsFlags && integrationsFlags.sdk.enabled) {
fflagsJson["FFlagUserIsBloxstrap"] = "true";
if (integrationsFlags.sdk.window) fflagsJson["FFlagUserAllowsWindowMovement"] = "true";
}

return fflagsJson;
} else {
if (!(await pathExists(path.join(appPath, "fflags.json")))) {
return {};
}
const neuPath = path.join(appPath, "fflags.json");
const skibidiOhioFanumTax: { flag: string; enabled: boolean; value: string | number }[] = JSON.parse(await filesystem.readFile(neuPath));
for (const flag of skibidiOhioFanumTax) {
if (flag.enabled) {
fflagsJson[flag.flag] = flag.value;
return fflagsJson;
} else {
if (!(await pathExists(path.join(appPath, "fflags.json")))) {
return {};
}
const neuPath = path.join(appPath, "fflags.json");
const skibidiOhioFanumTax: { flag: string; enabled: boolean; value: string | number }[] = JSON.parse(await filesystem.readFile(neuPath));
for (const flag of skibidiOhioFanumTax) {
if (flag.enabled) {
fflagsJson[flag.flag] = flag.value;
}
}
return fflagsJson;
}
return fflagsJson;
}
}
}
1 change: 1 addition & 0 deletions frontend/src/windows/main/ts/roblox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { launchRoblox } from "./launch";
import { RobloxUtils } from "./utils";
import { RobloxWindow } from "./window";

// Simple export
class Roblox {
static FFlags = RobloxFFlags
static Instance = RobloxInstance
Expand Down
Loading

0 comments on commit 583a255

Please sign in to comment.