This commit is contained in:
Nikita Podvirnyi 2024-06-17 15:55:35 +02:00
commit 795ef8d62e
No known key found for this signature in database
GPG key ID: 859D416E5142AFF3
15 changed files with 556 additions and 359 deletions

8
.idea/.gitignore vendored
View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/the-honkers-railway-launcher.iml" filepath="$PROJECT_DIR$/.idea/the-honkers-railway-launcher.iml" />
</modules>
</component>
</project>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -9,6 +9,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### 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
## [1.5.5] - 08.05.2024
### Added
- Added Czech
## [1.5.4] - 27.03.2024
@ -27,6 +45,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
@ -271,7 +293,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<br>
[unreleased]: https://github.com/an-anime-team/the-honkers-railway-launcher/compare/1.5.4...next
[unreleased]: https://github.com/an-anime-team/the-honkers-railway-launcher/compare/1.5.5...next
[1.5.5]: https://github.com/an-anime-team/the-honkers-railway-launcher/compare/1.5.4...1.5.5
[1.5.4]: https://github.com/an-anime-team/the-honkers-railway-launcher/compare/1.5.3...1.5.4
[1.5.3]: https://github.com/an-anime-team/the-honkers-railway-launcher/compare/1.5.2...1.5.3
[1.5.2]: https://github.com/an-anime-team/the-honkers-railway-launcher/compare/1.5.1...1.5.2

720
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", "star-rail", "star-rail-patch"]
# 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://hk", "rpg-launcher-static.ho", "yov", "ers", "e.com/hk", "rpg_global/mdk/launcher/api/content?filter_adv=true&key=vplOVX8Vn7cwG8yb&launcher_id=35&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/honkers-railway-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/honkers-railway-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

@ -103,7 +103,23 @@ impl SimpleComponent for AboutDialog {
"<p>Added</p>",
"<ul>",
"<li>Added Czech</li>",
"<li>List missing dependencies on non-standard distros during initial setup</li>",
"<li>Added 2.1.0 voiceovers sizes</li>",
"</ul>",
"<p>Fixed</p>",
"<ul>",
"<li>Fixed Italian localization breaking the launcher</li>",
"</ul>",
"<p>Changed</p>",
"<ul>",
"<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

@ -68,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
}
},
@ -85,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
}
},
@ -102,7 +102,7 @@ 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
}
},
@ -125,6 +125,10 @@ impl SimpleAsyncComponent for DependenciesApp {
adw::ActionRow {
set_title: "p7zip"
},
adw::ActionRow {
set_title: "libwebp"
}
}
}
@ -191,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) {