From 6025432a3ad061a96c24b1b503f1df6545329d0c Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 16 Apr 2023 18:18:57 +0200 Subject: [PATCH 01/10] 3.5.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c48bd0..5f7c0ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ dependencies = [ [[package]] name = "anime-game-launcher" -version = "3.4.1" +version = "3.5.0" dependencies = [ "anime-launcher-sdk", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 1b01968..16df4b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-game-launcher" -version = "3.4.1" +version = "3.5.0" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" From 5fed930c56a6e921bbf19e403d0d6a9a614bce3c Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 16 Apr 2023 18:32:34 +0200 Subject: [PATCH 02/10] docs: updated changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac97adc..54a366f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.5.0] ### Added @@ -185,7 +185,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-[unreleased]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.4.1...next +[unreleased]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.5.0...next +[3.5.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.4.1...3.5.0 [3.4.1]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.4.0...3.4.1 [3.4.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.3.0...3.4.0 [3.3.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.2.1...3.3.0 From edaecf9e932447d704cfd2b7ea2208556d4a6b25 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 16 Apr 2023 19:44:57 +0200 Subject: [PATCH 03/10] 3.5.1 --- CHANGELOG.md | 11 +++++++++-- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/ui/about.rs | 12 ++---------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a366f..2355f6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [3.5.0] +## [3.5.1] (hotfix) - 16.04.2023 + +### Fixed + +- Fixed telemetry checking + +## [3.5.0] - 16.04.2023 ### Added @@ -185,7 +191,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-[unreleased]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.5.0...next +[unreleased]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.5.1...next +[3.5.1]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.5.0...3.5.1 [3.5.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.4.1...3.5.0 [3.4.1]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.4.0...3.4.1 [3.4.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.3.0...3.4.0 diff --git a/Cargo.lock b/Cargo.lock index 5f7c0ad..1a2f67e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ dependencies = [ [[package]] name = "anime-game-launcher" -version = "3.5.0" +version = "3.5.1" dependencies = [ "anime-launcher-sdk", "anyhow", @@ -87,8 +87,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "1.0.1" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.1#1d56514b71da92b827ec4162975a12e4bf9b13fc" +version = "1.0.2" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.2#979ca46f5b4ba8961b0effa4e35ba8f8069c9607" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 16df4b4..2f008d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-game-launcher" -version = "3.5.0" +version = "3.5.1" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "1.0.1" +tag = "1.0.2" features = ["all", "genshin"] # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/about.rs b/src/ui/about.rs index 33bae89..37dcf42 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -82,18 +82,10 @@ impl SimpleComponent for AboutDialog { set_release_notes_version: &APP_VERSION, set_release_notes: &[ - "

Added

", + "

Fixed

", "
    ", - "
  • Added game sandboxing feature
  • ", - "
  • Added debugger to wine tools
  • ", - "
", - - "

Changed

", - - "
    ", - "
  • Removed fractions displaying in components downloading progress bar
  • ", - "
  • Moved to upgraded launcher SDK
  • ", + "
  • Fixed telemetry checking
  • ", "
", ].join("\n"), From dc8377c94de888eee47760ece781c04b8a9f2700 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 11:45:28 +0200 Subject: [PATCH 04/10] build: updated dependencies --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2f008d7..24a5c09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "1.0.2" +tag = "1.0.4" features = ["all", "genshin"] # path = "../anime-launcher-sdk" # ! for dev purposes only @@ -30,7 +30,7 @@ adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] } rfd = { version = "0.11", features = ["xdg-portal"], default-features = false } open = "4.0" -serde_json = "1" +serde_json = "1.0" anyhow = "1.0" lazy_static = "1.4.0" cached = { version = "0.43", features = ["proc_macro"] } From addb71305fb842b1dc4ed922db35d60c787b4ec6 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 11:49:32 +0200 Subject: [PATCH 05/10] feat: add inputs clearing in environment/sandbox settings closes #133 --- Cargo.lock | 8 ++++---- src/ui/preferences/environment.rs | 3 +++ src/ui/preferences/sandbox.rs | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a2f67e..55c3a18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.7.0" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.7.0#290cc5ff9399f68799e8e00fd3f78fa26d076296" +version = "1.7.1" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.7.1#8978728ce5d94aec5c6aecfe470e45fc43d5b522" dependencies = [ "anyhow", "bzip2", @@ -87,8 +87,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "1.0.2" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.2#979ca46f5b4ba8961b0effa4e35ba8f8069c9607" +version = "1.0.4" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.4#5d4e541db4b9e56cf128243a8b19f675adcbc26d" dependencies = [ "anime-game-core", "anyhow", diff --git a/src/ui/preferences/environment.rs b/src/ui/preferences/environment.rs index a41ecbd..6cdf707 100644 --- a/src/ui/preferences/environment.rs +++ b/src/ui/preferences/environment.rs @@ -172,6 +172,9 @@ impl SimpleAsyncComponent for EnvironmentApp { let value = self.value_entry.text().trim().to_string(); if !name.is_empty() && !value.is_empty() { + self.name_entry.set_text(""); + self.value_entry.set_text(""); + config.game.environment.insert(name.clone(), value.clone()); Config::update(config); diff --git a/src/ui/preferences/sandbox.rs b/src/ui/preferences/sandbox.rs index 439cc4a..9f88ae1 100644 --- a/src/ui/preferences/sandbox.rs +++ b/src/ui/preferences/sandbox.rs @@ -329,6 +329,8 @@ impl SimpleAsyncComponent for SandboxApp { let path = self.private_path_entry.text().trim().to_string(); if !path.is_empty() { + self.private_path_entry.set_text(""); + config.sandbox.private.push(path.clone()); Config::update(config); @@ -358,6 +360,9 @@ impl SimpleAsyncComponent for SandboxApp { let read_only = self.read_only_switch.state(); if !from.is_empty() && !to.is_empty() { + self.shared_path_from_entry.set_text(""); + self.shared_path_to_entry.set_text(""); + if read_only { config.sandbox.mounts.read_only.insert(from.clone(), to.clone()); } else { From db5a27dfd22d25093f1dd13f25ae0c7c72e5e507 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 13:07:54 +0200 Subject: [PATCH 06/10] feat(i18n): updated Spanish --- assets/locales/es/general.ftl | 2 +- assets/locales/es/sandbox.ftl | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/assets/locales/es/general.ftl b/assets/locales/es/general.ftl index 7379d51..bf14f22 100755 --- a/assets/locales/es/general.ftl +++ b/assets/locales/es/general.ftl @@ -69,7 +69,7 @@ registry-editor = Editor del Registro explorer = Explorador task-manager = Administrador de Tareas configuration = Configuración -debugger = Debugger +debugger = Depurador dxvk-version = Versión de DXVK dxvk-selection-disabled = La selección de DXVK está deshabilitada por las preferencias de su grupo de vinos diff --git a/assets/locales/es/sandbox.ftl b/assets/locales/es/sandbox.ftl index 4d09ae6..af5cb73 100644 --- a/assets/locales/es/sandbox.ftl +++ b/assets/locales/es/sandbox.ftl @@ -1,24 +1,24 @@ -sandbox = Sandbox -sandbox-description = Run the game in isolated environment, preventing it from accessing your personal data +sandbox = Aislamiento +sandbox-description = Ejecutar el juego en un entorno aislado, previniendo el acceso a datos personales -enable-sandboxing = Enable sandboxing -enable-sandboxing-description = Run the game in read-only copy of your root filesystem +enable-sandboxing = Activar aislamiento +enable-sandboxing-description = Ejecutar el juego en una copia de sólo lectura de tu sistema de archivos -hide-home-directory = Hide home directory -hide-home-directory-description = Isolate your /home, /var/home/$USER, and $HOME folders from the game +hide-home-directory = Esconder el directorio home +hide-home-directory-description = Aisla las carpetas /home, /var/home/$USER, y $HOME del juego -hostname = Hostname +hostname = Nombre del host -private-directories = Private directories -private-directories-description = These folders will be replaced by an empty virtual filesystem (tmpfs), and their original content will not be available to sandboxed game +private-directories = Directorios privados +private-directories-description = Estas carpetas serán reemplazadas por un sistema de archivos virtual (tmpfs) vacío, y su contenido real no será accesible al juego aislado -path = Path +path = Ruta -shared-directories = Shared directories -shared-directories-description = These directories will be symlinked to directories in your host system +shared-directories = Directorios compartidos +shared-directories-description = Estos directorios serán enlazados a directorios de tu sistema anfitrión -original-path = Original path -new-path = New path +original-path = Ruta original +new-path = Nueva ruta -read-only = Read-only -read-only-description = Forbid game to write any data to this directory +read-only = Sólo lectura +read-only-description = Le prohibe al juego escribir datos en este directorio From 3f197708edc9e22ba2137b6bedc09e8f382bb9ae Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 13:23:27 +0200 Subject: [PATCH 07/10] build(i18n): added fluent files scanning tool --- fluentscan.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 fluentscan.py diff --git a/fluentscan.py b/fluentscan.py new file mode 100644 index 0000000..cf05b5e --- /dev/null +++ b/fluentscan.py @@ -0,0 +1,74 @@ +#!/usr/bin/python + +# Author: @xstraok +# Modified by Observer KRypt0n_ + +import os +import sys + +path = "assets/locales/" + sys.argv[1] + "/" + +for filename in os.listdir("assets/locales/en"): + with open(os.path.join("assets/locales/en", filename), 'r') as locale_file: + created_locale = open(path + filename) + + def to_dict(text): + result={} + + for i in text: + if " = " in i: + try: + result[i.split()[0]] = ' '.join(i.split()[2:]) + + except: + pass + + elif i: + result[list(result.keys())[-1]] += i + + return result + + def dict_compare(d1, d2): + d1_keys = set(d1.keys()) + d2_keys = set(d2.keys()) + + shared_keys = d1_keys.intersection(d2_keys) + + added = d1_keys - d2_keys + removed = d2_keys - d1_keys + + modified = {o : (d1[o], d2[o]) for o in shared_keys if d1[o] != d2[o]} + + same = set(o for o in shared_keys if d1[o] == d2[o]) + + return added, removed, modified, same + + expected=to_dict(locale_file) + expected2=to_dict(created_locale) + + # TODO: why modified is not used? + added, removed, modified, same = dict_compare(expected, expected2) + + if added or removed or same: + print(f"[{created_locale.name[15:]}]") + + if added: + print(" [Added]") + + for i in added: + print(f" {i} = {expected[i]}") + + if removed: + print(" [Removed]") + + for i in removed: + print(f" {i} = {expected2[i]}") + + #workaround + if same and same != "set()": + print(" [Untranslated]") + + for i in same: + print(f" {i} = {expected[i]}") + + print("") From e5daf0cfea8ed98a7f4743c1eccf3aeb7215231f Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 15:29:11 +0200 Subject: [PATCH 08/10] feat(ui): added symlinks and args to sandbox settings --- Cargo.lock | 4 +- Cargo.toml | 2 +- src/ui/preferences/sandbox.rs | 267 +++++++++++++++++++++------------- 3 files changed, 167 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55c3a18..512b138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,8 +87,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "1.0.4" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.4#5d4e541db4b9e56cf128243a8b19f675adcbc26d" +version = "1.0.5" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.5#3505a2ef55fc89fb09d7a75849b6ce38c713973a" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 24a5c09..452d0e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "1.0.4" +tag = "1.0.5" features = ["all", "genshin"] # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/preferences/sandbox.rs b/src/ui/preferences/sandbox.rs index 9f88ae1..a223c59 100644 --- a/src/ui/preferences/sandbox.rs +++ b/src/ui/preferences/sandbox.rs @@ -9,116 +9,82 @@ use anime_launcher_sdk::is_available; use crate::i18n::tr; use crate::*; -#[derive(Debug)] -struct PrivateDirectory { - path: String -} +macro_rules! impl_directory { + ($name:ident, $msg:expr) => { + #[derive(Debug)] + struct $name { + from: String, + to: Option + } -#[relm4::factory(async)] -impl AsyncFactoryComponent for PrivateDirectory { - type Init = String; - type Input = SandboxAppMsg; - type Output = SandboxAppMsg; - type CommandOutput = (); - type ParentInput = SandboxAppMsg; - type ParentWidget = adw::PreferencesGroup; + #[relm4::factory(async)] + impl AsyncFactoryComponent for $name { + type Init = (String, Option); + type Input = SandboxAppMsg; + type Output = SandboxAppMsg; + type CommandOutput = (); + type ParentInput = SandboxAppMsg; + type ParentWidget = adw::PreferencesGroup; - view! { - root = adw::ActionRow { - set_title: &self.path, + view! { + root = adw::ActionRow { + set_title: &self.from, + set_subtitle: match self.to.as_ref() { + Some(to) => to, + None => "" + }, - add_suffix = >k::Button { - set_icon_name: "user-trash-symbolic", - add_css_class: "flat", - set_valign: gtk::Align::Center, + add_suffix = >k::Button { + set_icon_name: "user-trash-symbolic", + add_css_class: "flat", + set_valign: gtk::Align::Center, - connect_clicked[sender, index] => move |_| { - sender.input(SandboxAppMsg::RemovePrivate(index.clone())); + connect_clicked[sender, index] => move |_| { + sender.input($msg(index.clone())); + } + } } } + + fn output_to_parent_input(output: Self::Output) -> Option { + Some(output) + } + + async fn init_model( + init: Self::Init, + _index: &DynamicIndex, + _sender: AsyncFactorySender, + ) -> Self { + Self { + from: init.0, + to: init.1 + } + } + + async fn update(&mut self, msg: Self::Input, sender: AsyncFactorySender) { + sender.output(msg); + } } } - - fn output_to_parent_input(output: Self::Output) -> Option { - Some(output) - } - - async fn init_model( - init: Self::Init, - _index: &DynamicIndex, - _sender: AsyncFactorySender, - ) -> Self { - Self { - path: init - } - } - - async fn update(&mut self, msg: Self::Input, sender: AsyncFactorySender) { - sender.output(msg); - } } -#[derive(Debug)] -struct SharedDirectory { - mount_from: String, - mount_to: String -} - -#[relm4::factory(async)] -impl AsyncFactoryComponent for SharedDirectory { - type Init = (String, String); - type Input = SandboxAppMsg; - type Output = SandboxAppMsg; - type CommandOutput = (); - type ParentInput = SandboxAppMsg; - type ParentWidget = adw::PreferencesGroup; - - view! { - root = adw::ActionRow { - set_title: &self.mount_to, - set_subtitle: &self.mount_from, - - add_suffix = >k::Button { - set_icon_name: "user-trash-symbolic", - add_css_class: "flat", - set_valign: gtk::Align::Center, - - connect_clicked[sender, index] => move |_| { - sender.input(SandboxAppMsg::RemoveShared(index.clone())); - } - } - } - } - - fn output_to_parent_input(output: Self::Output) -> Option { - Some(output) - } - - async fn init_model( - init: Self::Init, - _index: &DynamicIndex, - _sender: AsyncFactorySender, - ) -> Self { - Self { - mount_from: init.0, - mount_to: init.1 - } - } - - async fn update(&mut self, msg: Self::Input, sender: AsyncFactorySender) { - sender.output(msg); - } -} +impl_directory!(PrivateDirectory, SandboxAppMsg::RemovePrivate); +impl_directory!(SharedDirectory, SandboxAppMsg::RemoveShared); +impl_directory!(SymlinkPath, SandboxAppMsg::RemoveSymlink); pub struct SandboxApp { private_paths: AsyncFactoryVecDeque, shared_paths: AsyncFactoryVecDeque, + symlink_paths: AsyncFactoryVecDeque, private_path_entry: adw::EntryRow, shared_path_from_entry: adw::EntryRow, shared_path_to_entry: adw::EntryRow, - read_only_switch: gtk::Switch + read_only_switch: gtk::Switch, + + symlink_path_from_entry: adw::EntryRow, + symlink_path_to_entry: adw::EntryRow } #[derive(Debug, Clone)] @@ -127,7 +93,10 @@ pub enum SandboxAppMsg { RemovePrivate(DynamicIndex), AddShared, - RemoveShared(DynamicIndex) + RemoveShared(DynamicIndex), + + AddSymlink, + RemoveSymlink(DynamicIndex) } #[relm4::component(async, pub)] @@ -203,6 +172,25 @@ impl SimpleAsyncComponent for SandboxApp { Some(command) }; + Config::update(config); + } + } + }, + + adw::EntryRow { + set_title: "Additional arguments", + set_text: CONFIG.sandbox.args.as_ref().unwrap_or(&String::new()).trim(), + + connect_changed => |entry| { + if let Ok(mut config) = Config::get() { + let command = entry.text().trim().to_string(); + + config.sandbox.args = if command.is_empty() { + None + } else { + Some(command) + }; + Config::update(config); } } @@ -268,7 +256,35 @@ impl SimpleAsyncComponent for SandboxApp { }, #[local_ref] - add = shared_paths -> adw::PreferencesGroup {} + add = shared_paths -> adw::PreferencesGroup {}, + + add = &adw::PreferencesGroup { + set_title: "Symlinks", + set_description: Some("Symlink original path inside of your sandbox"), + + #[local_ref] + symlink_path_from_entry -> adw::EntryRow { + set_title: &tr("original-path") + }, + + #[local_ref] + symlink_path_to_entry -> adw::EntryRow { + set_title: &tr("new-path") + }, + + gtk::Button { + set_label: &tr("add"), + add_css_class: "pill", + + set_margin_top: 8, + set_halign: gtk::Align::Start, + + connect_clicked => SandboxAppMsg::AddSymlink + } + }, + + #[local_ref] + add = symlink_paths -> adw::PreferencesGroup {} } } @@ -282,34 +298,46 @@ impl SimpleAsyncComponent for SandboxApp { let mut model = Self { private_paths: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()), shared_paths: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()), + symlink_paths: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()), private_path_entry: adw::EntryRow::new(), shared_path_from_entry: adw::EntryRow::new(), shared_path_to_entry: adw::EntryRow::new(), - read_only_switch: gtk::Switch::new() + read_only_switch: gtk::Switch::new(), + + symlink_path_from_entry: adw::EntryRow::new(), + symlink_path_to_entry: adw::EntryRow::new() }; for path in &CONFIG.sandbox.private { - model.private_paths.guard().push_back(path.trim().to_string()); + model.private_paths.guard().push_back((path.trim().to_string(), None)); } for (from, to) in &CONFIG.sandbox.mounts.read_only { model.shared_paths.guard().push_back(( from.trim().to_string(), - format!("[read-only] {}", to.trim()) + Some(format!("[read-only] {}", to.trim())) )); } for (from, to) in &CONFIG.sandbox.mounts.bind { model.shared_paths.guard().push_back(( from.trim().to_string(), - to.trim().to_string() + Some(to.trim().to_string()) + )); + } + + for (from, to) in &CONFIG.sandbox.mounts.symlinks { + model.symlink_paths.guard().push_back(( + from.trim().to_string(), + Some(to.trim().to_string()) )); } let private_paths = model.private_paths.widget(); let shared_paths = model.shared_paths.widget(); + let symlink_paths = model.symlink_paths.widget(); let private_path_entry = &model.private_path_entry; @@ -317,6 +345,9 @@ impl SimpleAsyncComponent for SandboxApp { let shared_path_to_entry = &model.shared_path_to_entry; let read_only_switch = &model.read_only_switch; + let symlink_path_from_entry = &model.symlink_path_from_entry; + let symlink_path_to_entry = &model.symlink_path_to_entry; + let widgets = view_output!(); AsyncComponentParts { model, widgets } @@ -335,7 +366,7 @@ impl SimpleAsyncComponent for SandboxApp { Config::update(config); - self.private_paths.guard().push_back(path); + self.private_paths.guard().push_back((path, None)); } } } @@ -343,7 +374,7 @@ impl SimpleAsyncComponent for SandboxApp { SandboxAppMsg::RemovePrivate(index) => { if let Ok(mut config) = Config::get() { if let Some(var) = self.private_paths.guard().get(index.current_index()) { - config.sandbox.private.retain(|item| item != &var.path); + config.sandbox.private.retain(|item| item != &var.from); Config::update(config); } @@ -373,11 +404,11 @@ impl SimpleAsyncComponent for SandboxApp { self.shared_paths.guard().push_back(( from, - if read_only { + Some(if read_only { format!("[read-only] {}", to) } else { to - } + }) )); } } @@ -386,14 +417,44 @@ impl SimpleAsyncComponent for SandboxApp { SandboxAppMsg::RemoveShared(index) => { if let Ok(mut config) = Config::get() { if let Some(var) = self.shared_paths.guard().get(index.current_index()) { - config.sandbox.mounts.read_only.remove(&var.mount_from); - config.sandbox.mounts.bind.remove(&var.mount_from); + config.sandbox.mounts.read_only.remove(&var.from); + config.sandbox.mounts.bind.remove(&var.from); Config::update(config); } self.shared_paths.guard().remove(index.current_index()); } + }, + + SandboxAppMsg::AddSymlink => { + if let Ok(mut config) = Config::get() { + let from = self.symlink_path_from_entry.text().trim().to_string(); + let to = self.symlink_path_to_entry.text().trim().to_string(); + + if !from.is_empty() && !to.is_empty() { + self.symlink_path_from_entry.set_text(""); + self.symlink_path_to_entry.set_text(""); + + config.sandbox.mounts.symlinks.insert(from.clone(), to.clone()); + + Config::update(config); + + self.symlink_paths.guard().push_back((from, Some(to))); + } + } + } + + SandboxAppMsg::RemoveSymlink(index) => { + if let Ok(mut config) = Config::get() { + if let Some(var) = self.symlink_paths.guard().get(index.current_index()) { + config.sandbox.mounts.symlinks.remove(&var.from); + + Config::update(config); + } + + self.symlink_paths.guard().remove(index.current_index()); + } } } } From 6281d1a49d031ce5d6a76e96a5bb8d7b4f489265 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 15:50:55 +0200 Subject: [PATCH 09/10] feat(i18n): updated base sandbox locales --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- assets/locales/de/errors.ftl | 5 +++++ assets/locales/de/sandbox.ftl | 4 ++++ assets/locales/en/errors.ftl | 4 ++++ assets/locales/en/sandbox.ftl | 4 ++++ assets/locales/es/errors.ftl | 4 ++++ assets/locales/es/sandbox.ftl | 4 ++++ assets/locales/fr/errors.ftl | 4 ++++ assets/locales/fr/sandbox.ftl | 4 ++++ assets/locales/ru/errors.ftl | 4 ++++ assets/locales/ru/sandbox.ftl | 4 ++++ assets/locales/tr/errors.ftl | 4 ++++ assets/locales/tr/sandbox.ftl | 4 ++++ assets/locales/zh-cn/errors.ftl | 4 ++++ assets/locales/zh-cn/sandbox.ftl | 4 ++++ src/ui/preferences/main.rs | 2 +- src/ui/preferences/sandbox.rs | 25 ++++++++++++++++++++----- 18 files changed, 81 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 512b138..92cb0dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,8 +87,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "1.0.5" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.5#3505a2ef55fc89fb09d7a75849b6ce38c713973a" +version = "1.0.6" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.6#2a8272c1afdd006925c150ac480a82be645f4b52" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 452d0e2..9247270 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "1.0.5" +tag = "1.0.6" features = ["all", "genshin"] # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/assets/locales/de/errors.ftl b/assets/locales/de/errors.ftl index 7644b57..89ae284 100644 --- a/assets/locales/de/errors.ftl +++ b/assets/locales/de/errors.ftl @@ -37,6 +37,11 @@ dxvk-unpack-error = Entpacken von DXVK fehlgeschlagen dxvk-apply-error = DXVK konnte nicht angewendet werden downloaded-wine-list-failed = Auflistung der heruntergeladenen Wine versionen fehlgeschlagen + patch-sync-failed = Synchronisierung des Patch-Ordners fehlgeschlagen patch-state-check-failed = Status des Patchordners konnte nicht überprüft werden game-patching-error = Spiel konnte nicht gepatcht werden + +# Sandbox + +documentation-url-open-failed = Failed to open documentation URL diff --git a/assets/locales/de/sandbox.ftl b/assets/locales/de/sandbox.ftl index 4d09ae6..de61f49 100644 --- a/assets/locales/de/sandbox.ftl +++ b/assets/locales/de/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = Hide home directory hide-home-directory-description = Isolate your /home, /var/home/$USER, and $HOME folders from the game hostname = Hostname +additional-arguments = Additional arguments private-directories = Private directories private-directories-description = These folders will be replaced by an empty virtual filesystem (tmpfs), and their original content will not be available to sandboxed game @@ -22,3 +23,6 @@ new-path = New path read-only = Read-only read-only-description = Forbid game to write any data to this directory + +symlinks = Symlinks +symlinks-description = Symlink original path to the new one inside of your sandbox diff --git a/assets/locales/en/errors.ftl b/assets/locales/en/errors.ftl index 8271f84..f790d04 100644 --- a/assets/locales/en/errors.ftl +++ b/assets/locales/en/errors.ftl @@ -41,3 +41,7 @@ downloaded-wine-list-failed = Failed to list downloaded wine versions patch-sync-failed = Failed to sync patch folder patch-state-check-failed = Failed to check patch folder state game-patching-error = Failed to patch game + +# Sandbox + +documentation-url-open-failed = Failed to open documentation URL diff --git a/assets/locales/en/sandbox.ftl b/assets/locales/en/sandbox.ftl index 4d09ae6..de61f49 100644 --- a/assets/locales/en/sandbox.ftl +++ b/assets/locales/en/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = Hide home directory hide-home-directory-description = Isolate your /home, /var/home/$USER, and $HOME folders from the game hostname = Hostname +additional-arguments = Additional arguments private-directories = Private directories private-directories-description = These folders will be replaced by an empty virtual filesystem (tmpfs), and their original content will not be available to sandboxed game @@ -22,3 +23,6 @@ new-path = New path read-only = Read-only read-only-description = Forbid game to write any data to this directory + +symlinks = Symlinks +symlinks-description = Symlink original path to the new one inside of your sandbox diff --git a/assets/locales/es/errors.ftl b/assets/locales/es/errors.ftl index 97a76a8..a8369ba 100755 --- a/assets/locales/es/errors.ftl +++ b/assets/locales/es/errors.ftl @@ -41,3 +41,7 @@ downloaded-wine-list-failed = Fallo al listar versiones descargadas de Wine patch-sync-failed = Fallo al sincronizar carpeta del parche patch-state-check-failed = Fallo al comprobar estado de carpeta del parche game-patching-error = Fallo al parchear el juego + +# Sandbox + +documentation-url-open-failed = Failed to open documentation URL diff --git a/assets/locales/es/sandbox.ftl b/assets/locales/es/sandbox.ftl index af5cb73..e6a241e 100644 --- a/assets/locales/es/sandbox.ftl +++ b/assets/locales/es/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = Esconder el directorio home hide-home-directory-description = Aisla las carpetas /home, /var/home/$USER, y $HOME del juego hostname = Nombre del host +additional-arguments = Additional arguments private-directories = Directorios privados private-directories-description = Estas carpetas serán reemplazadas por un sistema de archivos virtual (tmpfs) vacío, y su contenido real no será accesible al juego aislado @@ -22,3 +23,6 @@ new-path = Nueva ruta read-only = Sólo lectura read-only-description = Le prohibe al juego escribir datos en este directorio + +symlinks = Symlinks +symlinks-description = Symlink original path to the new one inside of your sandbox diff --git a/assets/locales/fr/errors.ftl b/assets/locales/fr/errors.ftl index a1fda2e..0e4ac5d 100644 --- a/assets/locales/fr/errors.ftl +++ b/assets/locales/fr/errors.ftl @@ -41,3 +41,7 @@ downloaded-wine-list-failed = Impossible de lister les versions de wine téléch patch-sync-failed = Impossible de synchroniser le patch patch-state-check-failed = Impossible de déterminer l'état du patch game-patching-error = Le patch du jeu a échoué + +# Sandbox + +documentation-url-open-failed = Failed to open documentation URL diff --git a/assets/locales/fr/sandbox.ftl b/assets/locales/fr/sandbox.ftl index 4d09ae6..de61f49 100644 --- a/assets/locales/fr/sandbox.ftl +++ b/assets/locales/fr/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = Hide home directory hide-home-directory-description = Isolate your /home, /var/home/$USER, and $HOME folders from the game hostname = Hostname +additional-arguments = Additional arguments private-directories = Private directories private-directories-description = These folders will be replaced by an empty virtual filesystem (tmpfs), and their original content will not be available to sandboxed game @@ -22,3 +23,6 @@ new-path = New path read-only = Read-only read-only-description = Forbid game to write any data to this directory + +symlinks = Symlinks +symlinks-description = Symlink original path to the new one inside of your sandbox diff --git a/assets/locales/ru/errors.ftl b/assets/locales/ru/errors.ftl index bc6731a..7f144ca 100644 --- a/assets/locales/ru/errors.ftl +++ b/assets/locales/ru/errors.ftl @@ -41,3 +41,7 @@ downloaded-wine-list-failed = Не удалось получить список patch-sync-failed = Ошибка синхронизации папки патча patch-state-check-failed = Ошибка проверки статуса папки патча game-patching-error = Не удалось установить патч игры + +# Sandbox + +documentation-url-open-failed = Не удалось открыть ссылку с документацией diff --git a/assets/locales/ru/sandbox.ftl b/assets/locales/ru/sandbox.ftl index a0ab2be..33151d3 100644 --- a/assets/locales/ru/sandbox.ftl +++ b/assets/locales/ru/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = Скрыть домашнюю директорию hide-home-directory-description = Изолировать ваши директории /home, /var/home/$USER, и $HOME от игры hostname = Имя хоста +additional-arguments = Дополнительные аргументы private-directories = Приватные директории private-directories-description = Эти папки будут заменены пустой виртуальной файловой системой (tmpfs) и их изначальное содержимое не будет доступно игре @@ -22,3 +23,6 @@ new-path = Путь в песочнице read-only = Только для чтения read-only-description = Запретить игре изменять содержимое этой директории + +symlinks = Ссылки +symlinks-description = Добавить ссылку на оригинальный файл или папку в вашу песочницу diff --git a/assets/locales/tr/errors.ftl b/assets/locales/tr/errors.ftl index de9bf31..6a66ead 100644 --- a/assets/locales/tr/errors.ftl +++ b/assets/locales/tr/errors.ftl @@ -41,3 +41,7 @@ downloaded-wine-list-failed = İndirilmiş Wine versiyonlarını listeleme başa patch-sync-failed = Yama dosyalarını senkronize etme başarısız oldu patch-state-check-failed = Yama dosyalarının durumunu kontrol etme başarısız oldu game-patching-error = Yamayı uygulamada sorun çıktı + +# Sandbox + +documentation-url-open-failed = Failed to open documentation URL diff --git a/assets/locales/tr/sandbox.ftl b/assets/locales/tr/sandbox.ftl index 4d09ae6..de61f49 100644 --- a/assets/locales/tr/sandbox.ftl +++ b/assets/locales/tr/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = Hide home directory hide-home-directory-description = Isolate your /home, /var/home/$USER, and $HOME folders from the game hostname = Hostname +additional-arguments = Additional arguments private-directories = Private directories private-directories-description = These folders will be replaced by an empty virtual filesystem (tmpfs), and their original content will not be available to sandboxed game @@ -22,3 +23,6 @@ new-path = New path read-only = Read-only read-only-description = Forbid game to write any data to this directory + +symlinks = Symlinks +symlinks-description = Symlink original path to the new one inside of your sandbox diff --git a/assets/locales/zh-cn/errors.ftl b/assets/locales/zh-cn/errors.ftl index 448f22b..4026f9b 100644 --- a/assets/locales/zh-cn/errors.ftl +++ b/assets/locales/zh-cn/errors.ftl @@ -41,3 +41,7 @@ downloaded-wine-list-failed = 列举 Wine 版本失败 patch-sync-failed = 同步补丁文件夹失败 patch-state-check-failed = 检查补丁文件夹失败 game-patching-error = 应用游戏补丁失败 + +# Sandbox + +documentation-url-open-failed = Failed to open documentation URL diff --git a/assets/locales/zh-cn/sandbox.ftl b/assets/locales/zh-cn/sandbox.ftl index 57f20e5..11a9617 100644 --- a/assets/locales/zh-cn/sandbox.ftl +++ b/assets/locales/zh-cn/sandbox.ftl @@ -8,6 +8,7 @@ hide-home-directory = 隐藏家目录 hide-home-directory-description = 将 /home、 /var/home/$USER 和 $HOME 目录与游戏隔离 hostname = 主机名 +additional-arguments = Additional arguments private-directories = 隐私目录 private-directories-description = 这些目录将会被空的虚拟文件系统(tmpfs)替代,其中的原始内容不可被沙盒中的游戏访问 @@ -22,3 +23,6 @@ new-path = 新路径 read-only = 只读 read-only-description = 禁止游戏向此目录写入任何数据 + +symlinks = Symlinks +symlinks-description = Symlink original path to the new one inside of your sandbox diff --git a/src/ui/preferences/main.rs b/src/ui/preferences/main.rs index 545ef80..7665219 100644 --- a/src/ui/preferences/main.rs +++ b/src/ui/preferences/main.rs @@ -103,7 +103,7 @@ impl SimpleAsyncComponent for PreferencesApp { sandbox: SandboxApp::builder() .launch(()) - .detach(), + .forward(sender.input_sender(), std::convert::identity), environment: EnvironmentApp::builder() .launch(()) diff --git a/src/ui/preferences/sandbox.rs b/src/ui/preferences/sandbox.rs index a223c59..8283b23 100644 --- a/src/ui/preferences/sandbox.rs +++ b/src/ui/preferences/sandbox.rs @@ -6,6 +6,7 @@ use adw::prelude::*; use anime_launcher_sdk::is_available; +use super::main::PreferencesAppMsg; use crate::i18n::tr; use crate::*; @@ -103,7 +104,7 @@ pub enum SandboxAppMsg { impl SimpleAsyncComponent for SandboxApp { type Init = (); type Input = SandboxAppMsg; - type Output = (); + type Output = PreferencesAppMsg; view! { adw::PreferencesPage { @@ -178,7 +179,7 @@ impl SimpleAsyncComponent for SandboxApp { }, adw::EntryRow { - set_title: "Additional arguments", + set_title: &tr("additional-arguments"), set_text: CONFIG.sandbox.args.as_ref().unwrap_or(&String::new()).trim(), connect_changed => |entry| { @@ -193,6 +194,20 @@ impl SimpleAsyncComponent for SandboxApp { Config::update(config); } + }, + + add_suffix = >k::Button { + set_valign: gtk::Align::Center, + set_icon_name: "dialog-information-symbolic", + + connect_clicked[sender] => move |_| { + if let Err(err) = open::that("https://man.archlinux.org/man/bwrap.1") { + sender.output(PreferencesAppMsg::Toast { + title: tr("documentation-url-open-failed"), + description: Some(err.to_string()) + }).unwrap(); + } + } } } }, @@ -259,8 +274,8 @@ impl SimpleAsyncComponent for SandboxApp { add = shared_paths -> adw::PreferencesGroup {}, add = &adw::PreferencesGroup { - set_title: "Symlinks", - set_description: Some("Symlink original path inside of your sandbox"), + set_title: &tr("symlinks"), + set_description: Some(&tr("symlinks-description")), #[local_ref] symlink_path_from_entry -> adw::EntryRow { @@ -293,7 +308,7 @@ impl SimpleAsyncComponent for SandboxApp { root: Self::Root, sender: AsyncComponentSender, ) -> AsyncComponentParts { - tracing::info!("Initializing environment settings"); + tracing::info!("Initializing sandbox settings"); let mut model = Self { private_paths: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()), From f9bf0accf844a048872068689748c36ad7d85969 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 17 Apr 2023 19:09:30 +0200 Subject: [PATCH 10/10] docs: updated changelog --- CHANGELOG.md | 10 ++++++++++ src/ui/about.rs | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2355f6f..c9307eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Added arguments and symlinks editor to sandbox settings + +### Fixed + +- Fixed game running issue if you have spaces in paths + ## [3.5.1] (hotfix) - 16.04.2023 ### Fixed diff --git a/src/ui/about.rs b/src/ui/about.rs index 37dcf42..9e0105e 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -82,10 +82,16 @@ impl SimpleComponent for AboutDialog { set_release_notes_version: &APP_VERSION, set_release_notes: &[ + "

Added

", + + "
    ", + "
  • Added arguments and symlinks editor to sandbox settings
  • ", + "
", + "

Fixed

", "
    ", - "
  • Fixed telemetry checking
  • ", + "
  • Fixed game running issue if you have spaces in paths
  • ", "
", ].join("\n"),