Skip to content

Commit

Permalink
feat: make tos more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
Mivik committed Oct 27, 2023
1 parent 1d94b6b commit 4d4a003
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
6 changes: 3 additions & 3 deletions phira/locales/en-US/common.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ chart-unstable = Unstable
list-empty = Nothing here
tos-and-policy = Terms of Service and Privacy Policy
tos-and-policy-desc = You must read and agree to our Terms of Service and Privacy Policy before using Phira online services provided by TeamFlos.
tos = Terms of Service
policy = Privacy Policy
tos-and-policy-desc = You must read (by clicking here) and agree to our Terms of Service and Privacy Policy before using Phira online services provided by TeamFlos.
tos-deny = Deny
tos-accept = Accept
open-in-web = Open in Web
6 changes: 3 additions & 3 deletions phira/locales/zh-CN/common.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ chart-unstable = 未上架
list-empty = 空空如也
tos-and-policy = 《服务条款》和《隐私政策》
tos-and-policy-desc = 在使用由 TeamFlos 提供的 Phira 线上服务部分之前,你必须阅读并同意我们的《服务条款》和《隐私政策》。
tos = 服务条款
policy = 隐私政策
tos-and-policy-desc = 在使用由 TeamFlos 提供的 Phira 线上服务部分之前,你必须 *点击此处* 阅读并同意我们的《服务条款》和《隐私政策》。
tos-deny = 拒绝
tos-accept = 同意
open-in-web = 在网站中打开
27 changes: 9 additions & 18 deletions phira/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,21 @@ pub fn check_read_tos_and_policy() -> bool {
return true;
}

let mut done = 0;
Dialog::plain(ttl!("tos-and-policy"), ttl!("tos-and-policy-desc"))
.buttons(vec![ttl!("cancel").into_owned(), ttl!("tos").into_owned(), ttl!("policy").into_owned()])
.listener(move |pos| {
match pos {
1 => {
open_url("https://phira.moe/terms-of-use").unwrap();
done |= 1;
}
2 => {
open_url("https://phira.moe/privacy-policy").unwrap();
done |= 2;
}
_ => {
return false;
}
.buttons(vec![ttl!("tos-deny").into_owned(), ttl!("tos-accept").into_owned()])
.listener(move |pos| match pos {
-2 => {
open_url("https://phira.moe/terms-of-use").unwrap();
true
}
if done == 3 {
-1 => true,
0 => false,
1 => {
get_data_mut().read_tos_and_policy = true;
let _ = save_data();
false
} else {
true
}
_ => unreachable!(),
})
.show();

Expand Down
22 changes: 17 additions & 5 deletions prpr/src/ui/dialog.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
crate::tl_file!("dialog");

use super::{DRectButton, Scroll, Ui};
use super::{DRectButton, RectButton, Scroll, Ui};
use crate::{core::BOLD_FONT, ext::RectExt, scene::show_message};
use anyhow::Error;
use macroquad::prelude::*;
Expand All @@ -13,7 +13,9 @@ pub struct Dialog {
title: String,
message: String,
buttons: Vec<String>,
listener: Option<Box<dyn FnMut(i32) -> bool>>, // -1 for cancel
listener: Option<Box<dyn FnMut(i32) -> bool>>, // -1 for cancel, -2 for text

text_btn: RectButton,

h: Option<f32>,

Expand All @@ -30,6 +32,8 @@ impl Default for Dialog {
buttons: vec![tl!("ok").to_string()],
listener: None,

text_btn: RectButton::new(),

h: None,

scroll: Scroll::new(),
Expand Down Expand Up @@ -104,17 +108,24 @@ impl Dialog {
let mut exit = false;
for (index, btn) in self.rect_buttons.iter_mut().enumerate() {
if btn.touch(touch, t) {
exit = true;
if let Some(listener) = self.listener.as_mut() {
if listener(index as i32) {
exit = false;
if !listener(index as i32) {
exit = true;
}
}
}
}
if self.text_btn.touch(touch) {
if let Some(listener) = self.listener.as_mut() {
if !listener(-2) {
exit = true;
}
}
}
if exit {
return false;
}

if self
.window_rect
.map_or(true, |rect| rect.contains(touch.position) || touch.phase != TouchPhase::Started)
Expand Down Expand Up @@ -193,6 +204,7 @@ impl Dialog {
.max_width(wr.w - pad * 3.)
.multiline()
.draw();
self.text_btn.set(ui, r);
(r.w, r.h + 0.04)
});
});
Expand Down

0 comments on commit 4d4a003

Please sign in to comment.