feat: collapsible scrollable active effects sub-section in tile drawer
Each entity type (Spirit, SpiritToken, ArchSpirit, Ruin) now gets its own
"Active Effects (N)" section immediately below its stats section. The section:
- starts collapsed to keep the drawer compact
- shows a count badge in the header ("Active Effects (3)")
- scrolls when the effect list is longer than the visible area (~90 px)
- hides entirely when the entity has no active effects
Effects are no longer appended inline to the stat labels list; they live in
dedicated scrollable sections built by _create_scrollable_section /
_set_effects_section helpers.
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:
@@ -193,6 +193,14 @@ var _tile_drawer_spirit_section : Dictionary = {}
|
||||
var _tile_drawer_token_section : Dictionary = {}
|
||||
var _tile_drawer_arch_section : Dictionary = {}
|
||||
var _tile_drawer_ruin_section : Dictionary = {}
|
||||
var _tile_drawer_spirit_effects_section : Dictionary = {}
|
||||
var _tile_drawer_token_effects_section : Dictionary = {}
|
||||
var _tile_drawer_arch_effects_section : Dictionary = {}
|
||||
var _tile_drawer_ruin_effects_section : Dictionary = {}
|
||||
var _tile_drawer_spirit_effects_labels : Array = []
|
||||
var _tile_drawer_token_effects_labels : Array = []
|
||||
var _tile_drawer_arch_effects_labels : Array = []
|
||||
var _tile_drawer_ruin_effects_labels : Array = []
|
||||
const _TILE_DRAWER_WIDTH: float = 260.0
|
||||
const _TILE_DRAWER_TOGGLE_WIDTH: float = 36.0
|
||||
const _TILE_DRAWER_TOGGLE_MARGIN: float = 12.0
|
||||
@@ -2824,17 +2832,21 @@ func _create_tile_drawer() -> void:
|
||||
sep.layout_mode = 2
|
||||
vbox.add_child(sep)
|
||||
|
||||
_tile_drawer_tile_section = _create_tile_drawer_section(vbox, "Tile Details", true)
|
||||
_tile_drawer_tile_section = _create_tile_drawer_section(vbox, "Tile Details", true)
|
||||
_tile_drawer_spirit_section = _create_tile_drawer_section(vbox, "Spirit Details", false)
|
||||
_tile_drawer_token_section = _create_tile_drawer_section(vbox, "Spirit Token Details", false)
|
||||
_tile_drawer_arch_section = _create_tile_drawer_section(vbox, "ArchSpirit Details", false)
|
||||
_tile_drawer_ruin_section = _create_tile_drawer_section(vbox, "Ruin Details", false)
|
||||
_tile_drawer_spirit_effects_section = _create_scrollable_section(vbox, "Active Effects")
|
||||
_tile_drawer_token_section = _create_tile_drawer_section(vbox, "Spirit Token Details", false)
|
||||
_tile_drawer_token_effects_section = _create_scrollable_section(vbox, "Active Effects")
|
||||
_tile_drawer_arch_section = _create_tile_drawer_section(vbox, "ArchSpirit Details", false)
|
||||
_tile_drawer_arch_effects_section = _create_scrollable_section(vbox, "Active Effects")
|
||||
_tile_drawer_ruin_section = _create_tile_drawer_section(vbox, "Ruin Details", false)
|
||||
_tile_drawer_ruin_effects_section = _create_scrollable_section(vbox, "Active Effects")
|
||||
|
||||
_tile_drawer_tile_labels = _create_detail_labels(_tile_drawer_tile_section["content"], 5)
|
||||
_tile_drawer_tile_labels = _create_detail_labels(_tile_drawer_tile_section["content"], 5)
|
||||
_tile_drawer_spirit_labels = _create_detail_labels(_tile_drawer_spirit_section["content"], 5)
|
||||
_tile_drawer_token_labels = _create_detail_labels(_tile_drawer_token_section["content"], 5)
|
||||
_tile_drawer_arch_labels = _create_detail_labels(_tile_drawer_arch_section["content"], 6)
|
||||
_tile_drawer_ruin_labels = _create_detail_labels(_tile_drawer_ruin_section["content"], 2)
|
||||
_tile_drawer_token_labels = _create_detail_labels(_tile_drawer_token_section["content"], 5)
|
||||
_tile_drawer_arch_labels = _create_detail_labels(_tile_drawer_arch_section["content"], 6)
|
||||
_tile_drawer_ruin_labels = _create_detail_labels(_tile_drawer_ruin_section["content"], 2)
|
||||
|
||||
_set_tile_drawer_button_state()
|
||||
|
||||
@@ -2878,6 +2890,71 @@ func _tile_drawer_section_title(title: String, expanded: bool) -> String:
|
||||
return "%s %s" % ["[-]" if expanded else "[+]", title]
|
||||
|
||||
|
||||
## Creates a collapsible section whose content sits inside a ScrollContainer so that
|
||||
## long effect lists don't overflow the drawer. The returned dict has the same keys
|
||||
## as _create_tile_drawer_section ("root", "header", "content", "title") plus "scroll"
|
||||
## and a mutable "count" entry used to keep the header label up-to-date.
|
||||
func _create_scrollable_section(parent: VBoxContainer, title: String) -> Dictionary:
|
||||
var section := VBoxContainer.new()
|
||||
section.layout_mode = 2
|
||||
section.add_theme_constant_override("separation", 4)
|
||||
parent.add_child(section)
|
||||
|
||||
var header := Button.new()
|
||||
header.layout_mode = 2
|
||||
header.toggle_mode = true
|
||||
header.button_pressed = false
|
||||
header.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
header.text = _tile_drawer_section_title(title, false)
|
||||
section.add_child(header)
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.layout_mode = 2
|
||||
scroll.custom_minimum_size = Vector2(0, 90)
|
||||
scroll.vertical_scroll_mode = ScrollContainer.SCROLL_MODE_AUTO
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
scroll.visible = false
|
||||
section.add_child(scroll)
|
||||
|
||||
var content := VBoxContainer.new()
|
||||
content.layout_mode = 2
|
||||
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
content.add_theme_constant_override("separation", 2)
|
||||
scroll.add_child(content)
|
||||
|
||||
section.visible = false
|
||||
|
||||
var data: Dictionary = {
|
||||
"root": section,
|
||||
"header": header,
|
||||
"scroll": scroll,
|
||||
"content": content,
|
||||
"title": title,
|
||||
"count": 0,
|
||||
}
|
||||
|
||||
header.toggled.connect(func(is_pressed: bool) -> void:
|
||||
scroll.visible = is_pressed
|
||||
var n: int = data.get("count", 0)
|
||||
var t: String = data.get("title", "Active Effects")
|
||||
var display: String = ("%s (%d)" % [t, n]) if n > 0 else t
|
||||
header.text = _tile_drawer_section_title(display, is_pressed))
|
||||
|
||||
return data
|
||||
|
||||
|
||||
## Updates the effects section header text (e.g. "Active Effects (3)") and stores
|
||||
## the count so the toggle signal can rebuild the label correctly.
|
||||
func _update_effects_section_header(section: Dictionary, count: int) -> void:
|
||||
section["count"] = count
|
||||
var header: Button = section.get("header") as Button
|
||||
if not is_instance_valid(header):
|
||||
return
|
||||
var title: String = section.get("title", "Active Effects")
|
||||
var display: String = ("%s (%d)" % [title, count]) if count > 0 else title
|
||||
header.text = _tile_drawer_section_title(display, header.button_pressed)
|
||||
|
||||
|
||||
func _create_detail_labels(parent: VBoxContainer, count: int) -> Array:
|
||||
var labels: Array = []
|
||||
for _i in range(count):
|
||||
@@ -2964,10 +3041,6 @@ func _build_unit_detail_lines(unit: Dictionary, owner_id: String,
|
||||
lines.append("Ability: %s" % ability_name)
|
||||
tooltips.append(ability_desc)
|
||||
|
||||
var unit_id: String = str(unit.get("instanceId", ""))
|
||||
if not unit_id.is_empty():
|
||||
_append_active_effect_lines(unit_id, lines, tooltips)
|
||||
|
||||
return {
|
||||
"lines": lines,
|
||||
"tooltips": tooltips,
|
||||
@@ -3011,11 +3084,15 @@ func _set_tile_drawer_content(tile: Dictionary) -> void:
|
||||
_tile_drawer_last_tile = tile.duplicate(true)
|
||||
_set_tile_drawer_button_state()
|
||||
if tile.is_empty():
|
||||
_set_tile_drawer_lines(_tile_drawer_tile_section, _tile_drawer_tile_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_tile_section, _tile_drawer_tile_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_spirit_section, _tile_drawer_spirit_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_token_section, _tile_drawer_token_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_arch_section, _tile_drawer_arch_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_token_section, _tile_drawer_token_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_arch_section, _tile_drawer_arch_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_token_effects_section, _tile_drawer_token_effects_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels, [])
|
||||
return
|
||||
|
||||
var coord : Dictionary = tile.get("coord", {})
|
||||
@@ -3046,45 +3123,53 @@ func _set_tile_drawer_content(tile: Dictionary) -> void:
|
||||
var spirit_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else _find_unit_owner_account_id(occ_id)
|
||||
var spirit_detail: Dictionary = _build_unit_detail_lines(occ_unit, spirit_owner_id)
|
||||
_set_tile_drawer_lines(
|
||||
_tile_drawer_spirit_section,
|
||||
_tile_drawer_spirit_labels,
|
||||
spirit_detail.get("lines", []),
|
||||
spirit_detail.get("tooltips", []))
|
||||
_tile_drawer_spirit_section, _tile_drawer_spirit_labels,
|
||||
spirit_detail.get("lines", []), spirit_detail.get("tooltips", []))
|
||||
_set_effects_section(occ_id, _tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels)
|
||||
else:
|
||||
_set_tile_drawer_lines(_tile_drawer_spirit_section, _tile_drawer_spirit_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_spirit_effects_section, _tile_drawer_spirit_effects_labels, [])
|
||||
|
||||
if not occ_id.is_empty() and occ_id != "null" and occ_type == "SpiritToken":
|
||||
var token_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else _find_unit_owner_account_id(occ_id)
|
||||
var token_detail: Dictionary = _build_unit_detail_lines(occ_unit, token_owner_id)
|
||||
_set_tile_drawer_lines(
|
||||
_tile_drawer_token_section,
|
||||
_tile_drawer_token_labels,
|
||||
token_detail.get("lines", []),
|
||||
token_detail.get("tooltips", []))
|
||||
_tile_drawer_token_section, _tile_drawer_token_labels,
|
||||
token_detail.get("lines", []), token_detail.get("tooltips", []))
|
||||
_set_effects_section(occ_id, _tile_drawer_token_effects_section, _tile_drawer_token_effects_labels)
|
||||
else:
|
||||
_set_tile_drawer_lines(_tile_drawer_token_section, _tile_drawer_token_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_token_section, _tile_drawer_token_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_token_effects_section, _tile_drawer_token_effects_labels, [])
|
||||
|
||||
if not occ_id.is_empty() and occ_id != "null" and occ_type == "ArchSpirit":
|
||||
var arch_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else _find_unit_owner_account_id(occ_id)
|
||||
var arch_detail: Dictionary = _build_unit_detail_lines(occ_unit, arch_owner_id, true)
|
||||
_set_tile_drawer_lines(
|
||||
_tile_drawer_arch_section,
|
||||
_tile_drawer_arch_labels,
|
||||
arch_detail.get("lines", []),
|
||||
arch_detail.get("tooltips", []))
|
||||
_tile_drawer_arch_section, _tile_drawer_arch_labels,
|
||||
arch_detail.get("lines", []), arch_detail.get("tooltips", []))
|
||||
_set_effects_section(occ_id, _tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels)
|
||||
else:
|
||||
_set_tile_drawer_lines(_tile_drawer_arch_section, _tile_drawer_arch_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_arch_section, _tile_drawer_arch_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_arch_effects_section, _tile_drawer_arch_effects_labels, [])
|
||||
|
||||
if ruin_id_value != null and not ruin_id.is_empty() and ruin_id != "null":
|
||||
var ruin_lines : Array = [
|
||||
"Ruin: %s" % ruin_id,
|
||||
"Owner: %s" % Game.get_display_name(ruin_owner_id),
|
||||
]
|
||||
var ruin_tooltips : Array = ["", ""]
|
||||
_append_active_effect_lines(ruin_id, ruin_lines, ruin_tooltips)
|
||||
var ruin_lines : Array = ["Ruin: %s" % ruin_id, "Owner: %s" % Game.get_display_name(ruin_owner_id)]
|
||||
var ruin_tooltips: Array = ["", ""]
|
||||
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, ruin_lines, ruin_tooltips)
|
||||
_set_effects_section(ruin_id, _tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels)
|
||||
else:
|
||||
_set_tile_drawer_lines(_tile_drawer_ruin_section, _tile_drawer_ruin_labels, [])
|
||||
_set_tile_drawer_lines(_tile_drawer_ruin_effects_section, _tile_drawer_ruin_effects_labels, [])
|
||||
|
||||
|
||||
## Populates [param section] (a scrollable effects section) with effects targeting
|
||||
## [param target_ref], then updates the header count badge.
|
||||
func _set_effects_section(target_ref: String, section: Dictionary, labels: Array) -> void:
|
||||
var effect_lines : Array = []
|
||||
var effect_tooltips : Array = []
|
||||
_append_active_effect_lines(target_ref, effect_lines, effect_tooltips)
|
||||
_set_tile_drawer_lines(section, labels, effect_lines, effect_tooltips)
|
||||
_update_effects_section_header(section, effect_lines.size())
|
||||
|
||||
|
||||
func _set_tile_drawer_button_state() -> void:
|
||||
|
||||
Reference in New Issue
Block a user