mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-25 15:03:34 +00:00
add engine constant flags for difficulty and 2P menus
This commit is contained in:
parent
153b1b4962
commit
4ae085f7e2
|
@ -320,6 +320,8 @@ pub struct EngineConstants {
|
|||
pub is_switch: bool,
|
||||
pub is_demo: bool,
|
||||
pub supports_og_textures: bool,
|
||||
pub has_difficulty_menu: bool,
|
||||
pub supports_two_player: bool,
|
||||
pub game: GameConsts,
|
||||
pub player: PlayerConsts,
|
||||
pub booster: BoosterConsts,
|
||||
|
@ -353,6 +355,8 @@ impl Clone for EngineConstants {
|
|||
is_switch: self.is_switch,
|
||||
is_demo: self.is_demo,
|
||||
supports_og_textures: self.supports_og_textures,
|
||||
has_difficulty_menu: self.has_difficulty_menu,
|
||||
supports_two_player: self.supports_two_player,
|
||||
game: self.game,
|
||||
player: self.player,
|
||||
booster: self.booster,
|
||||
|
@ -388,6 +392,8 @@ impl EngineConstants {
|
|||
is_switch: false,
|
||||
is_demo: false,
|
||||
supports_og_textures: false,
|
||||
has_difficulty_menu: true,
|
||||
supports_two_player: cfg!(not(target_os = "android")),
|
||||
game: GameConsts {
|
||||
intro_stage: 72,
|
||||
intro_event: 100,
|
||||
|
|
|
@ -118,17 +118,13 @@ impl PlayerCountMenu {
|
|||
CurrentMenu::CoopMenu => match self.coop_menu.tick(controller, state) {
|
||||
MenuSelectionResult::Selected(CoopMenuEntry::Back, _) | MenuSelectionResult::Canceled => exit_action(),
|
||||
MenuSelectionResult::Selected(CoopMenuEntry::One, _) => {
|
||||
state.player_count = PlayerCount::One;
|
||||
state.reload_resources(ctx)?;
|
||||
state.load_or_start_game(ctx)?;
|
||||
self.start_game(PlayerCount::One, state, ctx)?;
|
||||
}
|
||||
MenuSelectionResult::Selected(CoopMenuEntry::Two, _) => {
|
||||
if state.constants.is_cs_plus {
|
||||
self.current_menu = CurrentMenu::PlayerSkin;
|
||||
} else {
|
||||
state.player_count = PlayerCount::Two;
|
||||
state.reload_resources(ctx)?;
|
||||
state.load_or_start_game(ctx)?;
|
||||
self.start_game(PlayerCount::Two, state, ctx)?;
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
|
@ -178,6 +174,7 @@ impl PlayerCountMenu {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn draw(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||
match self.current_menu {
|
||||
CurrentMenu::CoopMenu => {
|
||||
|
@ -189,4 +186,11 @@ impl PlayerCountMenu {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn start_game(&mut self, player_count: PlayerCount, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||
state.player_count = player_count;
|
||||
state.reload_resources(ctx)?;
|
||||
state.load_or_start_game(ctx)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ use crate::framework::filesystem;
|
|||
use crate::game::profile::GameProfile;
|
||||
use crate::game::shared_game_state::{GameDifficulty, SharedGameState};
|
||||
use crate::input::combined_menu_controller::CombinedMenuController;
|
||||
use crate::menu::{Menu, MenuSelectionResult};
|
||||
use crate::menu::coop_menu::PlayerCountMenu;
|
||||
use crate::menu::MenuEntry;
|
||||
use crate::menu::{Menu, MenuSelectionResult};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct MenuSaveInfo {
|
||||
|
@ -155,8 +155,10 @@ impl SaveSelectMenu {
|
|||
|
||||
self.save_menu.push_entry(SaveMenuEntry::Back, MenuEntry::Active(state.loc.t("common.back").to_owned()));
|
||||
|
||||
self.difficulty_menu
|
||||
.push_entry(DifficultyMenuEntry::Title, MenuEntry::Disabled(state.loc.t("menus.difficulty_menu.title").to_owned()));
|
||||
self.difficulty_menu.push_entry(
|
||||
DifficultyMenuEntry::Title,
|
||||
MenuEntry::Disabled(state.loc.t("menus.difficulty_menu.title").to_owned()),
|
||||
);
|
||||
self.difficulty_menu.push_entry(
|
||||
DifficultyMenuEntry::Difficulty(GameDifficulty::Easy),
|
||||
MenuEntry::Active(state.loc.t("menus.difficulty_menu.easy").to_owned()),
|
||||
|
@ -169,23 +171,34 @@ impl SaveSelectMenu {
|
|||
DifficultyMenuEntry::Difficulty(GameDifficulty::Hard),
|
||||
MenuEntry::Active(state.loc.t("menus.difficulty_menu.hard").to_owned()),
|
||||
);
|
||||
self.difficulty_menu.push_entry(DifficultyMenuEntry::Back, MenuEntry::Active(state.loc.t("common.back").to_owned()));
|
||||
self.difficulty_menu
|
||||
.push_entry(DifficultyMenuEntry::Back, MenuEntry::Active(state.loc.t("common.back").to_owned()));
|
||||
|
||||
self.difficulty_menu.selected = DifficultyMenuEntry::Difficulty(GameDifficulty::Normal);
|
||||
|
||||
//self.coop_menu.init(state, ctx);
|
||||
|
||||
self.delete_confirm.push_entry(
|
||||
DeleteConfirmMenuEntry::Title,
|
||||
MenuEntry::Disabled(state.loc.t("menus.save_menu.delete_confirm").to_owned()),
|
||||
);
|
||||
self.delete_confirm
|
||||
.push_entry(DeleteConfirmMenuEntry::Title, MenuEntry::Disabled(state.loc.t("menus.save_menu.delete_confirm").to_owned()));
|
||||
self.delete_confirm.push_entry(DeleteConfirmMenuEntry::Yes, MenuEntry::Active(state.loc.t("common.yes").to_owned()));
|
||||
self.delete_confirm.push_entry(DeleteConfirmMenuEntry::No, MenuEntry::Active(state.loc.t("common.no").to_owned()));
|
||||
.push_entry(DeleteConfirmMenuEntry::Yes, MenuEntry::Active(state.loc.t("common.yes").to_owned()));
|
||||
self.delete_confirm
|
||||
.push_entry(DeleteConfirmMenuEntry::No, MenuEntry::Active(state.loc.t("common.no").to_owned()));
|
||||
|
||||
self.delete_confirm.selected = DeleteConfirmMenuEntry::No;
|
||||
|
||||
self.load_confirm.push_entry(LoadConfirmMenuEntry::Start, MenuEntry::Active(state.loc.t("menus.main_menu.start").to_owned()));
|
||||
self.load_confirm.push_entry(
|
||||
LoadConfirmMenuEntry::Start,
|
||||
MenuEntry::Active(state.loc.t("menus.main_menu.start").to_owned()),
|
||||
);
|
||||
self.load_confirm.push_entry(
|
||||
LoadConfirmMenuEntry::Delete,
|
||||
MenuEntry::Active(state.loc.t("menus.save_menu.delete_confirm").to_owned()),
|
||||
);
|
||||
self.load_confirm
|
||||
.push_entry(LoadConfirmMenuEntry::Delete, MenuEntry::Active(state.loc.t("menus.save_menu.delete_confirm").to_owned()));
|
||||
self.load_confirm.push_entry(LoadConfirmMenuEntry::Back, MenuEntry::Active(state.loc.t("common.back").to_owned()));
|
||||
.push_entry(LoadConfirmMenuEntry::Back, MenuEntry::Active(state.loc.t("common.back").to_owned()));
|
||||
|
||||
self.save_detailed.draw_cursor = false;
|
||||
|
||||
|
@ -245,7 +258,7 @@ impl SaveSelectMenu {
|
|||
state.save_slot = slot + 1;
|
||||
|
||||
if self.skip_difficulty_menu {
|
||||
self.current_menu = CurrentMenu::PlayerCountMenu;
|
||||
self.confirm_save_slot(state, ctx)?;
|
||||
} else {
|
||||
self.difficulty_menu.selected = DifficultyMenuEntry::Difficulty(GameDifficulty::Normal);
|
||||
self.current_menu = CurrentMenu::DifficultyMenu;
|
||||
|
@ -255,7 +268,7 @@ impl SaveSelectMenu {
|
|||
state.save_slot = slot + 1;
|
||||
|
||||
if let Ok(_) =
|
||||
filesystem::user_open(ctx, state.get_save_filename(state.save_slot).unwrap_or(String::new()))
|
||||
filesystem::user_open(ctx, state.get_save_filename(state.save_slot).unwrap_or(String::new()))
|
||||
{
|
||||
if let (_, MenuEntry::SaveData(save)) = self.save_menu.entries[slot] {
|
||||
self.save_detailed.entries.clear();
|
||||
|
@ -274,7 +287,7 @@ impl SaveSelectMenu {
|
|||
}
|
||||
MenuSelectionResult::Selected(DifficultyMenuEntry::Difficulty(difficulty), _) => {
|
||||
state.difficulty = difficulty;
|
||||
self.current_menu = CurrentMenu::PlayerCountMenu;
|
||||
self.confirm_save_slot(state, ctx)?;
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
|
@ -316,7 +329,7 @@ impl SaveSelectMenu {
|
|||
},
|
||||
CurrentMenu::LoadConfirm => match self.load_confirm.tick(controller, state) {
|
||||
MenuSelectionResult::Selected(LoadConfirmMenuEntry::Start, _) => {
|
||||
self.current_menu = CurrentMenu::PlayerCountMenu;
|
||||
self.confirm_save_slot(state, ctx)?;
|
||||
}
|
||||
MenuSelectionResult::Selected(LoadConfirmMenuEntry::Delete, _) => {
|
||||
self.current_menu = CurrentMenu::DeleteConfirm;
|
||||
|
@ -354,4 +367,15 @@ impl SaveSelectMenu {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn confirm_save_slot(&mut self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||
if state.constants.supports_two_player {
|
||||
self.current_menu = CurrentMenu::PlayerCountMenu;
|
||||
} else {
|
||||
state.reload_resources(ctx)?;
|
||||
state.load_or_start_game(ctx)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,11 +135,12 @@ impl TitleScene {
|
|||
}
|
||||
|
||||
fn draw_text_centered(&self, text: &str, y: f32, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||
state.font.builder()
|
||||
.center(state.canvas_size.0)
|
||||
.y(y)
|
||||
.shadow(true)
|
||||
.draw(text, ctx, &state.constants, &mut state.texture_set)?;
|
||||
state.font.builder().center(state.canvas_size.0).y(y).shadow(true).draw(
|
||||
text,
|
||||
ctx,
|
||||
&state.constants,
|
||||
&mut state.texture_set,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -195,7 +196,8 @@ impl Scene for TitleScene {
|
|||
self.controller.add(state.settings.create_player1_controller());
|
||||
self.controller.add(state.settings.create_player2_controller());
|
||||
|
||||
self.main_menu.push_entry(MainMenuEntry::Start, MenuEntry::Active(state.loc.t("menus.main_menu.start").to_owned()));
|
||||
self.main_menu
|
||||
.push_entry(MainMenuEntry::Start, MenuEntry::Active(state.loc.t("menus.main_menu.start").to_owned()));
|
||||
|
||||
if !state.mod_list.mods.is_empty() {
|
||||
self.main_menu.push_entry(
|
||||
|
@ -213,11 +215,14 @@ impl Scene for TitleScene {
|
|||
}
|
||||
|
||||
if state.constants.is_switch {
|
||||
self.main_menu
|
||||
.push_entry(MainMenuEntry::Jukebox, MenuEntry::Active(state.loc.t("menus.main_menu.jukebox").to_owned()));
|
||||
self.main_menu.push_entry(
|
||||
MainMenuEntry::Jukebox,
|
||||
MenuEntry::Active(state.loc.t("menus.main_menu.jukebox").to_owned()),
|
||||
);
|
||||
}
|
||||
|
||||
self.main_menu.push_entry(MainMenuEntry::Quit, MenuEntry::Active(state.loc.t("menus.main_menu.quit").to_owned()));
|
||||
self.main_menu
|
||||
.push_entry(MainMenuEntry::Quit, MenuEntry::Active(state.loc.t("menus.main_menu.quit").to_owned()));
|
||||
|
||||
self.settings_menu.init(state, ctx)?;
|
||||
|
||||
|
@ -297,7 +302,7 @@ impl Scene for TitleScene {
|
|||
MenuSelectionResult::Selected(MainMenuEntry::Start, _) => {
|
||||
state.mod_path = None;
|
||||
self.save_select_menu.init(state, ctx)?;
|
||||
self.save_select_menu.set_skip_difficulty_menu(false);
|
||||
self.save_select_menu.set_skip_difficulty_menu(!state.constants.has_difficulty_menu);
|
||||
self.current_menu = CurrentMenu::SaveSelectMenu;
|
||||
}
|
||||
MenuSelectionResult::Selected(MainMenuEntry::Challenges, _) => {
|
||||
|
|
Loading…
Reference in a new issue