Merge pull request #385 from an-anime-team/next

Release 3.10.0
This commit is contained in:
Observer KRypt0n_ 2024-06-17 15:24:05 +02:00 committed by GitHub
commit 72a0345a73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 768 additions and 666 deletions

View file

@ -1,9 +0,0 @@
{
"recommendations": [
"vivaxy.vscode-conventional-commits",
"gruntfuggly.todo-tree",
"rust-lang.rust-analyzer",
"bungcip.better-toml",
"serayuzgur.crates"
]
}

26
.vscode/launch.json vendored
View file

@ -1,26 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"cargo": {
"args": [
"build",
"--bin=anime-game-launcher",
"--package=anime-game-launcher"
],
"filter": {
"name": "anime-game-launcher",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

10
.vscode/settings.json vendored
View file

@ -1,10 +0,0 @@
{
"conventionalCommits.scopes": [
"tracing",
"core",
"ui",
"i18n"
],
"editor.tabCompletion": "on",
"diffEditor.codeLens": true
}

View file

@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- List missing dependencies on non-standard distros during initial setup
- Added 4.7.0 voiceovers sizes
### Fixed
- Fixed Italian localization breaking the launcher
### Changed
- Support new game API
- Improved background pictures processing
- Updated desktop file entry to include "aagl" keyword
- Localized `force-grab-cursor` to Ukrainian
## [3.9.6] - 08.05.2024
### Added
@ -28,6 +44,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added Thai
- Added Ukrainian
### Fixed
- Fixed GtkSwitch UI state representation
### Changed
- Update wish url
@ -35,10 +55,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved app args parsing
- Updated locales
### Fixed
- Fixed GtkSwitch UI state representation
## [3.9.4] - 29.12.2023
### Changed

1195
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@ glib-build-tools = "0.19"
[dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "1.12.10"
tag = "1.14.0"
features = ["all", "genshin"]
# path = "../anime-launcher-sdk" # ! for dev purposes only

View file

@ -5,3 +5,4 @@ Exec=AppRun
Type=Application
Categories=Game
Terminal=false
Keywords=aagl

View file

@ -17,12 +17,12 @@ wish-url = Apri i desideri
about = Informazioni
close = { $commandType ->
close = { $form ->
[verb] Chiudersi
*[noun] Chiudi
}
hide = { $commandType ->
hide = { $form ->
[verb] Nascondersi
*[noun] Nascondi
}

View file

@ -12,5 +12,5 @@ other-settings = Інші налаштування
framerate-limit = Обмеження кількості кадрів
unfocused-framerate-limit = Обмеження кількості кадрів поза фокусом
force-grab-cursor = Force grab cursor
force-grab-cursor-description = Always use relative mouse mode instead of flipping dependent on cursor visibility. The mouse cursor will correctly be centered in the game
force-grab-cursor = Примусове захоплення курсору
force-grab-cursor-description = Завжди використовувати відносний режим миші замість гортання залежно від видимості курсору. Курсор миші буде коректно відцентровано у грі

View file

@ -1,8 +1,8 @@
let
nixpkgs = builtins.fetchGit {
name = "nixos-23.11";
name = "nixos-24.05";
url = "https://github.com/nixos/nixpkgs";
ref = "refs/heads/nixos-23.11";
ref = "refs/heads/nixos-24.05";
};
nixpkgs-unstable = builtins.fetchGit {
@ -23,6 +23,9 @@ in pkgs.mkShell {
gcc
cmake
pkg-config
xdelta
libwebp
];
buildInputs = with pkgs; [

View file

@ -1,3 +1,5 @@
use std::process::Command;
use anime_launcher_sdk::anime_game_core::installer::downloader::Downloader;
use anime_launcher_sdk::anime_game_core::minreq;
@ -10,30 +12,46 @@ pub struct Background {
}
pub fn get_uri() -> String {
let uri = concat!("https://sdk-os-static.", "ho", "yo", "verse", ".com/hk4e_global/mdk/launcher/api/content?filter_adv=true&key=gcStgarh&launcher_id=10&language=");
let lang = crate::i18n::get_lang();
uri.to_owned() + &crate::i18n::format_lang(&crate::i18n::get_lang())
if lang.language == unic_langid::langid!("zh-cn").language {
concat!("https://hyp-api.", "mi", "ho", "yo", ".com/hyp/hyp-connect/api/getAllGameBasicInfo?launcher_id=jGHBHlcOq1").to_owned()
}
else {
let uri = concat!("https://sg-hyp-api.", "ho", "yo", "verse", ".com/hyp/hyp-connect/api/getAllGameBasicInfo?launcher_id=VYTpXlbWo8&language=");
uri.to_owned() + &crate::i18n::format_lang(&lang)
}
}
#[cached::proc_macro::cached(result)]
pub fn get_background_info() -> anyhow::Result<Background> {
let json = serde_json::from_slice::<serde_json::Value>(minreq::get(get_uri()).send()?.as_bytes())?;
let uri = match json["data"]["adv"]["background"].as_str() {
Some(uri) => uri.to_owned(),
None => anyhow::bail!("Failed to get background picture uri")
};
let uri = json["data"]["game_info_list"].as_array()
.ok_or_else(|| anyhow::anyhow!("Failed to list games in the backgrounds API"))?
.iter()
.find(|game| {
match game["game"]["biz"].as_str() {
Some(biz) => biz.starts_with("hk4e_"),
_ => false
}
})
.ok_or_else(|| anyhow::anyhow!("Failed to find the game in the backgrounds API"))?["backgrounds"]
.as_array()
.and_then(|backgrounds| backgrounds.iter().next())
.and_then(|background| background["background"]["url"].as_str())
.ok_or_else(|| anyhow::anyhow!("Failed to get background picture url"))?
.to_string();
// This API field contains wrong md5 hash, but file's name
// from the uri above actually contains correct one, so
// I parse and use it few lines below
/*let hash = match json["data"]["adv"]["bg_checksum"].as_str() {
Some(uri) => uri.to_owned(),
None => anyhow::bail!("Failed to get background picture checksum")
};*/
let hash = uri.split('/').last().unwrap_or_default().split('_').next().unwrap_or_default().to_owned();
let hash = uri.split('/')
.last()
.unwrap_or_default()
.split('_')
.next()
.unwrap_or_default()
.to_owned();
Ok(Background {
uri,
@ -46,22 +64,46 @@ pub fn download_background() -> anyhow::Result<()> {
let info = get_background_info()?;
let mut download_image = true;
if crate::BACKGROUND_FILE.exists() {
let hash = Md5::digest(std::fs::read(crate::BACKGROUND_FILE.as_path())?);
if format!("{:x}", hash).to_lowercase() == info.hash {
tracing::debug!("Background picture is already downloaded. Skipping");
return Ok(());
download_image = false;
if crate::BACKGROUND_PRIMARY_FILE.exists() {
tracing::debug!("Background picture is already patched. Skipping");
return Ok(());
}
}
}
let mut downloader = Downloader::new(info.uri)?;
if download_image {
let mut downloader = Downloader::new(&info.uri)?;
downloader.continue_downloading = false;
downloader.continue_downloading = false;
if let Err(err) = downloader.download(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
anyhow::bail!(err);
if let Err(err) = downloader.download(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
anyhow::bail!(err);
}
}
// Workaround for GTK weakness
if info.uri.ends_with(".webp") {
Command::new("dwebp")
.arg(crate::BACKGROUND_FILE.as_path())
.arg("-o")
.arg(crate::BACKGROUND_PRIMARY_FILE.as_path())
.spawn()?
.wait_with_output()?;
}
else {
std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::BACKGROUND_PRIMARY_FILE.as_path())?;
}
Ok(())

View file

@ -61,6 +61,9 @@ lazy_static::lazy_static! {
/// Path to `background` file. Standard is `$HOME/.local/share/anime-game-launcher/background`
pub static ref BACKGROUND_FILE: PathBuf = LAUNCHER_FOLDER.join("background");
/// Path to `background-primary` file. Standard is `$HOME/.local/share/anime-game-launcher/background-primary`
pub static ref BACKGROUND_PRIMARY_FILE: PathBuf = LAUNCHER_FOLDER.join("background-primary");
/// Path to `.keep-background` file. Used to mark launcher that it shouldn't update background picture
///
/// Standard is `$HOME/.local/share/anime-game-launcher/.keep-background`
@ -99,7 +102,7 @@ lazy_static::lazy_static! {
.round-bin {{
border-radius: 24px;
}}
", BACKGROUND_FILE.to_string_lossy());
", BACKGROUND_PRIMARY_FILE.to_string_lossy());
}
fn main() -> anyhow::Result<()> {

View file

@ -98,15 +98,23 @@ impl SimpleComponent for AboutDialog {
"<p>Added</p>",
"<ul>",
"<li>Added 4.6.0 voiceovers sizes</li>",
"<li>Added Czech</li>",
"<li>List missing dependencies on non-standard distros during initial setup</li>",
"<li>Added 4.7.0 voiceovers sizes</li>",
"</ul>",
"<p>Fixed</p>",
"<ul>",
"<li>Fixed Italian localization breaking the launcher</li>",
"</ul>",
"<p>Changed</p>",
"<ul>",
"<li>Changed labels for the payment processing options</li>",
"<li>Changed one of translator's username</li>",
"<li>Support new game API</li>",
"<li>Improved background pictures processing</li>",
"<li>Updated desktop file entry to include aagl keyword</li>",
"<li>Localized force-grab-cursor to Ukrainian</li>",
"</ul>"
].join("\n"),

View file

@ -10,7 +10,8 @@ use super::main::FirstRunAppMsg;
pub struct DependenciesApp {
show_arch: bool,
show_debian: bool,
show_fedora: bool
show_fedora: bool,
show_list: bool
}
#[derive(Debug, Clone)]
@ -21,9 +22,9 @@ pub enum DependenciesAppMsg {
#[relm4::component(async, pub)]
impl SimpleAsyncComponent for DependenciesApp {
type Init = ();
type Input = DependenciesAppMsg;
type Output = FirstRunAppMsg;
type Init = ();
view! {
adw::PreferencesPage {
@ -67,7 +68,7 @@ impl SimpleAsyncComponent for DependenciesApp {
},
gtk::Entry {
set_text: "sudo pacman -Syu git xdelta3 p7zip",
set_text: "sudo pacman -Syu git xdelta3 p7zip libwebp",
set_editable: false
}
},
@ -84,7 +85,7 @@ impl SimpleAsyncComponent for DependenciesApp {
},
gtk::Entry {
set_text: "sudo apt install git xdelta3 p7zip-full",
set_text: "sudo apt install git xdelta3 p7zip-full webp",
set_editable: false
}
},
@ -101,9 +102,35 @@ impl SimpleAsyncComponent for DependenciesApp {
},
gtk::Entry {
set_text: "sudo dnf install git xdelta p7zip",
set_text: "sudo dnf install git xdelta p7zip libwebp",
set_editable: false
}
},
gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_spacing: 16,
#[watch]
set_visible: model.show_list,
adw::PreferencesGroup {
adw::ActionRow {
set_title: "git"
},
adw::ActionRow {
set_title: "xdelta3"
},
adw::ActionRow {
set_title: "p7zip"
},
adw::ActionRow {
set_title: "libwebp"
}
}
}
}
},
@ -138,7 +165,7 @@ impl SimpleAsyncComponent for DependenciesApp {
async fn init(_init: Self::Init, root: Self::Root, _sender: AsyncComponentSender<Self>) -> AsyncComponentParts<Self> {
let distro = whatadistro::identify();
let model = Self {
let mut model = Self {
show_arch: match &distro {
Some(distro) => distro.is_similar("arch"),
None => false
@ -152,9 +179,13 @@ impl SimpleAsyncComponent for DependenciesApp {
show_fedora: match &distro {
Some(distro) => distro.is_similar("fedora"),
None => false
}
},
show_list: false
};
model.show_list = !model.show_arch && !model.show_debian && !model.show_fedora;
let widgets = view_output!();
AsyncComponentParts { model, widgets }
@ -164,7 +195,7 @@ impl SimpleAsyncComponent for DependenciesApp {
match msg {
#[allow(unused_must_use)]
DependenciesAppMsg::Continue => {
let packages = ["git", "xdelta3"];
let packages = ["git", "xdelta3", "dwebp"];
for package in packages {
if !is_available(package) {