feat(ui): made "update background" switcher
Now this switch will create `.keep-background` file in the launcher folder if launcher is supposed to keep current `background` file
This commit is contained in:
parent
6340ccbd6e
commit
fcb24f803b
3 changed files with 20 additions and 4 deletions
|
@ -42,6 +42,11 @@ lazy_static::lazy_static! {
|
||||||
|
|
||||||
/// Path to `background` file. Standard is `$HOME/.local/share/anime-game-launcher/background`
|
/// Path to `background` file. Standard is `$HOME/.local/share/anime-game-launcher/background`
|
||||||
pub static ref BACKGROUND_FILE: PathBuf = anime_launcher_sdk::consts::launcher_dir().unwrap_or_default().join("background");
|
pub static ref BACKGROUND_FILE: PathBuf = anime_launcher_sdk::consts::launcher_dir().unwrap_or_default().join("background");
|
||||||
|
|
||||||
|
/// 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`
|
||||||
|
pub static ref KEEP_BACKGROUND_FILE: PathBuf = anime_launcher_sdk::consts::launcher_dir().unwrap_or_default().join(".keep-background");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -401,7 +401,7 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
tracing::info!("Main window initialized");
|
tracing::info!("Main window initialized");
|
||||||
|
|
||||||
let download_picture = model.style == LauncherStyle::Classic;
|
let download_picture = model.style == LauncherStyle::Classic && !KEEP_BACKGROUND_FILE.exists();
|
||||||
|
|
||||||
// Initialize some heavy tasks
|
// Initialize some heavy tasks
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
|
|
|
@ -48,6 +48,7 @@ pub enum GeneralAppMsg {
|
||||||
title: String,
|
title: String,
|
||||||
description: Option<String>
|
description: Option<String>
|
||||||
},
|
},
|
||||||
|
|
||||||
UpdateLauncherStyle(LauncherStyle),
|
UpdateLauncherStyle(LauncherStyle),
|
||||||
WineRecommendedOnly(bool),
|
WineRecommendedOnly(bool),
|
||||||
DxvkRecommendedOnly(bool),
|
DxvkRecommendedOnly(bool),
|
||||||
|
@ -142,7 +143,17 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
set_subtitle: &tr("update-background-description"),
|
set_subtitle: &tr("update-background-description"),
|
||||||
|
|
||||||
add_suffix = >k::Switch {
|
add_suffix = >k::Switch {
|
||||||
set_valign: gtk::Align::Center
|
set_valign: gtk::Align::Center,
|
||||||
|
set_active: !KEEP_BACKGROUND_FILE.exists(),
|
||||||
|
|
||||||
|
connect_state_notify => |switch| {
|
||||||
|
#[allow(unused_must_use)]
|
||||||
|
if switch.state() {
|
||||||
|
std::fs::remove_file(KEEP_BACKGROUND_FILE.as_path());
|
||||||
|
} else {
|
||||||
|
std::fs::write(KEEP_BACKGROUND_FILE.as_path(), "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -513,11 +524,11 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
match msg {
|
match msg {
|
||||||
GeneralAppMsg::UpdateGameDiff(diff) => {
|
GeneralAppMsg::UpdateGameDiff(diff) => {
|
||||||
self.game_diff = diff;
|
self.game_diff = diff;
|
||||||
},
|
}
|
||||||
|
|
||||||
GeneralAppMsg::UpdatePatch(patch) => {
|
GeneralAppMsg::UpdatePatch(patch) => {
|
||||||
self.patch = patch;
|
self.patch = patch;
|
||||||
},
|
}
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
#[allow(unused_must_use)]
|
||||||
GeneralAppMsg::UpdateLauncherStyle(style) => {
|
GeneralAppMsg::UpdateLauncherStyle(style) => {
|
||||||
|
|
Loading…
Reference in a new issue