From 6f87db20c635c7646c82bfcea4ede16f1b231d19 Mon Sep 17 00:00:00 2001 From: cakipaul Date: Tue, 4 Feb 2025 19:50:48 +0800 Subject: [PATCH] =?UTF-8?q?prop=20hud=20=E5=8F=B3=E4=BE=A7=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E5=88=86=E6=A0=8F=EF=BC=9A=E8=A2=AB=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E9=A1=B9+=E5=8F=B3=E4=BE=A7=E5=B1=95=E5=BC=80=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=EF=BC=8C=E5=8F=B3=E4=BE=A7=E5=8C=BA=E5=9F=9F=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=80=89=E4=B8=AD=E9=81=93=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asset/art/ui/hud/select_mark.png | Bin 0 -> 405 bytes asset/art/ui/hud/select_mark.png.import | 34 +++++ asset/art/ui/hud/selecting_bg.png | Bin 0 -> 4832 bytes asset/art/ui/hud/selecting_bg.png.import | 34 +++++ scene/prop/prop_hud.gd | 177 +++++++++++++++-------- scene/prop/prop_hud.tscn | 93 ++++++++++-- scene/prop/prop_inventory_resource.gd | 3 +- scene/prop/test_hbox.gd | 2 +- 8 files changed, 268 insertions(+), 75 deletions(-) create mode 100644 asset/art/ui/hud/select_mark.png create mode 100644 asset/art/ui/hud/select_mark.png.import create mode 100644 asset/art/ui/hud/selecting_bg.png create mode 100644 asset/art/ui/hud/selecting_bg.png.import diff --git a/asset/art/ui/hud/select_mark.png b/asset/art/ui/hud/select_mark.png new file mode 100644 index 0000000000000000000000000000000000000000..a1d35cdc9ec1d86d845a696cf031c9ce99bf9b9b GIT binary patch literal 405 zcmeAS@N?(olHy`uVBq!ia0vp^O(4v{1|++f1^xml#^NA%Cx&(BWL^T<{+=$5Ar*7p z-a6ZR$UuVS0%PC|>4m#YCY{?PE+3Y3Sn7v?ebxImj z=cRXL`=75k_453Kcanc@so1!u`iU>JHTrQ+<;v=FFMqs9sA>PCR3UXHaPPULt^rLu zwXXmE(&f3*c+%+;b%*2{Rk|FObEpKeSh*^6DqYZI@)T+G6ZBZbQPSlw>7aP<9OIgO zyNzR`ZfnKWJ*Yh)0(3WVVBh&mx3+EBw)dCaielZ%hwt&%)!VIqJ^%Vg%YUc8C_UJF zOylr#sgqwU-j`LRcR2{TE(m6sq`@>-X@ZO33lX@hc3pnas;oZoobt2PR*HJHN*3GZ ztuESo`oGka#J*Rh+uRjSKIqomzQKRSa--#UFT9)S!uf2nFoXXmW;2W2$k|&Qr-2;n M>FVdQ&MBb@07uxN-2eap literal 0 HcmV?d00001 diff --git a/asset/art/ui/hud/select_mark.png.import b/asset/art/ui/hud/select_mark.png.import new file mode 100644 index 00000000..d749b544 --- /dev/null +++ b/asset/art/ui/hud/select_mark.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0gjes4a8ou3b" +path="res://.godot/imported/select_mark.png-3482e4ba252b94def00b26feddc6d4da.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://asset/art/ui/hud/select_mark.png" +dest_files=["res://.godot/imported/select_mark.png-3482e4ba252b94def00b26feddc6d4da.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/asset/art/ui/hud/selecting_bg.png b/asset/art/ui/hud/selecting_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..ce7f00750ac4ed69fb54bfa5b3518c4eaaff863c GIT binary patch literal 4832 zcmV<65+Ch}P)Px{nn^@KRCt{2T|J8&#}+-ah$l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G-nAfmL+$>MvI zNBbBb$qu`D^Ezp~f@id+ON>nLZ_~gkV7{xkg=P9GsJ4!*&KbDp~Pnl0OEol6?pO>P25BX!Wem1wvK}VV9L$0Qf)Q$dhwx6q+{x0000 void: if Engine.is_editor_hint(): return - # read prop containers,第一个为 head 跳过, 最后一个为 tail 跳过 - for id in range(props_hbox.get_child_count() - 2): - var container = props_hbox.get_child(id + 1) + # read prop containers + for id in range(props_bag.get_child_count()): + var container = props_bag.get_child(id) prop_containers.append(container) container.get_child(0).get_child(0).pressed.connect(_on_prop_pressed.bind(id)) + display_prop.pressed.connect(_on_prop_pressed.bind(-1)) _load_items() _load_from_archive() - props_scroll.scroll_horizontal = PROP_CONTAINER_X - focus_exited.connect(_on_focus_exited) + selecting_bg.modulate.a = 0.0 + prop_scroll.scroll_horizontal = PROP_CONTAINER_X + props_bag_scroll.scroll_horizontal = 0.0 + props_bag_scroll.custom_minimum_size.x = 0.0 + # focus_exited.connect(_on_focus_exited) # 存档更新时,从存档加载 prop ArchiveManager.archive_loaded.connect(_load_from_archive) # tween timer @@ -83,11 +102,6 @@ func _ready() -> void: mouse_exited.connect(_on_mouse_exited) -func _on_focus_exited() -> void: - if selected: - selected = false - - func _load_items(): var id = item_config_res.titles["PropItems"] var current_line = item_config_res.lines[id] @@ -154,53 +168,70 @@ func _load_texture_cache() -> void: func _update_prop_display_with_texture(): if not inventory: return - var prop = prop_containers[0].get_child(0).get_child(0) as TextureButton # 在没有道具时,展示空手 placeholder if inventory.enabled_items.size() == 0: - prop.texture_normal = preload("res://asset/art/ui/hud/placeholder.png") - prop.size = Vector2(PROP_CONTROL_X, PROP_CONTROL_X) - prop.scale = Vector2(1.0, 1.0) + display_prop.texture_normal = preload("res://asset/art/ui/hud/placeholder.png") + display_prop.size = Vector2(PROP_CONTROL_X, PROP_CONTROL_X) + display_prop.scale = Vector2(1.0, 1.0) title_label.text = tr("prop_空手") - return + else: + var key = inventory.current_item_key() + _display_texture_by_key(display_prop, key) + title_label.text = tr(key) + # 选中标记 select_mark; 如果被 free 掉,则重新创建 + if select_mark and is_instance_valid(select_mark): + var parent = select_mark.get_parent() + if parent: + parent.remove_child(select_mark) + else: + select_mark = TextureRect.new() + select_mark.custom_minimum_size = Vector2(PROP_CONTAINER_X, PROP_CONTAINER_X) + select_mark.texture = preload("res://asset/art/ui/hud/select_mark.png") + # bag for i in range(prop_containers.size()): - var id = wrapi(inventory.current_index + i, 0, inventory.enabled_items.size()) - var item = items_dict[inventory.enabled_items[id]] - prop = prop_containers[i].get_child(0).get_child(0) as TextureButton - if i == 0: - title_label.text = tr(item.key) - if item.key in cached_inventory_textures: - prop.texture_normal = cached_inventory_textures[item.key] - var t_size = prop.texture_normal.get_size() - var max_x = max(t_size.x, t_size.y) - var p_scale = min(PROP_CONTROL_X / t_size.x, PROP_CONTROL_X / t_size.y) - prop.scale = Vector2(p_scale, p_scale) - prop.size = Vector2(max_x, max_x) - else: - printerr("PropHUD: Texture not found! key=", item.key) - prop.texture_normal = null - props_scroll.scroll_horizontal = PROP_CONTAINER_X + var id = wrapi(i, 0, inventory.enabled_items.size()) + var key = inventory.enabled_items[id] + var button = prop_containers[i].get_child(0).get_child(0) as TextureButton + _display_texture_by_key(button, key) + if id == inventory.current_index: + prop_containers[i].get_child(0).add_child(select_mark) + prop_scroll.scroll_horizontal = PROP_CONTAINER_X + # props_bag_scroll.scroll_horizontal = 0.0 + + +func _display_texture_by_key(button, key) -> void: + if not key: + button.texture_normal = null + return + var item = items_dict[key] + button.texture_normal = cached_inventory_textures[item.key] + var t_size = button.texture_normal.get_size() + var max_x = max(t_size.x, t_size.y) + var p_scale = min(PROP_CONTROL_X / t_size.x, PROP_CONTROL_X / t_size.y) + button.scale = Vector2(p_scale, p_scale) + button.size = Vector2(max_x, max_x) func on_left_pressed() -> void: if locked: return sfx_click.play() - _mouse_moved_on_listening() if inventory.index_wrap_add(-1): - selected = false + selected = true _update_prop_display_with_texture() _tween_container(true) + _mouse_moved_on_listening() func on_right_pressed() -> void: if locked: return sfx_click.play() - _mouse_moved_on_listening() if inventory.index_wrap_add(1): - selected = false + selected = true _update_prop_display_with_texture() _tween_container(false) + _mouse_moved_on_listening() func _tween_container(left_to_right := true) -> void: @@ -208,11 +239,11 @@ func _tween_container(left_to_right := true) -> void: container_tween.kill() container_tween = create_tween() if left_to_right: - props_scroll.scroll_horizontal = 2 * PROP_CONTAINER_X + prop_scroll.scroll_horizontal = 2 * PROP_CONTAINER_X else: - props_scroll.scroll_horizontal = 0.0 + prop_scroll.scroll_horizontal = 0.0 # 通过 Head 与 Tail 占位符,实现滚动效果;否则会导致卡在边界上,无法滚动 - container_tween.tween_property(props_scroll, "scroll_horizontal", PROP_CONTAINER_X, 0.2) + container_tween.tween_property(prop_scroll, "scroll_horizontal", PROP_CONTAINER_X, 0.2) func _on_prop_pressed(id := 0) -> void: @@ -221,33 +252,55 @@ func _on_prop_pressed(id := 0) -> void: sfx_click.play() if GlobalConfig.DEBUG: print("PropHUD Panel pressed.") - if not selected: - focus_mode = FOCUS_ALL - grab_focus() - selected = true - inventory.current_index += id + focus_mode = FOCUS_ALL + grab_focus() + selected = true + if id >= 0: + inventory.current_index = id _update_prop_display_with_texture() _mouse_moved_on_listening(true) +var prop_blink: Tween var tween_scroll: Tween func _toggle_scroll(fold := true) -> void: + if prop_blink and prop_blink.is_running(): + prop_blink.kill() if tween_scroll and tween_scroll.is_running(): tween_scroll.kill() + # PROP_CONTAINER_X + 10. 为hud的两侧留出的空间 if fold: + # kill blink + select_mark.modulate.a = 1.0 + selecting_bg.modulate.a = 0.0 + # fold tween_scroll = create_tween() - tween_scroll.tween_property(props_scroll, "custom_minimum_size:x", PROP_CONTAINER_X, 0.5) + tween_scroll.tween_property(props_bag_scroll, "custom_minimum_size:x", 0.0, 0.5) tween_scroll.parallel().tween_property( hud_rect, "custom_minimum_size:x", PROP_CONTAINER_X + 10., 0.5 ) else: - # 保持最小宽度 - var x_size = max(1, prop_containers.size()) * PROP_CONTAINER_X + # blink + if prop_containers.size() > 0: + prop_blink = create_tween().set_loops(0) + prop_blink.tween_property(select_mark, "modulate:a", 0.6, 1.).set_ease( + Tween.EASE_IN_OUT + ) + prop_blink.parallel().tween_property(selecting_bg, "modulate:a", 0.2, 1.).set_ease( + Tween.EASE_IN_OUT + ) + prop_blink.tween_property(select_mark, "modulate:a", 1., 1.).set_ease(Tween.EASE_IN_OUT) + prop_blink.parallel().tween_property(selecting_bg, "modulate:a", .6, 1.).set_ease( + Tween.EASE_IN_OUT + ) + # unfold + var bag_x = prop_containers.size() * PROP_CONTAINER_X + var hud_x = bag_x + PROP_CONTAINER_X + 10. tween_scroll = create_tween() - tween_scroll.tween_property(props_scroll, "custom_minimum_size:x", x_size, 0.5) - tween_scroll.parallel().tween_property(hud_rect, "custom_minimum_size:x", x_size + 10., 0.5) + tween_scroll.tween_property(props_bag_scroll, "custom_minimum_size:x", bag_x, 0.5) + tween_scroll.parallel().tween_property(hud_rect, "custom_minimum_size:x", hud_x, 0.5) func _on_mouse_entered() -> void: @@ -355,13 +408,13 @@ func _align_container_size() -> void: # 判断是否需要添加新的 prop container while inventory.enabled_items.size() > prop_containers.size(): append_prop_container() - # 判断是否需要删除 prop container,最少保留一个 - while inventory.enabled_items.size() < prop_containers.size() and prop_containers.size() > 1: + # 判断是否需要删除 prop container,不保留余数 + while inventory.enabled_items.size() < prop_containers.size(): remove_prop_container() if displaying: _mouse_moved_on_listening() # 如果正在展示,则更新 scroll 长度 - if displaying and props_scroll.custom_minimum_size.x > PROP_CONTAINER_X: + if displaying and props_bag_scroll.custom_minimum_size.x > 0.0: _toggle_scroll(false) @@ -378,17 +431,15 @@ func append_prop_container() -> void: prop.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_CENTERED control.add_child(prop) # 添加到 hbox: container -> control -> prop - props_hbox.add_child(container) - # 放在 Tail 占位符 之前 - props_hbox.move_child(container, -2) + props_bag.add_child(container) prop.pressed.connect(_on_prop_pressed.bind(prop_containers.size() - 1)) func remove_prop_container() -> void: - if prop_containers.size() <= 1: + if prop_containers.size() == 0: return var container = prop_containers.pop_back() - props_hbox.remove_child(container) + props_bag.remove_child(container) container.queue_free() diff --git a/scene/prop/prop_hud.tscn b/scene/prop/prop_hud.tscn index 1f1de8cb..bd089dc8 100644 --- a/scene/prop/prop_hud.tscn +++ b/scene/prop/prop_hud.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://dc778gsjfr3ky"] +[gd_scene load_steps=14 format=3 uid="uid://dc778gsjfr3ky"] [ext_resource type="Script" path="res://scene/prop/prop_hud.gd" id="1_bbv0a"] [ext_resource type="Texture2D" uid="uid://dok08tovej18w" path="res://asset/art/ui/hud/normal_left.png" id="2_bjc2b"] @@ -6,6 +6,8 @@ [ext_resource type="Texture2D" uid="uid://c45k7ncg6xhpv" path="res://asset/art/ui/hud/pressed_left.png" id="3_fca7p"] [ext_resource type="Texture2D" uid="uid://c2jq2neda32ix" path="res://asset/art/ui/hud/Prop.png" id="5_6tt77"] [ext_resource type="Texture2D" uid="uid://0uwun1mo726u" path="res://asset/art/prop/c02/绳子物品.png" id="6_0m706"] +[ext_resource type="Texture2D" uid="uid://d4nxjk0127u23" path="res://asset/art/ui/hud/selecting_bg.png" id="6_5ixbr"] +[ext_resource type="Texture2D" uid="uid://c0gjes4a8ou3b" path="res://asset/art/ui/hud/select_mark.png" id="7_53yeo"] [ext_resource type="FontFile" uid="uid://dr8bp6p7byb37" path="res://asset/font/字体/方正楷体简体.TTF" id="10_mye4q"] [ext_resource type="Texture2D" uid="uid://c1ogeaa836kry" path="res://asset/art/ui/hud/normal_right.png" id="10_vkaik"] [ext_resource type="Script" path="res://scene/prop/test_hbox.gd" id="11_008sv"] @@ -80,7 +82,11 @@ theme_override_constants/margin_top = 5 theme_override_constants/margin_right = 5 theme_override_constants/margin_bottom = 5 -[node name="PropScrollContainer" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 0 + +[node name="PropScrollContainer" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer"] unique_name_in_owner = true custom_minimum_size = Vector2(130, 130) layout_mode = 2 @@ -91,26 +97,45 @@ scroll_horizontal = 130 horizontal_scroll_mode = 3 vertical_scroll_mode = 0 -[node name="PropsHBox" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/PropScrollContainer"] +[node name="PropHBox" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 theme_override_constants/separation = 0 -[node name="Head" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/PropScrollContainer/PropsHBox"] +[node name="Head" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer/PropHBox"] custom_minimum_size = Vector2(130, 130) layout_mode = 2 -[node name="PropContainer" type="CenterContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/PropScrollContainer/PropsHBox"] +[node name="PropContainer" type="CenterContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer/PropHBox"] custom_minimum_size = Vector2(130, 130) layout_mode = 2 size_flags_horizontal = 4 -[node name="Control" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/PropScrollContainer/PropsHBox/PropContainer"] +[node name="Control" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer/PropHBox/PropContainer"] custom_minimum_size = Vector2(110, 110) layout_mode = 2 -[node name="Prop" type="TextureButton" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/PropScrollContainer/PropsHBox/PropContainer/Control"] +[node name="SelectingBG" type="TextureRect" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer/PropHBox/PropContainer/Control"] +unique_name_in_owner = true +self_modulate = Color(0.837083, 0.510264, 0.465919, 1) +custom_minimum_size = Vector2(120, 120) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -65.0 +offset_top = -65.0 +offset_right = 65.0 +offset_bottom = 65.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("6_5ixbr") + +[node name="DiaplayProp" type="TextureButton" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer/PropHBox/PropContainer/Control"] +unique_name_in_owner = true layout_mode = 0 offset_right = 146.0 offset_bottom = 146.0 @@ -118,10 +143,60 @@ scale = Vector2(0.75, 0.75) texture_normal = ExtResource("6_0m706") stretch_mode = 5 -[node name="Tail" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/PropScrollContainer/PropsHBox"] +[node name="Tail" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropScrollContainer/PropHBox"] custom_minimum_size = Vector2(130, 130) layout_mode = 2 +[node name="PropsBagScroll" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(130, 130) +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 4 +mouse_filter = 2 +horizontal_scroll_mode = 3 +vertical_scroll_mode = 0 + +[node name="PropsBag" type="HBoxContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropsBagScroll"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_constants/separation = 0 + +[node name="PropContainer" type="CenterContainer" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropsBagScroll/PropsBag"] +custom_minimum_size = Vector2(130, 130) +layout_mode = 2 +size_flags_horizontal = 4 + +[node name="Control" type="Control" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropsBagScroll/PropsBag/PropContainer"] +custom_minimum_size = Vector2(110, 110) +layout_mode = 2 + +[node name="Prop" type="TextureButton" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropsBagScroll/PropsBag/PropContainer/Control"] +layout_mode = 0 +offset_right = 146.0 +offset_bottom = 146.0 +scale = Vector2(0.75, 0.75) +texture_normal = ExtResource("6_0m706") +stretch_mode = 5 + +[node name="SelectMark" type="TextureRect" parent="VBoxContainer/HBoxContainer/HudRect/MarginContainer/HBoxContainer/PropsBagScroll/PropsBag/PropContainer/Control"] +unique_name_in_owner = true +custom_minimum_size = Vector2(130, 130) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -65.0 +offset_top = -65.0 +offset_right = 65.0 +offset_bottom = 65.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("7_53yeo") + [node name="RightMargin" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 0 @@ -138,7 +213,7 @@ texture_pressed = ExtResource("11_a512b") stretch_mode = 5 [node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer"] -custom_minimum_size = Vector2(170, 0) +custom_minimum_size = Vector2(165, 0) layout_mode = 2 size_flags_horizontal = 0 mouse_filter = 2 diff --git a/scene/prop/prop_inventory_resource.gd b/scene/prop/prop_inventory_resource.gd index b3d5c216..c5085769 100644 --- a/scene/prop/prop_inventory_resource.gd +++ b/scene/prop/prop_inventory_resource.gd @@ -2,8 +2,7 @@ class_name PropInventory extends Resource signal current_item_changed(prop_key: String) -# prop_空手 默认就存在,并且不可删除 -@export var enabled_items := ["prop_空手"] +@export var enabled_items := [] @export var current_index := 0: set(val): if current_index != val: diff --git a/scene/prop/test_hbox.gd b/scene/prop/test_hbox.gd index 33d85943..66603c2a 100644 --- a/scene/prop/test_hbox.gd +++ b/scene/prop/test_hbox.gd @@ -1,6 +1,6 @@ extends HBoxContainer -var items := ["prop_令牌", "prop_令牌", "prop_信碎片1", "prop_火柴", "prop_绳子", "prop_1012钥匙", "prop_老虎钳"] +var items := ["prop_令牌", "prop_信碎片1", "prop_火柴", "prop_绳子", "prop_令牌", "prop_1012钥匙", "prop_老虎钳"] var id := 0