diff --git a/src-tauri/src/app/app_data.rs b/src-tauri/src/app/app_data.rs index 7929dc6..a20d8ea 100644 --- a/src-tauri/src/app/app_data.rs +++ b/src-tauri/src/app/app_data.rs @@ -48,12 +48,20 @@ pub(crate) struct LauncherOptions { pub preferred_build: Option, #[serde(rename = "currentAccount")] pub current_account: Option, - #[serde(rename = "modStates", default)] - pub mod_states: HashMap, + #[serde(rename = "branchOptions", default)] + pub branch_options: HashMap, #[serde(rename = "concurrentDownloads", default = "default_concurrent_downloads")] pub concurrent_downloads: i32 } +#[derive(Clone, Debug, Serialize, Deserialize)] +pub(crate) struct BranchOptions { + #[serde(rename = "modStates", default)] + pub mod_states: HashMap, + #[serde(rename = "customModStates", default)] + pub custom_mod_states: HashMap, +} + impl LauncherOptions { pub async fn load(app_data: &Path) -> Result { @@ -82,7 +90,7 @@ impl Default for LauncherOptions { preferred_branch: None, preferred_build: None, current_account: None, - mod_states: HashMap::new(), + branch_options: HashMap::new(), concurrent_downloads: 10 } } diff --git a/src/lib/main/MainScreen.svelte b/src/lib/main/MainScreen.svelte index b96182c..dce984d 100644 --- a/src/lib/main/MainScreen.svelte +++ b/src/lib/main/MainScreen.svelte @@ -137,18 +137,21 @@ }) .catch(e => console.error(e)); - requestMods(b.mcVersion, b.subsystem); + requestMods(b.branch, b.mcVersion, b.subsystem); } /// Request mods from API server - function requestMods(mcVersion, subsystem) { + function requestMods(branch, mcVersion, subsystem) { invoke("request_mods", { mcVersion, subsystem }) .then(result => { mods = result; - mods.forEach(mod => { - mod.enabled = options.modStates[mod.name] ?? mod.enabled; - }); + const branchOptions = options.branchOptions[branch]; + if (branchOptions) { + mods.forEach(mod => { + mod.enabled = branchOptions.modStates[mod.name] ?? mod.enabled; + }); + } }) .catch(e => console.error(e)); } @@ -206,12 +209,18 @@ }); function updateModStates() { - options.modStates = mods.reduce(function(map, mod) { + const branchOptions = options.branchOptions[options.preferredBranch] ?? { + modStates: {}, + customModStates: {} + }; + + branchOptions.modStates = mods.reduce(function(map, mod) { map[mod.name] = mod.enabled; return map; }, {}); - console.debug("Updated mod states", options.modStates); + console.debug("Updated mod states", branchOptions.modStates); + options.branchOptions[options.preferredBranch] = branchOptions; options.store(); }