mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-07-10 12:02:54 +08:00
feat(初始选择面板): 添加武器选择功能并优化界面布局
- 在初始选择面板中增加武器选择功能 - 添加开始游戏按钮 - 优化界面布局,将标题和选择项分组显示 - 实现选择后自动关闭对应选择区域的功能
This commit is contained in:
@@ -11,17 +11,39 @@ script = ExtResource("2_eugsq")
|
|||||||
[node name="wrapper" parent="content" index="1"]
|
[node name="wrapper" parent="content" index="1"]
|
||||||
theme_override_constants/separation = 40
|
theme_override_constants/separation = 40
|
||||||
|
|
||||||
[node name="title" type="Label" parent="content/wrapper" index="0"]
|
[node name="container" type="ScrollContainer" parent="content/wrapper" index="0"]
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 4
|
|
||||||
text = "在游戏开始前,你可以选择一项初始增益。"
|
|
||||||
|
|
||||||
[node name="container" type="ScrollContainer" parent="content/wrapper" index="1"]
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
follow_focus = true
|
follow_focus = true
|
||||||
vertical_scroll_mode = 0
|
vertical_scroll_mode = 0
|
||||||
|
|
||||||
[node name="initialFeedSelection" type="HBoxContainer" parent="content/wrapper/container" index="0"]
|
[node name="wrapper" type="VBoxContainer" parent="content/wrapper/container" index="0"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_constants/separation = 10
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="title1" type="Label" parent="content/wrapper/container/wrapper" index="0"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
alignment = 1
|
size_flags_horizontal = 0
|
||||||
|
text = "在游戏开始前,你可以选择一项初始增益。"
|
||||||
|
|
||||||
|
[node name="initialFeedSelection" type="HBoxContainer" parent="content/wrapper/container/wrapper" index="1"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="title2" type="Label" parent="content/wrapper/container/wrapper" index="2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 0
|
||||||
|
text = "在游戏开始前,你可以选择一个初始武器。"
|
||||||
|
|
||||||
|
[node name="initialWeaponSelection" type="HBoxContainer" parent="content/wrapper/container/wrapper" index="3"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="startBtn" type="Button" parent="content/wrapper" index="1"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
text = "开始游戏"
|
||||||
|
|||||||
@@ -2,15 +2,39 @@
|
|||||||
extends FullscreenPanelBase
|
extends FullscreenPanelBase
|
||||||
|
|
||||||
@onready var initialFeedSelection: HBoxContainer = $%initialFeedSelection
|
@onready var initialFeedSelection: HBoxContainer = $%initialFeedSelection
|
||||||
|
@onready var initialWeaponSelection: HBoxContainer = $%initialWeaponSelection
|
||||||
|
@onready var startBtn: Button = $%startBtn
|
||||||
|
@onready var title1: Label = $%title1
|
||||||
|
@onready var title2: Label = $%title2
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
startBtn.pressed.connect(func(): UIState.closeCurrentPanel())
|
||||||
|
|
||||||
func beforeOpen(_args: Array = []):
|
func beforeOpen(_args: Array = []):
|
||||||
for feed in initialFeedSelection.get_children():
|
clearFeeds()
|
||||||
feed.queue_free()
|
clearWeapons()
|
||||||
ComponentManager.feeds.shuffle()
|
ComponentManager.feeds.shuffle()
|
||||||
for feed in ComponentManager.feeds:
|
for feed in ComponentManager.feeds:
|
||||||
var card = feed.instantiate() as Feed
|
var card = feed.instantiate() as Feed
|
||||||
if card.topic == FeedName.Topic.WEAPON:
|
|
||||||
continue
|
|
||||||
card.freeToBuy = true
|
card.freeToBuy = true
|
||||||
card.selected.connect(func(_success): UIState.closeCurrentPanel())
|
if card.topic == FeedName.Topic.WEAPON:
|
||||||
initialFeedSelection.add_child(card)
|
initialWeaponSelection.add_child(card)
|
||||||
|
card.selected.connect(
|
||||||
|
func(_x):
|
||||||
|
clearWeapons()
|
||||||
|
title2.hide()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
initialFeedSelection.add_child(card)
|
||||||
|
card.selected.connect(
|
||||||
|
func(_x):
|
||||||
|
clearFeeds()
|
||||||
|
title1.hide()
|
||||||
|
)
|
||||||
|
|
||||||
|
func clearFeeds():
|
||||||
|
for feed in initialFeedSelection.get_children():
|
||||||
|
feed.queue_free()
|
||||||
|
func clearWeapons():
|
||||||
|
for weapon in initialWeaponSelection.get_children():
|
||||||
|
weapon.queue_free()
|
||||||
|
|||||||
Reference in New Issue
Block a user