Add prompts
This commit is contained in:
parent
5331087313
commit
fea4df8284
@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Hud.cs" id="1_hvqpl"]
|
||||
|
||||
[node name="HUD" type="Control" node_paths=PackedStringArray("HoverText", "CameraHeightContainer", "CameraHeightSlider")]
|
||||
[node name="HUD" type="Control" node_paths=PackedStringArray("HoverText", "CameraHeightContainer", "CameraHeightSlider", "CornerPrompt")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -14,6 +14,7 @@ script = ExtResource("1_hvqpl")
|
||||
HoverText = NodePath("CenterContainer2/HoverText")
|
||||
CameraHeightContainer = NodePath("CameraHeightContainer")
|
||||
CameraHeightSlider = NodePath("CameraHeightContainer/CameraHeightSlider")
|
||||
CornerPrompt = NodePath("TableRecallPrompt")
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
@ -56,23 +57,25 @@ horizontal_alignment = 1
|
||||
|
||||
[node name="CenterContainer2" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -94.0
|
||||
offset_top = -118.59
|
||||
offset_right = 95.0
|
||||
offset_bottom = -73.59
|
||||
offset_top = -134.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="HoverText" type="RichTextLabel" parent="CenterContainer2"]
|
||||
[node name="HoverText" type="Label" parent="CenterContainer2"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/normal_font_size = 32
|
||||
bbcode_enabled = true
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "[Hover Text]"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="TableRecallPrompt" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
offset_left = 34.0
|
||||
offset_top = 22.0
|
||||
offset_right = 314.0
|
||||
offset_bottom = 67.0
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "[Table Recall Text]"
|
||||
|
@ -26,6 +26,7 @@ namespace Gmtk24 {
|
||||
Name = "BuildingBlock";
|
||||
FreezeMode = FreezeModeEnum.Kinematic;
|
||||
CanSleep = false;
|
||||
InteractName = "Pick Up";
|
||||
}
|
||||
|
||||
public override void _Ready() {
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Gmtk24 {
|
||||
@ -6,16 +8,20 @@ namespace Gmtk24 {
|
||||
[Export]
|
||||
public Player Player;
|
||||
[Export]
|
||||
public RichTextLabel HoverText;
|
||||
public Label HoverText;
|
||||
[Export]
|
||||
public bool InteractionPaused = false;
|
||||
[Export]
|
||||
public Container CameraHeightContainer;
|
||||
[Export]
|
||||
public Slider CameraHeightSlider;
|
||||
[Export]
|
||||
public Label CornerPrompt;
|
||||
|
||||
private Interactible Hovered;
|
||||
|
||||
private Dictionary<string, string> ButtonNames = new();
|
||||
|
||||
public override void _Process(double delta) {
|
||||
if (Player == null)
|
||||
return;
|
||||
@ -30,24 +36,48 @@ namespace Gmtk24 {
|
||||
}
|
||||
|
||||
|
||||
if (!InteractionPaused && collider is Interactible interactible) {
|
||||
if (interactible != Hovered) {
|
||||
Hovered?.SetHovered(false);
|
||||
interactible.SetHovered(true);
|
||||
if (!InteractionPaused) {
|
||||
if (collider is Interactible interactible) {
|
||||
if (interactible != Hovered) {
|
||||
Hovered?.SetHovered(false);
|
||||
interactible.SetHovered(true);
|
||||
}
|
||||
|
||||
Hovered = interactible;
|
||||
|
||||
HoverText.Text = $"{FormButtonNames("interact")}: {interactible.InteractName}";
|
||||
} else {
|
||||
HoverText.Text = "";
|
||||
}
|
||||
|
||||
Hovered = interactible;
|
||||
|
||||
StringBuilder Builder = new StringBuilder();
|
||||
foreach (var e in InputMap.ActionGetEvents("interact")) {
|
||||
Builder.Append($"{e.AsText().Replace("(Physical)", "")}: {interactible.InteractName}");
|
||||
}
|
||||
|
||||
HoverText.Text = Builder.ToString();
|
||||
} else {
|
||||
Hovered?.SetHovered(false);
|
||||
Hovered = null;
|
||||
HoverText.Text = "";
|
||||
if (Player.Table.Orbit.HeldBlock != null) {
|
||||
var release = FormButtonNames("release_block");
|
||||
var place = FormButtonNames("place_block");
|
||||
var rotate_right = FormButtonNames("rotate_block_right");
|
||||
var rotate_left = FormButtonNames("rotate_block_left");
|
||||
HoverText.Text = $"{place}: Place Block\n{release}: Throw Block\nRotate Block: ({rotate_right}/{rotate_left})";
|
||||
} else {
|
||||
HoverText.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!Player.Table.Orbit.IsEnabled) {
|
||||
var names = FormButtonNames("toggle_table");
|
||||
if (Player.Table.IsEnabled)
|
||||
CornerPrompt.Text = $"{names}: {"Recall Table"}";
|
||||
else
|
||||
CornerPrompt.Text = $"{names}: {"Spawn Table"}";
|
||||
} else {
|
||||
if (Player.Table.Orbit.HeldBlock == null) {
|
||||
var zoom_out = FormButtonNames("zoom_orbit_out");
|
||||
var zoom_in = FormButtonNames("zoom_orbit_out");
|
||||
var drag = FormButtonNames("drag_orbit");
|
||||
CornerPrompt.Text = $"Zoom: {zoom_in}/{zoom_out}\nDrag: {drag}";
|
||||
} else {
|
||||
CornerPrompt.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,5 +87,19 @@ namespace Gmtk24 {
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
}
|
||||
|
||||
private string FormButtonNames(string actionName) {
|
||||
if (!ButtonNames.ContainsKey(actionName)) {
|
||||
ButtonNames.Add(actionName, InputMap.ActionGetEvents(actionName)
|
||||
.Select(e => e.AsText().Replace(" (Physical)", ""))
|
||||
.Aggregate((a, b) => $"{a}, {b}"));
|
||||
}
|
||||
|
||||
return ButtonNames[actionName];
|
||||
}
|
||||
|
||||
public void ResetPromptCache() {
|
||||
ButtonNames.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@ -93,7 +93,7 @@ namespace Gmtk24 {
|
||||
if (!IsEnabled)
|
||||
return;
|
||||
|
||||
if (@event.IsAction("toggle_pause_menu")) {
|
||||
if (@event.IsAction("toggle_pause_menu") && HeldBlock == null) {
|
||||
SetEnabled(false);
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user