Support display backpack page.
支持展示背包页面。
This commit is contained in:
parent
db0a2fa1ee
commit
adeda2f786
|
@ -37,26 +37,11 @@ position = Vector2(491, 193)
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Slot1"]
|
||||
position = Vector2(5, 0)
|
||||
shape = SubResource("RectangleShape2D_jxmys")
|
||||
debug_color = Color(0.854902, 0.14902, 0.823529, 0.419608)
|
||||
debug_color = Color(0, 0.6, 0.701961, 0.419608)
|
||||
|
||||
[node name="Marker2D" type="Marker2D" parent="."]
|
||||
position = Vector2(216, 113)
|
||||
script = ExtResource("2_6p8mv")
|
||||
|
||||
[node name="StaffOfTheUndead" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(231, 116)
|
||||
|
||||
[node name="StaffOfTheUndead2" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(113, 149)
|
||||
|
||||
[node name="StaffOfTheUndead5" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(213, 177)
|
||||
|
||||
[node name="StaffOfTheUndead6" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(290, 167)
|
||||
|
||||
[node name="StaffOfTheUndead3" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(70, 88)
|
||||
|
||||
[node name="StaffOfTheUndead4" parent="." instance=ExtResource("3_ud0w8")]
|
||||
position = Vector2(367, 85)
|
||||
|
|
|
@ -1,32 +1,54 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://dsat7xk63bfg2"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/inventory/PacksackUi.cs" id="1_jgs18"]
|
||||
[ext_resource type="Script" path="res://scripts/loader/uiLoader/PacksackUi.cs" id="1_wm4bu"]
|
||||
|
||||
[node name="PacksackUi" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 33.0
|
||||
offset_top = 81.0
|
||||
offset_right = -58.0
|
||||
offset_bottom = -35.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_jgs18")
|
||||
script = ExtResource("1_wm4bu")
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 0.294118)
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 3.0
|
||||
offset_top = -43.0
|
||||
offset_right = 43.0
|
||||
offset_bottom = -18.0
|
||||
text = "背包"
|
||||
[node name="TitleLabel" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 30.0
|
||||
grow_horizontal = 2
|
||||
text = "ui_name"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 36.0
|
||||
offset_top = 57.0
|
||||
offset_right = -34.0
|
||||
offset_bottom = -23.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="ExitButton" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -75.0
|
||||
offset_top = 8.0
|
||||
offset_right = -8.0
|
||||
offset_bottom = 41.0
|
||||
grow_horizontal = 0
|
||||
text = "ui_close"
|
||||
|
|
|
@ -211,7 +211,7 @@ text = "ui_load"
|
|||
layout_mode = 2
|
||||
text = "ui_create_room"
|
||||
|
||||
[node name="ReturnButton" type="Button" parent="HBoxContainer"]
|
||||
[node name="ExitButton" type="Button" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "ui_close"
|
||||
|
||||
|
|
|
@ -84,6 +84,14 @@ offset_right = 20.0
|
|||
offset_bottom = 25.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="BackpackUIContainer" type="Control" parent="CanvasLayer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="GameOverMenu" parent="CanvasLayer" instance=ExtResource("6_yjmrv")]
|
||||
visible = false
|
||||
|
||||
|
|
|
@ -75,4 +75,14 @@ public static class GameSceneNodeHolder
|
|||
/// <para>操作提示</para>
|
||||
/// </summary>
|
||||
public static RichTextLabel? OperationTipLabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>BackpackUiContainer</para>
|
||||
/// <para>背包Ui容器</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>The knapsack Ui container houses the container of the knapsack ui node. When a user uses a backpack, the node to which his backpack is attached is displayed from within the backpack ui container.</para>
|
||||
///<para>背包Ui容器内存放的是背包ui节点的容器。当用户使用背包时,会从背包ui容器内将其背包对于的节点展示出来。</para>
|
||||
/// </remarks>
|
||||
public static Control? BackpackUiContainer { get; set; }
|
||||
}
|
|
@ -176,7 +176,8 @@ public class UniversalItemContainer : IItemContainer
|
|||
|
||||
public ItemSlotNode? Match(IItemStack stack)
|
||||
{
|
||||
return _itemSlotNodes?.FirstOrDefault(itemSlotNode => itemSlotNode.CanAddItem(stack.GetItem()!));
|
||||
var item = stack.GetItem();
|
||||
return item == null ? null : _itemSlotNodes?.FirstOrDefault(itemSlotNode => itemSlotNode.CanAddItem(item));
|
||||
}
|
||||
|
||||
public ItemSlotNode? Match(Func<ItemSlotNode, bool> predicate)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using ColdMint.scripts.pickable;
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
using PacksackUi = ColdMint.scripts.loader.uiLoader.PacksackUi;
|
||||
|
||||
namespace ColdMint.scripts.item;
|
||||
|
||||
|
@ -34,6 +35,11 @@ public partial class Packsack : PickAbleTemplate
|
|||
if (_packsackUi == null)
|
||||
{
|
||||
_packsackUi = NodeUtils.InstantiatePackedScene<PacksackUi>(_packedScene,this);
|
||||
if (_packsackUi != null)
|
||||
{
|
||||
_packsackUi.Title = Name;
|
||||
_packsackUi.ItemContainer = ItemContainer;
|
||||
}
|
||||
}
|
||||
_packsackUi?.Show();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,10 @@ public partial class GameSceneLoader : SceneLoaderTemplate
|
|||
//加载HotBar
|
||||
var hotBar = GetNode<HotBar>("CanvasLayer/Control/VBoxContainer/HotBar");
|
||||
GameSceneNodeHolder.HotBar = hotBar;
|
||||
//Backpack Ui container
|
||||
//背包Ui容器
|
||||
var backpackUiContainer = GetNode<Control>("CanvasLayer/BackpackUIContainer");
|
||||
GameSceneNodeHolder.BackpackUiContainer = backpackUiContainer;
|
||||
//Load operation prompt
|
||||
//加载操作提示
|
||||
var operationTip = GetNode<RichTextLabel>("CanvasLayer/Control/VBoxContainer/OperationTip");
|
||||
|
|
|
@ -308,9 +308,9 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
};
|
||||
}
|
||||
|
||||
if (_nodeBinding.ReturnButton != null)
|
||||
if (_nodeBinding.ExitButton != null)
|
||||
{
|
||||
_nodeBinding.ReturnButton.Pressed += () =>
|
||||
_nodeBinding.ExitButton.Pressed += () =>
|
||||
{
|
||||
if (_mainMenu == null)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
using ColdMint.scripts.utils;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.inventory;
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.inventory;
|
||||
namespace ColdMint.scripts.loader.uiLoader;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Backpack UI</para>
|
||||
/// <para>背包UI</para>
|
||||
/// </summary>
|
||||
public partial class PacksackUi : Control
|
||||
public partial class PacksackUi : UiLoaderTemplate
|
||||
{
|
||||
private IItemContainer? _itemContainer;
|
||||
|
||||
|
@ -15,6 +17,26 @@ public partial class PacksackUi : Control
|
|||
|
||||
private GridContainer? _gridContainer;
|
||||
|
||||
private Label? _titleLabel;
|
||||
|
||||
private string? _title;
|
||||
|
||||
private Button? _exitButton;
|
||||
|
||||
/// <summary>
|
||||
/// <para>title</para>
|
||||
/// <para>标题</para>
|
||||
/// </summary>
|
||||
public string? Title
|
||||
{
|
||||
get => _title;
|
||||
set
|
||||
{
|
||||
_title = value;
|
||||
SetTile(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Packsack</para>
|
||||
/// <para>背包</para>
|
||||
|
@ -48,13 +70,43 @@ public partial class PacksackUi : Control
|
|||
}
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
/// <summary>
|
||||
/// <para>SetTile</para>
|
||||
/// <para>设置标题</para>
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
private void SetTile(string? title)
|
||||
{
|
||||
if (_titleLabel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_titleLabel.Text = title;
|
||||
}
|
||||
|
||||
public override void InitializeData()
|
||||
{
|
||||
_packedScene = GD.Load<PackedScene>("res://prefab/ui/ItemSlot.tscn");
|
||||
}
|
||||
|
||||
public override void InitializeUi()
|
||||
{
|
||||
_gridContainer = GetNode<GridContainer>("GridContainer");
|
||||
_titleLabel = GetNode<Label>("TitleLabel");
|
||||
_exitButton = GetNode<Button>("ExitButton");
|
||||
_gridContainer.Columns = Config.HotBarSize;
|
||||
//If the item container was set before this node was placed in the node tree, load it here.
|
||||
//若物品容器在此节点放置到节点树之前被设置了,那么在这里加载。
|
||||
PlaceItemSlot(_itemContainer);
|
||||
SetTile(_title);
|
||||
}
|
||||
|
||||
public override void LoadUiActions()
|
||||
{
|
||||
if (_exitButton != null)
|
||||
{
|
||||
_exitButton.Pressed += Hide;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public class LevelGraphEditorBinding : INodeBinding
|
|||
public LineEdit? RoomNameLineEdit;
|
||||
public LineEdit? RoomDescriptionLineEdit;
|
||||
public Button? CreateRoomButton;
|
||||
public Button? ReturnButton;
|
||||
public Button? ExitButton;
|
||||
public TextEdit? RoomTemplateCollectionTextEdit;
|
||||
public Label? RoomTemplateTipsLabel;
|
||||
public Button? ShowSavePanelButton;
|
||||
|
@ -48,7 +48,7 @@ public class LevelGraphEditorBinding : INodeBinding
|
|||
GraphEdit = root.GetNode<GraphEdit>("GraphEdit");
|
||||
DeleteSelectedNodeButton = root.GetNode<Button>("HBoxContainer/DeleteSelectedNodeButton");
|
||||
ShowCreateRoomPanelButton = root.GetNode<Button>("HBoxContainer/ShowCreateRoomPanelButton");
|
||||
ReturnButton = root.GetNode<Button>("HBoxContainer/ReturnButton");
|
||||
ExitButton = root.GetNode<Button>("HBoxContainer/ExitButton");
|
||||
CreateOrEditorPanel = root.GetNode<Panel>("CreateOrEditorPanel");
|
||||
HideCreateRoomPanelButton = root.GetNode<Button>("CreateOrEditorPanel/HideCreateRoomPanelButton");
|
||||
RoomNameLineEdit = root.GetNode<LineEdit>("CreateOrEditorPanel/RoomNameLineEdit");
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.inventory;
|
||||
using ColdMint.scripts.item;
|
||||
using ColdMint.scripts.item.weapon;
|
||||
using Godot;
|
||||
using PacksackUi = ColdMint.scripts.loader.uiLoader.PacksackUi;
|
||||
|
||||
|
||||
namespace ColdMint.scripts.utils;
|
||||
|
@ -129,6 +131,11 @@ public static class NodeUtils
|
|||
{
|
||||
return GameSceneNodeHolder.PacksackContainer;
|
||||
}
|
||||
|
||||
if (GameSceneNodeHolder.BackpackUiContainer!=null && childNode is PacksackUi)
|
||||
{
|
||||
return GameSceneNodeHolder.BackpackUiContainer;
|
||||
}
|
||||
return defaultParentNode;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user