diff --git a/Cargo.lock b/Cargo.lock index 4527d6b..db62b10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.7.1" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.7.1#8978728ce5d94aec5c6aecfe470e45fc43d5b522" +version = "1.7.2" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.7.2#b367ea1303c9687217024902e37dbb4e24b05f37" dependencies = [ "anyhow", "bzip2", @@ -65,8 +65,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "1.0.6" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.6#2a8272c1afdd006925c150ac480a82be645f4b52" +version = "1.0.10" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.0.10#204369158e57056dfc64fbff62fbe6a571034913" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 5683df6..91ef4f8 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.6" +tag = "1.0.10" features = ["all", "genshin"] # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/README.md b/README.md index d76a346..d39f90e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@
-# Please don't link to this repository +# ⚠️ Please don't link to this repository We understand you want to help people run An Anime Game on Linux. The issue is, the more people know of the tools involved in it, the higher the chances The Anime Game Company will notice them, and then @@ -32,26 +32,38 @@ Or share them and ruin it for the dozens of Linux players. It's up to you. Do what you must, but we would respectfully request that you try to label the game as "An Anime Game" instead of the actual name of the game, to avoid search engine parsing. -# Documentation +
-Documentation for the launcher can be found in the [repository wiki](https://github.com/an-anime-team/the-honkers-railway-launcher/wiki). +# ♥️ Useful links and thanks -# Download +* Original patch project without which this project wouldn't be possible. Link is omitted for "privacy" purposes +* [macOS launcher](https://github.com/3Shain/yet-another-anime-game-launcher) which contains some additional compatibility components +* [Wiki](https://github.com/an-anime-team/an-anime-game-launcher/wiki) contains some basic FAQ, installation instructions and more +* [Releases page](https://github.com/an-anime-team/an-anime-game-launcher/releases) where you can find latest available version +* [Changelog](CHANGELOG.md) with chronology of the project -Currently there are 5 options available: -1. Flatpak -2. AUR -3. RPM -4. Gentoo/ebuild -5. NixOS +
-To see the installation guides, [Please visit the wiki page here](https://github.com/an-anime-team/the-honkers-railway-launcher/wiki/Installation) +# ⬇️ Download + +| Distribution | Format | Wiki | Source | +| - | - | - | - | +| Fedora | Flatpak | [link](https://github.com/an-anime-team/an-anime-game-launcher/wiki/Installation#-any-distribution-flatpak) | - | +| Arch Linux, Manjaro | AUR | [link](https://github.com/an-anime-team/an-anime-game-launcher/wiki/Installation#-arch-linux-aur) | [an-anime-game-launcher-bin](https://aur.archlinux.org/packages/an-anime-game-launcher-bin) | +| Fedora, OpenSUSE | RPM | [link](https://github.com/an-anime-team/an-anime-game-launcher/wiki/Installation#-fedora-rpm) | [AAGL](https://build.opensuse.org/repositories/home:Maroxy:AAT-Apps/AAGL) | +| Ubuntu | pacstall | - | [an-anime-game-launcher-bin](https://pacstall.dev/packages/an-anime-game-launcher-bin) | +| Gentoo | ebuild | [link](https://github.com/an-anime-team/an-anime-game-launcher/wiki/Installation#-gentoo-linux-ebuild) | [aagl-ebuilds](https://github.com/an-anime-team/aagl-ebuilds) | +| NixOS | nixpkg | [link](https://github.com/an-anime-team/an-anime-game-launcher/wiki/Installation#-nixos-nixpkg) | [aagl-gtk-on-nix](https://github.com/ezKEa/aagl-gtk-on-nix) | + +To see the installation guides, please visit the wiki page [here](https://github.com/an-anime-team/an-anime-game-launcher/wiki/Installation) ## Chinese version support -This should be automatically enabled if you're using zh_cn (Chinese) as your system language. If you're not using it - you'll need to set `China` as your `launcher.edition` in the `config.json` file +This should be automatically enabled if you're using zh_cn (Chinese) as your system language. If you're not using it - you can change the game edition in the launcher settings -# Development +
+ +# 💻 Development | Folder | Description | | - | - | diff --git a/assets/locales/en/first_run.ftl b/assets/locales/en/first_run.ftl index 7d4ba1e..28001db 100644 --- a/assets/locales/en/first_run.ftl +++ b/assets/locales/en/first_run.ftl @@ -23,6 +23,12 @@ tos-violation-warning-message = If you understand the risk of trying to play the game in an unofficial capacity, press OK and let's go researching the world of Teyvat! +tos-dialog-title = Are you sure you understand what we want to say? +tos-dialog-message = + 1. Don't publish any information about this project + 2. Don't abuse it by using some modded clients and so + 3. Ask questions exceptionally in our discord or matrix server + dependencies = Dependencies missing-dependencies-title = You're missing some dependencies! diff --git a/assets/locales/en/main.ftl b/assets/locales/en/main.ftl index f36da46..f448ac1 100644 --- a/assets/locales/en/main.ftl +++ b/assets/locales/en/main.ftl @@ -22,6 +22,7 @@ continue = Continue exit = Exit check = Check restart = Restart +agree = Agree loading-data = Loading data diff --git a/assets/locales/es/sandbox.ftl b/assets/locales/es/sandbox.ftl index e6a241e..530e1fe 100644 --- a/assets/locales/es/sandbox.ftl +++ b/assets/locales/es/sandbox.ftl @@ -8,7 +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 +additional-arguments = Argumentos adicionales 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 @@ -24,5 +24,5 @@ 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 +symlinks = Enlaces simbólicos +symlinks-description = Enlaza la ruta original a la nueva dentro de tu entorno aislado diff --git a/assets/locales/zh-cn/sandbox.ftl b/assets/locales/zh-cn/sandbox.ftl index 11a9617..9714308 100644 --- a/assets/locales/zh-cn/sandbox.ftl +++ b/assets/locales/zh-cn/sandbox.ftl @@ -8,7 +8,7 @@ hide-home-directory = 隐藏家目录 hide-home-directory-description = 将 /home、 /var/home/$USER 和 $HOME 目录与游戏隔离 hostname = 主机名 -additional-arguments = Additional arguments +additional-arguments = 额外参数 private-directories = 隐私目录 private-directories-description = 这些目录将会被空的虚拟文件系统(tmpfs)替代,其中的原始内容不可被沙盒中的游戏访问 @@ -24,5 +24,5 @@ new-path = 新路径 read-only = 只读 read-only-description = 禁止游戏向此目录写入任何数据 -symlinks = Symlinks -symlinks-description = Symlink original path to the new one inside of your sandbox +symlinks = 软链接 +symlinks-description = 软链接原始路径到沙盒里的新路径 diff --git a/fluentscan.py b/fluentscan.py old mode 100644 new mode 100755 index cf05b5e..1f3e632 --- a/fluentscan.py +++ b/fluentscan.py @@ -5,51 +5,118 @@ import os import sys +import glob +import re -path = "assets/locales/" + sys.argv[1] + "/" +valid_commands = ["diff", "unused", "missing"] + +if len(sys.argv) < 3: + print(f"Command format: ./fluentscan.py [command] [locale]\nAvailable commands: {valid_commands}") + + sys.exit() + +if sys.argv[1] not in valid_commands: + print(f"Invalid command \"{sys.argv[1]}\". Available commands: {valid_commands}") + + sys.exit() + +path = "assets/locales/" + sys.argv[2] + "/" + +try: + open(path + "/main.ftl", "r").close() + +except: + print(f"{path} does not exist") + + sys.exit() + +all_entries = {} + +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 + + same = set(o for o in shared_keys if d1[o] == d2[o]) + + return added, removed, same + +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 get_line_num(text,pattern): + line = 1 + + for i in text.split("\n"): + if pattern in i: + return line + + line += 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={} + expected = to_dict(locale_file) + expected2 = to_dict(created_locale) - for i in text: - if " = " in i: - try: - result[i.split()[0]] = ' '.join(i.split()[2:]) + all_entries.update(expected) - except: - pass + added, removed, same = dict_compare(expected, expected2) - elif i: - result[list(result.keys())[-1]] += i + if sys.argv[1] == "unused" or sys.argv[1] == "missing": + files = glob.glob("src/**/*.rs", recursive=True) - return result + used = [] + vars = {} - def dict_compare(d1, d2): - d1_keys = set(d1.keys()) - d2_keys = set(d2.keys()) + for i in files: + with open(i, "r") as script: + text = script.read() - shared_keys = d1_keys.intersection(d2_keys) + if sys.argv[1] == "unused": + for j in expected: + if f"\"{j}\"" in text: + used.append(j) - added = d1_keys - d2_keys - removed = d2_keys - d1_keys + elif sys.argv[1] == "missing": + for j in text.split(): + # TODO: ignore comments + if 'tr("' in j: + index = j.find('tr("') - modified = {o : (d1[o], d2[o]) for o in shared_keys if d1[o] != d2[o]} + var_name = re.sub('[^\\w-]+', '', j[index:].replace('tr("', '').replace("Some", "")) - same = set(o for o in shared_keys if d1[o] == d2[o]) + # TODO: index multiple matches + vars[var_name] = [script.name, get_line_num(text,var_name)] - return added, removed, modified, same + if sys.argv[1] == "unused": + for i in expected: + if i not in used: + print(f"[{locale_file.name}]\n" + " [Unused]\n" + f" {i}") - expected=to_dict(locale_file) - expected2=to_dict(created_locale) + continue - # TODO: why modified is not used? - added, removed, modified, same = dict_compare(expected, expected2) - - if added or removed or same: + if (added or removed or same) and sys.argv[1] == "diff": print(f"[{created_locale.name[15:]}]") if added: @@ -72,3 +139,14 @@ for filename in os.listdir("assets/locales/en"): print(f" {i} = {expected[i]}") print("") + +if sys.argv[1] == "missing": + added, removed, same = dict_compare(vars, all_entries) + + if not added: + print("Nothing is missing") + + for i in added: + print(f"[{vars[i][0]}, line {vars[i][1]}]\n" + " [Missing]\n" + f" {i}") diff --git a/src/ui/first_run/tos_warning.rs b/src/ui/first_run/tos_warning.rs index 08ae5b1..364632b 100644 --- a/src/ui/first_run/tos_warning.rs +++ b/src/ui/first_run/tos_warning.rs @@ -8,6 +8,8 @@ use anime_launcher_sdk::is_available; use crate::i18n::*; use super::main::FirstRunAppMsg; +use super::main::MAIN_WINDOW; + pub struct TosWarningApp; #[derive(Debug, Clone)] @@ -86,11 +88,34 @@ impl SimpleAsyncComponent for TosWarningApp { match msg { #[allow(unused_must_use)] TosWarningAppMsg::Continue => { - if is_available("git") && is_available("xdelta3") { - sender.output(Self::Output::ScrollToDefaultPaths); - } else { - sender.output(Self::Output::ScrollToDependencies); - } + let dialog = adw::MessageDialog::new( + unsafe { MAIN_WINDOW.as_ref() }, + Some(&tr("tos-dialog-title")), + Some(&tr("tos-dialog-message")) + ); + + dialog.add_responses(&[ + ("exit", &tr("exit")), + ("continue", &tr("agree")) + ]); + + dialog.connect_response(None, move |_, response| { + match response { + "exit" => relm4::main_application().quit(), + + "continue" => { + if is_available("git") && is_available("xdelta3") { + sender.output(Self::Output::ScrollToDefaultPaths); + } else { + sender.output(Self::Output::ScrollToDependencies); + } + } + + _ => unreachable!() + } + }); + + dialog.show(); } TosWarningAppMsg::Exit => relm4::main_application().quit() diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 9376a68..6c09ff2 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -1035,7 +1035,8 @@ impl SimpleAsyncComponent for GeneralApp { let config = Config::get().unwrap_or_else(|_| CONFIG.clone()); if let Ok(Some(wine)) = config.get_selected_wine() { - let result = wine.to_wine(config.components.path, Some(config.game.wine.builds.join(&wine.name))) + let result = wine + .to_wine(config.components.path, Some(config.game.wine.builds.join(&wine.name))) .with_prefix(config.game.wine.prefix) .with_loader(WineLoader::Current) .with_arch(WineArch::Win64)