From aa5215533ad0249e8729f4e549f5b793d6554459 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 22 Apr 2023 18:06:41 +0200 Subject: [PATCH] feat: added rules approving dialog to the first run window --- assets/locales/en/first_run.ftl | 6 ++++++ assets/locales/en/main.ftl | 1 + src/ui/first_run/tos_warning.rs | 35 ++++++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/assets/locales/en/first_run.ftl b/assets/locales/en/first_run.ftl index 9ab26c6..9432dcf 100644 --- a/assets/locales/en/first_run.ftl +++ b/assets/locales/en/first_run.ftl @@ -23,6 +23,12 @@ tos-violation-warning-message = If you understand the risk of trying to play the game in an unofficial capacity, press OK and let's go researching the world of Teyvat! +tos-dialog-title = Are you sure you understand what we want to say? +tos-dialog-message = + 1. Don't publish any information about this project + 2. Don't abuse it by using some modded clients and so + 3. Ask questions exceptionally in our discord or matrix server + dependencies = Dependencies missing-dependencies-title = You're missing some dependencies! diff --git a/assets/locales/en/main.ftl b/assets/locales/en/main.ftl index f36da46..f448ac1 100644 --- a/assets/locales/en/main.ftl +++ b/assets/locales/en/main.ftl @@ -22,6 +22,7 @@ continue = Continue exit = Exit check = Check restart = Restart +agree = Agree loading-data = Loading data diff --git a/src/ui/first_run/tos_warning.rs b/src/ui/first_run/tos_warning.rs index 08ae5b1..364632b 100644 --- a/src/ui/first_run/tos_warning.rs +++ b/src/ui/first_run/tos_warning.rs @@ -8,6 +8,8 @@ use anime_launcher_sdk::is_available; use crate::i18n::*; use super::main::FirstRunAppMsg; +use super::main::MAIN_WINDOW; + pub struct TosWarningApp; #[derive(Debug, Clone)] @@ -86,11 +88,34 @@ impl SimpleAsyncComponent for TosWarningApp { match msg { #[allow(unused_must_use)] TosWarningAppMsg::Continue => { - if is_available("git") && is_available("xdelta3") { - sender.output(Self::Output::ScrollToDefaultPaths); - } else { - sender.output(Self::Output::ScrollToDependencies); - } + let dialog = adw::MessageDialog::new( + unsafe { MAIN_WINDOW.as_ref() }, + Some(&tr("tos-dialog-title")), + Some(&tr("tos-dialog-message")) + ); + + dialog.add_responses(&[ + ("exit", &tr("exit")), + ("continue", &tr("agree")) + ]); + + dialog.connect_response(None, move |_, response| { + match response { + "exit" => relm4::main_application().quit(), + + "continue" => { + if is_available("git") && is_available("xdelta3") { + sender.output(Self::Output::ScrollToDefaultPaths); + } else { + sender.output(Self::Output::ScrollToDependencies); + } + } + + _ => unreachable!() + } + }); + + dialog.show(); } TosWarningAppMsg::Exit => relm4::main_application().quit()