From 7ff3532a026b45f4947f6c8d5c7f17792bbd48a5 Mon Sep 17 00:00:00 2001 From: ninjadev64 <63245705+ninjadev64@users.noreply.github.com> Date: Sat, 17 Aug 2024 09:23:55 +0100 Subject: [PATCH] Bug fix for plugin localisation --- README.md | 25 +++++---- src-tauri/src/events/frontend/profiles.rs | 7 +-- src-tauri/src/plugins/info_param.rs | 2 +- src/components/ProfileSelector.svelte | 67 +---------------------- 4 files changed, 18 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 0ba8043..4c16bfb 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,6 @@ Special thanks go to the developers of [Tauri](https://github.com/tauri-apps/tau - Open the installed application. Note: if you receive a warning about OpenDeck being distributed by an unknown developer, *right-click the app in Finder and then click Open* to suppress the warning. - If you intend to use plugins that are only compiled for Windows, you will need to have [Wine](https://www.winehq.org/) installed on your system. -## Showcase - -![Main menu](.github/readme/mainmenu.png) -![Light mode](.github/readme/lightmode.png) -![Multi action](.github/readme/multiaction.png) -![Plugins](.github/readme/plugins.png) -![Profiles](.github/readme/profiles.png) - ## Support ### How do I...? @@ -50,7 +42,7 @@ To view or modify an action's settings, left-click on it to display its property To edit an action's appearance, right-click on it and select "Edit" in the context menu. You should then be able to customise the image and title of each of its states. To choose an image from your device: left-click on the image, to reset it to the plugin-provided default: right-click on the image, and to remove the image entirely: CTRL+right-click on the image. -To select another device, or to view, switch, modify, import or export profiles, use the dropdowns in the top right corner. You can organise profiles into group-like folders by prefixing the profile name with the folder name and a forward slash. +To select another device, or to view or switch profiles, use the dropdowns in the top right corner. You can organise profiles into group-like folders by prefixing the profile name with the folder name and a forward slash. To enable automatic launch on startup, the light theme, or to change the language plugins are localised in, open Settings. From here, you can also view information about your version of OpenDeck or open the configuration directory. To add or remove plugins, visit the Plugins tab. @@ -58,9 +50,10 @@ To enable automatic launch on startup, the light theme, or to change the languag - Check the OpenDeck log file for any important messages. This file should be included with any support request. - GNU+Linux: `~/config/com.amansprojects.opendeck/logs/` - - Windows: `%appdata%/com.amansprojects.opendeck/logs` - - macOS: `~/Library/Application Support/com.amansprojects.opendeck/logs` -- When trying to run Windows-only plugins (which are the majority of plugins) on GNU+Linux or macOS, please ensure you have the latest version of Wine installed on your system. + - Windows: `%appdata%\com.amansprojects.opendeck\logs\` + - macOS: `~/Library/Application Support/com.amansprojects.opendeck/logs/` +- For issues with plugins, you can also check the plugin's logs (in the same folder as above, sometimes as well as a file named `plugin.log` or similar in the plugin's own folder). +- When trying to run Windows-only plugins (which are the majority of plugins) on GNU+Linux or macOS, please ensure you have the latest version of Wine (and Wine Mono) installed on your system. - If your device isn't showing up, ensure you have the correct permissions to access it, and that you have restarted OpenDeck since connecting it. ### Support forums @@ -76,3 +69,11 @@ You'll need to ensure that all of the [prerequisites for building a Tauri applic When submitting a pull request, ensure that all of your Rust code has been formatted using `cargo fmt`, `cargo clippy` returns no violations, `deno task check` returns no violations, and modified Svelte code sticks to the existing style used as far as possible. Feel free to reach out on the support channels above for guidance when contributing! OpenDeck is licensed under the MIT license. + +## Showcase + +![Main menu](.github/readme/mainmenu.png) +![Light mode](.github/readme/lightmode.png) +![Multi action](.github/readme/multiaction.png) +![Plugins](.github/readme/plugins.png) +![Profiles](.github/readme/profiles.png) diff --git a/src-tauri/src/events/frontend/profiles.rs b/src-tauri/src/events/frontend/profiles.rs index 98193b1..113bce4 100644 --- a/src-tauri/src/events/frontend/profiles.rs +++ b/src-tauri/src/events/frontend/profiles.rs @@ -23,7 +23,7 @@ pub async fn get_selected_profile(device: String) -> Result) -> Result<(), Error> { +pub async fn set_selected_profile(app: AppHandle, device: String, id: String) -> Result<(), Error> { let mut device_stores = DEVICE_STORES.write().await; let devices = DEVICES.read().await; let mut profile_stores = PROFILE_STORES.write().await; @@ -44,10 +44,7 @@ pub async fn set_selected_profile(app: AppHandle, device: String, id: String, pr // We must use the mutable version of get_profile_store in order to create the store if it does not exist. let store = profile_stores.get_profile_store_mut(devices.get(&device).unwrap(), &id, &app).await?; - let new_profile = &mut store.value; - if let Some(profile) = profile { - *new_profile = profile; - } + let new_profile = &store.value; for instance in new_profile.keys.iter().flatten().chain(&mut new_profile.sliders.iter().flatten()) { if !matches!(instance.action.uuid.as_str(), "com.amansprojects.opendeck.multiaction" | "com.amansprojects.opendeck.toggleaction") { let _ = crate::events::outbound::will_appear::will_appear(instance, false).await; diff --git a/src-tauri/src/plugins/info_param.rs b/src-tauri/src/plugins/info_param.rs index 85b4e58..e5b2a0d 100644 --- a/src-tauri/src/plugins/info_param.rs +++ b/src-tauri/src/plugins/info_param.rs @@ -84,7 +84,7 @@ pub async fn make_info(uuid: String, version: String, wine: bool) -> Info { Info { application: ApplicationInfo { font: "ui-sans-serif".to_owned(), - language: "en".to_owned(), + language: crate::store::get_settings(crate::APP_HANDLE.get().unwrap()).unwrap().value.language, platform: if !wine { platform.to_owned() } else { "windows".to_owned() }, platformVersion: if !wine { os_info::get().version().to_string() } else { "10.0.19045.4474".to_owned() }, version: env!("CARGO_PKG_VERSION").to_owned(), diff --git a/src/components/ProfileSelector.svelte b/src/components/ProfileSelector.svelte index ac96326..d8ed41b 100644 --- a/src/components/ProfileSelector.svelte +++ b/src/components/ProfileSelector.svelte @@ -28,13 +28,13 @@ getProfiles(device); export let profile: Profile; - export async function setProfile(id: string, toSet: Profile | undefined = undefined) { + export async function setProfile(id: string) { if (!device || !id) return; if (value != id) { value = id; return; } - await invoke("set_selected_profile", { device: device.id, id, profile: toSet }); + await invoke("set_selected_profile", { device: device.id, id }); profile = await invoke("get_selected_profile", { device: device.id }); let folder = id.includes("/") ? id.split("/")[0] : ""; @@ -52,43 +52,6 @@ folders = folders; } - function exportProfile() { - navigator.clipboard.writeText(JSON.stringify( - profile, - (k: string, v: string) => { - if (k == "context") return v.replace(device.id, "no-device"); - return v; - }, - 2 - )); - alert(`Copied profile ${value} to clipboard.`); - } - - let fileInput: HTMLInputElement; - function importProfile() { - if (!fileInput.files || fileInput.files.length == 0) return; - const reader = new FileReader(); - reader.onload = async () => { - let p: Profile = JSON.parse( - reader.result! as string, - (k: string, v: string) => { - if (k == "context") return v.replace("no-device", device.id); - return v; - } - ); - if (p.keys.length != device.rows * device.columns || p.sliders.length != device.sliders) { - alert("The imported profile is incompatible with the selected device."); - return; - } - if ((p.id.includes("/") ? folders[p.id.split("/")[0]] : folders[""]).includes(p.id)) { - if (!await confirm(`Are you sure you want to overwrite profile ${p.id}?`)) return; - } - setProfile(p.id, p); - value = p.id; - }; - reader.readAsText(fileInput.files[0]); - } - let oldValue: string; $: { if (value == "opendeck_edit_profiles") { @@ -135,22 +98,6 @@ placeholder='Profile ID (e.g. "folder/profile")' /> - - - - {:else} - {/if} {/each}