Implementing lighty launcher
This commit is contained in:
Generated
+1073
-4
File diff suppressed because it is too large
Load Diff
@@ -22,4 +22,4 @@ tauri = { version = "2", features = [] }
|
|||||||
tauri-plugin-opener = "2"
|
tauri-plugin-opener = "2"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
lighty-launcher = { version = "0.8.6", features = ["fabric", "tauri-commands"] }
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
use tauri::{AppHandle, Emitter, State};
|
use tauri::State;
|
||||||
|
|
||||||
use crate::{GameVersion, LauncherSettings, Mod, SharedState};
|
use crate::{LauncherSettings, Mod, SharedState};
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn get_versions(state: State<SharedState>) -> Vec<GameVersion> {
|
|
||||||
let state = state.lock().unwrap();
|
|
||||||
state.versions.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_installed_mods(state: State<SharedState>, version_id: String) -> Vec<Mod> {
|
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();
|
let mut state = state.lock().unwrap();
|
||||||
state.settings = new_settings;
|
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(())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
use lighty_launcher::tauri::lighty_plugin;
|
||||||
use saturn_launcher_lib::{commands::*, AppState};
|
use saturn_launcher_lib::{commands::*, AppState};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
@@ -8,15 +9,14 @@ use std::sync::Mutex;
|
|||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
|
.plugin(lighty_plugin())
|
||||||
.manage(Mutex::new(AppState::default()))
|
.manage(Mutex::new(AppState::default()))
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
get_versions,
|
|
||||||
get_installed_mods,
|
get_installed_mods,
|
||||||
toggle_mod,
|
toggle_mod,
|
||||||
install_mod,
|
install_mod,
|
||||||
get_settings,
|
get_settings,
|
||||||
update_settings,
|
update_settings
|
||||||
launch_game
|
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { GameVersion, LauncherSettings, Mod } from "./Types";
|
import { LauncherSettings, Mod } from "./Types";
|
||||||
|
|
||||||
// --- Versions ---
|
|
||||||
export async function getVersions(): Promise<GameVersion[]> {
|
|
||||||
return await invoke("get_versions");
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Mods ---
|
// --- Mods ---
|
||||||
export async function getInstalledMods(versionId: string): Promise<Mod[]> {
|
export async function getInstalledMods(versionId: string): Promise<Mod[]> {
|
||||||
@@ -75,5 +70,6 @@ export async function updateSettings(
|
|||||||
export async function launchGame(
|
export async function launchGame(
|
||||||
versionId: string,
|
versionId: string,
|
||||||
): Promise<{ success: boolean; message: string }> {
|
): Promise<{ success: boolean; message: string }> {
|
||||||
|
await invoke("plugin:lighty-launcher|launch", { versionId });
|
||||||
return await invoke("launch_game", { versionId });
|
return await invoke("launch_game", { versionId });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user