Working launch with auth and version
This commit is contained in:
@@ -1,23 +1,28 @@
|
||||
pub mod auth;
|
||||
pub mod downloader;
|
||||
pub mod install;
|
||||
pub mod auth;
|
||||
|
||||
use directories::ProjectDirs;
|
||||
use lyceris::minecraft::{
|
||||
config::ConfigBuilder,
|
||||
emitter::{Emitter, Event},
|
||||
launch::launch,
|
||||
loader::fabric::Fabric,
|
||||
use lyceris::{
|
||||
auth::microsoft::MinecraftAccount,
|
||||
minecraft::{
|
||||
config::ConfigBuilder,
|
||||
emitter::{Emitter, Event},
|
||||
launch::launch,
|
||||
loader::fabric::Fabric,
|
||||
},
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::GameVersion;
|
||||
|
||||
pub static LAUNCHER_DIR: Lazy<ProjectDirs> = Lazy::new(|| {
|
||||
ProjectDirs::from("org", "SaturnLauncher", "SaturnLauncher")
|
||||
.expect("Failed to create project directories")
|
||||
});
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn launch_game() -> Result<(), String> {
|
||||
pub async fn launch_game(version: GameVersion, account: MinecraftAccount) -> Result<(), String> {
|
||||
// Emitter uses `EventEmitter` inside of it
|
||||
// and it uses tokio::Mutex for locking.
|
||||
// That causes emitter methods to be async.
|
||||
@@ -58,14 +63,17 @@ pub async fn launch_game() -> Result<(), String> {
|
||||
let current_dir = LAUNCHER_DIR.data_dir();
|
||||
|
||||
let config = ConfigBuilder::new(
|
||||
current_dir.join("1.21.4"),
|
||||
"1.21.4".into(),
|
||||
lyceris::auth::AuthMethod::Offline {
|
||||
username: "Lyceris".into(),
|
||||
uuid: None,
|
||||
current_dir.join(&version.id),
|
||||
version.id.clone(),
|
||||
lyceris::auth::AuthMethod::Microsoft {
|
||||
username: account.username,
|
||||
xuid: account.xuid,
|
||||
uuid: account.uuid,
|
||||
access_token: account.access_token,
|
||||
refresh_token: account.refresh_token,
|
||||
},
|
||||
)
|
||||
.loader(Fabric("0.18.6".to_string()).into())
|
||||
.loader(Fabric(version.loader_version).into())
|
||||
.build();
|
||||
|
||||
println!("Starting installation");
|
||||
|
||||
+1
-23
@@ -21,8 +21,7 @@ pub struct Mod {
|
||||
pub struct GameVersion {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub release_date: String,
|
||||
pub r#type: String, // "release" | "snapshot"
|
||||
pub loader_version: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
@@ -33,7 +32,6 @@ pub struct LauncherSettings {
|
||||
|
||||
// --- App State ---
|
||||
pub struct AppState {
|
||||
pub versions: Vec<GameVersion>,
|
||||
pub mods: Vec<Mod>,
|
||||
pub settings: LauncherSettings,
|
||||
}
|
||||
@@ -41,26 +39,6 @@ pub struct AppState {
|
||||
impl Default for AppState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
versions: vec![
|
||||
GameVersion {
|
||||
id: "1.20.1".into(),
|
||||
name: "Fabric 1.20.1".into(),
|
||||
release_date: "2023-06-07".into(),
|
||||
r#type: "release".into(),
|
||||
},
|
||||
GameVersion {
|
||||
id: "1.20.4".into(),
|
||||
name: "Fabric 1.20.4".into(),
|
||||
release_date: "2023-12-07".into(),
|
||||
r#type: "release".into(),
|
||||
},
|
||||
GameVersion {
|
||||
id: "1.21".into(),
|
||||
name: "Fabric 1.21".into(),
|
||||
release_date: "2024-06-13".into(),
|
||||
r#type: "release".into(),
|
||||
},
|
||||
],
|
||||
mods: vec![
|
||||
Mod {
|
||||
id: "sodium".into(),
|
||||
|
||||
Reference in New Issue
Block a user