Skip to content

Commit

Permalink
show prompt exactly at custom point position
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jun 22, 2024
1 parent 710bbc8 commit e2d9c49
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pets-gd/scenes/interaction_manager.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ offset_bottom = 40.0
layout_mode = 1
anchors_preset = -1
offset_left = -160.0
offset_top = -288.0
offset_top = -48.0
offset_right = 160.0
offset_bottom = -192.0
offset_bottom = 48.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_ftgx8")
Expand Down
1 change: 1 addition & 0 deletions pets-gd/scenes/world.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ material = SubResource("ShaderMaterial_uyk0u")
offset_right = 1920.0
offset_bottom = 1080.0
color = Color(0, 0, 0, 1)
metadata/_edit_lock_ = true

[node name="Inventory" parent="UILayer" instance=ExtResource("3_jwkdy")]
unique_name_in_owner = true
Expand Down
3 changes: 3 additions & 0 deletions pets-lib/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub mod playercb {
pub mod dialogue {
use super::*;

/// Height above an interaction zone to display the prompt by default
pub const INTERACT_PROMPT_HEIGHT_OFFSET: real = 240.0;

pub const DEFAULT_VOX: &str = "_";

pub const TEXT_VISIBILITY_DELAY: f64 = 0.015;
Expand Down
2 changes: 2 additions & 0 deletions pets-lib/src/world/interaction/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use godot::engine::{Control, InputEvent, RichTextLabel};
use godot::prelude::*;

use crate::consts::dialogue::INTERACT_PROMPT_HEIGHT_OFFSET;
use crate::prelude::*;

#[derive(GodotClass)]
Expand Down Expand Up @@ -70,6 +71,7 @@ impl InteractionManager {

let pos = if custom_path.is_empty() {
zone.get_global_position()
+ Vector2::new(0.0, -INTERACT_PROMPT_HEIGHT_OFFSET)
} else {
zone.get_node_as::<Node2D>(custom_path)
.get_global_position()
Expand Down

0 comments on commit e2d9c49

Please sign in to comment.