Fiddle with UI

This commit is contained in:
2024-09-10 20:38:22 -07:00
parent 7268cb445a
commit 0c9b1cd689
5 changed files with 55 additions and 35 deletions

View File

@@ -2,3 +2,6 @@
# CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
dotnet_diagnostic.CS8632.severity = silent
# CS1998: Async method lacks 'await' operators and will run synchronously
dotnet_diagnostic.CS1998.severity = silent

View File

@@ -51,10 +51,16 @@ ui_accept={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_select={
"deadzone": 0.5,
"events": []
}
ui_cancel={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null)
]
}
ui_left={
@@ -89,24 +95,28 @@ MoveUp={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
MoveLeft={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
MoveRight={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
MoveDown={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
Attack={
@@ -118,6 +128,7 @@ Attack={
Sprint={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":7,"pressure":0.0,"pressed":true,"script":null)
]
}
MiniMap={
@@ -132,9 +143,11 @@ Inventory={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
}
Throw={
Cancel={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
StrafeLeft={

View File

@@ -22,7 +22,17 @@ public partial class InventoryMenu : Control, IInventoryMenu
[Dependency]
public IGame Game => this.DependOn<IGame>();
// Player Info
private InventoryPageNumber _currentPageNumber = InventoryPageNumber.FirstPage;
private string ITEM_SLOT_SCENE = "res://src/inventory_menu/ItemSlot.tscn";
private const int _itemsPerPage = 10;
private int _currentIndex = 0;
private IItemSlot[] ItemSlots => ItemsPage.GetChildren().OfType<IItemSlot>().ToArray();
#region Control Nodes
[Node] public Label FloorLabel { get; set; } = default!;
[Node] public Label CurrentLevelLabel { get; set; } = default!;
[Node] public Label EXPValue { get; set; } = default!;
@@ -47,6 +57,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
[Node] public Button UseButton { get; set; } = default!;
[Node] public Button ThrowButton { get; set; } = default!;
[Node] public Button DropButton { get; set; } = default!;
#endregion
public void OnReady()
{
@@ -55,24 +66,15 @@ public partial class InventoryMenu : Control, IInventoryMenu
DropButton.Pressed += DropButtonPressed;
}
private InventoryPageNumber _currentPageNumber = InventoryPageNumber.FirstPage;
private string ITEM_SLOT_SCENE = "res://src/inventory_menu/ItemSlot.tscn";
private const int _itemsPerPage = 10;
private int _currentIndex = 0;
private IItemSlot[] ItemSlots => ItemsPage.GetChildren().OfType<IItemSlot>().ToArray();
public async Task RedrawInventory()
{
await HideUserActionPrompt();
ClearItems();
await ClearItems();
PopulateInventory();
PopulatePlayerInfo();
}
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
public override void _UnhandledInput(InputEvent @event)
{
if (ItemSlots.Length == 0)
@@ -107,6 +109,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
DisplayUserActionPrompt();
}
}
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
private void PopulateItems()
{
@@ -114,12 +117,12 @@ public partial class InventoryMenu : Control, IInventoryMenu
PopulatePlayerInfo();
}
private void ClearItems()
private async Task ClearItems()
{
foreach (var item in ItemSlots)
ItemsPage.RemoveChildEx(item);
HideUserActionPrompt();
await HideUserActionPrompt();
}
private void PopulatePlayerInfo()
@@ -205,9 +208,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
DropButton.Hide();
}
private async void ChangeInventoryPage(InventoryPageNumber pageToChangeTo)
private async Task ChangeInventoryPage(InventoryPageNumber pageToChangeTo)
{
ClearItems();
await ClearItems();
await ToSignal(GetTree().CreateTimer(0.1f), "timeout");
_currentIndex = 0;
_currentPageNumber = pageToChangeTo;
@@ -255,7 +258,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
}
}
private async void SetToUnselectedStyle(IItemSlot itemSlot)
private async Task SetToUnselectedStyle(IItemSlot itemSlot)
{
await ToSignal(GetTree().CreateTimer(0.1f), "timeout");
itemSlot.SetItemStyle();
@@ -263,7 +266,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
itemSlot.SetEquippedItemStyle();
}
private async void SetToSelectedStyle(IItemSlot itemSlot)
private async Task SetToSelectedStyle(IItemSlot itemSlot)
{
await ToSignal(GetTree().CreateTimer(0.1f), "timeout");
itemSlot.SetSelectedItemStyle();
@@ -273,7 +276,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
ItemEffectLabel.Text = $"{itemSlot.Item.Info.Description}";
}
private async void EquipOrUnequipItem()
private async Task EquipOrUnequipItem()
{
var itemSlot = ItemSlots[_currentIndex];
await ToSignal(GetTree().CreateTimer(0.2f), "timeout");
@@ -316,7 +319,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
{
var currentItem = ItemSlots[_currentIndex].Item;
if (currentItem is IEquipable)
EquipOrUnequipItem();
await EquipOrUnequipItem();
if (currentItem is ConsumableItem consumable)
consumable.Use();

View File

@@ -52,7 +52,7 @@ public partial class Npc : Node3D
public override void _UnhandledInput(InputEvent @event)
{
if (@event.IsActionPressed(GameInputs.Throw) && _isInDialogueZone)
if (@event.IsActionPressed(GameInputs.Cancel) && _isInDialogueZone)
{
if (_isIntroductionComplete)
DialogueController.ShowDialogue(Dialogue, "general");

View File

@@ -92,8 +92,8 @@ Panel/styles/panel = SubResource("StyleBoxFlat_uy0d5")
[node name="DialogueBalloon" type="CanvasLayer"]
layer = 100
script = ExtResource("1_okfmu")
NextAction = "Throw"
SkipAction = "Throw"
NextAction = "ui_cancel"
SkipAction = "ui_accept"
[node name="Balloon" type="Control" parent="."]
unique_name_in_owner = true
@@ -105,27 +105,27 @@ grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_qq3yp")
[node name="CenterContainer2" type="CenterContainer" parent="Balloon"]
[node name="Dialogue" type="CenterContainer" parent="Balloon"]
custom_minimum_size = Vector2(1000, 250)
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -331.0
offset_top = -254.0
grow_horizontal = 2
grow_vertical = 0
size_flags_vertical = 3
[node name="Dialogue" type="MarginContainer" parent="Balloon/CenterContainer2"]
custom_minimum_size = Vector2(1000, 300)
[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/Dialogue"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/CenterContainer2/Dialogue"]
layout_mode = 2
[node name="CharacterLabel" type="RichTextLabel" parent="Balloon/CenterContainer2/Dialogue/VBoxContainer"]
[node name="CharacterLabel" type="RichTextLabel" parent="Balloon/Dialogue/VBoxContainer"]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0.501961)
custom_minimum_size = Vector2(800, 50)
layout_mode = 2
size_flags_vertical = 3
mouse_filter = 1
theme_override_colors/default_color = Color(0.737255, 0.705882, 0.690196, 1)
theme_override_fonts/normal_font = ExtResource("3_bc8ok")
@@ -138,8 +138,9 @@ text = "Character"
fit_content = true
scroll_active = false
[node name="DialogueLabel" parent="Balloon/CenterContainer2/Dialogue/VBoxContainer" instance=ExtResource("2_jm6sr")]
[node name="DialogueLabel" parent="Balloon/Dialogue/VBoxContainer" instance=ExtResource("2_jm6sr")]
unique_name_in_owner = true
custom_minimum_size = Vector2(800, 200)
layout_mode = 2
size_flags_vertical = 3
theme_override_fonts/normal_font = ExtResource("2_c4c1f")
@@ -151,7 +152,7 @@ theme_override_styles/focus = SubResource("StyleBoxEmpty_wv0ko")
theme_override_styles/normal = SubResource("StyleBoxEmpty_dboi3")
text = "I do not know thee but I perceive thine sorrows vividly,
for I am embraced by their brethren."
fit_content = false
skip_action = &"ui_accept"
[node name="CenterContainer" type="CenterContainer" parent="Balloon"]
layout_mode = 1