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

Release 1.3.0
This commit is contained in:
Nikita Podvirnyi 2024-10-09 22:37:28 +02:00 committed by GitHub
commit e33ffeb6e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 407 additions and 471 deletions

View file

@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Added 5.1.0 voiceovers sizes
### Removed
- Removed Discord RPC support
## [1.2.1] - 02.09.2024
### Fixed

638
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@ glib-build-tools = "0.20"
[dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "1.20.3"
tag = "1.22.0"
features = ["all", "zzz"]
# path = "../anime-launcher-sdk" # ! for dev purposes only
@ -29,7 +29,7 @@ relm4 = { version = "0.9.0", features = ["macros", "libadwaita"] }
gtk = { package = "gtk4", version = "0.9.0", features = ["v4_12"] }
adw = { package = "libadwaita", version = "0.7.0", features = ["v1_4"] }
rfd = { version = "0.14.1", features = ["xdg-portal", "tokio"], default-features = false }
rfd = { version = "0.15.0", features = ["xdg-portal", "tokio"], default-features = false }
open = "5.3.0"
whatadistro = "0.1.0"
@ -43,7 +43,7 @@ enum-ordinalize = "4.3"
tracing = "0.1"
tracing-subscriber = "0.3"
fluent-templates = "0.10"
fluent-templates = "0.11"
unic-langid = "0.9"
human-panic = "2.0.1"

View file

@ -91,10 +91,16 @@ impl SimpleComponent for AboutDialog {
set_release_notes_version: &APP_VERSION,
set_release_notes: &[
"<p>Fixed</p>",
"<p>Added</p>",
"<ul>",
"<li>Fixed gamescope config file layout</li>",
"<li>Added 5.1.0 voiceovers sizes</li>",
"</ul>",
"<p>Removed</p>",
"<ul>",
"<li>Removed Discord RPC support</li>",
"</ul>"
].join("\n"),

View file

@ -1,20 +1,10 @@
use relm4::prelude::*;
use relm4::factory::{
AsyncFactoryComponent,
AsyncFactorySender,
AsyncFactoryVecDeque
};
use adw::prelude::*;
use anime_launcher_sdk::config::ConfigExt;
use anime_launcher_sdk::zzz::config::Config;
use anime_launcher_sdk::config::schema_blanks::prelude::*;
use anime_launcher_sdk::anime_game_core::installer::downloader::Downloader;
use anime_launcher_sdk::discord_rpc::DiscordRpc;
use anime_launcher_sdk::is_available;
use enum_ordinalize::Ordinalize;
@ -32,64 +22,7 @@ use crate::*;
use super::gamescope::*;
use super::main::PreferencesAppMsg;
#[derive(Debug)]
struct DiscordRpcIcon {
pub check_button: gtk::CheckButton,
pub name: String,
pub path: PathBuf
}
#[relm4::factory(async)]
impl AsyncFactoryComponent for DiscordRpcIcon {
type Init = Self;
type Input = EnhancementsAppMsg;
type Output = EnhancementsAppMsg;
type CommandOutput = ();
type ParentWidget = adw::ExpanderRow;
view! {
root = adw::ActionRow {
set_title: &self.name,
// set_subtitle: &self.name,
// Don't even try to understand
add_prefix = &self.check_button.clone(),
add_suffix = &gtk::Picture {
set_margin_start: 4,
set_margin_top: 4,
set_margin_end: 4,
set_margin_bottom: 4,
add_css_class: "round-bin",
set_filename: Some(&self.path)
},
set_activatable: true,
connect_activated[sender, index] => move |_| {
sender.output(EnhancementsAppMsg::SetDiscordRpcIcon(index.clone()))
.unwrap();
}
}
}
#[inline]
async fn init_model(
init: Self::Init,
_index: &DynamicIndex,
_sender: AsyncFactorySender<Self>,
) -> Self {
init
}
}
pub struct EnhancementsApp {
discord_rpc_icons: AsyncFactoryVecDeque<DiscordRpcIcon>,
discord_rpc_root_check_button: gtk::CheckButton,
gamescope: AsyncController<GamescopeApp>,
game_page: AsyncController<GamePage>,
sandbox_page: AsyncController<SandboxPage>,
@ -99,9 +32,6 @@ pub struct EnhancementsApp {
#[derive(Debug)]
pub enum EnhancementsAppMsg {
SetGamescopeParent,
SetDiscordRpcIcon(DynamicIndex),
OpenGamescope,
OpenMainPage,
OpenGameSettingsPage,
@ -486,65 +416,6 @@ impl SimpleAsyncComponent for EnhancementsApp {
}
}
}
},
add = &adw::PreferencesGroup {
set_title: &tr!("discord-rpc"),
adw::ActionRow {
set_title: &tr!("enabled"),
set_subtitle: &tr!("discord-rpc-description"),
add_suffix = &gtk::Switch {
set_valign: gtk::Align::Center,
set_active: CONFIG.launcher.discord_rpc.enabled,
connect_state_notify => |switch| {
if is_ready() {
if let Ok(mut config) = Config::get() {
config.launcher.discord_rpc.enabled = switch.is_active();
Config::update(config);
}
}
}
}
},
#[local_ref]
discord_rpc_icons -> adw::ExpanderRow {
set_title: &tr!("icon")
},
adw::EntryRow {
set_title: &tr!("title"),
set_text: &CONFIG.launcher.discord_rpc.title,
connect_changed: |row| {
if is_ready() {
if let Ok(mut config) = Config::get() {
config.launcher.discord_rpc.title = row.text().to_string();
Config::update(config);
}
}
}
},
adw::EntryRow {
set_title: &tr!("description"),
set_text: &CONFIG.launcher.discord_rpc.subtitle,
connect_changed: |row| {
if is_ready() {
if let Ok(mut config) = Config::get() {
config.launcher.discord_rpc.subtitle = row.text().to_string();
Config::update(config);
}
}
}
}
}
},
@ -565,13 +436,7 @@ impl SimpleAsyncComponent for EnhancementsApp {
) -> AsyncComponentParts<Self> {
tracing::info!("Initializing enhancements settings");
let mut model = Self {
discord_rpc_icons: AsyncFactoryVecDeque::builder()
.launch_default()
.forward(sender.input_sender(), std::convert::identity),
discord_rpc_root_check_button: gtk::CheckButton::new(),
let model = Self {
gamescope: GamescopeApp::builder()
.launch(())
.detach(),
@ -589,73 +454,6 @@ impl SimpleAsyncComponent for EnhancementsApp {
.forward(sender.input_sender(), std::convert::identity)
};
match DiscordRpc::get_assets(CONFIG.launcher.discord_rpc.app_id) {
Ok(icons) => {
for icon in icons {
let cache_file = CACHE_FOLDER
.join("discord-rpc")
.join(&icon.name)
.join(&icon.id);
// let sender = sender.clone();
// Workaround for old folder structure (pre 3.7.3)
let old_path = CACHE_FOLDER.join("discord-rpc").join(&icon.name);
if old_path.exists() {
if let Ok(metadata) = old_path.metadata() {
if metadata.is_file() {
std::fs::remove_file(old_path).expect("Failed to delete old discord rpc icon");
}
}
}
if !cache_file.exists() {
std::thread::spawn(move || {
Downloader::new(icon.get_uri())
.expect("Failed to init Discord RPC icon downloader")
.with_continue_downloading(false)
.with_free_space_check(false)
.download(cache_file, |_, _| {})
.expect("Failed to download Discord RPC icon");
/*if let Err(err) = result {
sender.input(EnhancementsAppMsg::Toast {
title: tr!("discord-rpc-icon-download-failed"),
description: Some(err.to_string())
});
}*/
});
}
// TODO: add icons after thread above finishes its work as well
else {
let check_button = gtk::CheckButton::new();
check_button.set_group(Some(&model.discord_rpc_root_check_button));
if CONFIG.launcher.discord_rpc.icon == icon.name {
check_button.set_active(true);
}
model.discord_rpc_icons.guard().push_back(DiscordRpcIcon {
check_button,
name: icon.name.clone(),
path: cache_file.clone()
});
}
}
}
Err(err) => sender.input(EnhancementsAppMsg::Toast {
title: tr!("discord-rpc-icons-fetch-failed"),
description: Some(err.to_string())
})
}
let discord_rpc_icons = model.discord_rpc_icons.widget();
let game_page = model.game_page.widget();
let sandbox_page = model.sandbox_page.widget();
let environment_page = model.environment_page.widget();
@ -671,18 +469,6 @@ impl SimpleAsyncComponent for EnhancementsApp {
self.gamescope.widget().set_transient_for(super::main::PREFERENCES_WINDOW.as_ref());
}
EnhancementsAppMsg::SetDiscordRpcIcon(index) => {
if let Some(icon) = self.discord_rpc_icons.guard().get(index.current_index()) {
if let Ok(mut config) = Config::get() {
config.launcher.discord_rpc.icon.clone_from(&icon.name);
Config::update(config);
icon.check_button.set_active(true);
}
}
}
EnhancementsAppMsg::OpenGamescope => {
self.gamescope.widget().present();
}