diff --git a/src/features/pom/ui/context_menu.rs b/src/features/pom/ui/context_menu.rs index b62e9ff..b8b5b84 100644 --- a/src/features/pom/ui/context_menu.rs +++ b/src/features/pom/ui/context_menu.rs @@ -19,7 +19,7 @@ pub enum ButtonType { Cancel, } -pub fn spawn_context_menu( +pub fn open_context_menu( mut commands: Commands, mut tile_click_messages: MessageReader, root_query: Query>, @@ -57,22 +57,11 @@ pub fn spawn_context_menu( let options = InteractionAction::list_options(tile_state, &inventory, item_query, &game_config); - commands - .spawn(( - Node { - position_type: PositionType::Absolute, - left: px(screen_pos.x), - top: px(screen_pos.y), - padding: UiRect::all(px(5.0)), - ..Node::vstack(px(5.0)) - }, - ZIndex(100), - BackgroundColor(Color::srgb(0.1, 0.1, 0.1)), - BorderRadius::all(px(5)), - RootMarker::ContextMenu, - GlobalTransform::default(), - )) - .with_children(|parent| { + spawn_context_menu( + &mut commands, + RootMarker::ContextMenu, + screen_pos, + |parent| { for option in options { parent.spawn(button( ButtonType::Interact { @@ -98,7 +87,8 @@ pub fn spawn_context_menu( }, |c| text("Abbrechen", 20.0, c), )); - }); + }, + ); } } } diff --git a/src/features/pom/ui/mod.rs b/src/features/pom/ui/mod.rs index 37ba9c8..a59c0ca 100644 --- a/src/features/pom/ui/mod.rs +++ b/src/features/pom/ui/mod.rs @@ -8,7 +8,7 @@ impl Plugin for PomUiPlugin { fn build(&self, app: &mut App) { app.add_systems( Update, - context_menu::spawn_context_menu.run_if(in_state(AppState::GameScreen)), + context_menu::open_context_menu.run_if(in_state(AppState::GameScreen)), ); app.add_systems( Update,