diff --git a/README.md b/README.md index 69be6a6..19b39e2 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,3 @@ # Anime Launcher SDK -## Project goals - -* Unify backends for [gtk](https://github.com/an-anime-team/an-anime-game-launcher-gtk) and [tauri](https://github.com/an-anime-team/an-anime-game-launcher-tauri) launchers so they will have same functionality; -* Remove excess code from gtk launcher and prepare it for relm4 rewrite; -* Prepare codebase for tauri rewrite; - -## Current progress (75%) - -| Status | Feature | Description | -| :-: | - | - | -| ✅ | states | Getting current launcher's state (update available, etc.) | -| ✅ | config | Work with config file | -| ✅ | components | Work with components needed to run the game | -| ✅ | | List Wine and DXVK versions | -| ❌ | | Download, delete and select wine | -| ❌ | | Download, delete, select and apply DXVK | -| ✅ | game | Run the game | -| ✅ | fps-unlocker | Support of FPS unlocker. Manage its config, download, use in game runner | +SDK based on anime-game-core with some basic instruments like launcher state system and configuration file manager, written on Rust diff --git a/anime-game-core b/anime-game-core index ef498b2..a90aae5 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit ef498b2e16f9b4cc4c1ee6357e73caf4fbc81dec +Subproject commit a90aae53797802b458670bd99428cd258ac1d902 diff --git a/components b/components index 2833379..50c9322 160000 --- a/components +++ b/components @@ -1 +1 @@ -Subproject commit 2833379379917992c96ee606a6f54074ca53a985 +Subproject commit 50c93220b16ef7609f61fc0785a1e435683d4a0c diff --git a/src/components/loader.rs b/src/components/loader.rs new file mode 100644 index 0000000..70b786d --- /dev/null +++ b/src/components/loader.rs @@ -0,0 +1 @@ +// TODO diff --git a/src/components/mod.rs b/src/components/mod.rs index 969952d..312593a 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,2 +1,3 @@ +pub mod loader; pub mod wine; pub mod dxvk; diff --git a/src/config/components.rs b/src/config/components.rs new file mode 100644 index 0000000..254da68 --- /dev/null +++ b/src/config/components.rs @@ -0,0 +1,59 @@ +use serde::{Serialize, Deserialize}; +use serde_json::Value as JsonValue; + +use std::path::PathBuf; + +use crate::consts::launcher_dir; + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Components { + pub path: PathBuf, + pub servers: Vec +} + +impl Default for Components { + fn default() -> Self { + let launcher_dir = launcher_dir().expect("Failed to get launcher dir"); + + Self { + path: launcher_dir.join("components"), + servers: vec![ + "https://github.com/an-anime-team/components".to_string() + ] + } + } +} + +impl From<&JsonValue> for Components { + fn from(value: &JsonValue) -> Self { + let default = Self::default(); + + Self { + path: match value.get("path") { + Some(value) => match value.as_str() { + Some(value) => PathBuf::from(value), + None => default.path + }, + None => default.path + }, + + servers: match value.get("servers") { + Some(value) => match value.as_array() { + Some(values) => { + let mut servers = Vec::new(); + + for value in values { + if let Some(server) = value.as_str() { + servers.push(server.to_string()); + } + } + + servers + }, + None => default.servers + }, + None => default.servers + } + } + } +} diff --git a/src/config/mod.rs b/src/config/mod.rs index 7de9456..f3d5358 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -10,6 +10,7 @@ use crate::consts::config_file; pub mod launcher; pub mod game; +pub mod components; pub mod patch; pub mod resolution; @@ -17,6 +18,7 @@ pub mod prelude { pub use super::launcher::prelude::*; pub use super::game::prelude::*; + pub use super::components::Components; pub use super::patch::Patch; pub use super::resolution::Resolution; } @@ -156,6 +158,7 @@ pub fn flush() -> anyhow::Result<()> { pub struct Config { pub launcher: Launcher, pub game: Game, + pub components: Components, pub patch: Patch } @@ -174,6 +177,11 @@ impl From<&JsonValue> for Config { None => default.game }, + components: match value.get("components") { + Some(value) => Components::from(value), + None => default.components + }, + patch: match value.get("patch") { Some(value) => Patch::from(value), None => default.patch diff --git a/src/fps_unlocker/mod.rs b/src/fps_unlocker/mod.rs index 8e038c2..6c6a6c3 100644 --- a/src/fps_unlocker/mod.rs +++ b/src/fps_unlocker/mod.rs @@ -52,13 +52,9 @@ impl FpsUnlocker { } match downloader.download_to(dir.join("unlocker.exe"), |_, _| {}) { - Ok(_) => Ok(Self { - dir - }), + Ok(_) => Ok(Self { dir }), Err(err) => { - let err: std::io::Error = err.into(); - - tracing::error!("Downloading failed: {}", err.to_string()); + tracing::error!("Downloading failed: {err}"); Err(err.into()) }