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,
}
pub fn spawn_context_menu(
pub fn open_context_menu(
mut commands: Commands,
mut tile_click_messages: MessageReader<TileClickMessage>,
root_query: Query<Entity, With<RootMarker>>,
@@ -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)),
spawn_context_menu(
&mut commands,
RootMarker::ContextMenu,
GlobalTransform::default(),
))
.with_children(|parent| {
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),
));
});
},
);
}
}
}

View File

@@ -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,