From 3c13c14dea03c6b91716fb0f1578deb12fcf9756 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Fri, 16 Jan 2026 20:20:05 +0800 Subject: feat: implement instance management functionality Added a new InstancesState class to manage game instances, including loading, creating, deleting, updating, and duplicating instances. Integrated instance selection into the game launch process, ensuring an active instance is selected before starting a game. Updated the types to include instance-related data structures. --- ui/src/stores/game.svelte.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ui/src/stores/game.svelte.ts') diff --git a/ui/src/stores/game.svelte.ts b/ui/src/stores/game.svelte.ts index ca5dc2b..3efcf71 100644 --- a/ui/src/stores/game.svelte.ts +++ b/ui/src/stores/game.svelte.ts @@ -2,6 +2,7 @@ import { invoke } from "@tauri-apps/api/core"; import type { Version } from "../types"; import { uiState } from "./ui.svelte"; import { authState } from "./auth.svelte"; +import { instancesState } from "./instances.svelte"; export class GameState { versions = $state([]); @@ -34,10 +35,19 @@ export class GameState { return; } + if (!instancesState.activeInstanceId) { + alert("Please select an instance first!"); + uiState.setView("instances"); + return; + } + uiState.setStatus("Preparing to launch " + this.selectedVersion + "..."); - console.log("Invoking start_game for version:", this.selectedVersion); + console.log("Invoking start_game for version:", this.selectedVersion, "instance:", instancesState.activeInstanceId); try { - const msg = await invoke("start_game", { versionId: this.selectedVersion }); + const msg = await invoke("start_game", { + instanceId: instancesState.activeInstanceId, + versionId: this.selectedVersion, + }); console.log("Response:", msg); uiState.setStatus(msg); } catch (e) { -- cgit v1.2.3-70-g09d2