diff --git a/README.md b/README.md index 4970113..456868a 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Godot 4 tactical RPG prototype inspired by classic turn-based Romance of the Thr - Pre-battle Formation lets deployed officers swap starting positions inside scenario-defined cells, with portrait rows, readable zone badges, and hover placement instructions. - Pre-battle briefing shows the campaign chapter, chapter battle number, location, victory/defeat summary, and first-clear reward preview. - Pre-battle prep commands use compact icon buttons with active selection state and Korean hover labels for chapters, shop, talks, armory, roster, formation, and save records. -- Battle, top-toolbar, and pre-battle command buttons now prefer generated high-resolution bronze/parchment icon art under `art/ui/icons`, with procedural icon drawing kept only as a fallback. +- Battle, top-toolbar, and pre-battle command buttons now prefer generated high-resolution bronze/parchment icon art under `art/ui/icons` and generated lacquer/jade/cinnabar button surfaces under `art/ui/buttons`, with procedural icon drawing and flat button styles kept only as fallbacks. - Battle maps blend generated terrain texture tiles for plains, forests, hills, wasteland, roads, water, villages, and castles over the high-resolution battlefield backdrop. - Core UI panels now prefer generated high-resolution lacquer, scroll, jade, and command-seal frame textures under `art/ui/panels`, with the calmer ink/wood/jade flat styles kept as fallbacks instead of the earlier yellow, hard-edged frame treatment. - Pre-battle Chapters overview shows story-arc progress with map thumbnail rows, compact status badges, hover details, and can open completed or current battles. @@ -130,7 +130,7 @@ Godot 4 tactical RPG prototype inspired by classic turn-based Romance of the Thr - Victory and defeat result overlay. - Dialogue portrait slot stays fixed across speaker and narration lines, with officer default image paths, optional per-line overrides, and speaker-initial or record fallback. - Initial AI-generated photorealistic officer portraits for Cao Cao, Xiahou Dun, Xiahou Yuan, Cao Ren, Dian Wei, Guo Jia, and Zhang He. -- AI-generated scenario battlefield backgrounds, opening story panels, terrain textures, transparent class units, transparent generic-enemy units, item icons, toolbar UI icons, and generated UI panel frames live under `art/backgrounds`, `art/story`, `art/terrain`, `art/units`, `art/items`, `art/ui/icons`, and `art/ui/panels`. +- AI-generated scenario battlefield backgrounds, opening story panels, terrain textures, transparent class units, transparent generic-enemy units, item icons, toolbar UI icons, generated UI panel frames, and generated button surfaces live under `art/backgrounds`, `art/story`, `art/terrain`, `art/units`, `art/items`, `art/ui/icons`, `art/ui/panels`, and `art/ui/buttons`. - Battle HUD portrait thumbnails show the selected unit, or a hovered unit when nothing is selected. - Selected and hovered unit focus text shows combat role, movement type, current terrain move cost, terrain bonuses, core stats, and status effects. - Dialogue lines can mark speaking side for text alignment inside a fixed visual-novel-style dialogue panel with stable portrait, progress, and previous-line controls. diff --git a/art/ui/buttons/button_disabled.png b/art/ui/buttons/button_disabled.png new file mode 100644 index 0000000..87f6404 Binary files /dev/null and b/art/ui/buttons/button_disabled.png differ diff --git a/art/ui/buttons/button_hover.png b/art/ui/buttons/button_hover.png new file mode 100644 index 0000000..116c563 Binary files /dev/null and b/art/ui/buttons/button_hover.png differ diff --git a/art/ui/buttons/button_normal.png b/art/ui/buttons/button_normal.png new file mode 100644 index 0000000..404ac92 Binary files /dev/null and b/art/ui/buttons/button_normal.png differ diff --git a/art/ui/buttons/button_pressed.png b/art/ui/buttons/button_pressed.png new file mode 100644 index 0000000..523e995 Binary files /dev/null and b/art/ui/buttons/button_pressed.png differ diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 9c13dca..40f4485 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -62,7 +62,7 @@ Joined officers gate whether `requires_joined` player deployments are loaded at Inventory and campaign flags are copied from `CampaignState` into `BattleState` when a scenario starts. The pre-battle Chapters overview reads `CampaignState` chapter progress and can load completed or current battles without mutating the save. Briefings preview first-clear rewards, can expose `briefing.camp_conversations` through a selectable Talk menu with `briefing.camp_dialogue` as a fallback, can filter those conversations by saved campaign flags, can claim saved one-time camp conversation supply effects through `CampaignState` and refresh the loaded battle inventory copy, and show completed replay rewards as already claimed. The pre-battle Save menu can write the current campaign state to `user://campaign_manual_save.json`, and loading that checkpoint restores it into `user://campaign_save.json` before re-entering the same pending-choice, completion, or current-briefing branch as startup. Pre-battle shop stock comes from the loaded scenario's `shop.items` list plus matching `shop.conditional_items` blocks, with optional finite limits from item entries or `stock` maps, and `shop.merchant` lines are presentation-only camp flavor. Shop purchases and 50% sell-back are campaign transactions: they update saved gold, unequipped inventory, and finite-stock purchase counts immediately, write the save file, and refresh the already-loaded battle inventory before the player begins the battle. Camp conversation supply claims are also campaign transactions: they save a per-scenario conversation claim ledger and inventory immediately, then refresh the already-loaded battle inventory. Pre-battle Armory equipment changes use the same equipment rules as battle HUD equipment changes, then immediately save merged roster equipment/stat snapshots and inventory stock. Pre-battle Roster uses scenario `roster.max_units`, `roster.required_officers`, and `roster.required_units` to mark optional player deployments as sortie or reserve; reserve units remain in the candidate list but are excluded from board occupancy, drawing, selection, AI targeting, and living-unit victory checks. Non-controllable player units can act as protected escort targets: enemies can attack them and conditions can reference them, but they are skipped by player selection, Armory, Formation, counterattacks, and campaign roster progression snapshots when `persist_progression` is false. Scenario `ai_target_priority` nudges enemy movement and damage-skill scoring toward important targets such as envoys without overriding defeat bonuses or range checks, and `set_ai_target_priority` events can retune that battle-only pressure after an ambush, gate closure, or escort exposure. Pre-battle Formation uses the loaded scenario's `formation.cells` and only mutates current battle unit positions before battle-begin events fire. Destination victory cells from `unit_reaches_tile` conditions are exposed to the scene for objective overlays and tile info, and can be expressed as one `pos` or a multi-cell `cells` list; gated victory conditions can also expose the `unit_reaches_tile` event that unlocks them as the next visible objective marker. Rewarding movement events that grant items or gold can expose optional battlefield side markers and Korean tile-info labels through `when.label`, without being treated as victory objectives. Movement-triggered `unit_reaches_tile` events receive the unit that just moved, so ambushes and pickup events fire on entry rather than from units already standing on a marker; `unit_defeated` events receive the fallen unit before final victory/defeat checks, allowing named-officer reactions and last-moment reinforcements. Briefing data can append matching `briefing.conditional_lines`, and scenario events can use `when.campaign_flags` to branch dialogue, objective changes, item and gold pickups, AI target-priority shifts, and reinforcements from saved campaign choices or `when.after_event` to wait for earlier scenario beats. Consumable use can restore HP or MP, cure matching poison/seal/snare/disarm statuses, or cleanse negative stat debuffs, and in-battle item use, event pickup grants, event gold pickups, plus equipment swaps mutate only the battle copy until victory; defeats and restarts do not spend saved items, keep picked-up items or gold, or preserve in-battle gear changes. Post-battle choices write campaign `flags` only after the result-panel button is pressed; if the player reloads after rewards are saved but before selecting, the pending scenario id restores the victory choice panel without replaying rewards. The next battle button stays locked until the campaign choice save succeeds. Equipment rewards share the same `item_id -> count` inventory stock, cover weapon, armor, and accessory slots, can be equipped from the side HUD before the selected unit moves or acts, and do not appear in the consumable action menu. Named equipment currently uses the same stock model with a presentation-only rarity tag rather than unique item instances. Already completed scenarios can be replayed without granting duplicate rewards, choices, replay inventory consumption, event gold pickups, save writes, current-scenario advancement, finite-stock purchases, or camp conversation supply claims; pre-battle Shop, Armory, Roster, Formation, and Save are disabled on completed-scenario replays to avoid side effects. -The battle scene owns presentation feedback: briefing and result states use menu BGM, briefing headers combine `CampaignState` chapter ranges, campaign order, and title data with `BattleState` briefing, objective text, condition-progress text, and defeat-risk text, active battles use battle BGM and show an objective/progress/risk panel fed by `BattleState`, objective-update signals show a short HUD notice and refresh the objective panel immediately, core panels prefer generated lacquer, scroll, jade, and command-seal `StyleBoxTexture` frames with flat ink/wood/jade styles as fallbacks, dialogue lines can show optional cached portrait textures or speaker-initial fallback panels in an expanded visual-novel-style panel, keep the portrait slot fixed even for narration lines, mark speaking side through text alignment, and expose progress plus previous-line controls while a sequence is open, the side HUD reuses cached officer portrait textures or class sprites for the selected unit or hovered unit and formats focus text with role, movement type, facing, current terrain move cost, defense/avoid bonuses, core stats, status effects, guard-zone AI hints, and gear, board maps can draw a scenario background texture under translucent terrain overlays, generated terrain texture tiles, connected road segments, terrain detail patterns, shoreline/castle/forest/hill edge blends, compact recovery markers for healing terrain, compact side-event markers for visible item/gold pickups, and move-attack target badges for enemies that can be struck after movement, board units render class sprite tokens or generic-enemy transparent class cutouts, team rings, facing markers, generic-enemy marks, officer pins, low-HP warning rings, HP bar color states, active support/debuff/poison/seal/snare/disarm status pips, and a scene-clocked idle stance whose intensity reacts to selected, acted, and low-HP unit state, item buttons can show optional cached item icons, hover previews are rendered as target badges from existing `BattleState` forecast APIs and include compact side/rear attack bonuses when facing matters, equipment option menus show stat/range/effect deltas, result and inventory summaries show named equipment with compact rarity tags, selected area tactics highlight their affected cells, the Threat toggle overlays enemy physical and hostile tactic reach while tile info names threat sources, estimates physical damage, and summarizes hostile tactic damage or status effects against occupied cells, log/result hooks trigger placeholder SFX, support, debuff, poison, seal, snare, disarm, objective updates, AI target-focus changes, and item/gold pickup effects use distinct feedback, `BattleState.unit_motion_requested` asks the scene to interpolate a unit's draw position during movement, `BattleState.unit_action_motion_requested` keeps its rules-facing signal shape while the scene maps attacker class ids to infantry, archer, cavalry, command, and heavy attack presentation profiles, and `BattleState.combat_feedback_requested` asks the scene to draw transient floating combat text without changing battle rules. +The battle scene owns presentation feedback: briefing and result states use menu BGM, briefing headers combine `CampaignState` chapter ranges, campaign order, and title data with `BattleState` briefing, objective text, condition-progress text, and defeat-risk text, active battles use battle BGM and show an objective/progress/risk panel fed by `BattleState`, objective-update signals show a short HUD notice and refresh the objective panel immediately, core panels prefer generated lacquer, scroll, jade, and command-seal `StyleBoxTexture` frames with flat ink/wood/jade styles as fallbacks, core buttons prefer generated lacquer, jade-hover, cinnabar-pressed, and disabled-ink `StyleBoxTexture` surfaces with flat styles as fallbacks, dialogue lines can show optional cached portrait textures or speaker-initial fallback panels in an expanded visual-novel-style panel, keep the portrait slot fixed even for narration lines, mark speaking side through text alignment, and expose progress plus previous-line controls while a sequence is open, the side HUD reuses cached officer portrait textures or class sprites for the selected unit or hovered unit and formats focus text with role, movement type, facing, current terrain move cost, defense/avoid bonuses, core stats, status effects, guard-zone AI hints, and gear, board maps can draw a scenario background texture under translucent terrain overlays, generated terrain texture tiles, connected road segments, terrain detail patterns, shoreline/castle/forest/hill edge blends, compact recovery markers for healing terrain, compact side-event markers for visible item/gold pickups, and move-attack target badges for enemies that can be struck after movement, board units render class sprite tokens or generic-enemy transparent class cutouts, team rings, facing markers, generic-enemy marks, officer pins, low-HP warning rings, HP bar color states, active support/debuff/poison/seal/snare/disarm status pips, and a scene-clocked idle stance whose intensity reacts to selected, acted, and low-HP unit state, item buttons can show optional cached item icons, hover previews are rendered as target badges from existing `BattleState` forecast APIs and include compact side/rear attack bonuses when facing matters, equipment option menus show stat/range/effect deltas, result and inventory summaries show named equipment with compact rarity tags, selected area tactics highlight their affected cells, the Threat toggle overlays enemy physical and hostile tactic reach while tile info names threat sources, estimates physical damage, and summarizes hostile tactic damage or status effects against occupied cells, log/result hooks trigger placeholder SFX, support, debuff, poison, seal, snare, disarm, objective updates, AI target-focus changes, and item/gold pickup effects use distinct feedback, `BattleState.unit_motion_requested` asks the scene to interpolate a unit's draw position during movement, `BattleState.unit_action_motion_requested` keeps its rules-facing signal shape while the scene maps attacker class ids to infantry, archer, cavalry, command, and heavy attack presentation profiles, and `BattleState.combat_feedback_requested` asks the scene to draw transient floating combat text without changing battle rules. Large tactical maps are presented through a fixed visible map window rather than by shrinking the whole board, including the opening chapter-one battle. `BattleScene` keeps a clamped `board_scroll_offset`, scrolls the board while the mouse is near or slightly outside the visible map edge, brightens the scrollable frame edge under the cursor, ignores board clicks outside the visible map window, and draws a small minimap plate only when the board actually exceeds the visible map view; the minimap shows terrain, unit dots, objective seals, and side-event markers, and clicking or dragging it recenters the tactical viewport, while compact maps keep the lower-right tiles unobstructed. Board-attached command panels are repositioned after map scrolling so post-move choices stay beside the moved unit. Battle start focuses the board on the deployed player group, pre-battle Formation can focus the board on the selected unit even before the battle opens, and action feedback can focus the board on off-screen cells before motion or combat effects play. diff --git a/scripts/scenes/battle_scene.gd b/scripts/scenes/battle_scene.gd index 98b07a6..52880d7 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -30,6 +30,7 @@ const TITLE_BACKGROUND_PATH := "res://art/backgrounds/title_war_camp_dawn.png" const TITLE_PORTRAIT_PATH := "res://art/portraits/cao_cao.png" const TOOLBAR_ICON_PATH_TEMPLATE := "res://art/ui/icons/toolbar_%s.png" const PANEL_TEXTURE_PATH_TEMPLATE := "res://art/ui/panels/panel_%s.png" +const BUTTON_TEXTURE_PATH_TEMPLATE := "res://art/ui/buttons/button_%s.png" const TERRAIN_TEXTURE_PATH_TEMPLATE := "res://art/terrain/terrain_%s.png" const OPENING_PROLOGUE_REBELLION_PATH := "res://art/story/opening/yellow_turban_rebellion.png" const OPENING_PROLOGUE_RESOLVE_PATH := "res://art/story/opening/cao_cao_resolves.png" @@ -929,6 +930,42 @@ func _make_button_style(fill: Color, border: Color, border_width: int) -> StyleB return style +func _make_button_texture_style(state_key: String, content_margin: int = 10) -> StyleBoxTexture: + var texture := _load_art_texture(BUTTON_TEXTURE_PATH_TEMPLATE % state_key) + if texture == null: + return null + var style := StyleBoxTexture.new() + style.texture = texture + style.draw_center = true + style.texture_margin_left = 92 + style.texture_margin_right = 92 + style.texture_margin_top = 42 + style.texture_margin_bottom = 42 + var resolved_margin: int = maxi(content_margin, 8) + style.content_margin_left = resolved_margin + style.content_margin_right = resolved_margin + style.content_margin_top = maxi(5, resolved_margin - 2) + style.content_margin_bottom = maxi(5, resolved_margin - 2) + return style + + +func _apply_generated_button_style(button: Button, important: bool = false) -> bool: + var normal_style := _make_button_texture_style("pressed" if important else "normal") + var hover_style := _make_button_texture_style("hover") + var pressed_style := _make_button_texture_style("pressed") + var focus_style := _make_button_texture_style("hover") + var disabled_style := _make_button_texture_style("disabled") + if normal_style == null or hover_style == null or pressed_style == null or focus_style == null or disabled_style == null: + return false + button.add_theme_stylebox_override("normal", normal_style) + button.add_theme_stylebox_override("hover", hover_style) + button.add_theme_stylebox_override("pressed", pressed_style) + button.add_theme_stylebox_override("focus", focus_style) + button.add_theme_stylebox_override("disabled", disabled_style) + button.set_meta("generated_button_texture", true) + return true + + func _ui_font(bold: bool = false) -> Font: if bold: if ui_bold_font == null: @@ -994,6 +1031,14 @@ func _apply_control_font(control: Control, bold: bool = false) -> void: func _apply_button_style(button: Button, important: bool = false) -> void: if button == null: return + if _apply_generated_button_style(button, important): + button.add_theme_color_override("font_color", UI_PARCHMENT_TEXT) + button.add_theme_color_override("font_hover_color", UI_PARCHMENT_TEXT) + button.add_theme_color_override("font_pressed_color", UI_PARCHMENT_TEXT) + button.add_theme_color_override("font_focus_color", UI_PARCHMENT_TEXT) + button.add_theme_color_override("font_disabled_color", UI_DISABLED_TEXT) + _apply_control_font(button, important) + return var normal_fill := Color(0.28, 0.055, 0.040, 0.99) if important else Color(0.070, 0.085, 0.078, 0.98) var hover_fill := Color(0.36, 0.080, 0.055, 1.0) if important else Color(0.095, 0.135, 0.118, 1.0) var pressed_fill := Color(0.030, 0.036, 0.034, 1.0) @@ -1008,6 +1053,7 @@ func _apply_button_style(button: Button, important: bool = false) -> void: button.add_theme_color_override("font_focus_color", UI_PARCHMENT_TEXT) button.add_theme_color_override("font_disabled_color", UI_DISABLED_TEXT) _apply_control_font(button, important) + button.set_meta("generated_button_texture", false) func _suppress_local_command_tooltip(button: Button) -> void: @@ -3744,6 +3790,7 @@ func _create_hud() -> void: equip_button, mission_toggle_button, threat_button, + battle_unit_list_button, end_turn_button, top_save_button, top_load_button, diff --git a/tools/smoke_visual_assets.gd b/tools/smoke_visual_assets.gd index 7a165c1..a09a230 100644 --- a/tools/smoke_visual_assets.gd +++ b/tools/smoke_visual_assets.gd @@ -93,6 +93,7 @@ func _init() -> void: _check_battle_visual_data(failures) _check_generated_toolbar_icons(failures) _check_generated_panel_textures(failures) + _check_generated_button_textures(failures) _check_generated_terrain_textures(failures) _check_scene_texture_loading(failures) _check_hud_focus_text(failures) @@ -2984,6 +2985,12 @@ func _check_generated_panel_textures(failures: Array[String]) -> void: _check_panel_texture_path(failures, "res://art/ui/panels/panel_%s.png" % panel_key, "panel texture %s" % panel_key) +func _check_generated_button_textures(failures: Array[String]) -> void: + var button_keys := ["normal", "hover", "pressed", "disabled"] + for button_key in button_keys: + _check_button_texture_path(failures, "res://art/ui/buttons/button_%s.png" % button_key, "button texture %s" % button_key) + + func _check_generated_terrain_textures(failures: Array[String]) -> void: var terrain_keys := ["g", "f", "h", "d", "r", "w", "t", "c"] for terrain_key in terrain_keys: @@ -3814,6 +3821,26 @@ func _check_button_uses_generated_toolbar_icon(failures: Array[String], button: failures.append("%s should use generated high-resolution toolbar art, got %dx%d" % [context, button.icon.get_width(), button.icon.get_height()]) +func _check_button_uses_generated_surface(failures: Array[String], button: Button, context: String) -> void: + if button == null: + failures.append("%s button missing" % context) + return + var stylebox := button.get_theme_stylebox("normal") + if not (stylebox is StyleBoxTexture): + failures.append("%s should use a generated button texture surface" % context) + return + var style := stylebox as StyleBoxTexture + if style.texture == null: + failures.append("%s generated button style is missing its texture" % context) + return + if style.texture.get_width() < 512 or style.texture.get_height() < 192: + failures.append("%s generated button texture should keep high-resolution source pixels: %dx%d" % [context, style.texture.get_width(), style.texture.get_height()]) + if style.texture_margin_left < 48 or style.texture_margin_top < 24: + failures.append("%s generated button texture should define visible frame slice margins" % context) + if style.content_margin_left < 8 or style.content_margin_top < 5: + failures.append("%s generated button texture should reserve readable content margins" % context) + + func _check_local_command_icon_button(failures: Array[String], button: Button, expected_label: String, expected_icon: String) -> void: if button == null: failures.append("local command button missing: %s" % expected_label) @@ -3823,6 +3850,7 @@ func _check_local_command_icon_button(failures: Array[String], button: Button, e if button.icon == null or str(button.get_meta("command_icon", "")) != expected_icon: failures.append("local command should carry an immediate visual icon: %s icon=%s meta=%s" % [expected_label, str(button.icon), str(button.get_meta("command_icon", ""))]) _check_button_uses_generated_toolbar_icon(failures, button, expected_label) + _check_button_uses_generated_surface(failures, button, expected_label) if str(button.get_meta("command_label", "")) != expected_label: failures.append("local command should keep old wording in hover metadata: %s meta=%s" % [expected_label, str(button.get_meta("command_label", ""))]) if str(button.tooltip_text).strip_edges().is_empty() or not str(button.tooltip_text).contains(expected_label): @@ -3860,6 +3888,7 @@ func _check_hud_command_grid_layout(failures: Array[String]) -> void: if button.icon == null or str(button.get_meta("command_icon", "")) != str(expectation["icon"]): failures.append("unit command button should carry an immediate visual icon: %s icon=%s meta=%s" % [button.text, str(button.icon), str(button.get_meta("command_icon", ""))]) _check_button_uses_generated_toolbar_icon(failures, button, str(expectation["icon"])) + _check_button_uses_generated_surface(failures, button, str(expectation["icon"])) if not bool(button.get_meta("icon_only", false)) or button.text != "": failures.append("unit command button should be icon-first without visible text: %s text=%s" % [str(button.name), button.text]) if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"): @@ -3895,6 +3924,7 @@ func _check_hud_command_grid_layout(failures: Array[String]) -> void: if not bool(button.get_meta("icon_only", false)) or button.text != "" or button.icon == null: failures.append("top tool button should be icon-only with tooltip detail: %s text=%s icon=%s" % [str(button.name), button.text, str(button.icon)]) _check_button_uses_generated_toolbar_icon(failures, button, str(button.name)) + _check_button_uses_generated_surface(failures, button, str(button.name)) if button.custom_minimum_size.x < BattleSceneScript.TOP_TOOL_BUTTON_SIZE.x or button.custom_minimum_size.y < BattleSceneScript.TOP_TOOL_BUTTON_SIZE.y: failures.append("top tool button should reserve stable icon space: %s" % str(button.custom_minimum_size)) scene.free() @@ -4005,6 +4035,7 @@ func _check_prep_menu_icon_button(failures: Array[String], button: Button, expec if button.icon == null or str(button.get_meta("command_icon", "")) != expected_icon: failures.append("pre-battle prep button should carry a distinct icon: %s icon=%s meta=%s" % [expected_label, str(button.icon), str(button.get_meta("command_icon", ""))]) _check_button_uses_generated_toolbar_icon(failures, button, expected_label) + _check_button_uses_generated_surface(failures, button, expected_label) if str(button.get_meta("command_label", "")) != expected_label: failures.append("pre-battle prep button should preserve Korean label in metadata: %s meta=%s" % [expected_label, str(button.get_meta("command_label", ""))]) if str(button.tooltip_text).strip_edges().is_empty() or not str(button.tooltip_text).contains(expected_label): @@ -4949,6 +4980,61 @@ func _check_panel_texture_path(failures: Array[String], path: String, context: S failures.append("%s should contain visible material contrast: %s" % [context, path]) +func _check_button_texture_path(failures: Array[String], path: String, context: String) -> void: + if path.is_empty(): + failures.append("%s has an empty button path" % context) + return + if not path.begins_with("res://"): + failures.append("%s must use a res:// path: %s" % [context, path]) + return + if not FileAccess.file_exists(path): + failures.append("%s references missing button texture: %s" % [context, path]) + return + var image := Image.new() + var err := image.load(path) + if err != OK: + failures.append("%s references unreadable button texture: %s" % [context, path]) + return + if image.get_width() < 512 or image.get_height() < 192: + failures.append("%s should keep high-resolution source pixels: %s (%dx%d)" % [context, path, image.get_width(), image.get_height()]) + return + if image.get_width() <= image.get_height(): + failures.append("%s should be a wide button surface: %s (%dx%d)" % [context, path, image.get_width(), image.get_height()]) + return + for corner in [Vector2i(0, 0), Vector2i(image.get_width() - 1, 0), Vector2i(0, image.get_height() - 1), Vector2i(image.get_width() - 1, image.get_height() - 1)]: + if image.get_pixelv(corner).a > 0.01: + failures.append("%s should have transparent corners: %s" % [context, path]) + return + var opaque_samples := 0 + var transparent_samples := 0 + var green_fringe_samples := 0 + var luma_min := 999.0 + var luma_max := -999.0 + var total_samples := 0 + for y in range(0, image.get_height(), 8): + for x in range(0, image.get_width(), 8): + total_samples += 1 + var pixel := image.get_pixel(x, y) + if pixel.a <= 0.01: + transparent_samples += 1 + continue + if pixel.a >= 0.80: + opaque_samples += 1 + if pixel.g > 0.80 and pixel.r < 0.18 and pixel.b < 0.18: + green_fringe_samples += 1 + var luma := pixel.r * 0.299 + pixel.g * 0.587 + pixel.b * 0.114 + luma_min = minf(luma_min, luma) + luma_max = maxf(luma_max, luma) + if transparent_samples < int(total_samples * 0.08): + failures.append("%s should retain transparent button padding: %s (%d/%d sampled pixels)" % [context, path, transparent_samples, total_samples]) + if opaque_samples < int(total_samples * 0.45): + failures.append("%s should contain substantial generated button artwork: %s (%d/%d sampled pixels)" % [context, path, opaque_samples, total_samples]) + if green_fringe_samples > 0: + failures.append("%s should not keep chroma-key green pixels: %s (%d sampled)" % [context, path, green_fringe_samples]) + if luma_max - luma_min < 0.08: + failures.append("%s should contain visible material contrast: %s" % [context, path]) + + func _check_terrain_texture_path(failures: Array[String], path: String, context: String) -> void: if path.is_empty(): failures.append("%s has an empty texture path" % context)