the-honkers-railway-launcher/src/ui/about.rs
2023-06-09 22:39:17 +02:00

164 lines
5.3 KiB
Rust

use relm4::prelude::*;
use gtk::prelude::*;
use anime_launcher_sdk::VERSION as SDK_VERSION;
use anime_launcher_sdk::anime_game_core::VERSION as CORE_VERSION;
use crate::*;
lazy_static::lazy_static! {
pub static ref APP_VERSION: String = if crate::APP_DEBUG && !crate::APP_VERSION.contains('-') {
format!("{}-dev", crate::APP_VERSION)
} else {
crate::APP_VERSION.to_string()
};
}
#[derive(Debug)]
pub struct AboutDialog {
visible: bool
}
#[derive(Debug)]
pub enum AboutDialogMsg {
Show,
Hide
}
#[relm4::component(pub)]
impl SimpleComponent for AboutDialog {
type Init = ();
type Input = AboutDialogMsg;
type Output = ();
view! {
dialog = adw::AboutWindow {
set_application_name: "An Anime Game Launcher",
set_application_icon: APP_ID,
set_website: "https://github.com/an-anime-team/an-anime-game-launcher",
set_issue_url: "https://github.com/an-anime-team/an-anime-game-launcher/issues",
set_license_type: gtk::License::Gpl30,
set_version: &APP_VERSION,
set_developers: &[
"Nikita Podvirnyy https://github.com/krypt0nn"
],
add_credit_section: (Some("Patch developer"), &[
"@Krock https://notabug.org/Krock/dawn"
]),
add_credit_section: (Some("An Anime Team"), &[
"Nikita Podvirnyy https://github.com/krypt0nn",
"@Marie https://github.com/Mar0xy",
"@lane https://github.com/laurinneff",
"@jiro-too https://github.com/jiro-too",
"@cybik https://github.com/cybik",
"@mkrsym1 https://github.com/mkrsym1"
]),
set_artists: &[
"@nightany https://pinterest.com/pin/356206651788051017"
],
set_translator_credits: &[
"Русский, English — Nikita Podvirnyy https://github.com/krypt0nn",
"Deutsch — @Marie https://github.com/Mar0xy",
"Français — @zeGolem https://github.com/zeGolem",
"Español — Lautaro Garavano https://github.com/Rattlehead15",
"Türkçe — @Kaozix https://github.com/Kaozix1776",
"Türkçe — Kayra Nachfolger https://github.com/kayranachfolger",
"Italiano - @QuazarOmega https://github.com/quazar-omega",
"Indonesia - @yumekarisu https://github.com/yumekarisu",
"简体中文 — Caibin Chen https://github.com/tigersoldier"
].join("\n"),
set_debug_info: &[
format!("Anime Launcher SDK: {SDK_VERSION}"),
format!("Anime Game Core: {CORE_VERSION}"),
String::new(),
format!("GTK: {}.{}.{}", gtk::major_version(), gtk::minor_version(), gtk::micro_version()),
format!("libadwaita: {}.{}.{}", adw::major_version(), adw::minor_version(), adw::micro_version()),
format!("pango: {}", gtk::pango::version_string()),
format!("cairo: {}", gtk::cairo::version_string()),
].join("\n"),
set_release_notes_version: &APP_VERSION,
set_release_notes: &[
"<p>Added</p>",
"<ul>",
"<li>Added Discord RPC icon selection</li>",
"</ul>",
"<p>Fixed</p>",
"<ul>",
"<li>Fixed progress bar style after running game repairer</li>",
"<li>Fixed repair button functionality</li>",
"<li>Fixed default launcher language selection at the first start</li>",
"<li>Fixed some installer updates reporting (including \"checking free space\")</li>",
"</ul>",
"<p>Changed</p>",
"<ul>",
"<li>Reworked game sessions selection</li>",
"<li>Updated Indonesian</li>",
"<li>Updated French</li>",
"<li>Made initial tasks async which has decreased startup time</li>",
"<li>Updated fps unlocker to 2.1.1</li>",
"</ul>",
"<p>Removed</p>",
"<ul>",
"<li>Removed 3.7.0 workaround</li>",
"<li>Removed patch mirror migration</li>",
"</ul>",
].join("\n"),
set_modal: true,
set_hide_on_close: true,
#[watch]
set_visible: model.visible,
connect_close_request[sender] => move |_| {
sender.input(AboutDialogMsg::Hide);
gtk::Inhibit(false)
}
}
}
fn init(
_init: Self::Init,
root: &Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
tracing::info!("Initializing about dialog");
let model = Self {
visible: false
};
let widgets = view_output!();
ComponentParts { model, widgets }
}
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
match msg {
AboutDialogMsg::Show => {
self.visible = true;
}
AboutDialogMsg::Hide => {
self.visible = false;
}
}
}
}