mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-07-21 11:41:18 +00:00
Main menu music and cursor for nikumaru time
This commit is contained in:
parent
5725948f85
commit
9f530ce6a5
|
@ -232,6 +232,11 @@ pub struct TitleConsts {
|
|||
pub menu_middle: Rect<u16>,
|
||||
pub menu_left: Rect<u16>,
|
||||
pub menu_right: Rect<u16>,
|
||||
pub cursor_quote: [Rect<u16>; 4],
|
||||
pub cursor_curly: [Rect<u16>; 4],
|
||||
pub cursor_toroko: [Rect<u16>; 4],
|
||||
pub cursor_king: [Rect<u16>; 4],
|
||||
pub cursor_sue: [Rect<u16>; 4],
|
||||
}
|
||||
|
||||
impl Clone for TitleConsts {
|
||||
|
@ -248,6 +253,11 @@ impl Clone for TitleConsts {
|
|||
menu_middle: self.menu_middle,
|
||||
menu_left: self.menu_left,
|
||||
menu_right: self.menu_right,
|
||||
cursor_quote: self.cursor_quote,
|
||||
cursor_curly: self.cursor_curly,
|
||||
cursor_toroko: self.cursor_toroko,
|
||||
cursor_king: self.cursor_king,
|
||||
cursor_sue: self.cursor_sue,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1480,6 +1490,36 @@ impl EngineConstants {
|
|||
menu_bottom: Rect { left: 8, top: 16, right: 236, bottom: 24 },
|
||||
menu_left: Rect { left: 0, top: 8, right: 8, bottom: 16 },
|
||||
menu_right: Rect { left: 236, top: 8, right: 244, bottom: 16 },
|
||||
cursor_quote: [
|
||||
Rect { left: 0, top: 16, right: 16, bottom: 32 },
|
||||
Rect { left: 16, top: 16, right: 32, bottom: 32 },
|
||||
Rect { left: 0, top: 16, right: 16, bottom: 32 },
|
||||
Rect { left: 32, top: 16, right: 48, bottom: 32 },
|
||||
],
|
||||
cursor_curly: [
|
||||
Rect { left: 0, top: 112, right: 16, bottom: 128 },
|
||||
Rect { left: 16, top: 112, right: 32, bottom: 128 },
|
||||
Rect { left: 0, top: 112, right: 16, bottom: 128 },
|
||||
Rect { left: 32, top: 112, right: 48, bottom: 128 },
|
||||
],
|
||||
cursor_toroko: [
|
||||
Rect { left: 64, top: 80, right: 80, bottom: 96 },
|
||||
Rect { left: 80, top: 80, right: 96, bottom: 96 },
|
||||
Rect { left: 64, top: 80, right: 80, bottom: 96 },
|
||||
Rect { left: 96, top: 80, right: 112, bottom: 96 },
|
||||
],
|
||||
cursor_king: [
|
||||
Rect { left: 224, top: 48, right: 240, bottom: 64 },
|
||||
Rect { left: 288, top: 48, right: 304, bottom: 64 },
|
||||
Rect { left: 224, top: 48, right: 240, bottom: 64 },
|
||||
Rect { left: 304, top: 48, right: 320, bottom: 64 },
|
||||
],
|
||||
cursor_sue: [
|
||||
Rect { left: 0, top: 16, right: 16, bottom: 32 },
|
||||
Rect { left: 32, top: 16, right: 48, bottom: 32 },
|
||||
Rect { left: 0, top: 16, right: 16, bottom: 32 },
|
||||
Rect { left: 48, top: 16, right: 64, bottom: 32 },
|
||||
],
|
||||
},
|
||||
inventory_dim_color: Color::from_rgba(0, 0, 0, 0),
|
||||
font_path: "csfont.fnt".to_owned(),
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::common::Rect;
|
|||
use crate::framework::context::Context;
|
||||
use crate::framework::error::GameResult;
|
||||
use crate::input::combined_menu_controller::CombinedMenuController;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
use crate::shared_game_state::{MenuCharacter, SharedGameState};
|
||||
|
||||
pub mod pause_menu;
|
||||
pub mod settings_menu;
|
||||
|
@ -74,8 +74,6 @@ pub struct Menu {
|
|||
custom_cursor: Cell<bool>,
|
||||
}
|
||||
|
||||
static QUOTE_FRAMES: [u16; 4] = [0, 1, 0, 2];
|
||||
|
||||
impl Menu {
|
||||
pub fn new(x: isize, y: isize, width: u16, height: u16) -> Menu {
|
||||
Menu {
|
||||
|
@ -216,14 +214,39 @@ impl Menu {
|
|||
}
|
||||
|
||||
if !self.custom_cursor.get() {
|
||||
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, "MyChar")?;
|
||||
let menu_texture: &str;
|
||||
let character_rect: [Rect<u16>; 4];
|
||||
|
||||
rect.left = QUOTE_FRAMES[self.anim_num as usize] * 16;
|
||||
rect.top = 16;
|
||||
rect.right = rect.left + 16;
|
||||
rect.bottom = rect.top + 16;
|
||||
match state.menu_character {
|
||||
MenuCharacter::Quote => {
|
||||
menu_texture = "MyChar";
|
||||
character_rect = state.constants.title.cursor_quote;
|
||||
}
|
||||
MenuCharacter::Curly => {
|
||||
menu_texture = "Npc/NpcRegu";
|
||||
character_rect = state.constants.title.cursor_curly;
|
||||
}
|
||||
MenuCharacter::Toroko => {
|
||||
menu_texture = "Npc/NpcRegu";
|
||||
character_rect = state.constants.title.cursor_toroko;
|
||||
}
|
||||
MenuCharacter::King => {
|
||||
menu_texture = "Npc/NpcRegu";
|
||||
character_rect = state.constants.title.cursor_king;
|
||||
}
|
||||
MenuCharacter::Sue => {
|
||||
menu_texture = "Npc/NpcRegu";
|
||||
character_rect = state.constants.title.cursor_sue;
|
||||
}
|
||||
}
|
||||
|
||||
batch.add_rect(self.x as f32, self.y as f32 + 4.0 + self.entry_y as f32, &rect);
|
||||
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, menu_texture)?;
|
||||
|
||||
batch.add_rect(
|
||||
self.x as f32,
|
||||
self.y as f32 + 4.0 + self.entry_y as f32,
|
||||
&character_rect[self.anim_num as usize],
|
||||
);
|
||||
|
||||
batch.draw(ctx)?;
|
||||
}
|
||||
|
@ -413,13 +436,12 @@ impl Menu {
|
|||
}
|
||||
}
|
||||
|
||||
// todo nikumaru counter support
|
||||
self.anim_wait += 1;
|
||||
if self.anim_wait > 8 {
|
||||
self.anim_wait = 0;
|
||||
|
||||
self.anim_num += 1;
|
||||
if self.anim_num >= QUOTE_FRAMES.len() as u16 {
|
||||
if self.anim_num >= 4 as u16 {
|
||||
self.anim_num = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::input::combined_menu_controller::CombinedMenuController;
|
|||
use crate::menu::MenuEntry;
|
||||
use crate::menu::{Menu, MenuSelectionResult};
|
||||
use crate::scene::title_scene::TitleScene;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
use crate::shared_game_state::{MenuCharacter, SharedGameState};
|
||||
|
||||
use super::settings_menu::SettingsMenu;
|
||||
|
||||
|
@ -67,6 +67,8 @@ impl PauseMenu {
|
|||
self.controller.update(state, ctx)?;
|
||||
self.controller.update_trigger();
|
||||
|
||||
state.menu_character = MenuCharacter::Quote;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::map::Map;
|
|||
use crate::menu::settings_menu::SettingsMenu;
|
||||
use crate::menu::{Menu, MenuEntry, MenuSelectionResult};
|
||||
use crate::scene::Scene;
|
||||
use crate::shared_game_state::{SharedGameState, TileSize};
|
||||
use crate::shared_game_state::{MenuCharacter, SharedGameState, TileSize};
|
||||
use crate::stage::{BackgroundType, NpcType, Stage, StageData, StageTexturePaths, Tileset};
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
|
@ -89,6 +89,33 @@ impl TitleScene {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_menu_cursor(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||
let minutes = self.nikumaru_rec.tick / (60 * state.settings.timing_mode.get_tps());
|
||||
let song_id: usize;
|
||||
|
||||
if self.nikumaru_rec.shown && minutes < 3 {
|
||||
state.menu_character = MenuCharacter::Sue;
|
||||
song_id = 2;
|
||||
} else if self.nikumaru_rec.shown && minutes < 4 {
|
||||
state.menu_character = MenuCharacter::King;
|
||||
song_id = 41;
|
||||
} else if self.nikumaru_rec.shown && minutes < 5 {
|
||||
state.menu_character = MenuCharacter::Toroko;
|
||||
song_id = 40;
|
||||
} else if self.nikumaru_rec.shown && minutes < 6 {
|
||||
state.menu_character = MenuCharacter::Curly;
|
||||
song_id = 36;
|
||||
} else {
|
||||
state.menu_character = MenuCharacter::Quote;
|
||||
song_id = 24;
|
||||
}
|
||||
|
||||
if song_id != state.sound_manager.current_song() {
|
||||
state.sound_manager.play_song(song_id, &state.constants, &state.settings, ctx)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// asset copyright for freeware version
|
||||
|
@ -99,7 +126,6 @@ impl Scene for TitleScene {
|
|||
self.controller.add(state.settings.create_player1_controller());
|
||||
self.controller.add(state.settings.create_player2_controller());
|
||||
|
||||
state.sound_manager.play_song(24, &state.constants, &state.settings, ctx)?;
|
||||
self.main_menu.push_entry(MenuEntry::Active("New game".to_string()));
|
||||
self.main_menu.push_entry(MenuEntry::Active("Load game".to_string()));
|
||||
self.main_menu.push_entry(MenuEntry::Active("Options".to_string()));
|
||||
|
@ -122,6 +148,7 @@ impl Scene for TitleScene {
|
|||
self.controller.update_trigger();
|
||||
|
||||
self.nikumaru_rec.load_counter(ctx)?;
|
||||
self.update_menu_cursor(state, ctx)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -166,6 +193,7 @@ impl Scene for TitleScene {
|
|||
_ => {}
|
||||
},
|
||||
CurrentMenu::OptionMenu => {
|
||||
let timing_mode = state.settings.timing_mode;
|
||||
let cm = &mut self.current_menu;
|
||||
self.option_menu.tick(
|
||||
&mut || {
|
||||
|
@ -175,6 +203,9 @@ impl Scene for TitleScene {
|
|||
state,
|
||||
ctx,
|
||||
)?;
|
||||
if timing_mode != state.settings.timing_mode {
|
||||
self.update_menu_cursor(state, ctx)?;
|
||||
}
|
||||
}
|
||||
CurrentMenu::StartGame => {
|
||||
if self.tick == 10 {
|
||||
|
|
|
@ -111,6 +111,15 @@ impl Season {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
pub enum MenuCharacter {
|
||||
Quote,
|
||||
Curly,
|
||||
Toroko,
|
||||
King,
|
||||
Sue,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
pub enum TileSize {
|
||||
Tile8x8,
|
||||
|
@ -167,6 +176,7 @@ pub struct SharedGameState {
|
|||
pub creditscript_vm: CreditScriptVM,
|
||||
pub lightmap_canvas: Option<Box<dyn BackendTexture>>,
|
||||
pub season: Season,
|
||||
pub menu_character: MenuCharacter,
|
||||
pub constants: EngineConstants,
|
||||
pub font: BMFontRenderer,
|
||||
pub texture_set: TextureSet,
|
||||
|
@ -270,6 +280,7 @@ impl SharedGameState {
|
|||
creditscript_vm: CreditScriptVM::new(),
|
||||
lightmap_canvas: None,
|
||||
season,
|
||||
menu_character: MenuCharacter::Quote,
|
||||
constants,
|
||||
font,
|
||||
texture_set,
|
||||
|
|
Loading…
Reference in a new issue