Implementing lighty launcher

This commit is contained in:
2026-04-03 20:58:08 +02:00
parent eed6069685
commit cd8c9c464a
5 changed files with 1081 additions and 47 deletions
+1073 -4
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -22,4 +22,4 @@ tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
lighty-launcher = { version = "0.8.6", features = ["fabric", "tauri-commands"] }
+2 -33
View File
@@ -1,12 +1,6 @@
use tauri::{AppHandle, Emitter, State};
use tauri::State;
use crate::{GameVersion, LauncherSettings, Mod, SharedState};
#[tauri::command]
pub fn get_versions(state: State<SharedState>) -> Vec<GameVersion> {
let state = state.lock().unwrap();
state.versions.clone()
}
use crate::{LauncherSettings, Mod, SharedState};
#[tauri::command]
pub fn get_installed_mods(state: State<SharedState>, version_id: String) -> Vec<Mod> {
@@ -47,28 +41,3 @@ pub fn update_settings(state: State<SharedState>, new_settings: LauncherSettings
let mut state = state.lock().unwrap();
state.settings = new_settings;
}
#[tauri::command]
pub fn launch_game(app: AppHandle, version_id: String) -> Result<(), String> {
std::thread::spawn(move || {
app.emit("is-launching", "true").unwrap();
app.emit("launch-status", "Preparing...").unwrap();
std::thread::sleep(std::time::Duration::from_millis(500));
app.emit("launch-status", "Verifying assets...").unwrap();
std::thread::sleep(std::time::Duration::from_millis(700));
app.emit("launch-status", "Applying Saturn optimizations...")
.unwrap();
std::thread::sleep(std::time::Duration::from_millis(700));
app.emit("launch-status", "Starting game...").unwrap();
std::thread::sleep(std::time::Duration::from_millis(1000));
app.emit("launch-status", "Game launched!").unwrap();
app.emit("is-launching", "false").unwrap();
});
Ok(())
}
+3 -3
View File
@@ -1,6 +1,7 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use lighty_launcher::tauri::lighty_plugin;
use saturn_launcher_lib::{commands::*, AppState};
use std::sync::Mutex;
@@ -8,15 +9,14 @@ use std::sync::Mutex;
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(lighty_plugin())
.manage(Mutex::new(AppState::default()))
.invoke_handler(tauri::generate_handler![
get_versions,
get_installed_mods,
toggle_mod,
install_mod,
get_settings,
update_settings,
launch_game
update_settings
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
+2 -6
View File
@@ -1,10 +1,5 @@
import { invoke } from "@tauri-apps/api/core";
import { GameVersion, LauncherSettings, Mod } from "./Types";
// --- Versions ---
export async function getVersions(): Promise<GameVersion[]> {
return await invoke("get_versions");
}
import { LauncherSettings, Mod } from "./Types";
// --- Mods ---
export async function getInstalledMods(versionId: string): Promise<Mod[]> {
@@ -75,5 +70,6 @@ export async function updateSettings(
export async function launchGame(
versionId: string,
): Promise<{ success: boolean; message: string }> {
await invoke("plugin:lighty-launcher|launch", { versionId });
return await invoke("launch_game", { versionId });
}