Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcco committed Jan 22, 2024
1 parent f22786a commit 36d3dbd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions extern/VitaShell
Submodule VitaShell added at 81af70
1 change: 1 addition & 0 deletions src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ pub const DIALOG_CANCEL_TEXT: &str = "(X) 取消";
// home page
pub const HOME_PAGE_URL: &str = "https://save-cloud.sketchraw.com?psvita=go";
pub const INVALID_EAT_PANCAKE: &str = "缺少 eat.pancake";
pub const ABOUT_TEXT: &str = "Save Cloud 云存档,扫码访问主页!";
2 changes: 1 addition & 1 deletion src/ui/ui_cloud/action/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl Action for CloudAction {
let dir = Arc::clone(dir);
let path = path.to_string();
let name = item_name.to_string();
Loading::show();
tokio::spawn(async move {
Loading::show();
do_cloud_action(&path, &name, action, dir);
Loading::hide();
});
Expand Down
23 changes: 16 additions & 7 deletions src/ui/ui_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::time::Instant;

use crate::{
constant::{
ANIME_TIME_160, DIALOG_BOTTOM_TOP, DIALOG_CANCEL_TEXT, DIALOG_CONFIRM_TEXT, DIALOG_HEIGHT,
DIALOG_WIDTH, INVALID_EAT_PANCAKE, SCREEN_HEIGHT, SCREEN_WIDTH,
ABOUT_TEXT, ANIME_TIME_160, DIALOG_BOTTOM_TOP, DIALOG_CANCEL_TEXT, DIALOG_CONFIRM_TEXT,
DIALOG_HEIGHT, DIALOG_WIDTH, INVALID_EAT_PANCAKE, SCREEN_HEIGHT, SCREEN_WIDTH,
},
utils::ease_out_expo,
vita2d::{
Expand All @@ -16,7 +16,7 @@ use crate::{
pub struct UIDialog;

impl UIDialog {
fn draw(text: &str, is_qrcode: bool) -> bool {
fn draw(text: &str, is_qrcode: bool, is_about: bool) -> bool {
// qrcode
let qr_code = if is_qrcode {
let buf = qrcode_generator::to_png_to_vec(text, qrcode_generator::QrCodeEcc::Low, 150)
Expand Down Expand Up @@ -118,12 +118,17 @@ impl UIDialog {
DIALOG_CONFIRM_TEXT,
);
if let Some(qr_code) = &qr_code {
let text = if is_about {
ABOUT_TEXT
} else {
INVALID_EAT_PANCAKE
};
vita2d_draw_text(
left as i32 + (DIALOG_WIDTH - vita2d_text_width(1.0, INVALID_EAT_PANCAKE)) / 2,
left as i32 + (DIALOG_WIDTH - vita2d_text_width(1.0, text)) / 2,
top as i32 + 30,
rgba(0xff, 0xff, 0xff, 0xff),
1.0,
INVALID_EAT_PANCAKE,
text,
);
vita2d_draw_texture(
qr_code,
Expand All @@ -147,10 +152,14 @@ impl UIDialog {
}

pub fn present(text: &str) -> bool {
UIDialog::draw(text, false)
UIDialog::draw(text, false, false)
}

pub fn present_qrcode(text: &str) -> bool {
UIDialog::draw(text, true)
UIDialog::draw(text, true, false)
}

pub fn present_about(text: &str) -> bool {
UIDialog::draw(text, true, true)
}
}
6 changes: 5 additions & 1 deletion src/ui/ui_titles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{

use crate::{
app::AppData,
constant::HOME_PAGE_URL,
utils::get_active_color,
vita2d::{
is_button, rgba, vita2d_draw_rect, vita2d_draw_text, vita2d_draw_texture_scale,
Expand All @@ -16,7 +17,7 @@ use crate::{

use self::{game_menu::GameMenu, save_menu::SaveMenu};

use super::ui_base::UIBase;
use super::{ui_base::UIBase, ui_dialog::UIDialog};

pub mod game_menu;
pub mod save_menu;
Expand Down Expand Up @@ -299,6 +300,9 @@ impl UIBase for UITitles {
self.game_menu.open();
}
}
if is_button(buttons, SceCtrlButtons::SceCtrlSquare) {
UIDialog::present_about(HOME_PAGE_URL);
}
// update selected title icon
UITitles::update_selected(self, app_data, buttons);
}
Expand Down

0 comments on commit 36d3dbd

Please sign in to comment.