diff --git a/DungeonShooting_Godot/prefab/ui/Encyclopedia.tscn b/DungeonShooting_Godot/prefab/ui/Encyclopedia.tscn index c638dc8..0492f40 100644 --- a/DungeonShooting_Godot/prefab/ui/Encyclopedia.tscn +++ b/DungeonShooting_Godot/prefab/ui/Encyclopedia.tscn @@ -116,47 +116,23 @@ anchor_top = 1.0 anchor_bottom = 1.0 offset_left = 16.0 -offset_top = -52.0 -offset_right = 80.0 +offset_top = -68.0 +offset_right = 96.0 offset_bottom = 4.0 grow_vertical = 0 texture_normal = ExtResource("4_nm64b") -[node name="TabButton2" type="TextureButton" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control"] +[node name="Icon" type="TextureRect" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control/TabButton"] layout_mode = 1 -anchors_preset = 2 -anchor_top = 1.0 +anchors_preset = 15 +anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = 80.0 -offset_top = -52.0 -offset_right = 144.0 -offset_bottom = 4.0 -grow_vertical = 0 -texture_normal = ExtResource("4_nm64b") - -[node name="TabButton3" type="TextureButton" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control"] -layout_mode = 1 -anchors_preset = 2 -anchor_top = 1.0 -anchor_bottom = 1.0 -offset_left = 144.0 -offset_top = -52.0 -offset_right = 208.0 -offset_bottom = 4.0 -grow_vertical = 0 -texture_normal = ExtResource("4_nm64b") - -[node name="TabButton4" type="TextureButton" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control"] -layout_mode = 1 -anchors_preset = 2 -anchor_top = 1.0 -anchor_bottom = 1.0 -offset_left = 208.0 -offset_top = -52.0 -offset_right = 272.0 -offset_bottom = 4.0 -grow_vertical = 0 -texture_normal = ExtResource("4_nm64b") +offset_left = 8.0 +offset_top = 24.0 +offset_right = -8.0 +grow_horizontal = 2 +grow_vertical = 2 +stretch_mode = 3 [node name="NinePatchRect" type="NinePatchRect" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2"] layout_mode = 2 diff --git a/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/Tab.png b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/Tab.png index 26e6fd4..b59decf 100644 --- a/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/Tab.png +++ b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/Tab.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabIcon1.png b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabIcon1.png new file mode 100644 index 0000000..66be38c --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabIcon1.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabIcon1.png.import b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabIcon1.png.import new file mode 100644 index 0000000..e81cd0c --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabIcon1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b3cyuhkpk5jc0" +path="res://.godot/imported/TabIcon1.png-959d0384e8e61550e56702a962ae1355.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/ui/encyclopedia/TabIcon1.png" +dest_files=["res://.godot/imported/TabIcon1.png-959d0384e8e61550e56702a962ae1355.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 diff --git a/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabSelect.png b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabSelect.png new file mode 100644 index 0000000..0abc873 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabSelect.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabSelect.png.import b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabSelect.png.import new file mode 100644 index 0000000..2f15299 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/encyclopedia/TabSelect.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://vpm33qtm7w" +path="res://.godot/imported/TabSelect.png-d8a3ea74ef504abc15dab702abedc9bc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/ui/encyclopedia/TabSelect.png" +dest_files=["res://.godot/imported/TabSelect.png-d8a3ea74ef504abc15dab702abedc9bc.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 diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 091e957..2eef041 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -299,6 +299,14 @@ public const string resource_sprite_ui_sursors_CursorCenter_png = "res://resource/sprite/ui/sursors/CursorCenter.png"; public const string resource_sprite_ui_sursors_Cursors_png = "res://resource/sprite/ui/sursors/Cursors.png"; public const string resource_sprite_ui_sursors_Cursors_Ui_png = "res://resource/sprite/ui/sursors/Cursors_Ui.png"; + public const string resource_sprite_ui_encyclopedia_TitleBg_png = "res://resource/sprite/ui/encyclopedia/TitleBg.png"; + public const string resource_sprite_ui_encyclopedia_Panel2_png = "res://resource/sprite/ui/encyclopedia/Panel2.png"; + public const string resource_sprite_ui_encyclopedia_Tab_png = "res://resource/sprite/ui/encyclopedia/Tab.png"; + public const string resource_sprite_ui_encyclopedia_Panel_png = "res://resource/sprite/ui/encyclopedia/Panel.png"; + public const string resource_sprite_ui_encyclopedia_Item_png = "res://resource/sprite/ui/encyclopedia/Item.png"; + public const string resource_sprite_ui_encyclopedia_TabSelect_png = "res://resource/sprite/ui/encyclopedia/TabSelect.png"; + public const string resource_sprite_ui_encyclopedia_Select_png = "res://resource/sprite/ui/encyclopedia/Select.png"; + public const string resource_sprite_ui_encyclopedia_TabIcon1_png = "res://resource/sprite/ui/encyclopedia/TabIcon1.png"; public const string resource_sprite_ui_mapEditorTools_DoorDragButton_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton.png"; public const string resource_sprite_ui_mapEditorTools_DoorDragButton_hover_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_hover.png"; public const string resource_sprite_ui_mapEditorTools_DoorDragButton_down_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_down.png"; diff --git a/DungeonShooting_Godot/src/game/ui/encyclopedia/Encyclopedia.cs b/DungeonShooting_Godot/src/game/ui/encyclopedia/Encyclopedia.cs index 208e2c8..00c46dd 100644 --- a/DungeonShooting_Godot/src/game/ui/encyclopedia/Encyclopedia.cs +++ b/DungeonShooting_Godot/src/game/ui/encyclopedia/Encyclopedia.cs @@ -82,42 +82,37 @@ } /// + /// 类型: , 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton.Icon + /// + public class Icon : UiNode + { + public Icon(EncyclopediaPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } + public override Icon Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); + } + + /// /// 类型: , 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton /// public class TabButton : UiNode { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.Icon + /// + public Icon L_Icon + { + get + { + if (_L_Icon == null) _L_Icon = new Icon(UiPanel, Instance.GetNode("Icon")); + return _L_Icon; + } + } + private Icon _L_Icon; + public TabButton(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { } public override TabButton Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate()); } /// - /// 类型: , 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton2 - /// - public class TabButton2 : UiNode - { - public TabButton2(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { } - public override TabButton2 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate()); - } - - /// - /// 类型: , 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton3 - /// - public class TabButton3 : UiNode - { - public TabButton3(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { } - public override TabButton3 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate()); - } - - /// - /// 类型: , 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton4 - /// - public class TabButton4 : UiNode - { - public TabButton4(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { } - public override TabButton4 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate()); - } - - /// /// 类型: , 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control /// public class Control : UiNode @@ -135,45 +130,6 @@ } private TabButton _L_TabButton; - /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.TabButton2 - /// - public TabButton2 L_TabButton2 - { - get - { - if (_L_TabButton2 == null) _L_TabButton2 = new TabButton2(UiPanel, Instance.GetNode("TabButton2")); - return _L_TabButton2; - } - } - private TabButton2 _L_TabButton2; - - /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.TabButton3 - /// - public TabButton3 L_TabButton3 - { - get - { - if (_L_TabButton3 == null) _L_TabButton3 = new TabButton3(UiPanel, Instance.GetNode("TabButton3")); - return _L_TabButton3; - } - } - private TabButton3 _L_TabButton3; - - /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.TabButton4 - /// - public TabButton4 L_TabButton4 - { - get - { - if (_L_TabButton4 == null) _L_TabButton4 = new TabButton4(UiPanel, Instance.GetNode("TabButton4")); - return _L_TabButton4; - } - } - private TabButton4 _L_TabButton4; - public Control(EncyclopediaPanel uiPanel, Godot.Control node) : base(uiPanel, node) { } public override Control Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); } @@ -582,26 +538,16 @@ public TextureRect S_TextureRect => L_NinePatchRect.L_TextureRect; /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton.Icon + /// + public Icon S_Icon => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton.L_Icon; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton /// public TabButton S_TabButton => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton2 - /// - public TabButton2 S_TabButton2 => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton2; - - /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton3 - /// - public TabButton3 S_TabButton3 => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton3; - - /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton4 - /// - public TabButton4 S_TabButton4 => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton4; - - /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control /// public Control S_Control => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control; diff --git a/DungeonShooting_Godot/src/game/ui/encyclopedia/EncyclopediaPanel.cs b/DungeonShooting_Godot/src/game/ui/encyclopedia/EncyclopediaPanel.cs index 060d35d..1bc52f2 100644 --- a/DungeonShooting_Godot/src/game/ui/encyclopedia/EncyclopediaPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/encyclopedia/EncyclopediaPanel.cs @@ -6,32 +6,47 @@ public partial class EncyclopediaPanel : Encyclopedia { - + //tab网格 + private UiGrid _tab; + //item网格 private UiGrid _grid; private long _id; public override void OnCreateUi() { + _tab = CreateUiGrid(S_TabButton); + _tab.SetColumns(10); + _tab.SetCellOffset(new Vector2I(0, 0)); + _tab.Add(new TabData(ResourcePath.resource_sprite_ui_encyclopedia_TabIcon1_png, ActivityType.Weapon)); + _tab.Add(new TabData(ResourcePath.resource_sprite_ui_encyclopedia_TabIcon1_png, ActivityType.Prop)); + _tab.Add(new TabData(ResourcePath.resource_sprite_ui_encyclopedia_TabIcon1_png, ActivityType.Enemy)); + _grid = CreateUiGrid(S_ObjectButton); _grid.SetHorizontalExpand(true); _grid.SetAutoColumns(true); _grid.SetCellOffset(new Vector2I(10, 10)); - ShowWeaponItem(); + + _tab.SelectIndex = 0; } public override void OnDestroyUi() { } - - private void ShowWeaponItem() + + /// + /// 设置选中的tab + /// + public void SelectTab(ActivityType type) { StopCoroutine(_id); _id = StartCoroutine( _grid.SetDataListCoroutine( - ExcelConfig.ActivityBase_List.Where(data => data.Type == ActivityType.Weapon).ToArray() + ExcelConfig.ActivityBase_List.Where(data => data.Type == type).ToArray() ) ); + + SelectItem(null); } /// @@ -43,7 +58,14 @@ { S_ItemName.Instance.Text = config.Name; S_ItemTexture.Instance.Texture = ResourceManager.LoadTexture2D(config.Icon); - S_ItemDes.Instance.Text = config.Details; + S_ItemDes.Instance.Text = config.Intro; + //S_ItemDes.Instance.Text = config.Details; + } + else + { + S_ItemName.Instance.Text = null; + S_ItemTexture.Instance.Texture = null; + S_ItemDes.Instance.Text = null; } } diff --git a/DungeonShooting_Godot/src/game/ui/encyclopedia/TabCell.cs b/DungeonShooting_Godot/src/game/ui/encyclopedia/TabCell.cs new file mode 100644 index 0000000..bda34ac --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/encyclopedia/TabCell.cs @@ -0,0 +1,54 @@ +using Godot; + +namespace UI.Encyclopedia; + +public class TabCell : UiCell +{ + //选中时页签显示的纹理 + private const string SelectTexture = ResourcePath.resource_sprite_ui_encyclopedia_TabSelect_png; + private static Texture2D _selectTexture; + + private static Texture2D GetSelectTexture() + { + if (_selectTexture == null) + { + _selectTexture = ResourceManager.LoadTexture2D(SelectTexture); + } + + return _selectTexture; + } + + + private float _startY; + private Texture2D _originTexture; + + public override void OnInit() + { + _originTexture = CellNode.Instance.TextureNormal; + } + + public override void OnSetData(TabData data) + { + CellNode.L_Icon.Instance.Texture = ResourceManager.LoadTexture2D(data.Icon); + var position = CellNode.L_Icon.Instance.Position; + _startY = position.Y; + } + + public override void OnClick() + { + Grid.SelectIndex = Index; + } + + public override void OnSelect() + { + CellNode.Instance.TextureNormal = GetSelectTexture(); + CellNode.L_Icon.Instance.Position = new Vector2(CellNode.L_Icon.Instance.Position.X, _startY - 12); + CellNode.UiPanel.SelectTab(Data.Type); + } + + public override void OnUnSelect() + { + CellNode.Instance.TextureNormal = _originTexture; + CellNode.L_Icon.Instance.Position = new Vector2(CellNode.L_Icon.Instance.Position.X, _startY); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/encyclopedia/TabData.cs b/DungeonShooting_Godot/src/game/ui/encyclopedia/TabData.cs new file mode 100644 index 0000000..75c0884 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/encyclopedia/TabData.cs @@ -0,0 +1,19 @@ +namespace UI.Encyclopedia; + +public class TabData +{ + /// + /// 图标 + /// + public string Icon; + /// + /// 物体类型 + /// + public ActivityType Type; + + public TabData(string icon, ActivityType type) + { + Icon = icon; + Type = type; + } +} \ No newline at end of file