mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-21 12:26:00 +03:00
feat: changed background images processing logic
This commit is contained in:
parent
39527c18d7
commit
b7ca18495e
2 changed files with 7 additions and 13 deletions
|
@ -73,12 +73,6 @@ pub fn download_background() -> anyhow::Result<()> {
|
|||
tracing::debug!("Background picture is already downloaded. Skipping");
|
||||
|
||||
download_image = false;
|
||||
|
||||
if crate::BACKGROUND_PRIMARY_FILE.exists() {
|
||||
tracing::debug!("Background picture is already patched. Skipping");
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,20 +91,20 @@ pub fn download_background() -> anyhow::Result<()> {
|
|||
Command::new("dwebp")
|
||||
.arg(crate::BACKGROUND_FILE.as_path())
|
||||
.arg("-o")
|
||||
.arg(crate::BACKGROUND_PRIMARY_FILE.as_path())
|
||||
.arg(crate::PROCESSED_BACKGROUND_FILE.as_path())
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
|
||||
// If it failed to re-code the file - just copy it
|
||||
// Will happen with HSR because devs apparently named
|
||||
// their background image ".webp" while it's JPEG
|
||||
if !crate::BACKGROUND_PRIMARY_FILE.exists() {
|
||||
std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::BACKGROUND_PRIMARY_FILE.as_path())?;
|
||||
if !crate::PROCESSED_BACKGROUND_FILE.exists() {
|
||||
std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::PROCESSED_BACKGROUND_FILE.as_path())?;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::BACKGROUND_PRIMARY_FILE.as_path())?;
|
||||
std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::PROCESSED_BACKGROUND_FILE.as_path())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -61,8 +61,8 @@ 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 the processed `background` file. Standard is `$HOME/.cache/anime-game-launcher/background`
|
||||
pub static ref PROCESSED_BACKGROUND_FILE: PathBuf = CACHE_FOLDER.join("background");
|
||||
|
||||
/// Path to `.keep-background` file. Used to mark launcher that it shouldn't update background picture
|
||||
///
|
||||
|
@ -102,7 +102,7 @@ lazy_static::lazy_static! {
|
|||
.round-bin {{
|
||||
border-radius: 24px;
|
||||
}}
|
||||
", BACKGROUND_PRIMARY_FILE.to_string_lossy());
|
||||
", PROCESSED_BACKGROUND_FILE.to_string_lossy());
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
|
|
Loading…
Reference in a new issue