diff --git a/src/components/pages/sub/OverviewSubPage.svelte b/src/components/pages/sub/OverviewSubPage.svelte index e1e4da6..f14e917 100644 --- a/src/components/pages/sub/OverviewSubPage.svelte +++ b/src/components/pages/sub/OverviewSubPage.svelte @@ -3,14 +3,16 @@ import ProcessList from "./items/ProcessList.svelte"; import Analytics from "./items/Analytics.svelte"; + let consoleOutput: ConsoleOutput + let instances: number
- - + consoleOutput.switchConsole(event.detail)}/> +
\ No newline at end of file diff --git a/src/components/pages/sub/items/Analytics.svelte b/src/components/pages/sub/items/Analytics.svelte index 7fbfcc7..e92fdc1 100644 --- a/src/components/pages/sub/items/Analytics.svelte +++ b/src/components/pages/sub/items/Analytics.svelte @@ -1,3 +1,62 @@ +

Analytics

@@ -5,19 +64,19 @@

Ram Usage

-

0.01%

+

{memoryUsage === "N/A" ? memoryUsage : `${memoryUsage}mb`}

-

MC Processes

-

10 Processes

+

MC Process Count

+

{instances} {instances > 1 ? "Processes" : "Process"}

Time Played

-

10 Hours

+

{timePlayed}

Avg. Launch

-

10 Seconds

+

{avgLaunchTime}

diff --git a/src/components/pages/sub/items/ConsoleOutput.svelte b/src/components/pages/sub/items/ConsoleOutput.svelte index 71607ce..6cf195a 100644 --- a/src/components/pages/sub/items/ConsoleOutput.svelte +++ b/src/components/pages/sub/items/ConsoleOutput.svelte @@ -1,68 +1,45 @@
@@ -76,14 +53,22 @@
-

PName: Lunar

+

Client: {client}

-

PID: 5728

+

PID: {pid}

- {longString} + {#if switchingConsole} +
+ +
+ {:else} + {#each [...output.values()] as line} +

{line}

+ {/each} + {/if}
diff --git a/src/components/pages/sub/items/ProcessList.svelte b/src/components/pages/sub/items/ProcessList.svelte index f9c60dd..ef0036e 100644 --- a/src/components/pages/sub/items/ProcessList.svelte +++ b/src/components/pages/sub/items/ProcessList.svelte @@ -1,22 +1,66 @@
@@ -24,8 +68,7 @@

Minecraft Processes

- -
+
+
+
\ No newline at end of file diff --git a/src/components/popups/CreateLaunchProfilePopUp.svelte b/src/components/popups/CreateLaunchProfilePopUp.svelte new file mode 100644 index 0000000..3dc29fd --- /dev/null +++ b/src/components/popups/CreateLaunchProfilePopUp.svelte @@ -0,0 +1,55 @@ + + + {launchProfileInfo = undefined; failed = false;}}> +
+
+ Failed to create Launch Profile +
+ +
+ + +
+
+
+ + + \ No newline at end of file diff --git a/src/components/util/PopUp.svelte b/src/components/util/PopUp.svelte new file mode 100644 index 0000000..5b6490f --- /dev/null +++ b/src/components/util/PopUp.svelte @@ -0,0 +1,58 @@ + + + +
+

{title}

+
+ +
+
+
+ + \ No newline at end of file diff --git a/src/scripts/shared.ts b/src/scripts/shared.ts index 0359926..d09e274 100644 --- a/src/scripts/shared.ts +++ b/src/scripts/shared.ts @@ -1,11 +1,46 @@ -import type {MinecraftProcess} from "./types"; +import type {MinecraftInfo, MinecraftProcess} from "./types"; +import {BaseDirectory, writeFile, exists, createDir} from "@tauri-apps/api/fs" +import {homeDir} from "@tauri-apps/api/path"; export async function showProcessInfo(mcProcess: MinecraftProcess) { } -export async function createLaunchProfile(mcProcess: MinecraftProcess) { +/** + * Creates a Launch Profile using information retrieved from Minecraft processes. + * @param name The name of the profile + * @param mcInfo The minecraft information needed to re-launch this process with Weave + * @return True if successful, False if the file already exists + */ +export async function createLaunchProfile(name: string, mcInfo: MinecraftInfo): Promise { + if (name.length == 0) // empty names are not allowed + return false + + // sanitize the file name + const cleanName = name.replace(/[^a-z0-9]/gi, '_').toLowerCase(); + const filePath = `${await getProfileDirectory()}/${cleanName}.launch` + + if (await exists(filePath)) + return false + + await writeFile(filePath, JSON.stringify(mcInfo)) + return true +} + +async function getProfileDirectory() { + const profileDir = `${await getWeaveDirectory()}/profiles` + if (!await exists(profileDir)) + await createDir(profileDir) + + return profileDir +} + +async function getWeaveDirectory() { + const weaveDir = await homeDir() + "/.weave" + if (!await exists(weaveDir)) + await createDir(weaveDir) + return weaveDir } export function checkVerticalOverflow(element: HTMLElement): boolean {