1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-22 13:42:47 +00:00

Delete replay menu option

This commit is contained in:
dawnDus 2022-04-20 08:47:31 -04:00
parent 28a3f160c3
commit daea35381b
No known key found for this signature in database
GPG key ID: 972AABDE81848F21
5 changed files with 27 additions and 8 deletions

View file

@ -44,7 +44,8 @@
"challenge_menu": {
"start": "Start",
"no_replay": "No Replay",
"replay_best": "Replay Best"
"replay_best": "Replay Best",
"delete_replay": "Delete Replay"
},
"options_menu": {

View file

@ -39,7 +39,8 @@
"challenge_menu": {
"start": "スタート",
"no_replay": "ノーリプレイ",
"replay_best": "ベストプレイを再生"
"replay_best": "ベストプレイを再生",
"delete_replay": "リプレイを削除"
},
"options_menu": {
"graphics": "グラフィック",

View file

@ -41,7 +41,7 @@ use crate::npc::list::NPCList;
use crate::npc::{NPCLayer, NPC};
use crate::physics::{PhysicalEntity, OFFSETS};
use crate::player::{ControlMode, Player, TargetPlayer};
use crate::rng::{XorShift, RNG};
use crate::rng::RNG;
use crate::scene::title_scene::TitleScene;
use crate::scene::Scene;
use crate::scripting::tsc::credit_script::CreditScriptVM;

View file

@ -192,6 +192,7 @@ impl Scene for TitleScene {
self.confirm_menu.push_entry(MenuEntry::Disabled("".to_owned()));
self.confirm_menu.push_entry(MenuEntry::Active(state.t("menus.challenge_menu.start")));
self.confirm_menu.push_entry(MenuEntry::Disabled(state.t("menus.challenge_menu.no_replay")));
self.confirm_menu.push_entry(MenuEntry::Hidden);
self.confirm_menu.push_entry(MenuEntry::Active(state.t("common.back")));
self.confirm_menu.selected = 1;
@ -301,11 +302,16 @@ impl Scene for TitleScene {
self.confirm_menu.width =
(state.font.text_width(mod_name.chars(), &state.constants).max(50.0) + 32.0) as u16;
self.confirm_menu.entries[0] = MenuEntry::Disabled(mod_name);
self.confirm_menu.entries[2] = if state.has_replay_data(ctx) {
MenuEntry::Active(state.t("menus.challenge_menu.replay_best"))
if state.has_replay_data(ctx) {
self.confirm_menu.entries[2] =
MenuEntry::Active(state.t("menus.challenge_menu.replay_best"));
self.confirm_menu.entries[3] =
MenuEntry::Active(state.t("menus.challenge_menu.delete_replay"));
} else {
MenuEntry::Disabled(state.t("menus.challenge_menu.no_replay"))
};
self.confirm_menu.entries[2] =
MenuEntry::Disabled(state.t("menus.challenge_menu.no_replay"));
self.confirm_menu.entries[3] = MenuEntry::Hidden;
}
self.nikumaru_rec.load_counter(state, ctx)?;
self.current_menu = CurrentMenu::ChallengeConfirmMenu;
}
@ -332,7 +338,11 @@ impl Scene for TitleScene {
state.reload_resources(ctx)?;
state.start_new_game(ctx)?;
}
MenuSelectionResult::Selected(3, _) | MenuSelectionResult::Canceled => {
MenuSelectionResult::Selected(3, _) => {
state.delete_replay_data(ctx)?;
self.current_menu = CurrentMenu::ChallengesMenu;
}
MenuSelectionResult::Selected(4, _) | MenuSelectionResult::Canceled => {
self.current_menu = CurrentMenu::ChallengesMenu;
}
_ => (),

View file

@ -729,6 +729,13 @@ impl SharedGameState {
filesystem::user_exists(ctx, [self.get_rec_filename(), ".rep".to_string()].join(""))
}
pub fn delete_replay_data(&self, ctx: &mut Context) -> GameResult {
if self.has_replay_data(ctx) {
filesystem::user_delete(ctx, [self.get_rec_filename(), ".rep".to_string()].join(""))?;
}
Ok(())
}
pub fn get_damage(&self, hp: i32) -> i32 {
match self.difficulty {
GameDifficulty::Easy => cmp::max(hp / 2, 1),