Working structure
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
use directories::ProjectDirs;
|
||||
use lighty_launcher::{
|
||||
auth::{Authenticator, OfflineAuth},
|
||||
java::JavaDistribution,
|
||||
launch::Launch,
|
||||
loaders::Loader,
|
||||
version::VersionBuilder,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
static LAUNCHER_DIR: Lazy<ProjectDirs> = Lazy::new(|| {
|
||||
ProjectDirs::from("org", "SaturnLauncher", "SaturnLauncher")
|
||||
.expect("Failed to create project directories")
|
||||
});
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn launch() -> Result<(), String> {
|
||||
println!("Launcher directory: {:?}", LAUNCHER_DIR);
|
||||
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
// Authenticate
|
||||
let mut auth = OfflineAuth::new("PlayerName");
|
||||
let profile = auth
|
||||
.authenticate()
|
||||
.await
|
||||
.map_err(|e| format!("Authentication failed: {}", e))?;
|
||||
|
||||
// Create version instance
|
||||
let mut version = VersionBuilder::new(
|
||||
"vanilla-1.21.1",
|
||||
Loader::Vanilla,
|
||||
"",
|
||||
"1.21.1",
|
||||
&LAUNCHER_DIR,
|
||||
);
|
||||
|
||||
// Launch the game
|
||||
version
|
||||
.launch(&profile, JavaDistribution::Temurin)
|
||||
.run()
|
||||
.await
|
||||
.map_err(|e| format!("Launch failed: {}", e))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod commands;
|
||||
pub mod launcher;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Mutex;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// 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;
|
||||
|
||||
@@ -9,14 +8,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_installed_mods,
|
||||
toggle_mod,
|
||||
install_mod,
|
||||
get_settings,
|
||||
update_settings
|
||||
update_settings,
|
||||
saturn_launcher_lib::launcher::launch
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
Reference in New Issue
Block a user