feat: Add achievements button to HUD settings (#47)

This commit is contained in:
demenik
2025-12-11 20:21:02 +01:00
parent 8c9a27f0df
commit 52dd300ca0
3 changed files with 18 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ pub enum ButtonType {
SettingsOpen,
SettingsExit,
SettingsSave,
SettingsAchievements,
SettingsTimerChange {
input: SettingsTimerInput,
amount: i32,

View File

@@ -1,3 +1,4 @@
use crate::features::achievement::{components::AchievementProgress, ui::open_achievements_menu};
use crate::features::phase::components::TimerSettings;
use crate::features::savegame::messages::SavegameDumpMessage;
use crate::features::{inventory, shop};
@@ -151,6 +152,8 @@ fn buttons(
mut next_state: ResMut<NextState<AppState>>,
mut timer_settings: ResMut<TimerSettings>,
keys: Res<ButtonInput<KeyCode>>,
achievement_progress: Res<AchievementProgress>,
root_query: Query<(Entity, &RootMarker)>,
) {
let shift_multiplier = if keys.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight]) {
10
@@ -171,6 +174,14 @@ fn buttons(
ButtonType::SettingsSave => {
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 {
SettingsTimerInput::Minutes(timer_type) => {
timer_settings.change(timer_type, 60 * amount * shift_multiplier)

View File

@@ -27,6 +27,12 @@ pub fn open_settings(commands: &mut Commands) {
ButtonVariant::Secondary,
Node::from_padding(UiRect::all(px(10))),
|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 {
justify_content: JustifyContent::Center,