Skip to content

Commit

Permalink
Merge pull request #88 from thombruce/feat/menu-nav
Browse files Browse the repository at this point in the history
Feat/menu nav
  • Loading branch information
thombruce authored Nov 6, 2023
2 parents d6a2bcc + 2246b34 commit b0f5f7d
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 75 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- New start menu with "New Game", "Credits" and "Quit" buttons

### Changed

- Changed basic English (US) translations for start menu
- Changed basic Russian (RU) translations for start menu
- Changed basic German (DE) translations for start menu

## [0.0.22] - 2023-11-03

### Added
Expand Down
92 changes: 92 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
bevy = "0.11.3"
bevy-inspector-egui = "0.20.0"
bevy-ui-navigation = "0.32.0"
bevy_asset_loader = { version = "0.17.0", features = ["2d"] }
bevy_common_assets = { version = "0.7.0", features = ["ron"] }
bevy_fluent = "0.7.0"
Expand Down
6 changes: 4 additions & 2 deletions assets/locales/de/de-DE/start_menu.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
press-start = Drücke Start
credits-prompt = Drücken Sie „C“ für Credits
new-game = Neues Spiel
settings = Einstellungen
credits = Credits
quit = Aufhören
6 changes: 4 additions & 2 deletions assets/locales/en/en-US/start_menu.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
press-start = Press Start
credits-prompt = Press 'C' for Credits
new-game = New Game
settings = Settings
credits = Credits
quit = Quit
6 changes: 4 additions & 2 deletions assets/locales/ru/ru-RU/start_menu.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
press-start = нажмите старт
credits-prompt = Нажмите «C», чтобы получить кредиты
new-game = Новая игра
settings = Настройки
credits = Кредиты
quit = Покидать
11 changes: 10 additions & 1 deletion src/inputs/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ use leafwing_input_manager::prelude::*;

#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)]
pub enum MenuAction {
Select,
Start,
Credits,
Quit,
}

pub fn menu_input_map() -> InputMap<MenuAction> {
let mut input_map = InputMap::<MenuAction>::new([
(KeyCode::Return, MenuAction::Start),
// Action Keys
(KeyCode::Return, MenuAction::Select),
// Hotkeys
(KeyCode::N, MenuAction::Start),
(KeyCode::C, MenuAction::Credits),
(KeyCode::Q, MenuAction::Quit),
]);
// Action Buttons
input_map.insert(GamepadButtonType::South, MenuAction::Select);
// Hotkey Buttons
input_map.insert(GamepadButtonType::Start, MenuAction::Start);
input_map.insert(GamepadButtonType::North, MenuAction::Credits);

Expand Down
7 changes: 7 additions & 0 deletions src/systems/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy::prelude::*;
use bevy_ui_navigation::prelude::NavRequestSystem;

pub mod events;
pub mod states;
Expand Down Expand Up @@ -133,6 +134,12 @@ impl Plugin for SystemsPlugin {
Update,
start_menu::menu_input_system.run_if(is_in_menu_state),
);
app.add_systems(
Update,
start_menu::menu_focus_system
.after(NavRequestSystem)
.run_if(is_in_menu_state),
);

app.add_systems(
Update,
Expand Down
Loading

0 comments on commit b0f5f7d

Please sign in to comment.