Display items in inventory
This commit is contained in:
@@ -101,7 +101,7 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
CallDeferred(nameof(SetPauseMode), output.IsPaused);
|
||||
})
|
||||
.Handle((in GameLogic.Output.SetInventoryMode _) => { InventoryMenu.PopulateItems(_.Inventory); InventoryMenu.Show(); })
|
||||
.Handle((in GameLogic.Output.SetInventoryMode _) => { InventoryMenu.PopulateItems(); InventoryMenu.Show(); })
|
||||
.Handle((in GameLogic.Output.HideInventory _) => { InventoryMenu.Hide(); InventoryMenu.ClearItems(); })
|
||||
.Handle((in GameLogic.Output.ShowMiniMap _) => { MiniMap.Show(); })
|
||||
.Handle((in GameLogic.Output.HideMiniMap _) => { MiniMap.Hide(); })
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public interface IInventoryMenu : IControl
|
||||
{
|
||||
public void PopulateItems(List<IInventoryItem> items);
|
||||
public void PopulateItems();
|
||||
|
||||
public void ClearItems();
|
||||
}
|
||||
@@ -17,188 +17,82 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public IVBoxContainer ItemList { get; set; } = default!;
|
||||
[Dependency]
|
||||
public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
[Node] public TextureRect Cursor { get; set; } = default!;
|
||||
// Player Info
|
||||
[Node] public Label FloorLabel { get; set; } = default!;
|
||||
[Node] public Label CurrentLevelLabel { get; set; } = default!;
|
||||
[Node] public Label EXPValue { get; set; } = default!;
|
||||
[Node] public Label HPValue { get; set; } = default!;
|
||||
[Node] public Label HPBonusLabel { get; set; } = default!;
|
||||
[Node] public Label VTValue { get; set; } = default!;
|
||||
[Node] public Label VTBonusLabel { get; set; } = default!;
|
||||
[Node] public Label ATKValue { get; set; } = default!;
|
||||
[Node] public Label ATKBonusLabel { get; set; } = default!;
|
||||
[Node] public Label DEFValue { get; set; } = default!;
|
||||
[Node] public Label DEFBonusLabel { get; set; } = default!;
|
||||
[Node] public Label ItemDescriptionTitle { get; set; } = default!;
|
||||
[Node] public Label ItemEffectLabel { get; set; } = default!;
|
||||
|
||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
// Item Menu
|
||||
[Node] public Label BackArrow { get; set; } = default!;
|
||||
[Node] public Label ForwardArrow { get; set; } = default!;
|
||||
[Node] public Control ItemsPage { get; set; } = default!;
|
||||
|
||||
private int _currentSelection = 0;
|
||||
|
||||
public void PopulateItems(List<IInventoryItem> items)
|
||||
private enum InventoryPageNumber
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
var label = new ItemLabel(item) { Text = item.Info.Name };
|
||||
ItemList.AddChild(label);
|
||||
FirstPage,
|
||||
SecondPage
|
||||
}
|
||||
|
||||
if (ItemList.GetChildCount() > 0)
|
||||
CallDeferred(nameof(InitializeInventoryMenu));
|
||||
private InventoryPageNumber _currentPageNumber = InventoryPageNumber.FirstPage;
|
||||
|
||||
private string ITEM_SLOT_SCENE = "res://src/inventory_menu/ItemSlot.tscn";
|
||||
|
||||
private const int _itemsPerPage = 10;
|
||||
|
||||
public void PopulateItems()
|
||||
{
|
||||
var inventory = GameRepo.InventoryItems.Value;
|
||||
var numberOfItemsToDisplay = inventory.Count <= _itemsPerPage ? inventory.Count : _itemsPerPage;
|
||||
var indexToStart = _currentPageNumber == InventoryPageNumber.FirstPage ? 0 : 10;
|
||||
|
||||
ForwardArrow.Text = "";
|
||||
BackArrow.Text = "";
|
||||
|
||||
if (_currentPageNumber == InventoryPageNumber.FirstPage && inventory.Count > _itemsPerPage)
|
||||
{
|
||||
ForwardArrow.Text = "►";
|
||||
BackArrow.Text = "";
|
||||
}
|
||||
if (_currentPageNumber == InventoryPageNumber.SecondPage)
|
||||
{
|
||||
ForwardArrow.Text = "";
|
||||
BackArrow.Text = "◄";
|
||||
}
|
||||
|
||||
public void InitializeInventoryMenu()
|
||||
{
|
||||
if (ItemList.GetChildCount() > 0)
|
||||
{
|
||||
var currentItem = ItemList.GetChild<ItemLabel>(_currentSelection);
|
||||
SetCursorLocation(currentItem);
|
||||
}
|
||||
|
||||
foreach (ItemLabel item in ItemList.GetChildren())
|
||||
for (var i = indexToStart; i < numberOfItemsToDisplay + indexToStart; i++)
|
||||
{
|
||||
if (item.InventoryItem == GameRepo.EquippedWeapon || item.InventoryItem == GameRepo.EquippedArmor || item.InventoryItem == GameRepo.EquippedAccessory)
|
||||
item.EquipItem();
|
||||
var item = inventory.ElementAt(i);
|
||||
var itemScene = GD.Load<PackedScene>(ITEM_SLOT_SCENE);
|
||||
var itemSlot = itemScene.Instantiate<IItemSlot>();
|
||||
ItemsPage.AddChildEx(itemSlot);
|
||||
|
||||
itemSlot.ItemName.Text = item.Info.Name;
|
||||
itemSlot.ItemTexture.Texture = item.Info.Texture;
|
||||
itemSlot.EquipBonus.Text = "...";
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearItems()
|
||||
{
|
||||
foreach (var item in ItemList.GetChildren())
|
||||
ItemList.RemoveChild(item);
|
||||
}
|
||||
|
||||
public void SetCursorLocation(Control menuItem)
|
||||
var items = ItemsPage.GetChildren().OfType<ItemSlot>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var position = menuItem.GlobalPosition;
|
||||
var size = menuItem.Size;
|
||||
|
||||
Cursor.GlobalPosition = new Vector2(position.X, position.Y + size.Y / 2.0f) - Cursor.Size / 2.0f - new Vector2(15, -5);
|
||||
}
|
||||
|
||||
public void SetCursorToPrevious()
|
||||
{
|
||||
if (ItemList.GetChildCount() == 0)
|
||||
return;
|
||||
|
||||
if (_currentSelection > 0)
|
||||
{
|
||||
_currentSelection -= 1;
|
||||
var selectedMenuItem = ItemList.GetChild<Control>(_currentSelection);
|
||||
SetCursorLocation(selectedMenuItem);
|
||||
ItemsPage.RemoveChild(item);
|
||||
CallDeferred(nameof(item.QueueFree));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCursorToNext()
|
||||
{
|
||||
if (ItemList.GetChildCount() == 0)
|
||||
return;
|
||||
|
||||
if (_currentSelection < ItemList.GetChildCount() - 1)
|
||||
{
|
||||
_currentSelection += 1;
|
||||
var selectedMenuItem = ItemList.GetChild<Control>(_currentSelection);
|
||||
SetCursorLocation(selectedMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var input = Vector2.Zero;
|
||||
if (Input.IsActionJustPressed(GameInputs.MoveUp))
|
||||
SetCursorToPrevious();
|
||||
if (Input.IsActionJustPressed(GameInputs.MoveDown))
|
||||
SetCursorToNext();
|
||||
if (Input.IsActionJustPressed(GameInputs.Attack))
|
||||
EquipOrUnequipCurrentItem();
|
||||
if (Input.IsActionJustPressed(GameInputs.Throw))
|
||||
{
|
||||
var selectedMenuItem = ItemList.GetChild<ItemLabel>(_currentSelection);
|
||||
GameRepo.InventoryItems.Value.Remove(selectedMenuItem.InventoryItem);
|
||||
ItemList.RemoveChild(selectedMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void EquipOrUnequipCurrentItem()
|
||||
{
|
||||
if (ItemList.GetChildCount() == 0)
|
||||
return;
|
||||
|
||||
var currentlySelectedItem = ItemList.GetChild<ItemLabel>(_currentSelection);
|
||||
|
||||
if (currentlySelectedItem.InventoryItem is Weapon weapon && GameRepo.EquippedWeapon == weapon)
|
||||
{
|
||||
UnequipItem(currentlySelectedItem);
|
||||
GameRepo.OnWeaponEquipped(new Weapon());
|
||||
}
|
||||
else if (currentlySelectedItem.InventoryItem is Armor armor && GameRepo.EquippedArmor == armor)
|
||||
{
|
||||
UnequipItem(currentlySelectedItem);
|
||||
GameRepo.OnArmorEquipped(null);
|
||||
}
|
||||
else if (currentlySelectedItem.InventoryItem is Accessory accessory && GameRepo.EquippedAccessory == accessory)
|
||||
{
|
||||
UnequipItem(currentlySelectedItem);
|
||||
GameRepo.OnAccessoryEquipped(null);
|
||||
}
|
||||
else if (currentlySelectedItem.InventoryItem is IEquippable)
|
||||
EquipItem(currentlySelectedItem);
|
||||
}
|
||||
|
||||
private void EquipItem(ItemLabel currentItem) => EquipItemInternal(currentItem, (dynamic)currentItem.InventoryItem);
|
||||
|
||||
private void UnequipItem(ItemLabel item)
|
||||
{
|
||||
item.UnequipItem();
|
||||
}
|
||||
|
||||
private void EquipItemInternal(ItemLabel currentItem, Accessory accessory)
|
||||
{
|
||||
foreach (ItemLabel item in ItemList.GetChildren())
|
||||
{
|
||||
if (item.InventoryItem is Accessory)
|
||||
UnequipItem(item);
|
||||
}
|
||||
|
||||
GameRepo.OnAccessoryEquipped(accessory);
|
||||
currentItem.EquipItem();
|
||||
}
|
||||
|
||||
private void EquipItemInternal(ItemLabel currentItem, Armor armor)
|
||||
{
|
||||
foreach (ItemLabel item in ItemList.GetChildren())
|
||||
{
|
||||
if (item.InventoryItem is Armor)
|
||||
UnequipItem(item);
|
||||
}
|
||||
|
||||
GameRepo.OnArmorEquipped(armor);
|
||||
currentItem.EquipItem();
|
||||
}
|
||||
|
||||
private void EquipItemInternal(ItemLabel currentItem, Weapon weapon)
|
||||
{
|
||||
foreach (ItemLabel item in ItemList.GetChildren())
|
||||
{
|
||||
if (item.InventoryItem is Weapon)
|
||||
UnequipItem(item);
|
||||
}
|
||||
|
||||
GameRepo.OnWeaponEquipped(weapon);
|
||||
currentItem.EquipItem();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ItemLabel : Label
|
||||
{
|
||||
public ItemLabel(IInventoryItem inventoryItem)
|
||||
{
|
||||
InventoryItem = inventoryItem;
|
||||
LabelSettings = UnequippedItemFont;
|
||||
}
|
||||
|
||||
public IInventoryItem InventoryItem { get; set; } = default!;
|
||||
|
||||
private static LabelSettings UnequippedItemFont => GD.Load<LabelSettings>("res://src/inventory_menu/InventoryLabelSettings.tres");
|
||||
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/inventory_menu/EquippedInventoryLabelSettings.tres");
|
||||
|
||||
public void EquipItem()
|
||||
{
|
||||
LabelSettings = EquippedItemFont;
|
||||
}
|
||||
|
||||
public void UnequipItem()
|
||||
{
|
||||
LabelSettings = UnequippedItemFont;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,64 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dlj8qdg1c5048"]
|
||||
[gd_scene load_steps=20 format=3 uid="uid://dlj8qdg1c5048"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dr8mjn3wahdvp" path="res://src/inventory_menu/cursor.png" id="1_efrp8"]
|
||||
[ext_resource type="Script" path="res://src/inventory_menu/InventoryMenu.cs" id="1_l64wl"]
|
||||
[ext_resource type="Texture2D" uid="uid://c8tnq16qgjurc" path="res://src/ui/textures/INVENTORY-BACKGROUND.png" id="2_plijd"]
|
||||
[ext_resource type="FontFile" uid="uid://cm8j5vcdop5x0" path="res://src/ui/fonts/Mrs-Eaves-OT-Roman_31443.ttf" id="3_lm4o1"]
|
||||
[ext_resource type="FontFile" uid="uid://cb41qqmxqurj8" path="res://src/ui/fonts/FT88-Bold.ttf" id="4_rg5yb"]
|
||||
[ext_resource type="FontFile" uid="uid://dit3vylt7hmmx" path="res://src/ui/fonts/FT88-Regular.ttf" id="5_2qnnx"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="5_v2ky8"]
|
||||
[ext_resource type="LabelSettings" uid="uid://c4wbba5mo7qcp" path="res://src/ui/label_settings/MainTextFontItalicized.tres" id="6_q3oua"]
|
||||
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="6_tmdno"]
|
||||
[ext_resource type="PackedScene" uid="uid://c005nd0m2eim" path="res://src/inventory_menu/ItemSlot.tscn" id="9_0io04"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_q0afw"]
|
||||
font = ExtResource("3_lm4o1")
|
||||
font_size = 48
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_yw3yo"]
|
||||
font = ExtResource("3_lm4o1")
|
||||
font_size = 64
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_xxgnh"]
|
||||
font = ExtResource("4_rg5yb")
|
||||
font_size = 46
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_biilt"]
|
||||
font = ExtResource("5_2qnnx")
|
||||
font_size = 46
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_dot3k"]
|
||||
font = ExtResource("4_rg5yb")
|
||||
font_size = 46
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_th0sm"]
|
||||
font = ExtResource("4_rg5yb")
|
||||
font_size = 46
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ankkq"]
|
||||
font = ExtResource("4_rg5yb")
|
||||
font_size = 46
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ouwww"]
|
||||
font = ExtResource("4_rg5yb")
|
||||
font_size = 46
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_x4aj3"]
|
||||
font = ExtResource("3_lm4o1")
|
||||
font_size = 80
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_31kc7"]
|
||||
font = ExtResource("3_lm4o1")
|
||||
font_size = 80
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
|
||||
[node name="InventoryMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -14,23 +71,298 @@ size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1_l64wl")
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 1536.0
|
||||
grow_horizontal = 2
|
||||
texture = ExtResource("2_plijd")
|
||||
|
||||
[node name="InventoryInfo" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_bottom = 194.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_top = 112
|
||||
|
||||
[node name="ItemList" type="VBoxContainer" parent="CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Cursor" type="TextureRect" parent="."]
|
||||
[node name="PlayerInfo" type="VBoxContainer" parent="InventoryInfo/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 40
|
||||
|
||||
[node name="FloorBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/FloorBox"]
|
||||
custom_minimum_size = Vector2(176, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FloorLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/FloorBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = -88.0
|
||||
offset_top = -47.0
|
||||
offset_right = -48.0
|
||||
offset_bottom = -7.0
|
||||
texture = ExtResource("1_efrp8")
|
||||
layout_mode = 2
|
||||
text = "FLOOR 02"
|
||||
label_settings = SubResource("LabelSettings_q0afw")
|
||||
|
||||
[node name="LevelBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/LevelBox"]
|
||||
custom_minimum_size = Vector2(176, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CurrentLevelLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/LevelBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "LEVEL 4"
|
||||
label_settings = SubResource("LabelSettings_yw3yo")
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
custom_minimum_size = Vector2(0, 12)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="EXPBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/EXPBox"]
|
||||
custom_minimum_size = Vector2(247, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="EXPLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/EXPBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "EXP"
|
||||
label_settings = SubResource("LabelSettings_xxgnh")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/EXPBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="EXPValue" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/EXPBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "444/888"
|
||||
label_settings = SubResource("LabelSettings_biilt")
|
||||
|
||||
[node name="HPBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/HPBox"]
|
||||
custom_minimum_size = Vector2(247, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HPLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/HPBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "HP"
|
||||
label_settings = SubResource("LabelSettings_dot3k")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/HPBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HPValue" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/HPBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
text = "222/222"
|
||||
label_settings = SubResource("LabelSettings_th0sm")
|
||||
|
||||
[node name="ReferenceRect3" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/HPBox"]
|
||||
custom_minimum_size = Vector2(18, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HPBonusLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/HPBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "..."
|
||||
label_settings = ExtResource("6_tmdno")
|
||||
|
||||
[node name="VTBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/VTBox"]
|
||||
custom_minimum_size = Vector2(247, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VTLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/VTBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "VT"
|
||||
label_settings = SubResource("LabelSettings_ankkq")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/VTBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VTValue" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/VTBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
text = "444/444"
|
||||
label_settings = SubResource("LabelSettings_ouwww")
|
||||
|
||||
[node name="ReferenceRect4" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/VTBox"]
|
||||
custom_minimum_size = Vector2(18, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VTBonusLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/VTBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "..."
|
||||
label_settings = ExtResource("6_tmdno")
|
||||
|
||||
[node name="ATKBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/ATKBox"]
|
||||
custom_minimum_size = Vector2(247, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ATKLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/ATKBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "ATK"
|
||||
label_settings = SubResource("LabelSettings_ankkq")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/ATKBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ATKValue" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/ATKBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
text = "666/666"
|
||||
label_settings = SubResource("LabelSettings_ouwww")
|
||||
|
||||
[node name="ReferenceRect4" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/ATKBox"]
|
||||
custom_minimum_size = Vector2(18, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ATKBonusLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/ATKBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "+50"
|
||||
label_settings = ExtResource("6_tmdno")
|
||||
|
||||
[node name="DEFBox" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/DEFBox"]
|
||||
custom_minimum_size = Vector2(247, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DEFLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/DEFBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "DEF
|
||||
"
|
||||
label_settings = SubResource("LabelSettings_ankkq")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/DEFBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DEFValue" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/DEFBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
text = "888/888"
|
||||
label_settings = SubResource("LabelSettings_ouwww")
|
||||
|
||||
[node name="ReferenceRect4" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/DEFBox"]
|
||||
custom_minimum_size = Vector2(18, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DEFBonusLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/DEFBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "..."
|
||||
label_settings = ExtResource("6_tmdno")
|
||||
|
||||
[node name="ReferenceRect3" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
custom_minimum_size = Vector2(0, 55)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(247, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ItemDescriptionTitle" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/HBoxContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(800, 100)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
text = "Mask of the Goddess of Destruction"
|
||||
label_settings = ExtResource("6_q3oua")
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="ItemEffectLabel" type="Label" parent="InventoryInfo/HBoxContainer/PlayerInfo/HBoxContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(800, 200)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
text = "Raises ATK"
|
||||
label_settings = ExtResource("5_v2ky8")
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="ItemInfo" type="VBoxContainer" parent="InventoryInfo/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
theme_override_constants/separation = 30
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/ItemInfo"]
|
||||
custom_minimum_size = Vector2(800, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="BackArrow" type="Label" parent="InventoryInfo/HBoxContainer/ItemInfo/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
text = "◄"
|
||||
label_settings = SubResource("LabelSettings_x4aj3")
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="ItemsTitle" type="Label" parent="InventoryInfo/HBoxContainer/ItemInfo/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(600, 0)
|
||||
layout_mode = 2
|
||||
text = " ITEMS"
|
||||
label_settings = SubResource("LabelSettings_31kc7")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ForwardArrow" type="Label" parent="InventoryInfo/HBoxContainer/ItemInfo/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
text = "►"
|
||||
label_settings = SubResource("LabelSettings_x4aj3")
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="ItemsPage" type="VBoxContainer" parent="InventoryInfo/HBoxContainer/ItemInfo"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/separation = 15
|
||||
alignment = 1
|
||||
|
||||
[node name="ReferenceRect3" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/ItemInfo/ItemsPage"]
|
||||
custom_minimum_size = Vector2(0, 38)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ItemSlot" parent="InventoryInfo/HBoxContainer/ItemInfo/ItemsPage" instance=ExtResource("9_0io04")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
25
src/inventory_menu/ItemLabel.cs
Normal file
25
src/inventory_menu/ItemLabel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
|
||||
public partial class ItemLabel : Label
|
||||
{
|
||||
public ItemLabel()
|
||||
{
|
||||
LabelSettings = UnequippedItemFont;
|
||||
}
|
||||
|
||||
public IInventoryItem InventoryItem { get; set; } = default!;
|
||||
|
||||
private static LabelSettings UnequippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextRegular.tres");
|
||||
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontEquipped.tres");
|
||||
|
||||
public void EquipItem()
|
||||
{
|
||||
LabelSettings = EquippedItemFont;
|
||||
}
|
||||
|
||||
public void UnequipItem()
|
||||
{
|
||||
LabelSettings = UnequippedItemFont;
|
||||
}
|
||||
}
|
||||
25
src/inventory_menu/ItemSlot.cs
Normal file
25
src/inventory_menu/ItemSlot.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
public interface IItemSlot : IHBoxContainer
|
||||
{
|
||||
public Label EquipBonus { get; }
|
||||
|
||||
public TextureRect ItemTexture { get; }
|
||||
|
||||
public Label ItemName { get; }
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ItemSlot : HBoxContainer, IItemSlot
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public Label EquipBonus { get; set; } = default!;
|
||||
|
||||
[Node] public TextureRect ItemTexture { get; set; } = default!;
|
||||
|
||||
[Node] public Label ItemName { get; set; } = default!;
|
||||
}
|
||||
51
src/inventory_menu/ItemSlot.tscn
Normal file
51
src/inventory_menu/ItemSlot.tscn
Normal file
@@ -0,0 +1,51 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://c005nd0m2eim"]
|
||||
|
||||
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="1_ybfv1"]
|
||||
[ext_resource type="Script" path="res://src/inventory_menu/ItemSlot.cs" id="1_yttxt"]
|
||||
[ext_resource type="Texture2D" uid="uid://0r1dws4ajhdx" path="res://src/items/accessory/textures/MASK 01.PNG" id="2_7kdbd"]
|
||||
[ext_resource type="Script" path="res://src/inventory_menu/ItemLabel.cs" id="3_xlgl0"]
|
||||
[ext_resource type="FontFile" uid="uid://bohbd123672ea" path="res://src/ui/fonts/FT88-Italic.ttf" id="3_ysc8t"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_1303o"]
|
||||
font = ExtResource("3_ysc8t")
|
||||
font_size = 30
|
||||
font_color = Color(1, 0.94902, 0, 1)
|
||||
|
||||
[node name="ItemSlot" type="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(100, 60)
|
||||
offset_right = 1748.0
|
||||
offset_bottom = 85.0
|
||||
script = ExtResource("1_yttxt")
|
||||
|
||||
[node name="EquipBonus" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 50)
|
||||
layout_mode = 2
|
||||
text = "..."
|
||||
label_settings = ExtResource("1_ybfv1")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="."]
|
||||
custom_minimum_size = Vector2(40, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ItemTexture" type="TextureRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_7kdbd")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="ReferenceRect2" type="ReferenceRect" parent="."]
|
||||
custom_minimum_size = Vector2(40, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ItemName" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(500, 50)
|
||||
layout_mode = 2
|
||||
text = "Mask of the Goddess of Destruction"
|
||||
label_settings = SubResource("LabelSettings_1303o")
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 2
|
||||
script = ExtResource("3_xlgl0")
|
||||
@@ -10,7 +10,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://de55prolicl0u" path="res://src/player/slash_0004_Classic_26.png" id="6_ngag5"]
|
||||
[ext_resource type="Texture2D" uid="uid://bp0msic3uk3kc" path="res://src/player/slash_0005_Layer-1.png" id="7_tp5uu"]
|
||||
[ext_resource type="Texture2D" uid="uid://hg2kraa5nrnl" path="res://src/ui/textures/blank level symbol.png" id="10_rsd7v"]
|
||||
[ext_resource type="LabelSettings" uid="uid://cuuo43x72xcsc" path="res://src/ui/label_settings/MainTextBold.tres" id="11_6svf8"]
|
||||
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="11_6gvkm"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="12_f4uqk"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_up0v1"]
|
||||
@@ -210,7 +210,7 @@ stretch_mode = 4
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
layout_mode = 2
|
||||
text = "99"
|
||||
label_settings = ExtResource("11_6svf8")
|
||||
label_settings = ExtResource("11_6gvkm")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
@@ -227,7 +227,7 @@ size_flags_horizontal = 3
|
||||
[node name="HP" type="Label" parent="PlayerInfoUI/HBoxContainer/VBox/HBox"]
|
||||
layout_mode = 2
|
||||
text = "HP: "
|
||||
label_settings = ExtResource("11_6svf8")
|
||||
label_settings = ExtResource("11_6gvkm")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="PlayerInfoUI/HBoxContainer/VBox/HBox"]
|
||||
custom_minimum_size = Vector2(30, 0)
|
||||
@@ -246,7 +246,7 @@ layout_mode = 2
|
||||
[node name="VT" type="Label" parent="PlayerInfoUI/HBoxContainer/VBox/HBox2"]
|
||||
layout_mode = 2
|
||||
text = "VT:"
|
||||
label_settings = ExtResource("11_6svf8")
|
||||
label_settings = ExtResource("11_6gvkm")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="PlayerInfoUI/HBoxContainer/VBox/HBox2"]
|
||||
custom_minimum_size = Vector2(30, 0)
|
||||
|
||||
@@ -64,8 +64,10 @@ namespace DialogueManagerRuntime
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWaitingForInput) return;
|
||||
if (dialogueLine.Responses.Count > 0) return;
|
||||
if (!isWaitingForInput)
|
||||
return;
|
||||
if (dialogueLine.Responses.Count > 0)
|
||||
return;
|
||||
|
||||
GetViewport().SetInputAsHandled();
|
||||
|
||||
@@ -104,22 +106,6 @@ namespace DialogueManagerRuntime
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
|
||||
|
||||
public override async void _Notification(int what)
|
||||
{
|
||||
// Detect a change of locale and update the current dialogue line to show the new language
|
||||
if (what == NotificationTranslationChanged)
|
||||
{
|
||||
float visibleRatio = dialogueLabel.VisibleRatio;
|
||||
DialogueLine = await DialogueManager.GetNextDialogueLine(resource, DialogueLine.Id, temporaryGameStates);
|
||||
if (visibleRatio < 1.0f)
|
||||
{
|
||||
dialogueLabel.Call("skip_typing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async void Start(Resource dialogueResource, string title, Array<Variant> extraGameStates = null)
|
||||
{
|
||||
temporaryGameStates = extraGameStates ?? new Array<Variant>();
|
||||
|
||||
8
src/ui/label_settings/InventoryMainTextBold.tres
Normal file
8
src/ui/label_settings/InventoryMainTextBold.tres
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="LabelSettings" load_steps=2 format=3 uid="uid://ca1q6yu8blwxf"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://cb41qqmxqurj8" path="res://src/ui/fonts/FT88-Bold.ttf" id="1_v70mx"]
|
||||
|
||||
[resource]
|
||||
font = ExtResource("1_v70mx")
|
||||
font_size = 32
|
||||
font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
BIN
src/ui/textures/INVENTORY-BACKGROUND.png
Normal file
BIN
src/ui/textures/INVENTORY-BACKGROUND.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 MiB |
34
src/ui/textures/INVENTORY-BACKGROUND.png.import
Normal file
34
src/ui/textures/INVENTORY-BACKGROUND.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c8tnq16qgjurc"
|
||||
path="res://.godot/imported/INVENTORY-BACKGROUND.png-52bbab9ed91a19d32c4c01f282658810.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/ui/textures/INVENTORY-BACKGROUND.png"
|
||||
dest_files=["res://.godot/imported/INVENTORY-BACKGROUND.png-52bbab9ed91a19d32c4c01f282658810.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
Reference in New Issue
Block a user