1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Panels/MakeFeed.gd
T
fallingshrimp 9e396eef3d Refactor feed components and UI interactions
- Updated various feed components (Cake, Cupcake, Dango, Donut, FruitPlatter, FruitSalad, Milk, Orange, RedJam, Strawberry, Taco, WaterBottle, Xigua-Full, Xigua-Half, YellowJam) to correct names, textures, and display names.
- Modified MakeFeed scene to improve feed selection and display logic, including the addition of skip functionality.
- Enhanced UIState and EntityBase scripts to manage feed counts and selections more effectively.
- Introduced DirTool for directory operations and improved file loading mechanisms.
- Adjusted TickTool for frame-based operations.
2025-08-27 16:33:21 +08:00

52 lines
1.4 KiB
GDScript

@tool
extends FullscreenPanelBase
var selectedCount: int = 0
@onready var avaliableFeeds: Node2D = $"%avaliableFeeds"
@onready var feedCards: HBoxContainer = $"%feedcards"
@onready var waveLabel: RichTextLabel = $"%wave"
@onready var countLabel: RichTextLabel = $"%count"
@onready var skipBtn: Button = $"%skipBtn"
func _ready():
skipBtn.pressed.connect(
func():
finish()
)
for file in DirTool.listdir("res://components/Feeds/"):
var i = load(file).instantiate() as Feed
i.selected.connect(
func(applied: bool):
if applied:
selectedCount += 1
updateValue()
if selectedCount >= UIState.player.fields[FieldStore.Entity.FEED_COUNT_CAN_MADE]:
finish()
)
avaliableFeeds.add_child(i)
func beforeOpen():
selectedCount = 0
afterClose()
updateValue()
var feeds: Array[Feed] = []
for i in avaliableFeeds.get_children():
feeds.append(i)
feeds.shuffle()
for i in range(UIState.player.fields[FieldStore.Entity.FEED_COUNT_SHOW]):
var feed = feeds[i] as Feed
avaliableFeeds.remove_child(feed)
feedCards.add_child(feed)
func afterClose():
for i in feedCards.get_children():
feedCards.remove_child(i)
avaliableFeeds.add_child(i)
func updateValue():
waveLabel.text = str(Wave.current + 1)
countLabel.text = str(UIState.player.fields[FieldStore.Entity.FEED_COUNT_CAN_MADE] - selectedCount)
func finish():
Wave.next()
UIState.closeCurrentPanel()