Skip to content

Commit

Permalink
Implemented Launch Shortcuts and a button to write ClientAppSettings.…
Browse files Browse the repository at this point in the history
…json
  • Loading branch information
OrigamingWasTaken committed Jun 30, 2024
1 parent 5d45ce7 commit f0fda57
Show file tree
Hide file tree
Showing 12 changed files with 385 additions and 201 deletions.
Binary file added frontend/src/assets/play.icns
Binary file not shown.
15 changes: 15 additions & 0 deletions frontend/src/lib/components/ui/tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Tooltip as TooltipPrimitive } from "bits-ui";
import Content from "./tooltip-content.svelte";

const Root = TooltipPrimitive.Root;
const Trigger = TooltipPrimitive.Trigger;

export {
Root,
Trigger,
Content,
//
Root as Tooltip,
Content as TooltipContent,
Trigger as TooltipTrigger,
};
28 changes: 28 additions & 0 deletions frontend/src/lib/components/ui/tooltip/tooltip-content.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script lang="ts">
import { Tooltip as TooltipPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js";
type $$Props = TooltipPrimitive.ContentProps;
let className: $$Props["class"] = undefined;
export let sideOffset: $$Props["sideOffset"] = 4;
export let transition: $$Props["transition"] = flyAndScale;
export let transitionConfig: $$Props["transitionConfig"] = {
y: 8,
duration: 150,
};
export { className as class };
</script>

<TooltipPrimitive.Content
{transition}
{transitionConfig}
{sideOffset}
class={cn(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md",
className
)}
{...$$restProps}
>
<slot />
</TooltipPrimitive.Content>
6 changes: 5 additions & 1 deletion frontend/src/types/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />
declare module '*.svelte'
declare module '*.svelte'
declare module '*.icns' {
const src: string
export default src
}
61 changes: 37 additions & 24 deletions frontend/src/windows/main/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { hasRoblox, parseFFlags } from "./ts/roblox";
import Misc from "./pages/Misc.svelte";
import { toast } from "svelte-sonner";
import { debug, filesystem, os } from "@neutralinojs/lib";
import { app, debug, filesystem, os, window as w } from "@neutralinojs/lib";
import { ModeWatcher, setMode } from "mode-watcher";
import { pathExists } from "./ts/utils";
Expand All @@ -18,43 +18,56 @@
let launchProgess = 1;
let ltext = "Launching...";
async function checkArgs() {
if (window.NL_ARGS.includes("--launch")) {
w.hide().catch(console.error);
await launchRoblox();
setTimeout(()=>{
app.exit(0)
},7000)
}
}
checkArgs();
async function launchRoblox() {
launchingRoblox = true;
if (!(await hasRoblox())) {
launchingRoblox = false;
}
// FFLAGS
launchProgess = 20
launchProgess = 20;
if (await pathExists("/Applications/Roblox.app/Contents/MacOS/ClientSettings/ClientAppSettings.json")) {
await filesystem.remove("/Applications/Roblox.app/Contents/MacOS/ClientSettings/")
ltext = "Removing current ClientAppSettings..."
await filesystem.remove("/Applications/Roblox.app/Contents/MacOS/ClientSettings/");
ltext = "Removing current ClientAppSettings...";
}
launchProgess = 40
ltext = "Copying fast flags..."
await filesystem.createDirectory("/Applications/Roblox.app/Contents/MacOS/ClientSettings").catch(console.error)
console.log(await parseFFlags(true))
const fflags = {...(await parseFFlags(false)), ...(await parseFFlags(true))}
await filesystem.writeFile("/Applications/Roblox.app/Contents/MacOS/ClientSettings/ClientAppSettings.json",JSON.stringify(fflags))
launchProgess = 60
setTimeout(()=>{
os.execCommand("open /Applications/Roblox.app")
launchProgess = 100
ltext = "Roblox Launched"
setTimeout(()=>{
launchingRoblox = false
filesystem.remove("/Applications/Roblox.app/Contents/MacOS/ClientSettings/").catch(console.error)
},1000)
},1000)
launchProgess = 40;
ltext = "Copying fast flags...";
await filesystem.createDirectory("/Applications/Roblox.app/Contents/MacOS/ClientSettings").catch(console.error);
console.log(await parseFFlags(true));
const fflags = { ...(await parseFFlags(false)), ...(await parseFFlags(true)) };
await filesystem.writeFile(
"/Applications/Roblox.app/Contents/MacOS/ClientSettings/ClientAppSettings.json",
JSON.stringify(fflags)
);
launchProgess = 60;
setTimeout(() => {
os.execCommand("open /Applications/Roblox.app");
launchProgess = 100;
ltext = "Roblox Launched";
setTimeout(() => {
launchingRoblox = false;
filesystem.remove("/Applications/Roblox.app/Contents/MacOS/ClientSettings/").catch(console.error);
}, 1000);
}, 1000);
}
// Darkmode
setMode("system")
setMode("system");
</script>

<main>
<ModeWatcher track={true}/>
<ModeWatcher track={true} />
<Toaster richColors />
<!-- Content div -->
{#if launchingRoblox}
Expand Down
114 changes: 110 additions & 4 deletions frontend/src/windows/main/pages/Misc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import type { SettingsPanel } from "@/types/settings";
import Panel from "./Settings/Panel.svelte";
import { saveSettings } from "../ts/settings";
import { showNotification } from "../ts/notifications";
import { toast } from "svelte-sonner";
import { isRobloxOpen } from "../ts/roblox";
import { events, os } from "@neutralinojs/lib";
import { isRobloxOpen, parseFFlags } from "../ts/roblox";
import { events, filesystem, os } from "@neutralinojs/lib";
import { sleep } from "$lib/appleblox";
import AppIcon from "@/assets/play.icns";
import path from "path-browserify";
import { pathExists } from "../ts/utils";
function settingsChanged(o: Object) {
saveSettings("misc", o);
Expand All @@ -32,6 +34,13 @@
}
}
});
async function loadImageToBlob(url: string): Promise<Blob> {
const response = await fetch(url);
const blob = await response.blob();
return blob;
}
async function buttonClicked(e: CustomEvent) {
const id = e.detail;
switch (id) {
Expand All @@ -54,6 +63,75 @@
await os.execCommand(`ps aux | grep -i roblox | grep -v grep | awk '{print $2}' | xargs kill -9`);
toast.success("All Roblox Instances have been closed.");
break;
case "create_shortcut_btn":
const savePath = await os
.showFolderDialog("Where should the shortcut be created?", { defaultPath: "/Applications/" })
.catch(console.error);
if (!savePath) {
toast.error("An error occured while trying to save the shortcut", { duration: 2000 });
return;
}
try {
if (await pathExists(path.join(savePath, "Launch Roblox.app"))) {
await filesystem.remove(path.join(savePath, "Launch Roblox.app"));
}
await filesystem.createDirectory(path.join(savePath, "Launch Roblox.app/Contents/MacOS"));
await filesystem.createDirectory(path.join(savePath, "Launch Roblox.app/Contents/Resources"));
await filesystem.writeFile(
path.join(savePath, "Launch Roblox.app/Contents/Info.plist"),
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>launch</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
</dict>
</plist>`
);
const blob = await loadImageToBlob(AppIcon);
await filesystem.writeBinaryFile(
path.join(savePath, "Launch Roblox.app/Contents/Resources/icon.icns"),
await blob.arrayBuffer()
);
await filesystem.writeFile(
path.join(savePath, "Launch Roblox.app/Contents/MacOS/launch"),
"#!/bin/bash\n" + path.join(path.dirname(window.NL_PATH), "MacOS/bootstrap") + " --launch"
);
await os.execCommand(
`chmod +x ${path.join(savePath, "Launch Roblox.app/Contents/MacOS/launch").replaceAll(" ", "\\ ")}`
);
toast.success(`Created a shortcut at "${path.join(savePath, "Launch Roblox.app")}"`);
} catch (err) {
console.error(err);
toast.error("An error occured while trying to save the shortcut", { duration: 2000 });
return;
}
break;
case "write_clientappsettings_btn":
try {
const filePath = "/Applications/Roblox.app/Contents/MacOS/ClientSettings/AppClientSettings.json";
if (await pathExists(filePath)) {
await filesystem.remove(filePath);
}
await filesystem.createDirectory(path.dirname(filePath))
const fflags = { ...(await parseFFlags(false)), ...(await parseFFlags(true)) };
await filesystem.writeFile(filePath, JSON.stringify(fflags));
toast.success(`Wrote ClientAppSettings at "${filePath}"`);
} catch (err) {
console.error(err);
toast.error("An error occured while writing ClientAppSettings.json");
}
break;
}
}
Expand Down Expand Up @@ -87,7 +165,8 @@
},
{
label: "Terminate all instances",
description: "Closes every open Roblox instances. (This acts as a force-kill, so be sure to use this appropriately)",
description:
"Closes every open Roblox instances. (This acts as a force-kill, so be sure to use this appropriately)",
id: "close_roblox_btn",
options: {
type: "button",
Expand All @@ -96,6 +175,33 @@
},
],
},
{
name: "Roblox Launching",
description: "Settings about launching Roblox",
id: "multi_instances",
interactables: [
{
label: "Create a launch shortcut",
description:
"Creates a shortcut that can be used to launch Roblox (with all the AppleBlox features) without having to open this app.",
id: "create_shortcut_btn",
options: {
type: "button",
style: "default",
},
},
{
label: "Write ClientAppSettings.json",
description:
"Saves the FastFlags to Roblox directly for them to be used without using AppleBlox. This isn't recommended.",
id: "write_clientappsettings_btn",
options: {
type: "button",
style: "outline",
},
},
],
},
],
};
</script>
Expand Down
Loading

0 comments on commit f0fda57

Please sign in to comment.