feat: extract recruit card component showroom

This commit is contained in:
2026-09-09 19:36:53 +08:00
parent 4803e86999
commit 33dedf13d5
9 changed files with 455 additions and 0 deletions
@@ -185,6 +185,12 @@ bounds, and the title uses a bounded 26px design size so English and Chinese
subtitle lines cannot collide on phone-landscape widths. This remains a focused
M52-B correction pending owner visual review.
RecruitCard component extraction (`working tree`, 2026-09-09): the first
standalone module is now defined as `ABGM52RecruitCard` with independent
Portrait, Identity, Trait, Cost, State and HitArea children. Its HTML showroom
and component contract are kept separate from the Market composition so the
owner can approve the module before page integration.
### M52-C — Complete one playable loop and owner tryout
- Extend the same visual language through Recruit Review, Party, Battle and
@@ -0,0 +1,54 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Aetherbound Guild · Recruit Card Component</title>
<style>
:root{--ink:#3b2b22;--soft:#6d5038;--paper:#f7e9c7;--paper-light:#fff5dc;--shade:#e4c990;--wood:#74472d;--brass:#d9a848;--teal:#2f6b73;--teal-light:#74aeb0;--bg:#20323a}
*{box-sizing:border-box} body{margin:0;background:#111b20;color:#f8ecd0;font-family:"Noto Sans SC","PingFang SC",sans-serif}
.stage{min-height:100vh;padding:28px;display:grid;grid-template-columns:minmax(420px,1fr) minmax(280px,420px);gap:24px;background:radial-gradient(circle at 50% 0,#4b7180 0,#20323a 58%,#111b20 100%)}
.showcase{border:1px solid #9dc2bb66;border-radius:18px;padding:22px;background:#17262ccc;box-shadow:0 18px 45px #0006}
h1{margin:0 0 8px;font-size:22px;color:#fff5dc} .sub{color:#c6b99c;font-size:13px;margin-bottom:18px}
.cards{display:flex;align-items:end;justify-content:center;gap:22px;min-height:560px;padding:28px 18px 10px;background:#10242b99;border-radius:14px}
.card{position:relative;width:180px;height:420px;filter:drop-shadow(0 12px 10px #0007);transition:.18s ease;cursor:pointer}
.card:hover{transform:translateY(-6px)} .card.selected{transform:translateY(-10px);filter:drop-shadow(0 0 0 #000) drop-shadow(0 14px 15px #0008)}
.rope{position:absolute;z-index:1;left:28px;right:28px;top:0;height:35px;border-top:4px solid #8c613d;border-radius:50%}
.paper{position:absolute;inset:18px 0 0;border:3px solid var(--wood);border-radius:12px 12px 18px 18px;background:linear-gradient(110deg,#fff0c9,#ecd39b);box-shadow:inset 0 0 0 3px #fff5dc66,8px 8px 0 #3b241766}
.ribbon{position:absolute;z-index:3;left:14%;right:14%;top:30px;height:38px;display:grid;place-items:center;color:#fff5dc;font-size:12px;background:var(--teal);clip-path:polygon(5% 0,95% 0,100% 100%,0 100%);border-top:2px solid #a7d0c4}
.portrait{position:absolute;z-index:2;left:15%;right:15%;top:76px;height:170px;border:5px solid var(--wood);border-radius:10px;background:#d4b67d;overflow:hidden;display:grid;place-items:center;box-shadow:inset 0 0 0 2px var(--brass)}
.portrait img{width:125%;height:125%;object-fit:cover;object-position:center top}
.name{position:absolute;z-index:3;left:10%;right:10%;top:258px;height:40px;padding:0 8px;display:grid;place-items:center;color:var(--ink);font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border:1px solid var(--shade);border-radius:6px;background:#fff5dcef}
.trait{position:absolute;z-index:3;left:14%;right:14%;top:310px;text-align:center;color:var(--soft);font-size:12px;line-height:1.2}
.cost{position:absolute;z-index:3;left:14%;right:14%;top:350px;height:34px;display:grid;place-items:center;color:var(--ink);font-size:11px;border:1px solid var(--shade);border-radius:6px;background:#f7e9c7cc}
.selected .paper{border-color:var(--teal-light);box-shadow:0 0 0 3px #74aeb066,inset 0 0 0 3px #fff5dc66,8px 8px 0 #3b241766}
.disabled{opacity:.45;filter:grayscale(.4)} .legend{display:flex;gap:8px;margin-top:18px;color:#d6c6a7;font-size:12px}.dot{width:12px;height:12px;border-radius:50%;display:inline-block}.dot.normal{background:#d9a848}.dot.selected{background:#74aeb0}.dot.disabled{background:#888}
.anatomy{display:grid;gap:10px}.module{padding:12px;border:1px solid #b8d4ca44;border-radius:10px;background:#20353dcc}.module h2{font-size:14px;margin:0 0 4px;color:#ffe7ae}.module p{font-size:12px;line-height:1.5;color:#c6d1c7;margin:0}.contract{margin-top:18px;padding:14px;border-radius:12px;background:#101d22;border-left:3px solid var(--brass);font-size:12px;line-height:1.6;color:#d8cdb7}
@media(max-width:860px){.stage{grid-template-columns:1fr;padding:16px}.cards{min-height:470px;gap:8px;padding:18px 4px}.card{width:30%;height:350px}.ribbon{top:24px;font-size:10px}.portrait{top:60px;height:140px}.name{top:214px;font-size:12px}.trait{top:260px;font-size:10px}.cost{top:296px;font-size:9px}}
</style>
</head>
<body>
<main class="stage">
<section class="showcase">
<h1>招募卡 · RecruitCard</h1>
<div class="sub">单卡组件展示:正常、选中、不可用。文字和人物图都由运行时注入。</div>
<div class="cards">
<article class="card"><div class="rope"></div><div class="paper"></div><div class="ribbon">长枪使</div><div class="portrait"><img src="../../../../runtime/assets/entry/recruit_stickers/m52_q_company/spear_idle.png" alt="长枪使头像"></div><div class="name">Yori Valehook</div><div class="trait">最后见证</div><div class="cost">可招募 · 14 金币</div></article>
<article class="card selected"><div class="rope"></div><div class="paper"></div><div class="ribbon">护盾骑士</div><div class="portrait"><img src="../../../../runtime/assets/entry/recruit_stickers/m52_q_company/shield_idle.png" alt="护盾骑士头像"></div><div class="name">Lio Bellwake</div><div class="trait">二次草稿</div><div class="cost">已选中 · 14 金币</div></article>
<article class="card disabled"><div class="rope"></div><div class="paper"></div><div class="ribbon">奥术师</div><div class="portrait"><img src="../../../../runtime/assets/entry/recruit_stickers/m52_q_company/mage_idle.png" alt="奥术师头像"></div><div class="name">Neris Northcoil</div><div class="trait">薄血</div><div class="cost">金币不足</div></article>
</div>
<div class="legend"><span><i class="dot normal"></i> 正常</span><span><i class="dot selected"></i> 选中</span><span><i class="dot disabled"></i> 不可用</span></div>
</section>
<aside class="showcase anatomy">
<h1>组件拆解</h1>
<div class="module"><h2>CardShell</h2><p>纸张、内边框、阴影、挂绳。只负责材质,不承载动态文字。</p></div>
<div class="module"><h2>PortraitModule</h2><p>外框、内框、裁切窗口、人物图、阴影。人物始终保持比例并居中裁切。</p></div>
<div class="module"><h2>IdentityModule</h2><p>独立姓名板和姓名文字。单行,超长省略,不能越过姓名板。</p></div>
<div class="module"><h2>TraitModule</h2><p>特质文字独立占位,最多两行,不能侵入金额区域。</p></div>
<div class="module"><h2>CostModule</h2><p>状态和金币独立组合。金额是关键事实,保留完整可读内容。</p></div>
<div class="module"><h2>StateLayer / HitArea</h2><p>选中框、禁用层、悬停反馈和点击区域与视觉层分离。</p></div>
<div class="contract"><strong>验收标准</strong><br>每个文字只存在于自己的模块;每个模块独立裁切;组件内部无重叠;状态切换不改变页面其他模块的位置。</div>
</aside>
</main>
</body>
</html>
@@ -0,0 +1,56 @@
# M52 RecruitCard Component Contract
This is the first independently reviewable UI module in the M52 Market
reconstruction. It is intentionally not mounted by Market yet.
## Ownership tree
```text
ABGM52RecruitCard (Button)
├── VisualLayer
│ ├── CardShell
│ ├── ProfessionRibbon
│ ├── PortraitModule
│ │ ├── PortraitFrameOuter
│ │ ├── PortraitViewport (clip_contents=true)
│ │ │ ├── PortraitFrameInner
│ │ │ ├── PortraitImage (keep-aspect-covered)
│ │ │ └── PortraitShadow
│ │ ├── IdentityModule
│ │ ├── TraitModule
│ │ └── CostModule
├── StateLayer
│ └── SelectedBorder
└── HitArea
```
## Content rules
- The portrait keeps its aspect ratio and is center-cropped inside a fixed
viewport. It cannot paint over the frame or adjacent copy.
- The name is a single line with ellipsis inside `NamePlate`.
- The trait is a short, wrapped line inside `TraitModule`.
- Availability and cost are one line inside `CostModule`; the cost must remain
complete in the card's minimum play size.
- Dynamic text is engine-owned. Generated art supplies material and ornament,
never names, prices, or fake glyphs.
## State rules
`normal`, `hover`, `pressed`, `selected`, `disabled`, and `focus` are state
layers over the same geometry. State changes must not move the portrait,
identity, trait, or cost modules.
## Responsive rules
The card root receives a normalized slot from its parent. Children use local
normalized slots and local clipping. Background and paper may stretch; the
portrait and icons keep aspect; text is never geometrically stretched.
## Acceptance
- Component tree and slot boundaries pass
`m52_recruit_card_component_test.gd`.
- HTML showroom: `docs/prototype/m52_components/recruit_card/index.html`.
- Owner review is still required before this component is integrated into the
Market page.
@@ -0,0 +1,52 @@
extends SceneTree
const RecruitCard = preload("res://ui/m52/recruit_card.gd")
var failures: Array[String] = []
func _initialize() -> void:
call_deferred("run_test")
func run_test() -> void:
root.size = Vector2(320, 480)
var card := RecruitCard.new().configure({
"name": "Yori Valehook",
"profession": "长枪使",
"trait": "最后见证",
"availability": "可招募",
"cost": "14 金币",
"accent": "blue",
})
card.name = "RecruitCardFixture"
card.position = Vector2(40, 20)
card.size = Vector2(240, 400)
root.add_child(card)
await process_frame
for node_name in ["CardShell", "ProfessionRibbon", "PortraitModule", "IdentityModule", "TraitModule", "CostModule", "StateLayer", "HitArea"]:
expect(card.find_child(node_name, true, false) != null, "%s exists" % node_name)
var portrait := card.find_child("PortraitModule", true, false) as Control
var identity := card.find_child("IdentityModule", true, false) as Control
var trait_control := card.find_child("TraitModule", true, false) as Control
var cost := card.find_child("CostModule", true, false) as Control
if portrait != null and identity != null:
expect(not portrait.get_rect().intersects(identity.get_rect()), "portrait and identity do not overlap")
if identity != null and trait_control != null:
expect(not identity.get_rect().intersects(trait_control.get_rect()), "identity and trait do not overlap")
if trait_control != null and cost != null:
expect(not trait_control.get_rect().intersects(cost.get_rect()), "trait and cost do not overlap")
card.set_selected(true)
await process_frame
expect(bool(card.get_meta("selected", false)), "selection state is stored")
card.queue_free()
await process_frame
if failures.is_empty():
print("ABG_M52_RECRUIT_CARD_COMPONENT_OK tree=true slots=true clipping=true selected=true")
quit(0)
else:
for failure in failures:
push_error(failure)
quit(1)
func expect(condition: bool, message: String) -> void:
if not condition:
failures.append(message)
+37
View File
@@ -0,0 +1,37 @@
class_name ABGM52CostModule
extends Control
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
const UIFactory = preload("res://ui/shared/ui_factory.gd")
var status := ""
var cost := ""
func configure(next_status: String, next_cost: String) -> ABGM52CostModule:
status = next_status
cost = next_cost
return self
func _ready() -> void:
var plate := Panel.new()
plate.name = "CostPlate"
plate.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
plate.mouse_filter = Control.MOUSE_FILTER_IGNORE
var style := StyleBoxFlat.new()
style.bg_color = Color(MarketChrome.PAPER, 0.78)
style.border_color = MarketChrome.PAPER_SHADE
style.set_border_width_all(1)
style.set_corner_radius_all(5)
plate.add_theme_stylebox_override("panel", style)
add_child(plate)
var label := UIFactory.label("%s · %s" % [status, cost], "micro", 1.0, MarketChrome.INK)
label.name = "CostLabel"
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
label.offset_left = 4.0
label.offset_right = -4.0
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
plate.add_child(label)
+35
View File
@@ -0,0 +1,35 @@
class_name ABGM52IdentityModule
extends Control
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
const UIFactory = preload("res://ui/shared/ui_factory.gd")
var value := ""
func configure(next_value: String) -> ABGM52IdentityModule:
value = next_value
return self
func _ready() -> void:
var plate := Panel.new()
plate.name = "NamePlate"
plate.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
plate.mouse_filter = Control.MOUSE_FILTER_IGNORE
var style := StyleBoxFlat.new()
style.bg_color = Color(MarketChrome.PAPER_LIGHT, 0.92)
style.border_color = MarketChrome.PAPER_SHADE
style.set_border_width_all(1)
style.set_corner_radius_all(5)
plate.add_theme_stylebox_override("panel", style)
add_child(plate)
var label := UIFactory.label(value, "label", 1.0, MarketChrome.INK)
label.name = "NameLabel"
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
label.offset_left = 6.0
label.offset_right = -6.0
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
plate.add_child(label)
+70
View File
@@ -0,0 +1,70 @@
class_name ABGM52PortraitModule
extends Control
## A fixed portrait window. The frame owns the visual boundary; the viewport
## owns clipping; the image is never allowed to paint over adjacent copy.
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
var portrait_texture: Texture2D
func configure(texture: Texture2D) -> ABGM52PortraitModule:
portrait_texture = texture
return self
func _ready() -> void:
_build()
func _build() -> void:
clip_contents = true
mouse_filter = Control.MOUSE_FILTER_IGNORE
var outer := Panel.new()
outer.name = "PortraitFrameOuter"
outer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
outer.mouse_filter = Control.MOUSE_FILTER_IGNORE
var outer_style := StyleBoxFlat.new()
outer_style.bg_color = MarketChrome.WOOD
outer_style.border_color = MarketChrome.BRASS
outer_style.set_border_width_all(2)
outer_style.set_corner_radius_all(8)
outer.add_theme_stylebox_override("panel", outer_style)
add_child(outer)
var viewport := Control.new()
viewport.name = "PortraitViewport"
viewport.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
viewport.offset_left = 5.0
viewport.offset_top = 5.0
viewport.offset_right = -5.0
viewport.offset_bottom = -5.0
viewport.clip_contents = true
viewport.mouse_filter = Control.MOUSE_FILTER_IGNORE
outer.add_child(viewport)
var inner := Panel.new()
inner.name = "PortraitFrameInner"
inner.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
inner.mouse_filter = Control.MOUSE_FILTER_IGNORE
var inner_style := StyleBoxFlat.new()
inner_style.bg_color = MarketChrome.PAPER_SHADE
inner_style.border_color = MarketChrome.INK_SOFT
inner_style.set_border_width_all(1)
inner_style.set_corner_radius_all(5)
viewport.add_child(inner)
var image := TextureRect.new()
image.name = "PortraitImage"
image.texture = portrait_texture
image.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
image.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
image.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED
image.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
image.mouse_filter = Control.MOUSE_FILTER_IGNORE
viewport.add_child(image)
var shade := ColorRect.new()
shade.name = "PortraitShadow"
shade.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
shade.color = Color(0.10, 0.07, 0.05, 0.06)
shade.mouse_filter = Control.MOUSE_FILTER_IGNORE
viewport.add_child(shade)
+120
View File
@@ -0,0 +1,120 @@
class_name ABGM52RecruitCard
extends Button
## Standalone, reusable recruit card. The page only supplies data and a slot;
## this component owns its child layout, clipping and state layers.
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
const UIFactory = preload("res://ui/shared/ui_factory.gd")
const PortraitModule = preload("res://ui/m52/portrait_module.gd")
const IdentityModule = preload("res://ui/m52/identity_module.gd")
const TraitModule = preload("res://ui/m52/trait_module.gd")
const CostModule = preload("res://ui/m52/cost_module.gd")
var recruit_name := ""
var profession_name := ""
var trait_name := ""
var availability := "可招募"
var cost_text := "14 金币"
var portrait_texture: Texture2D
var accent := "blue"
func configure(data: Dictionary) -> ABGM52RecruitCard:
recruit_name = String(data.get("name", "未命名候选人"))
profession_name = String(data.get("profession", "冒险者"))
trait_name = String(data.get("trait", "待观察"))
availability = String(data.get("availability", "可招募"))
cost_text = String(data.get("cost", "14 金币"))
portrait_texture = data.get("portrait") as Texture2D
accent = String(data.get("accent", "blue"))
return self
func _ready() -> void:
flat = true
focus_mode = Control.FOCUS_ALL
mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
clip_contents = true
for state in ["normal", "hover", "pressed", "disabled", "focus", "hover_pressed"]:
add_theme_stylebox_override(state, StyleBoxEmpty.new())
_build()
func _build() -> void:
var visual := Control.new()
visual.name = "VisualLayer"
visual.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
visual.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(visual)
var shell := MarketChrome.new().configure("card", accent)
shell.name = "CardShell"
shell.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
visual.add_child(shell)
var ribbon := UIFactory.label(profession_name, "micro", 1.0, MarketChrome.PAPER_LIGHT)
ribbon.name = "ProfessionRibbon"
_place(ribbon, Rect2(0.10, 0.055, 0.80, 0.10))
ribbon.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
ribbon.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
ribbon.clip_text = true
ribbon.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
ribbon.mouse_filter = Control.MOUSE_FILTER_IGNORE
visual.add_child(ribbon)
var portrait := PortraitModule.new().configure(portrait_texture)
portrait.name = "PortraitModule"
_place(portrait, Rect2(0.16, 0.18, 0.68, 0.42))
visual.add_child(portrait)
var identity := IdentityModule.new().configure(recruit_name)
identity.name = "IdentityModule"
_place(identity, Rect2(0.10, 0.64, 0.80, 0.105))
visual.add_child(identity)
var trait_module := TraitModule.new().configure(trait_name)
trait_module.name = "TraitModule"
_place(trait_module, Rect2(0.14, 0.755, 0.72, 0.085))
visual.add_child(trait_module)
var cost := CostModule.new().configure(availability, cost_text)
cost.name = "CostModule"
_place(cost, Rect2(0.14, 0.865, 0.72, 0.085))
visual.add_child(cost)
var state_layer := Control.new()
state_layer.name = "StateLayer"
state_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
state_layer.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(state_layer)
var focus := Panel.new()
focus.name = "SelectedBorder"
focus.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
focus.mouse_filter = Control.MOUSE_FILTER_IGNORE
focus.visible = false
var focus_style := StyleBoxFlat.new()
focus_style.bg_color = Color(0, 0, 0, 0)
focus_style.border_color = MarketChrome.TEAL_LIGHT
focus_style.set_border_width_all(3)
focus_style.set_corner_radius_all(10)
focus.add_theme_stylebox_override("panel", focus_style)
state_layer.add_child(focus)
var hit := Control.new()
hit.name = "HitArea"
hit.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
hit.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(hit)
func set_selected(selected: bool) -> void:
var border := find_child("SelectedBorder", true, false) as Control
if border != null:
border.visible = selected
set_meta("selected", selected)
func _place(control: Control, area: Rect2) -> void:
control.anchor_left = area.position.x
control.anchor_top = area.position.y
control.anchor_right = area.end.x
control.anchor_bottom = area.end.y
control.offset_left = 0.0
control.offset_top = 0.0
control.offset_right = 0.0
control.offset_bottom = 0.0
+25
View File
@@ -0,0 +1,25 @@
class_name ABGM52TraitModule
extends Control
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
const UIFactory = preload("res://ui/shared/ui_factory.gd")
var value := ""
func configure(next_value: String) -> ABGM52TraitModule:
value = next_value
return self
func _ready() -> void:
var label := UIFactory.label(value, "micro", 1.0, MarketChrome.INK_SOFT)
label.name = "TraitLabel"
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
label.offset_left = 4.0
label.offset_right = -4.0
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(label)