Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

231 changes: 231 additions & 0 deletions docs/plans/string-overrides-implementation.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@tanstack/react-query": "^5.100.1",
"@tanstack/react-query-devtools": "^5.100.1",
"@tanstack/react-router": "^1.168.23",
"@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.13.24",
"@tauri-apps/api": "^2.11.0",
"@tauri-apps/plugin-deep-link": "^2.4.8",
Expand Down
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ tauri-plugin-single-instance = "2"
tauri-plugin-autostart = "2"
tauri-plugin-window-state = "2"

ltk_modpkg = { version = "0.5.0", features = ["project"] }
ltk_mod_project = { version = "0.4.1" }
ltk_modpkg = { version = "0.6.0", features = ["project"] }
ltk_mod_project = { version = "0.5.0" }
ltk_mod_core = { version = "0.1.0" }
ltk_fantome = { version = "0.5.1" }
ltk_overlay = { version = "0.3.1" }
ltk_fantome = { version = "0.6.0" }
ltk_overlay = { version = "0.4.0" }
ltk_rst = "0.2.0"
ltk_wad = "0.2.12"
ltk_file = { version = "0.2.8", features = ["serde"] }

camino = "1.2"
serde_yaml_ng = "0.10"
semver = "1.0"
toml = "0.8"
indexmap = { version = "2", features = ["serde"] }

tokio = { version = "1", features = ["full"] }
libloading = "0.9.0"
Expand All @@ -45,7 +48,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
regex = "1"

ts-rs = { version = "12", features = ["chrono-impl", "serde-json-impl"] }
ts-rs = { version = "12", features = ["chrono-impl", "serde-json-impl", "indexmap-impl"] }

thiserror = "2"
anyhow = "1"
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod profiles;
mod settings;
mod shell;
mod storage;
mod strings;
mod workshop;

pub use app::*;
Expand All @@ -44,4 +45,5 @@ pub use profiles::*;
pub use settings::*;
pub use shell::*;
pub use storage::*;
pub use strings::*;
pub use workshop::*;
37 changes: 37 additions & 0 deletions src-tauri/src/commands/strings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use crate::error::{AppError, AppResult, IpcResult, MutexResultExt};
use crate::state::SettingsState;
use crate::strings::{StringKeyIndexState, StringKeySearchResult};
use tauri::{AppHandle, State};

/// Search known stringtable field names for the workshop strings editor.
///
/// The first call builds the suggestion index (downloading the CommunityDragon
/// key list when missing and reading the game stringtable for value previews),
/// so it can take a few seconds; subsequent calls are instant.
#[tauri::command]
pub fn search_string_keys(
query: String,
limit: Option<u32>,
app_handle: AppHandle,
settings: State<SettingsState>,
index: State<StringKeyIndexState>,
) -> IpcResult<StringKeySearchResult> {
search_string_keys_inner(&query, limit, &app_handle, &settings, &index).into()
}

fn search_string_keys_inner(
query: &str,
limit: Option<u32>,
app_handle: &AppHandle,
settings: &SettingsState,
index: &StringKeyIndexState,
) -> AppResult<StringKeySearchResult> {
let settings = settings.0.lock().mutex_err()?.clone();
let cache_dir = crate::state::get_app_data_dir(app_handle)
.ok_or_else(|| AppError::Other("Could not determine app data directory".to_string()))?
.join("hashes");

let index = index.get_or_build(&cache_dir, &settings)?;
let limit = limit.unwrap_or(50).min(200) as usize;
Ok(index.search(query, limit))
}
3 changes: 2 additions & 1 deletion src-tauri/src/commands/workshop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::workshop::{
ImportGitRepoArgs, PackProjectArgs, PackResult, SaveProjectConfigArgs, ValidationResult,
WorkshopLayerInfo, WorkshopProject, WorkshopState,
};
use indexmap::IndexMap;
use std::collections::HashMap;
use tauri::State;

Expand Down Expand Up @@ -166,7 +167,7 @@ pub fn get_project_thumbnail(
pub fn save_layer_string_overrides(
project_path: String,
layer_name: String,
string_overrides: HashMap<String, HashMap<String, String>>,
string_overrides: IndexMap<String, IndexMap<String, String>>,
workshop: State<WorkshopState>,
) -> IpcResult<WorkshopProject> {
workshop
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod patcher;
mod setup;
mod state;
mod storage;
mod strings;
mod tray;
mod utils;
mod workshop;
Expand Down Expand Up @@ -140,6 +141,7 @@ fn main() {
commands::remove_project_thumbnail,
commands::get_project_thumbnail,
commands::save_layer_string_overrides,
commands::search_string_keys,
commands::get_layer_content_path,
commands::get_layer_info,
commands::create_project_layer,
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/src/overlay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,16 @@ impl ModLibrary {
let blocked_wads = resolve_blocked_wads(settings, &available_wads);
tracing::info!("Overlay: blocked_wads count={}", blocked_wads.len());

let string_override_mode = resolve_string_override_mode(settings, &game_dir);
tracing::info!("Overlay: string_override_mode={:?}", string_override_mode);

Self::clean_corrupt_overlay_state(&utf8_state_dir);

let app_handle_clone = self.app_handle().clone();
let mut builder =
ltk_overlay::OverlayBuilder::new(utf8_game_dir, utf8_overlay_root, utf8_state_dir)
.with_blocked_wads(blocked_wads)
.with_string_overrides(string_override_mode)
.with_progress(move |progress| {
let stage = match progress.stage {
ltk_overlay::OverlayStage::Indexing => OverlayStage::Indexing,
Expand Down Expand Up @@ -308,6 +312,27 @@ impl ModLibrary {
}
}

/// Resolve which locales mods' string overrides should be applied to.
///
/// With the "all locales" setting on, every installed locale is patched.
/// Otherwise only the locale the League client is configured to use — read
/// from `LeagueClientSettings.yaml`, falling back to the sole installed locale
/// and finally to `en_us` so string overrides still apply on unusual installs.
pub(crate) fn resolve_string_override_mode(
settings: &Settings,
game_dir: &Path,
) -> ltk_overlay::StringOverrideMode {
if settings.apply_string_overrides_to_all_locales {
return ltk_overlay::StringOverrideMode::AllInstalled;
}

let locale = crate::utils::locale::detect_league_locale(game_dir).unwrap_or_else(|| {
tracing::warn!("Falling back to 'en_us' for string overrides");
"en_us".to_string()
});
ltk_overlay::StringOverrideMode::Locales(vec![locale])
}

/// Resolve the user's blocklist settings into a concrete, deduped list of WAD
/// filenames to hand to `ltk_overlay::OverlayBuilder::with_blocked_wads`.
///
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub fn run(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
app.manage(settings_state);
app.manage(patcher_state);
app.manage(LinkedBinState::default());
app.manage(crate::strings::StringKeyIndexState::default());
app.manage(mod_library);
app.manage(workshop);
app.manage(hotkey_manager);
Expand Down
Loading
Loading