1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

refactor(UI): 优化字段显示逻辑并添加平滑相机移动

将字段显示和隐藏逻辑提取为独立方法
为相机添加位置平滑效果
在游戏重启时重置初始饲料选择状态
This commit is contained in:
2026-05-05 12:24:45 +08:00
parent 7e48372902
commit 11a293378c
5 changed files with 24 additions and 13 deletions
+1
View File
@@ -85,6 +85,7 @@ limit_left = -2400
limit_top = -1800
limit_right = 2400
limit_bottom = 1800
position_smoothing_enabled = true
editor_draw_limits = true
script = ExtResource("5_mk7bv")
constantOffset = Vector2(0, -80)
+4 -1
View File
@@ -89,7 +89,10 @@ func startSingleplayerGame():
), OutGameStorage.upgradableFieldsValue)
UIState.player = EntityBase.generatePlayer(playerNameInput.text, selectedCharacter, extras)
WorldManager.rootNode.spawnWave(Vector2.ZERO)
UIState.setPanel("CompilingTip")
if buildingShader:
UIState.setPanel("CompilingTip")
else:
UIState.setPanel("SelectInitialFeed")
func _ready():
historyStack = Composables.useHistoryStack(playerNameInput)
+17 -11
View File
@@ -48,19 +48,10 @@ func _physics_process(_delta):
if !fieldsAnimator.is_playing():
if showingFields:
if Input.is_action_just_released("showFields") || !(currentPanel is PausePanel):
showingFields = false
fieldsAnimator.play("hide")
hideFields()
else:
if Input.is_action_just_pressed("showFields") || currentPanel is PausePanel:
showingFields = true
for i in fields.get_children():
fields.remove_child(i)
for i in player.fields:
if player.fields[i] == EntityBase.TITLE_FLAG:
fields.add_child(QuickUI.graySmallText(i))
else:
fields.add_child(FieldShow.create(i, player.fields[i], false, player, true))
fieldsAnimator.play("show")
showFields()
if Input.is_action_just_pressed("pause"):
if currentPanel:
@@ -100,6 +91,7 @@ static func setPanel(targetName: String = "", args: Array = []):
panel.hidePanel()
static func closeCurrentPanel():
setPanel()
static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO):
var box = TipBox.create(text, messageType)
tips.add_child(box)
@@ -110,3 +102,17 @@ static func clearTips():
for child in tips.get_children():
if child is TipBox:
child.destroy()
static func showFields():
showingFields = true
for i in fields.get_children():
fields.remove_child(i)
for i in player.fields:
if player.fields[i] == EntityBase.TITLE_FLAG:
fields.add_child(QuickUI.graySmallText(i))
else:
fields.add_child(FieldShow.create(i, player.fields[i], false, player, true))
fieldsAnimator.play("show")
static func hideFields():
showingFields = false
fieldsAnimator.play("hide")
-1
View File
@@ -17,7 +17,6 @@ func _physics_process(_delta):
if is_instance_valid(UIState.player):
position = UIState.player.position + constantOffset
position += MathTool.sampleInCircle(shakeIntensity)
offset += ((get_global_mouse_position() - UIState.player.position).clampf(-100, 100) - offset) * 0.15
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
if StarterPanel.buildingShader: return
+2
View File
@@ -10,8 +10,10 @@ static func restart(tree: SceneTree):
for item in tree.get_nodes_in_group("items"):
item.queue_free()
UIState.hideFields()
OutGameStorage.saveInventory()
CameraManager.shakeStop()
WorldManager.timeRestart()
StarterPanel.selectingFeed = true
UIState.setPanel("Starter")