diff --git a/client/src-tauri/src/close_splashscreen.rs b/client/src-tauri/src/close_splashscreen.rs index 81371c8..aeb17ff 100644 --- a/client/src-tauri/src/close_splashscreen.rs +++ b/client/src-tauri/src/close_splashscreen.rs @@ -3,16 +3,15 @@ use tauri::{Manager, Window}; // This command must be async so that it doesn't run on the main thread. #[tauri::command] pub async fn close_splashscreen(window: Window) { + println!("Closing splashscreen"); // Close splashscreen - window - .get_window("splashscreen") - .expect("no window labeled 'splashscreen' found") - .close() - .unwrap(); - // Show main window - window - .get_window("main") - .expect("no window labeled 'main' found") - .show() - .unwrap(); + match window.get_window("splashscreen") { + Some(window) => window.close().unwrap(), + None => tracing::info!("Couldn't find splashscreen window"), + } + + match window.get_window("main") { + Some(window) => window.show().unwrap(), + None => tracing::info!("Couldn't find main window"), + } } diff --git a/client/src-tauri/src/main.rs b/client/src-tauri/src/main.rs index 88ada52..53ef00d 100644 --- a/client/src-tauri/src/main.rs +++ b/client/src-tauri/src/main.rs @@ -5,6 +5,7 @@ use tauri::Manager; mod telemetry; use tracing_subscriber::FmtSubscriber; mod close_splashscreen; +use close_splashscreen::close_splashscreen; #[derive(Clone, serde::Serialize)] struct Payload { @@ -24,13 +25,6 @@ fn main() { tracing::subscriber::set_global_default(subscriber).unwrap(); rt.block_on(async { - tauri::Builder::default() - .invoke_handler(tauri::generate_handler![ - close_splashscreen::close_splashscreen - ]) - .run(tauri::generate_context!()) - .expect("failed to run app"); - tauri::Builder::default() .setup(|app| { // create app handle and send it to our event listeners @@ -42,6 +36,7 @@ fn main() { Ok(()) }) + .invoke_handler(tauri::generate_handler![close_splashscreen]) .run(tauri::generate_context!()) .expect("failed to run app") }) diff --git a/client/src-tauri/tauri.conf.json b/client/src-tauri/tauri.conf.json index 7dee98d..06bc277 100644 --- a/client/src-tauri/tauri.conf.json +++ b/client/src-tauri/tauri.conf.json @@ -1,8 +1,8 @@ { "$schema": "../node_modules/@tauri-apps/cli/schema.json", "build": { - "beforeBuildCommand": "npm run build", - "beforeDevCommand": "npm run dev", + "beforeBuildCommand": "pnpm build", + "beforeDevCommand": "pnpm dev", "devPath": "http://localhost:5173", "distDir": "../dist" }, @@ -63,7 +63,8 @@ "resizable": true, "title": "Jankboard 2", "width": 800, - "visible": false + "visible": false, + "label": "main" }, { "fullscreen": false, @@ -74,7 +75,8 @@ "resizable": true, "width": 800, "url": "splashscreen.html", - "label": "splashscreen" + "label": "splashscreen", + "visible": true } ] } diff --git a/client/src/App.svelte b/client/src/App.svelte index c551ced..24f1c58 100644 --- a/client/src/App.svelte +++ b/client/src/App.svelte @@ -9,11 +9,16 @@ import { onDestroy, onMount } from 'svelte' import { Toaster } from 'svelte-french-toast' import { initializationSequence } from './lib/Sequences/sequences' - import Loading from './lib/Loading/Loading.svelte' import { settingsStore } from './lib/stores/settingsStore' import getSettings from './lib/utils/getSettings' + import hideSplashscreen from './lib/utils/hideSplashscreen' let activeApp: App = 'camera' + // fake loading splash screen to look cool if the model loads too fast + let fakeLoadingDone = false + // and the real one, to wait for massive robot model to load if it's slow + let realLoadingDone = false + let started = false let unlistenAll: () => void @@ -27,22 +32,39 @@ initializeTelemetry().then((unsubFunction: () => void) => { unlistenAll = unsubFunction }) - setTimeout(initializationSequence, 3000) settingsStore.subscribe((value) => { localStorage.setItem('settings', JSON.stringify(value)) }) + + setTimeout(() => { + fakeLoadingDone = true + }, 3000) }) onDestroy(() => { unlistenAll && unlistenAll() }) + + const start = () => { + hideSplashscreen() + initializationSequence() + } + + const onVisualizationLoaded = () => { + realLoadingDone = true + } + + $: if (realLoadingDone && fakeLoadingDone && !started) { + started = true + start() + }
- +
diff --git a/client/src/lib/Dashboard/Dashboard.svelte b/client/src/lib/Dashboard/Dashboard.svelte index bbeb052..691c449 100644 --- a/client/src/lib/Dashboard/Dashboard.svelte +++ b/client/src/lib/Dashboard/Dashboard.svelte @@ -45,7 +45,7 @@
- +
diff --git a/client/src/lib/Dashboard/Visualization/Scene.svelte b/client/src/lib/Dashboard/Visualization/Scene.svelte index 1b6de6e..2f0dd73 100644 --- a/client/src/lib/Dashboard/Visualization/Scene.svelte +++ b/client/src/lib/Dashboard/Visualization/Scene.svelte @@ -11,6 +11,9 @@ import RobotDecimated from './models/RobotDecimated.svelte' import { telemetryReadonlyStore } from '../../stores/telemetryStore' import { DEG2RAD } from 'three/src/math/MathUtils.js' + import { createEventDispatcher } from 'svelte' + + const dispatch = createEventDispatcher() const SPEED_MULTIPLIER = 4 const axis = new Vector3(0, 1, 0) @@ -137,6 +140,7 @@ on:create={({ ref }) => { // @ts-expect-error mesh.set(ref) + dispatch('loaded') }} /> diff --git a/client/src/lib/Dashboard/Visualization/Visualization.svelte b/client/src/lib/Dashboard/Visualization/Visualization.svelte index 4ae23fe..a07ee9b 100644 --- a/client/src/lib/Dashboard/Visualization/Visualization.svelte +++ b/client/src/lib/Dashboard/Visualization/Visualization.svelte @@ -4,5 +4,5 @@ - + diff --git a/client/src/lib/utils/hideSplashscreen.ts b/client/src/lib/utils/hideSplashscreen.ts index 8b069fa..3904e74 100644 --- a/client/src/lib/utils/hideSplashscreen.ts +++ b/client/src/lib/utils/hideSplashscreen.ts @@ -1,5 +1,6 @@ import { invoke } from '@tauri-apps/api/tauri' export default async () => { - await invoke('hide_splashscreen') + console.log('hiding') + await invoke('close_splashscreen') }