From 82a0473287323e56397cd66beee408250f869457 Mon Sep 17 00:00:00 2001 From: Raymond <101374892+raymonable@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:00:08 -0500 Subject: [PATCH] feat: add url support (wip) --- .../components/settings/ChuniSettings.svelte | 50 ++++++++++++++----- AquaNet/src/libs/i18n/en_ref.ts | 16 +++++- AquaNet/src/libs/userbox/ddsCache.ts | 11 +++- 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/AquaNet/src/components/settings/ChuniSettings.svelte b/AquaNet/src/components/settings/ChuniSettings.svelte index e945f9b5..10675f9c 100644 --- a/AquaNet/src/components/settings/ChuniSettings.svelte +++ b/AquaNet/src/components/settings/ChuniSettings.svelte @@ -96,6 +96,7 @@ let USERBOX_PROGRESS = 0; let USERBOX_SETUP_RUN = false; + let USERBOX_SETUP_MODE = false; let USERBOX_SETUP_TEXT = t("userbox.new.setup"); let USERBOX_ENABLED = useLocalStorage("userboxNew", false); @@ -117,6 +118,20 @@ }) ?? ""; } + function userboxHandleInput(e: KeyboardEvent) { + if (e.key != "Enter") + return; + let baseURL = (e.target as HTMLInputElement).value; + try { + // validate url + new URL(baseURL); + } catch(err) { + return error = t("userbox.new.error.invalidUrl") + } + useLocalStorage("userboxURL", "").value = baseURL; + location.reload(); + } + indexedDB.databases().then(async (dbi) => { let databaseExists = dbi.some(db => db.name == "userboxChusanDDS"); if (databaseExists) { @@ -233,7 +248,7 @@
{/if} - {#if !USERBOX_SUPPORT || !USERBOX_INSTALLED || !USERBOX_ENABLED.value} + {/if} {/if} @@ -256,21 +271,28 @@ @@ -304,13 +326,15 @@ p.notice border-radius: 25px +.base-url-text, .drop-btn + margin-bottom: 1em + .drop-btn position: relative width: 100% aspect-ratio: 3 background: transparent box-shadow: 0 0 1px 1px vars.$ov-lighter - margin-bottom: 1em > input position: absolute diff --git a/AquaNet/src/libs/i18n/en_ref.ts b/AquaNet/src/libs/i18n/en_ref.ts index 4538ed7f..d55159ca 100644 --- a/AquaNet/src/libs/i18n/en_ref.ts +++ b/AquaNet/src/libs/i18n/en_ref.ts @@ -92,7 +92,7 @@ export const EN_REF_HOME = { 'home.linkcard.account-card': 'Account Card', 'home.linkcard.registered': 'Registered', 'home.linkcard.lastused': 'Last used', - 'home.linkcard.enter-info': 'Please enter the following information', + 'home.linkcard.enter-info': 'Please enter the following information, or drag and drop your aime.txt / felica.txt file here', 'home.linkcard.access-code': 'The 20-digit access code on the back of your card. (If it doesn\'t work, please try scanning your card in game and enter the access code shown on screen)', 'home.linkcard.enter-sn1': 'Download the NFC Tools app on your phone', 'home.linkcard.enter-sn2': 'and scan your card. Then, enter the Serial Number.', @@ -180,18 +180,30 @@ export const EN_REF_USERBOX = { 'userbox.preview.url': 'Image URL', 'userbox.error.nodata': 'Chuni data not found', + 'userbox.matching.select': 'Select Matching Server', + 'userbox.matching.select.sub': 'Choose the matching server you want to use.', + 'userbox.matching.option.ui': 'Rooms', + 'userbox.matching.option.guide': 'Guide', + 'userbox.matching.option.collab': 'Collaborators', + 'userbox.matching.custom.name': 'Custom', + 'userbox.matching.custom.sub': 'Enter your own URL', + 'userbox.new.name': 'AquaBox', 'userbox.new.setup': 'Drag and drop your Chuni game folder (Lumi or newer) into the box below to display UserBoxes with their nameplate & avatar. All files are handled in-browser.', 'userbox.new.setup.processing_file': 'Processing', 'userbox.new.setup.finalizing': 'Saving to internal storage', 'userbox.new.drop': 'Drop game folder here', + 'userbox.new.switch.to_url': 'Switch to URL mode', + 'userbox.new.switch.to_drop': 'Switch to drop mode', + 'userbox.new.url_warning': 'You are responsible for the results in this state. Please read the documentation.', 'userbox.new.activate_first': 'Enable AquaBox (game files required)', 'userbox.new.activate_update': 'Update AquaBox (game files required)', 'userbox.new.activate': 'Use AquaBox', 'userbox.new.activate_desc': 'Enable displaying UserBoxes with their nameplate & avatar', 'userbox.new.activate_profile': 'Use AquaBox on profiles', 'userbox.new.activate_profile_desc': 'Enable displaying UserBoxes with their nameplate & avatar on profile pages', - 'userbox.new.error.invalidFolder': 'The folder you selected is invalid. Ensure that your game\'s version is Lumi or newer and that the "A001" option pack is present.' + 'userbox.new.error.invalidFolder': 'The folder you selected is invalid. Ensure that your game\'s version is Lumi or newer and that the "A000" option pack is present.', + 'userbox.new.error.invalidUrl': 'The URL you inputted is invalid.' } export const EN_REF = { ...EN_REF_USER, ...EN_REF_Welcome, ...EN_REF_GENERAL, diff --git a/AquaNet/src/libs/userbox/ddsCache.ts b/AquaNet/src/libs/userbox/ddsCache.ts index ff973d13..d8170f72 100644 --- a/AquaNet/src/libs/userbox/ddsCache.ts +++ b/AquaNet/src/libs/userbox/ddsCache.ts @@ -1,3 +1,5 @@ +import useLocalStorage from "../hooks/useLocalStorage.svelte"; + export default class DDSCache { constructor(db: IDBDatabase | undefined) { this.db = db; @@ -43,7 +45,13 @@ export default class DDSCache { * @param path Image path */ getFromDatabase(path: string): Promise