Skip to content

Commit

Permalink
Fix prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Sep 15, 2024
1 parent 55219d4 commit 18afb60
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ fn spawn_crosshair(mut commands: Commands, asset_server: Res<AssetServer>) {
}

fn capture_cursor(mut windows: Query<&mut Window>) {
info!("capture_cursor");
for mut window in &mut windows {
window.cursor.visible = false;
window.cursor.grab_mode = CursorGrabMode::Locked;
}
}

fn release_cursor(mut windows: Query<&mut Window>) {
info!("release_cursor");
for mut window in &mut windows {
window.cursor.visible = true;
window.cursor.grab_mode = CursorGrabMode::None;
Expand Down
2 changes: 1 addition & 1 deletion src/opportunities/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn usher_interact(
mut commands: Commands,
) {
for (action_state, mut active_interactable) in &mut q_player {
if !action_state.just_pressed(&CharacterAction::Interact) {
if active_interactable.is_none() || !action_state.just_pressed(&CharacterAction::Interact) {
continue;
}
let Some((interactable, rigid_body)) = active_interactable
Expand Down
11 changes: 8 additions & 3 deletions src/opportunities/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn show_prompt(
// The previous interactable is no longer available.
// Note that we don't check against previous values for change detection
// because this system is only run when the active interactable changes in the first place.
info!("hidder");
*prompt_visibility = Visibility::Hidden;
return;
};
Expand All @@ -48,17 +49,21 @@ fn spawn_prompt(mut commands: Commands) {
.column(|column| {
column
.label(LabelConfig::default())
.style()
.bottom(Percent(100. / 3.))
.entity_commands()
.set_text("This is label 1.", None)
.insert(PromptTextNode);
})
.style()
.position_type(PositionType::Absolute)
.bottom(Percent(1. / 3.))
.height(Val::Auto)
.width(Percent(100.0))
.height(Percent(100.0))
.align_items(AlignItems::Center)
.justify_content(JustifyContent::End)
.visibility(Visibility::Hidden)
.entity_commands()
.insert(PromptUiRootNode);
.insert((PromptUiRootNode, Name::new("Prompt UI")));
}

#[derive(Debug, Component, PartialEq, Eq, Clone, Reflect)]
Expand Down

0 comments on commit 18afb60

Please sign in to comment.