194 lines
7.9 KiB
GDScript
194 lines
7.9 KiB
GDScript
extends SceneTree
|
|
|
|
## GUI-only visual ownership probe for M52 Market. It writes static-only,
|
|
## dynamic-only-on-neutral and final composite PNGs for each shipped fixture.
|
|
|
|
const MarketPageView = preload("res://entry/views/market_page_view.gd")
|
|
const InkCheck = preload("res://tools/ui_ink_check.gd")
|
|
const FIXTURES := [
|
|
{"width": 760, "height": 360},
|
|
{"width": 844, "height": 390},
|
|
{"width": 1280, "height": 720},
|
|
]
|
|
const LOCALES := ["zh_CN", "en"]
|
|
var output_root := ""
|
|
var ink_scanned := 0
|
|
var ink_violations: Array = []
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
func _run() -> void:
|
|
if OS.get_environment("ABG_EVIDENCE_DIR").is_empty():
|
|
push_error("Market visual probe requires the owned test-attempt runner")
|
|
quit(1)
|
|
return
|
|
output_root = OS.get_environment("ABG_EVIDENCE_DIR").path_join("market-visual-probe")
|
|
DirAccess.make_dir_recursive_absolute(output_root)
|
|
var self_test := InkCheck.self_test(root)
|
|
if self_test.size() < 3:
|
|
push_error("M59 ink self-test expected at least 3 violations, got %d" % self_test.size())
|
|
quit(1)
|
|
return
|
|
print("ABG_M59_INK_SELF_TEST_OK violations=%d" % self_test.size())
|
|
ink_scanned = 0
|
|
ink_violations = []
|
|
for fixture in FIXTURES:
|
|
for locale in LOCALES:
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), false)
|
|
await _capture_fixture(int(fixture.width), int(fixture.height), String(locale), true)
|
|
if not ink_violations.is_empty():
|
|
for violation in ink_violations:
|
|
push_error("M59 ink violation %s %s %s %s [%s] %s: %s" % [
|
|
violation.variant, violation.locale, violation.size, violation.kind,
|
|
violation.path, violation.node, violation.detail,
|
|
])
|
|
print("ABG_M59_INK_CHECK_FAIL scanned=%d violations=%d" % [ink_scanned, ink_violations.size()])
|
|
quit(1)
|
|
return
|
|
print("ABG_M59_INK_CHECK_OK scanned=%d violations=0" % ink_scanned)
|
|
print("ABG_M52_MARKET_VISUAL_PROBE_OK fixtures=3 locales=2 variants=normal,longest views=static,dynamic,final")
|
|
quit(0)
|
|
|
|
func _capture_fixture(width: int, height: int, locale: String, longest: bool) -> void:
|
|
root.size = Vector2(width, height)
|
|
var view := MarketPageView.new()
|
|
view.name = "MarketVisualProbeView"
|
|
view.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
view.configure_presentation({"safe_area": 24, "text_scale": 1.0, "locale": locale})
|
|
root.add_child(view)
|
|
view.render(_fixture_data(locale, longest))
|
|
await process_frame
|
|
await RenderingServer.frame_post_draw
|
|
_save_image("%s/%s-%dx%d-%s-final.png" % [output_root, locale, width, height, "longest" if longest else "normal"])
|
|
|
|
var violations := InkCheck.scan(view)
|
|
ink_scanned += 1
|
|
for violation in violations:
|
|
violation["variant"] = "longest" if longest else "normal"
|
|
violation["locale"] = locale
|
|
violation["size"] = "%dx%d" % [width, height]
|
|
ink_violations.append(violation)
|
|
|
|
var page := view.find_child("M52MarketDesignPage", true, false) as Control
|
|
if page != null:
|
|
page.visible = false
|
|
await process_frame
|
|
await RenderingServer.frame_post_draw
|
|
_save_image("%s/%s-%dx%d-%s-static.png" % [output_root, locale, width, height, "longest" if longest else "normal"])
|
|
if page != null:
|
|
page.visible = true
|
|
var background := view.find_child("M52MarketWorldBackground", true, false) as Control
|
|
var matte := view.find_child("MarketMasterMatte", true, false) as Control
|
|
if background != null:
|
|
background.visible = false
|
|
if matte != null:
|
|
matte.visible = false
|
|
var neutral := ColorRect.new()
|
|
neutral.name = "NeutralProbeBackground"
|
|
neutral.color = Color("#26353c")
|
|
neutral.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
neutral.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
view.add_child(neutral)
|
|
view.move_child(neutral, 0)
|
|
await process_frame
|
|
await RenderingServer.frame_post_draw
|
|
_save_image("%s/%s-%dx%d-%s-dynamic.png" % [output_root, locale, width, height, "longest" if longest else "normal"])
|
|
view.queue_free()
|
|
await process_frame
|
|
|
|
func _save_image(path: String) -> void:
|
|
var texture := root.get_viewport().get_texture()
|
|
if texture != null:
|
|
texture.get_image().save_png(path)
|
|
|
|
func _fixture_data(locale: String, longest := false) -> Dictionary:
|
|
var is_zh := locale == "zh_CN"
|
|
var names := (
|
|
["卡珊德拉", "奥莉薇娅", "风语者"]
|
|
if longest and is_zh
|
|
else ["Gannet Faircurrent", "Cassa Stonebloom", "Hessa Quillwater"]
|
|
if longest
|
|
else ["阿里", "布兰", "塞拉"] if is_zh else ["Ari", "Bram", "Cera"]
|
|
)
|
|
return {
|
|
"ok": true,
|
|
"page_id": "market",
|
|
"locale": locale,
|
|
"category": "recruit",
|
|
"selected_kind": "recruit",
|
|
"selected_offer_id": "R-001",
|
|
"selected_offer": _recruit("R-001", names[0], locale, longest),
|
|
"offers": {
|
|
"recruit": [
|
|
_recruit("R-001", names[0], locale, longest),
|
|
_recruit("R-002", names[1], locale, longest),
|
|
_recruit("R-003", names[2], locale, longest),
|
|
],
|
|
},
|
|
"available": {"recruit": ["R-001", "R-002", "R-003"]},
|
|
"company": (
|
|
{"owned_count": 8, "line_capacity": 8, "coin": 999}
|
|
if longest
|
|
else {"owned_count": 2, "line_capacity": 4, "coin": 38}
|
|
),
|
|
"commands": {"return_contract": {"enabled": true, "reason": "ready"}},
|
|
}
|
|
|
|
|
|
func _recruit(offer_id: String, recruit_name: String, locale: String, longest := false) -> Dictionary:
|
|
var is_zh := locale == "zh_CN"
|
|
# Real per-offer identity: three different base professions so the board
|
|
# renders three different portraits. A single hardcoded profession_id made
|
|
# the capture show three copies of one recruit.
|
|
var index := int(offer_id.trim_prefix("R-"))
|
|
var slot := clampi(index - 1, 0, 2)
|
|
var profession_ids := ["PF-B01", "PF-B05", "PF-B07"]
|
|
var zh_professions := ["盾卫", "弓手", "治疗"]
|
|
var en_professions := ["Hearthguard", "Farstring", "Kindhand"]
|
|
var zh_traits := ["最后见证", "稳固阵线", "夜航直觉"]
|
|
var en_traits := ["Last Witness", "Steady Line", "Night Sense"]
|
|
var list_prices := [14, 18, 22]
|
|
var company_line := "队伍 2 → 3" if slot == 0 else "队伍 2 → 3"
|
|
var company_line_en := "Company 2 -> 3"
|
|
if longest:
|
|
# Longest shipped strings measured from the runtime catalog: base
|
|
# professions 护心卫士/逐风行者/远弦射手 and Hearthguard/Wayrunner/
|
|
# Farstring, traits 反转带扣/Turncoat Buckle (15 glyphs), recruit names
|
|
# from the display-name pool, three-digit coin and a full 8/8 line.
|
|
profession_ids = ["PF-B01", "PF-B04", "PF-B05"]
|
|
zh_professions = ["护心卫士", "逐风行者", "远弦射手"]
|
|
en_professions = ["Hearthguard", "Wayrunner", "Farstring"]
|
|
zh_traits = ["反转带扣", "松散阵形", "最后见证"]
|
|
en_traits = ["Turncoat Buckle", "Loose Formation", "Last Witness"]
|
|
list_prices = [999, 998, 997]
|
|
company_line = "队伍 8 → 9"
|
|
company_line_en = "Company 8 -> 9"
|
|
# The production context line is two short rows built by the Market
|
|
# controller ("profession · trait" then price and Company growth). Keep the
|
|
# fixture in that authored shape so the ledger slot is exercised honestly.
|
|
var zh_details := [
|
|
"%s · %s\n%d Coin · %s" % [zh_professions[slot], zh_traits[slot], list_prices[slot], company_line],
|
|
"%s · %s\n%d Coin · %s" % [zh_professions[1], zh_traits[1], list_prices[1], company_line],
|
|
"%s · %s\n%d Coin · %s" % [zh_professions[2], zh_traits[2], list_prices[2], company_line],
|
|
]
|
|
var en_details := [
|
|
"%s · %s\n%d COIN · %s" % [en_professions[slot], en_traits[slot], list_prices[slot], company_line_en],
|
|
"%s · %s\n%d COIN · %s" % [en_professions[1], en_traits[1], list_prices[1], company_line_en],
|
|
"%s · %s\n%d COIN · %s" % [en_professions[2], en_traits[2], list_prices[2], company_line_en],
|
|
]
|
|
return {
|
|
"source_offer_id": offer_id,
|
|
"display_name_tokens": [recruit_name],
|
|
"recruit_name": recruit_name,
|
|
"profession_id": profession_ids[slot],
|
|
"trait_id": "TR-%03d" % (slot + 1),
|
|
"list_price": list_prices[slot],
|
|
"presentation": {
|
|
"recruit_name": recruit_name,
|
|
"profession_name": zh_professions[slot] if is_zh else en_professions[slot],
|
|
"trait_name": zh_traits[slot] if is_zh else en_traits[slot],
|
|
"short_detail": zh_details[slot] if is_zh else en_details[slot],
|
|
},
|
|
}
|