Skip to content

Commit b9562e4

Browse files
authored
Merge pull request #73 from LeagueToolkit/support-for-old-patcher
feat: introduce legacy patcher system and mod management API with frontend integration
2 parents 2970311 + 62364a9 commit b9562e4

File tree

28 files changed

+2299
-155
lines changed

28 files changed

+2299
-155
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ltk-manager/src-tauri/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ tauri-plugin-process = "2"
2020
ltk_modpkg = { path = "../../ltk_modpkg" }
2121
ltk_mod_project = { path = "../../ltk_mod_project" }
2222
ltk_mod_core = { path = "../../ltk_mod_core" }
23+
ltk_fantome = { path = "../../ltk_fantome" }
24+
ltk_wad = "0.2.6"
2325

2426
tokio = { version = "1", features = ["full"] }
2527
libloading = "0.9.0"
@@ -32,9 +34,13 @@ anyhow = "1"
3234

3335
uuid = { version = "1", features = ["v4"] }
3436
chrono = { version = "0.4", features = ["serde"] }
37+
byteorder = "1.5.0"
38+
xxhash-rust = { version = "0.8.15", features = ["xxh3", "xxh64"] }
39+
zstd = { version = "0.13", default-features = false }
3540

3641
tracing = "0.1"
3742
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
43+
tracing-appender = "0.2"
3844

3945
[features]
4046
default = ["custom-protocol"]
-1.31 MB
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
mod app;
2+
mod mods;
23
mod patcher;
34
mod settings;
45

56
pub use app::*;
7+
pub use mods::*;
68
pub use patcher::*;
79
pub use settings::*;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
use crate::error::{AppResult, IpcResult, MutexResultExt};
2+
use crate::mods::{
3+
inspect_modpkg_file, install_mod_from_package, toggle_mod_enabled, uninstall_mod_by_id,
4+
InstalledMod, ModpkgInfo,
5+
};
6+
use crate::state::SettingsState;
7+
use tauri::{AppHandle, State};
8+
9+
/// Get all installed mods from the mod library.
10+
#[tauri::command]
11+
pub fn get_installed_mods(
12+
app_handle: AppHandle,
13+
settings: State<SettingsState>,
14+
) -> IpcResult<Vec<InstalledMod>> {
15+
get_installed_mods_inner(&app_handle, &settings).into()
16+
}
17+
18+
fn get_installed_mods_inner(
19+
app_handle: &AppHandle,
20+
settings: &State<SettingsState>,
21+
) -> AppResult<Vec<InstalledMod>> {
22+
let settings = settings.0.lock().mutex_err()?.clone();
23+
24+
crate::mods::get_installed_mods(app_handle, &settings)
25+
}
26+
27+
/// Install a mod from a `.modpkg` or `.fantome` file into `modStoragePath`.
28+
#[tauri::command]
29+
pub fn install_mod(
30+
file_path: String,
31+
app_handle: AppHandle,
32+
settings: State<SettingsState>,
33+
) -> IpcResult<InstalledMod> {
34+
install_mod_inner(file_path, &app_handle, &settings).into()
35+
}
36+
37+
fn install_mod_inner(
38+
file_path: String,
39+
app_handle: &AppHandle,
40+
settings: &State<SettingsState>,
41+
) -> AppResult<InstalledMod> {
42+
let settings = settings.0.lock().mutex_err()?.clone();
43+
install_mod_from_package(app_handle, &settings, &file_path)
44+
}
45+
46+
/// Uninstall a mod by id.
47+
#[tauri::command]
48+
pub fn uninstall_mod(
49+
mod_id: String,
50+
app_handle: AppHandle,
51+
settings: State<SettingsState>,
52+
) -> IpcResult<()> {
53+
uninstall_mod_inner(mod_id, &app_handle, &settings).into()
54+
}
55+
56+
fn uninstall_mod_inner(
57+
mod_id: String,
58+
app_handle: &AppHandle,
59+
settings: &State<SettingsState>,
60+
) -> AppResult<()> {
61+
let settings = settings.0.lock().mutex_err()?.clone();
62+
uninstall_mod_by_id(app_handle, &settings, &mod_id)
63+
}
64+
65+
/// Toggle a mod's enabled state.
66+
#[tauri::command]
67+
pub fn toggle_mod(
68+
mod_id: String,
69+
enabled: bool,
70+
app_handle: AppHandle,
71+
settings: State<SettingsState>,
72+
) -> IpcResult<()> {
73+
toggle_mod_inner(mod_id, enabled, &app_handle, &settings).into()
74+
}
75+
76+
fn toggle_mod_inner(
77+
mod_id: String,
78+
enabled: bool,
79+
app_handle: &AppHandle,
80+
settings: &State<SettingsState>,
81+
) -> AppResult<()> {
82+
let settings = settings.0.lock().mutex_err()?.clone();
83+
toggle_mod_enabled(app_handle, &settings, &mod_id, enabled)
84+
}
85+
86+
/// Inspect a `.modpkg` file and return its metadata.
87+
#[tauri::command]
88+
pub fn inspect_modpkg(file_path: String) -> IpcResult<ModpkgInfo> {
89+
inspect_modpkg_file(&file_path).into()
90+
}

0 commit comments

Comments
 (0)