feat: Add achievements button to HUD settings (#47)
This commit is contained in:
@@ -21,6 +21,7 @@ pub enum ButtonType {
|
|||||||
SettingsOpen,
|
SettingsOpen,
|
||||||
SettingsExit,
|
SettingsExit,
|
||||||
SettingsSave,
|
SettingsSave,
|
||||||
|
SettingsAchievements,
|
||||||
SettingsTimerChange {
|
SettingsTimerChange {
|
||||||
input: SettingsTimerInput,
|
input: SettingsTimerInput,
|
||||||
amount: i32,
|
amount: i32,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::features::achievement::{components::AchievementProgress, ui::open_achievements_menu};
|
||||||
use crate::features::phase::components::TimerSettings;
|
use crate::features::phase::components::TimerSettings;
|
||||||
use crate::features::savegame::messages::SavegameDumpMessage;
|
use crate::features::savegame::messages::SavegameDumpMessage;
|
||||||
use crate::features::{inventory, shop};
|
use crate::features::{inventory, shop};
|
||||||
@@ -151,6 +152,8 @@ fn buttons(
|
|||||||
mut next_state: ResMut<NextState<AppState>>,
|
mut next_state: ResMut<NextState<AppState>>,
|
||||||
mut timer_settings: ResMut<TimerSettings>,
|
mut timer_settings: ResMut<TimerSettings>,
|
||||||
keys: Res<ButtonInput<KeyCode>>,
|
keys: Res<ButtonInput<KeyCode>>,
|
||||||
|
achievement_progress: Res<AchievementProgress>,
|
||||||
|
root_query: Query<(Entity, &RootMarker)>,
|
||||||
) {
|
) {
|
||||||
let shift_multiplier = if keys.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight]) {
|
let shift_multiplier = if keys.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight]) {
|
||||||
10
|
10
|
||||||
@@ -171,6 +174,14 @@ fn buttons(
|
|||||||
ButtonType::SettingsSave => {
|
ButtonType::SettingsSave => {
|
||||||
savegame_messages.write(SavegameDumpMessage);
|
savegame_messages.write(SavegameDumpMessage);
|
||||||
}
|
}
|
||||||
|
ButtonType::SettingsAchievements => {
|
||||||
|
open_achievements_menu(&mut commands, &achievement_progress);
|
||||||
|
for (entity, root) in root_query.iter() {
|
||||||
|
if let RootMarker::Settings = root {
|
||||||
|
commands.entity(entity).despawn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ButtonType::SettingsTimerChange { input, amount } => match input {
|
ButtonType::SettingsTimerChange { input, amount } => match input {
|
||||||
SettingsTimerInput::Minutes(timer_type) => {
|
SettingsTimerInput::Minutes(timer_type) => {
|
||||||
timer_settings.change(timer_type, 60 * amount * shift_multiplier)
|
timer_settings.change(timer_type, 60 * amount * shift_multiplier)
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ pub fn open_settings(commands: &mut Commands) {
|
|||||||
ButtonVariant::Secondary,
|
ButtonVariant::Secondary,
|
||||||
Node::from_padding(UiRect::all(px(10))),
|
Node::from_padding(UiRect::all(px(10))),
|
||||||
|color| text("Spiel speichern", 24.0, color)
|
|color| text("Spiel speichern", 24.0, color)
|
||||||
|
),
|
||||||
|
button(
|
||||||
|
ButtonType::SettingsAchievements,
|
||||||
|
ButtonVariant::Secondary,
|
||||||
|
Node::from_padding(UiRect::all(px(10))),
|
||||||
|
|color| text("Erfolge", 24.0, color)
|
||||||
),(
|
),(
|
||||||
Node {
|
Node {
|
||||||
justify_content: JustifyContent::Center,
|
justify_content: JustifyContent::Center,
|
||||||
|
|||||||
Reference in New Issue
Block a user