mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-15 18:32:48 +00:00
add gamepad jukebox indicators
This commit is contained in:
parent
398f610c09
commit
4a6b2c4400
|
@ -11,6 +11,7 @@ use crate::input::combined_menu_controller::CombinedMenuController;
|
||||||
use crate::map::Map;
|
use crate::map::Map;
|
||||||
use crate::scene::title_scene::TitleScene;
|
use crate::scene::title_scene::TitleScene;
|
||||||
use crate::scene::Scene;
|
use crate::scene::Scene;
|
||||||
|
use crate::settings::ControllerType;
|
||||||
use crate::shared_game_state::{SharedGameState, TileSize};
|
use crate::shared_game_state::{SharedGameState, TileSize};
|
||||||
use crate::stage::{BackgroundType, NpcType, Stage, StageData, StageTexturePaths, Tileset};
|
use crate::stage::{BackgroundType, NpcType, Stage, StageData, StageTexturePaths, Tileset};
|
||||||
pub struct JukeboxScene {
|
pub struct JukeboxScene {
|
||||||
|
@ -284,20 +285,45 @@ impl Scene for JukeboxScene {
|
||||||
ctx,
|
ctx,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Write chevrons
|
// Write soundtrack switch indicators
|
||||||
|
|
||||||
let left_chevron = "<";
|
if state.settings.touch_controls || state.settings.player1_controller_type == ControllerType::Keyboard {
|
||||||
let right_chevron = ">";
|
let prev_chevron = "<";
|
||||||
|
let next_chevron = ">";
|
||||||
|
|
||||||
state.font.draw_text(left_chevron.chars(), init_x, 20.0, &state.constants, &mut state.texture_set, ctx)?;
|
state.font.draw_text(prev_chevron.chars(), init_x, 20.0, &state.constants, &mut state.texture_set, ctx)?;
|
||||||
state.font.draw_text(
|
state.font.draw_text(
|
||||||
right_chevron.chars(),
|
next_chevron.chars(),
|
||||||
state.canvas_size.0 - init_x - state.font.text_width(right_chevron.chars(), &state.constants),
|
state.canvas_size.0 - init_x - state.font.text_width(next_chevron.chars(), &state.constants),
|
||||||
20.0,
|
20.0,
|
||||||
&state.constants,
|
&state.constants,
|
||||||
&mut state.texture_set,
|
&mut state.texture_set,
|
||||||
ctx,
|
ctx,
|
||||||
)?;
|
)?;
|
||||||
|
} else {
|
||||||
|
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, "buttons")?;
|
||||||
|
|
||||||
|
let gamepad_sprite_offset = match state.settings.player1_controller_type {
|
||||||
|
ControllerType::Keyboard => 1,
|
||||||
|
ControllerType::Gamepad(index) => ctx.gamepad_context.get_gamepad_sprite_offset(index as usize),
|
||||||
|
};
|
||||||
|
|
||||||
|
let prev_rect = state
|
||||||
|
.settings
|
||||||
|
.player1_controller_button_map
|
||||||
|
.prev_weapon
|
||||||
|
.get_rect(gamepad_sprite_offset, &state.constants);
|
||||||
|
let next_rect = state
|
||||||
|
.settings
|
||||||
|
.player1_controller_button_map
|
||||||
|
.next_weapon
|
||||||
|
.get_rect(gamepad_sprite_offset, &state.constants);
|
||||||
|
|
||||||
|
batch.add_rect(init_x, 15.0, &prev_rect);
|
||||||
|
batch.add_rect(state.canvas_size.0 - init_x - next_rect.width() as f32, 15.0, &next_rect);
|
||||||
|
|
||||||
|
batch.draw(ctx)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue