feat: Use spawn_context_menu in features/pom

This commit is contained in:
demenik
2025-12-09 13:34:12 +01:00
parent bd89ac7435
commit e2b6e6ab0a
2 changed files with 9 additions and 19 deletions

View File

@@ -19,7 +19,7 @@ pub enum ButtonType {
Cancel, Cancel,
} }
pub fn spawn_context_menu( pub fn open_context_menu(
mut commands: Commands, mut commands: Commands,
mut tile_click_messages: MessageReader<TileClickMessage>, mut tile_click_messages: MessageReader<TileClickMessage>,
root_query: Query<Entity, With<RootMarker>>, root_query: Query<Entity, With<RootMarker>>,
@@ -57,22 +57,11 @@ pub fn spawn_context_menu(
let options = let options =
InteractionAction::list_options(tile_state, &inventory, item_query, &game_config); InteractionAction::list_options(tile_state, &inventory, item_query, &game_config);
commands spawn_context_menu(
.spawn(( &mut commands,
Node { RootMarker::ContextMenu,
position_type: PositionType::Absolute, screen_pos,
left: px(screen_pos.x), |parent| {
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| {
for option in options { for option in options {
parent.spawn(button( parent.spawn(button(
ButtonType::Interact { ButtonType::Interact {
@@ -98,7 +87,8 @@ pub fn spawn_context_menu(
}, },
|c| text("Abbrechen", 20.0, c), |c| text("Abbrechen", 20.0, c),
)); ));
}); },
);
} }
} }
} }

View File

@@ -8,7 +8,7 @@ impl Plugin for PomUiPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems( app.add_systems(
Update, 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( app.add_systems(
Update, Update,