Skip to content

Commit

Permalink
Merge pull request #14 from lu2000luk/main
Browse files Browse the repository at this point in the history
Version 0.9.6
  • Loading branch information
lu2000luk authored Jul 4, 2024
2 parents 1dff883 + 5b74442 commit b77ad5d
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "ETB Rocket",
"version": "0.9.5"
"version": "0.9.6"
},
"tauri": {
"allowlist": {
Expand Down
30 changes: 23 additions & 7 deletions src/lib/components/modcard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,25 @@
const basePath = steam_game_loc + "/EscapeTheBackrooms/Content/Paks/"
if (nexus) {
alert("In this beta you'll need to manually download files from nexus to install them.")
loading = "error";
installed = false;
loading = "Loading";
let file_data_url = "https://api.nexusmods.com/v1/games/escapethebackrooms/mods/"+mod_id+"/files.json?category=update%2Cmain";
let file_data_http = await httpclient.get(file_data_url, {
responseType: ResponseType.JSON,
headers: {
apiKey: $NexusConfig.apiKey
}
});
let file_data = file_data_http.data;
console.log(file_data);
loading = "Opening"
open("https://www.nexusmods.com/escapethebackrooms/mods/"+mod_id+"?tab=files&file_id="+file_data.files.at(-1).file_id+"&nmm=1")
return;
}
Expand Down Expand Up @@ -114,21 +130,21 @@
<div class="download flex items-end" ui-debug={$uidev}>
<div class="flex items-center" ui-debug={$uidev}>
<p class="px-1">Made by {author}</p>
{#if installed || get(downloaded).includes(downloadLink)}
{#if installed || get(downloaded).includes(downloadLink) || $downloaded.includes(name)}
<Button disabled bg="secondary">
<Check /> Installed
</Button>
{:else}
{#if loading !== "error" && loading}
<Button disabled bg="primary-dark">
<Button disabled bg="primary">
<Loading /> {loading}
</Button>
{:else if loading === "error"}
<Button click={() => {downloadMod(downloadLink, folder)}} bg="error" >
<Button click={() => {downloadMod(downloadLink, folder)}} bg="error">
<Error size={20} class="pr-1" /> Error
</Button>
{:else}
<Button click={() => {downloadMod(downloadLink, folder)}} >
<Button click={() => {downloadMod(downloadLink, folder)}} bg="primary-dark">
<Download size={20} class="pr-1" /> Download
</Button>
{/if}
Expand Down
21 changes: 14 additions & 7 deletions src/lib/components/nxmcard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@
loading = "Cleaning up";
loading = "Ready to install";
await installMod()
try {
await installMod()
} catch (err) {
alert(err)
}
}
async function installMod() {
Expand Down Expand Up @@ -108,7 +113,7 @@
}
});
loading = "Foldering"
loading = "Checking"
let folder = ""
Expand All @@ -130,9 +135,6 @@
break;
}
invoke("expand_scope", { folderPath: basePath })
try {await createDir(basePath+folder)} catch {console.log("No directory was created!")}
loading = "Extracting";
//@ts-ignore
Expand Down Expand Up @@ -186,9 +188,14 @@
//@ts-ignore
let modfile = entries[zipdataname]._reader.blob
loading = "Foldering";
invoke("expand_scope", { folderPath: basePath })
try {await createDir(basePath+folder)} catch {console.log("No directory was created!")}
loading = "Writing";
await writeBinaryFile(basePath+folder+"/"+zipdataname, new Uint8Array(await modfile.arrayBuffer()));
await writeBinaryFile(basePath+folder+"/"+zipdataname.split("/").at(-1), new Uint8Array(await modfile.arrayBuffer()));
loading = "Cleaning";
console.log("Mod File Saved to "+basePath+folder+"/"+zipdataname)
Expand Down Expand Up @@ -237,4 +244,4 @@
</div>
</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/routes/creators/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
</div>
<br>
<div class="flex justify-center flex-wrap" ui-debug={$uidev}>
<h3 class="text-xl">Here you can upload your mods to our service and give users the best experience downnloading your mods!</h3>
<h3 class="text-xl">Here you can upload your mods to our service and give users the best experience downloading your mods!</h3>
</div>
<br>
<div class="flex justify-center flex-wrap" ui-debug={$uidev}>
<Button bg="accent-dark" classes="py-5 px-5" click={() => {alert("Coming Soon™️")}}><LogIn size={20} class="pr-1" />Start today</Button>
<a href="../creators/coming_soon"><Button bg="accent-dark" classes="py-5 px-5"><LogIn size={20} class="pr-1" />Start today</Button></a>
</div>
<br />
<div class="flex justify-center flex-wrap" ui-debug={$uidev}>
Expand Down
3 changes: 3 additions & 0 deletions src/routes/creators/coming_soon/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>
Coming soon...
</h1>
3 changes: 3 additions & 0 deletions src/routes/creators/dashboard/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
</script>
106 changes: 106 additions & 0 deletions src/routes/creators/login/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<script>
//@ts-nocheck
import client from "$lib/aw";
import { Account, ID } from "appwrite";
import { goto } from "$app/navigation"
let step = 0;
let email = "";
let code = "";
let userId;
async function checkLogin() {
try {
await account.get();
goto("../creators/dashboard")
} catch {
step = 1;
}
}
const account = new Account(client);
async function continueLogin() {
const sessionToken = await account.createEmailToken(
ID.unique(),
email
);
userId = sessionToken.userId;
step = 2;
}
async function finalizeLogin() {
const session = await account.createSession(
userId,
code
);
console.log(session)
}
checkLogin()
</script>

<div class="flex min-h-[100dvh] items-center justify-center bg-background px-4 py-12 sm:px-6 lg:px-8">
<div class="mx-auto w-full max-w-md space-y-6">
<div class="text-center">
<h1 class="text-3xl font-bold tracking-tight text-foreground">Log in to your account</h1>
<p class="mt-2 text-muted-foreground">Enter your email and one-time password to access your account.</p>
</div>
{#if step === 1}
<div class="rounded-lg border bg-card text-card-foreground shadow-sm" data-v0-t="card">
<div class="p-6 space-y-2">
<div class="space-y-1">
<label
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
for="email"
>
Email
</label>
<input
class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
id="email"
placeholder="[email protected]"
required={true}
type="email"

bind:value={email}
/>
</div>
</div>
<div class="flex items-center p-6">
<button class="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full" on:click={continueLogin}>
Send Mail
</button>
</div>
</div>
{:else if step === 2}
<div class="rounded-lg border bg-card text-card-foreground shadow-sm" data-v0-t="card">
<div
data-input-otp-container="true"
class="flex items-center gap-2"

>
<div class="flex justify-center p-2 m-2">
<input
autocomplete="one-time-code"
inputmode="numeric"
pattern="^[0-9]+$"
maxlength="6"
bind:value={code}
class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div class="flex items-center p-6">
<button class="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2 w-full" on:click={finalizeLogin}>
Log In
</button>
</div></div>
{/if}
</div>
</div>
6 changes: 6 additions & 0 deletions src/routes/creators/not_verified/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="m-2">
<p class="text-xl">
Your account is not verified. Check back later. (Should not take more than 48 hrs)
To get verified faster contact lu2000luk on Discord.
</p>
</div>
97 changes: 88 additions & 9 deletions src/routes/mods/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import { NexusConfig } from "$lib/nexus"
import { getClient, ResponseType } from '@tauri-apps/api/http';
let loadingModsPhase = 0;
function limitStringTo240WordsAndRemoveBr(inputString) {
let stringWithoutBr = inputString.replace(/<br\s*\/?>/gi, ' ');
let wordsArray = stringWithoutBr.split(/\s+/);
Expand All @@ -17,25 +19,102 @@
return wordsArray.join(' ');
}
async function nexusGetTrending() {
async function NexusGetOthers() {
let modz = [];
if ($NexusConfig.apiKey === false) {return [];}
const httpclient = await getClient();
console.info("HTTPClient Loaded")
const nmods = await httpclient.get("https://api.nexusmods.com/v1/games/escapethebackrooms/mods/trending.json", {
loadingModsPhase++;
let latest_added = await httpclient.get("https://api.nexusmods.com/v1/games/escapethebackrooms/mods/latest_added.json", {
responseType: ResponseType.JSON,
headers: {
apiKey: $NexusConfig.apiKey
}
});
loadingModsPhase++;
let latest_updated = await httpclient.get("https://api.nexusmods.com/v1/games/escapethebackrooms/mods/latest_updated.json", {
responseType: ResponseType.JSON,
headers: {
apiKey: $NexusConfig.apiKey
}
});
loadingModsPhase++;
let trending = await httpclient.get("https://api.nexusmods.com/v1/games/escapethebackrooms/mods/trending.json", {
responseType: ResponseType.JSON,
headers: {
apiKey: $NexusConfig.apiKey
}
});
let mappedMods = [];
loadingModsPhase++;
let latest_added_mods = latest_added.data;
let latest_updated_mods = latest_updated.data;
let trending_mods = trending.data;
console.log(latest_added_mods)
console.log(latest_updated_mods)
console.log(trending_mods)
console.log("Indexing mods")
await nmods.data.forEach(async element => {
function isModAlreadyScanned(mod) {
for (let i = 0; i < modz.length; i++) {
if (modz[i].mod_id === mod.mod_id) {
return true;
}
}
console.log("Mod not found in array: "+mod)
return false;
}
await latest_added_mods.forEach(async element => {
if (element.name === "Interpose Map Loader" || element.name === "Interpose Mod Loader" || element.contains_adult_content === true) {return;}
mappedMods.push({
if (isModAlreadyScanned(element)) {return;}
modz.push({
cover: element.picture_url,
modVersion: element.version,
nexus: true,
description: limitStringTo240WordsAndRemoveBr(element.summary),
author: element.author,
name: element.name,
mod_id: element.mod_id
})
});
await latest_updated_mods.forEach(async element => {
if (element.name === "Interpose Map Loader" || element.name === "Interpose Mod Loader" || element.contains_adult_content === true) {return;}
if (isModAlreadyScanned(element)) {return;}
modz.push({
cover: element.picture_url,
modVersion: element.version,
nexus: true,
description: limitStringTo240WordsAndRemoveBr(element.summary),
author: element.author,
name: element.name,
mod_id: element.mod_id
})
});
await trending_mods.forEach(async element => {
if (element.name === "Interpose Map Loader" || element.name === "Interpose Mod Loader" || element.contains_adult_content === true) {return;}
if (isModAlreadyScanned(element)) {return;}
modz.push({
cover: element.picture_url,
modVersion: element.version,
nexus: true,
Expand All @@ -46,18 +125,18 @@
})
});
console.log(mappedMods)
loadingModsPhase++;
return mappedMods
return modz;
}
</script>

{#each Mods as mod}
<ModCard {...mod} />
{/each}

{#await nexusGetTrending()}
Loading...
{#await NexusGetOthers()}
Loading more... [{loadingModsPhase}/5]
{:then nlmods}
{#each nlmods as mod}
<ModCard {...mod} />
Expand Down

0 comments on commit b77ad5d

Please sign in to comment.