fix(hand): remove _restack_hand_cards to stop fan position shuffling
move_child was changing child indices which _layout_hand_cards uses to compute fan positions, causing the whole hand to shuffle on every spin or selection. z_index alone handles draw order correctly. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -4671,8 +4671,6 @@ func _layout_hand_cards() -> void:
|
||||
|
||||
_apply_hand_card_transform(widget, pos, deg_to_rad(angle_deg * 0.35), scale_amt, z)
|
||||
|
||||
_restack_hand_cards()
|
||||
|
||||
|
||||
func _apply_hand_card_transform(widget: Control, pos: Vector2, rot: float, scale_amt: float, z: int) -> void:
|
||||
widget.pivot_offset = _hand_card_size(widget) * 0.5
|
||||
@@ -4689,23 +4687,6 @@ func _apply_hand_card_transform(widget: Control, pos: Vector2, rot: float, scale
|
||||
widget.set_meta("_hand_tween", tw)
|
||||
|
||||
|
||||
func _restack_hand_cards() -> void:
|
||||
var ordered : Array[Control] = []
|
||||
for child in _hand_cards.get_children():
|
||||
if child is Control:
|
||||
ordered.append(child as Control)
|
||||
|
||||
ordered.sort_custom(func(a: Control, b: Control) -> bool:
|
||||
var za : int = int(a.get_meta("_hand_stack", 0))
|
||||
var zb : int = int(b.get_meta("_hand_stack", 0))
|
||||
if za == zb:
|
||||
return int(a.get_index()) < int(b.get_index())
|
||||
return za < zb
|
||||
)
|
||||
|
||||
for i in range(ordered.size()):
|
||||
_hand_cards.move_child(ordered[i], i)
|
||||
|
||||
|
||||
func _hand_card_size(widget: Control) -> Vector2:
|
||||
var size_v := widget.size
|
||||
|
||||
Reference in New Issue
Block a user