feat: Use spawn_context_menu in features/pom
This commit is contained in:
@@ -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 {
|
|
||||||
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,
|
RootMarker::ContextMenu,
|
||||||
GlobalTransform::default(),
|
screen_pos,
|
||||||
))
|
|parent| {
|
||||||
.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),
|
||||||
));
|
));
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user