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

fix difficulties interfering with challenges

This commit is contained in:
Sallai József 2022-02-27 12:50:41 +02:00 committed by alula
parent 6b7b6b7032
commit 0c33795356
2 changed files with 15 additions and 2 deletions

View file

@ -33,6 +33,7 @@ pub struct SaveSelectMenu {
save_menu: Menu,
difficulty_menu: Menu,
delete_confirm: Menu,
skip_difficulty_menu: bool,
}
impl SaveSelectMenu {
@ -43,6 +44,7 @@ impl SaveSelectMenu {
save_menu: Menu::new(0, 0, 230, 0),
difficulty_menu: Menu::new(0, 0, 130, 0),
delete_confirm: Menu::new(0, 0, 75, 0),
skip_difficulty_menu: false,
}
}
@ -50,6 +52,7 @@ impl SaveSelectMenu {
self.save_menu = Menu::new(0, 0, 230, 0);
self.difficulty_menu = Menu::new(0, 0, 130, 0);
self.delete_confirm = Menu::new(0, 0, 75, 0);
self.skip_difficulty_menu = false;
for (iter, save) in self.saves.iter_mut().enumerate() {
if let Ok(data) = filesystem::user_open(ctx, state.get_save_filename(iter + 1).unwrap_or("".to_string())) {
@ -90,6 +93,10 @@ impl SaveSelectMenu {
Ok(())
}
pub fn set_skip_difficulty_menu(&mut self, skip: bool) {
self.skip_difficulty_menu = skip;
}
fn update_sizes(&mut self, state: &SharedGameState) {
self.save_menu.update_height();
self.save_menu.x = ((state.canvas_size.0 - self.save_menu.width as f32) / 2.0).floor() as isize;
@ -117,7 +124,10 @@ impl SaveSelectMenu {
MenuSelectionResult::Selected(slot, _) => {
state.save_slot = slot + 1;
if let Ok(_) =
if self.skip_difficulty_menu {
state.reload_resources(ctx)?;
state.load_or_start_game(ctx)?;
} else if let Ok(_) =
filesystem::user_open(ctx, state.get_save_filename(state.save_slot).unwrap_or("".to_string()))
{
state.reload_resources(ctx)?;

View file

@ -13,7 +13,7 @@ use crate::menu::settings_menu::SettingsMenu;
use crate::menu::{Menu, MenuEntry, MenuSelectionResult};
use crate::scene::jukebox_scene::JukeboxScene;
use crate::scene::Scene;
use crate::shared_game_state::{MenuCharacter, SharedGameState, TileSize};
use crate::shared_game_state::{GameDifficulty, MenuCharacter, SharedGameState, TileSize};
use crate::stage::{BackgroundType, NpcType, Stage, StageData, StageTexturePaths, Tileset};
#[derive(PartialEq, Eq, Copy, Clone)]
@ -200,6 +200,7 @@ impl Scene for TitleScene {
MenuSelectionResult::Selected(0, _) => {
state.mod_path = None;
self.save_select_menu.init(state, ctx)?;
self.save_select_menu.set_skip_difficulty_menu(false);
self.current_menu = CurrentMenu::SaveSelectMenu;
}
MenuSelectionResult::Selected(1, _) => {
@ -263,6 +264,7 @@ impl Scene for TitleScene {
state.mod_path = Some(mod_info.path.clone());
if mod_info.save_slot >= 0 {
self.save_select_menu.init(state, ctx)?;
self.save_select_menu.set_skip_difficulty_menu(true);
self.nikumaru_rec.load_counter(state, ctx)?;
self.current_menu = CurrentMenu::SaveSelectMenu;
} else {
@ -285,6 +287,7 @@ impl Scene for TitleScene {
}
CurrentMenu::ChallengeConfirmMenu => match self.confirm_menu.tick(&mut self.controller, state) {
MenuSelectionResult::Selected(1, _) => {
state.difficulty = GameDifficulty::Normal;
state.reload_resources(ctx)?;
state.start_new_game(ctx)?;
}