feat: updated core library
Also started some work on adding local components downloading
This commit is contained in:
parent
6fa47d0338
commit
75444f0c58
8 changed files with 74 additions and 26 deletions
19
README.md
19
README.md
|
@ -1,20 +1,3 @@
|
||||||
# Anime Launcher SDK
|
# Anime Launcher SDK
|
||||||
|
|
||||||
## Project goals
|
SDK based on anime-game-core with some basic instruments like launcher state system and configuration file manager, written on Rust
|
||||||
|
|
||||||
* 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 |
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ef498b2e16f9b4cc4c1ee6357e73caf4fbc81dec
|
Subproject commit a90aae53797802b458670bd99428cd258ac1d902
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2833379379917992c96ee606a6f54074ca53a985
|
Subproject commit 50c93220b16ef7609f61fc0785a1e435683d4a0c
|
1
src/components/loader.rs
Normal file
1
src/components/loader.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
// TODO
|
|
@ -1,2 +1,3 @@
|
||||||
|
pub mod loader;
|
||||||
pub mod wine;
|
pub mod wine;
|
||||||
pub mod dxvk;
|
pub mod dxvk;
|
||||||
|
|
59
src/config/components.rs
Normal file
59
src/config/components.rs
Normal file
|
@ -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<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ use crate::consts::config_file;
|
||||||
|
|
||||||
pub mod launcher;
|
pub mod launcher;
|
||||||
pub mod game;
|
pub mod game;
|
||||||
|
pub mod components;
|
||||||
pub mod patch;
|
pub mod patch;
|
||||||
pub mod resolution;
|
pub mod resolution;
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ pub mod prelude {
|
||||||
pub use super::launcher::prelude::*;
|
pub use super::launcher::prelude::*;
|
||||||
pub use super::game::prelude::*;
|
pub use super::game::prelude::*;
|
||||||
|
|
||||||
|
pub use super::components::Components;
|
||||||
pub use super::patch::Patch;
|
pub use super::patch::Patch;
|
||||||
pub use super::resolution::Resolution;
|
pub use super::resolution::Resolution;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +158,7 @@ pub fn flush() -> anyhow::Result<()> {
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub launcher: Launcher,
|
pub launcher: Launcher,
|
||||||
pub game: Game,
|
pub game: Game,
|
||||||
|
pub components: Components,
|
||||||
pub patch: Patch
|
pub patch: Patch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +177,11 @@ impl From<&JsonValue> for Config {
|
||||||
None => default.game
|
None => default.game
|
||||||
},
|
},
|
||||||
|
|
||||||
|
components: match value.get("components") {
|
||||||
|
Some(value) => Components::from(value),
|
||||||
|
None => default.components
|
||||||
|
},
|
||||||
|
|
||||||
patch: match value.get("patch") {
|
patch: match value.get("patch") {
|
||||||
Some(value) => Patch::from(value),
|
Some(value) => Patch::from(value),
|
||||||
None => default.patch
|
None => default.patch
|
||||||
|
|
|
@ -52,13 +52,9 @@ impl FpsUnlocker {
|
||||||
}
|
}
|
||||||
|
|
||||||
match downloader.download_to(dir.join("unlocker.exe"), |_, _| {}) {
|
match downloader.download_to(dir.join("unlocker.exe"), |_, _| {}) {
|
||||||
Ok(_) => Ok(Self {
|
Ok(_) => Ok(Self { dir }),
|
||||||
dir
|
|
||||||
}),
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let err: std::io::Error = err.into();
|
tracing::error!("Downloading failed: {err}");
|
||||||
|
|
||||||
tracing::error!("Downloading failed: {}", err.to_string());
|
|
||||||
|
|
||||||
Err(err.into())
|
Err(err.into())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue