diff --git a/README.md b/README.md index cc8a773..c7e7cc3 100644 --- a/README.md +++ b/README.md @@ -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, generated UI panel frames, generated button surfaces, and tactical tile markers live under `art/backgrounds`, `art/story`, `art/terrain`, `art/units`, `art/items`, `art/ui/icons`, `art/ui/panels`, `art/ui/buttons`, and `art/ui/tiles`. +- 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, generated button surfaces, tactical tile markers, and class crest icons live under `art/backgrounds`, `art/story`, `art/terrain`, `art/units`, `art/items`, `art/ui/icons`, `art/ui/panels`, `art/ui/buttons`, `art/ui/tiles`, and `art/ui/class_icons`. - 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/class_icons/class_cavalry.png b/art/ui/class_icons/class_cavalry.png new file mode 100644 index 0000000..388aba7 Binary files /dev/null and b/art/ui/class_icons/class_cavalry.png differ diff --git a/art/ui/class_icons/class_generic.png b/art/ui/class_icons/class_generic.png new file mode 100644 index 0000000..3485994 Binary files /dev/null and b/art/ui/class_icons/class_generic.png differ diff --git a/art/ui/class_icons/class_heavy.png b/art/ui/class_icons/class_heavy.png new file mode 100644 index 0000000..0fb1e2a Binary files /dev/null and b/art/ui/class_icons/class_heavy.png differ diff --git a/art/ui/class_icons/class_infantry.png b/art/ui/class_icons/class_infantry.png new file mode 100644 index 0000000..cb60a49 Binary files /dev/null and b/art/ui/class_icons/class_infantry.png differ diff --git a/art/ui/class_icons/class_ranged.png b/art/ui/class_icons/class_ranged.png new file mode 100644 index 0000000..ab98c41 Binary files /dev/null and b/art/ui/class_icons/class_ranged.png differ diff --git a/art/ui/class_icons/class_tactic.png b/art/ui/class_icons/class_tactic.png new file mode 100644 index 0000000..7c8543f Binary files /dev/null and b/art/ui/class_icons/class_tactic.png differ diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index cfae6c3..e55abbf 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, 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, generated tactical tile markers for move, attack, selection, target, objective, and recovery overlays, 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, uses generated class crest icons for role badges, 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, generated tactical tile markers for move, attack, selection, target, objective, and recovery overlays, 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 with generated class crest markers, 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 e23a8c7..4eb11de 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -32,6 +32,7 @@ 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 TILE_MARKER_TEXTURE_PATH_TEMPLATE := "res://art/ui/tiles/tile_marker_%s.png" +const CLASS_ICON_TEXTURE_PATH_TEMPLATE := "res://art/ui/class_icons/class_%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" @@ -1180,11 +1181,7 @@ func _update_hud_unit_badges(unit: Dictionary, detail_text: String) -> void: _hud_unit_badge_tooltip(_unit_team_text(str(unit.get("team", ""))), detail_text), _hud_unit_team_badge_color(unit) )) - hud_unit_badge_row.add_child(_make_hud_unit_badge( - _hud_unit_class_badge_text(unit), - _hud_unit_badge_tooltip("%s · %s" % [_unit_class_display_name(unit), _unit_role_text(unit)], detail_text), - _hud_unit_class_badge_color(unit) - )) + hud_unit_badge_row.add_child(_make_hud_unit_class_badge(unit, detail_text)) hud_unit_badge_row.add_child(_make_hud_unit_badge( "동" if _unit_pixel_facing(unit) >= 0 else "서", _hud_unit_badge_tooltip("시선 %s\n등 뒤를 잡히면 피해가 커집니다." % _unit_facing_text(unit), detail_text), @@ -1221,12 +1218,32 @@ func _update_hud_unit_badges(unit: Dictionary, detail_text: String) -> void: )) +func _make_hud_unit_class_badge(unit: Dictionary, detail_text: String) -> PanelContainer: + var tooltip := _hud_unit_badge_tooltip("%s · %s" % [_unit_class_display_name(unit), _unit_role_text(unit)], detail_text) + var icon_texture := _load_unit_class_icon_texture(unit) + if icon_texture == null: + return _make_hud_unit_badge( + _hud_unit_class_badge_text(unit), + tooltip, + _hud_unit_class_badge_color(unit) + ) + return _make_hud_unit_badge( + "", + tooltip, + _hud_unit_class_badge_color(unit), + "", + UI_PARCHMENT_TEXT, + icon_texture + ) + + func _make_hud_unit_badge( label_text: String, tooltip: String, fill_color: Color, icon_kind: String = "", - text_color: Color = UI_PARCHMENT_TEXT + text_color: Color = UI_PARCHMENT_TEXT, + icon_texture: Texture2D = null ) -> PanelContainer: var panel := PanelContainer.new() panel.custom_minimum_size = HUD_UNIT_BADGE_SIZE @@ -1236,12 +1253,15 @@ func _make_hud_unit_badge( "panel", _make_panel_style(fill_color, fill_color.lightened(0.34), 1, 4, 2, 0) ) - if not icon_kind.strip_edges().is_empty(): + var resolved_icon := icon_texture + if resolved_icon == null and not icon_kind.strip_edges().is_empty(): + resolved_icon = _make_toolbar_icon(icon_kind) + if resolved_icon != null: var icon := TextureRect.new() icon.custom_minimum_size = Vector2(22, 18) icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED - icon.texture = _make_toolbar_icon(icon_kind) + icon.texture = resolved_icon icon.tooltip_text = tooltip panel.add_child(icon) return panel @@ -4874,6 +4894,26 @@ func _load_tile_marker_texture(marker_key: String) -> Texture2D: return _load_art_texture(TILE_MARKER_TEXTURE_PATH_TEMPLATE % normalized_key) +func _load_class_icon_texture(icon_key: String) -> Texture2D: + var normalized_key := icon_key.strip_edges().to_lower() + if normalized_key.is_empty(): + normalized_key = "generic" + if not ["infantry", "cavalry", "ranged", "tactic", "heavy", "generic"].has(normalized_key): + normalized_key = "generic" + return _load_art_texture(CLASS_ICON_TEXTURE_PATH_TEMPLATE % normalized_key) + + +func _load_unit_class_icon_texture(unit: Dictionary) -> Texture2D: + return _load_class_icon_texture(_unit_class_icon_key(unit)) + + +func _unit_class_icon_key(unit: Dictionary) -> String: + var family := _unit_class_family(unit) + if family.is_empty(): + return "generic" + return family + + func _draw_tile_marker(marker_key: String, rect: Rect2, modulate: Color = Color.WHITE, inset: float = 0.0) -> bool: var texture := _load_tile_marker_texture(marker_key) if texture == null: @@ -5348,9 +5388,9 @@ func _draw_units() -> void: selection_frame_drawn = _draw_tile_marker("select", rect.grow(2.0), Color(1.0, 1.0, 1.0, 0.82)) draw_circle(center + Vector2(0, 18), 22, Color(0.0, 0.0, 0.0, 0.28)) - _draw_unit_class_emblem(rect, center, unit, team_color) if not _draw_high_res_unit_sprite(rect, unit, sprite_modulate, _unit_pixel_facing(unit)): _draw_pixel_unit_sprite(rect, unit, team_color, sprite_modulate, _unit_pixel_facing(unit)) + _draw_unit_class_emblem(rect, center, unit, team_color) _draw_unit_identity_marks(rect, center, unit, team_color) _draw_unit_facing_marker(rect, unit, team_color, sprite_modulate) @@ -6134,6 +6174,8 @@ func _closed_polyline_points(points: PackedVector2Array) -> PackedVector2Array: func _draw_unit_class_emblem(rect: Rect2, center: Vector2, unit: Dictionary, team_color: Color) -> void: + if _draw_unit_class_icon_marker(rect, unit): + return var family := _unit_class_family(unit) var class_color := _unit_class_badge_color(unit, team_color) var emblem := class_color.lightened(0.36) @@ -6175,6 +6217,19 @@ func _draw_unit_class_emblem(rect: Rect2, center: Vector2, unit: Dictionary, tea draw_line(shield.position + Vector2(shield.size.x * 0.5, 3), shield.position + Vector2(shield.size.x * 0.5, shield.size.y - 3), emblem, 1.6) +func _draw_unit_class_icon_marker(rect: Rect2, unit: Dictionary) -> bool: + var texture := _load_unit_class_icon_texture(unit) + if texture == null: + return false + var icon_size := Vector2(20.0, 20.0) + var icon_rect := Rect2(rect.position + Vector2(2.0, 2.0), icon_size) + var center := icon_rect.get_center() + draw_circle(center + Vector2(1.0, 1.0), 11.5, Color(0.018, 0.014, 0.010, 0.70)) + draw_circle(center, 10.5, Color(0.055, 0.035, 0.018, 0.58)) + draw_texture_rect(texture, icon_rect.grow(1.0), false, Color(1.0, 1.0, 1.0, 0.92)) + return true + + func _unit_class_family(unit: Dictionary) -> String: var class_id := str(unit.get("class_id", "")) if class_id.contains("cavalry"): diff --git a/tools/smoke_visual_assets.gd b/tools/smoke_visual_assets.gd index 6006e19..e861c4a 100644 --- a/tools/smoke_visual_assets.gd +++ b/tools/smoke_visual_assets.gd @@ -95,6 +95,7 @@ func _init() -> void: _check_generated_panel_textures(failures) _check_generated_button_textures(failures) _check_generated_tile_marker_textures(failures) + _check_generated_class_icon_textures(failures) _check_generated_terrain_textures(failures) _check_scene_texture_loading(failures) _check_hud_focus_text(failures) @@ -2998,6 +2999,12 @@ func _check_generated_tile_marker_textures(failures: Array[String]) -> void: _check_tile_marker_texture_path(failures, "res://art/ui/tiles/tile_marker_%s.png" % marker_key, "tile marker %s" % marker_key) +func _check_generated_class_icon_textures(failures: Array[String]) -> void: + var icon_keys := ["infantry", "cavalry", "ranged", "tactic", "heavy", "generic"] + for icon_key in icon_keys: + _check_class_icon_texture_path(failures, "res://art/ui/class_icons/class_%s.png" % icon_key, "class icon %s" % icon_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: @@ -3020,6 +3027,8 @@ func _check_scene_texture_loading(failures: Array[String]) -> void: failures.append("battle scene should load panacea icon texture") if scene._load_tile_marker_texture("move") == null or scene._load_tile_marker_texture("target") == null: failures.append("battle scene should load generated tactical tile marker textures") + if scene._load_class_icon_texture("infantry") == null or scene._load_class_icon_texture("tactic") == null: + failures.append("battle scene should load generated class icon textures") var conversations: Array = scene.state.get_briefing().get("camp_conversations", []) if not conversations.is_empty(): var first_lines: Array = (conversations[0] as Dictionary).get("lines", []) @@ -3288,6 +3297,8 @@ func _check_unit_class_family(failures: Array[String], scene, unit_id: String, e var color: Color = scene._unit_class_badge_color(unit, Color(0.20, 0.42, 0.82)) if color.a <= 0.0: failures.append("%s class silhouette color should be visible" % unit_id) + if scene._load_unit_class_icon_texture(unit) == null: + failures.append("%s should resolve a generated class icon texture" % unit_id) func _check_ancient_ui_theme(failures: Array[String]) -> void: @@ -5099,6 +5110,61 @@ func _check_tile_marker_texture_path(failures: Array[String], path: String, cont failures.append("%s should contain visible generated material contrast: %s" % [context, path]) +func _check_class_icon_texture_path(failures: Array[String], path: String, context: String) -> void: + if path.is_empty(): + failures.append("%s has an empty icon 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 class icon texture: %s" % [context, path]) + return + var image := Image.new() + var err := image.load(path) + if err != OK: + failures.append("%s references unreadable class icon texture: %s" % [context, path]) + return + if image.get_width() < 512 or image.get_height() < 512: + 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 square: %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.82 and pixel.r < 0.16 and pixel.b < 0.16: + 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.24): + failures.append("%s should keep transparent icon padding: %s (%d/%d sampled pixels)" % [context, path, transparent_samples, total_samples]) + if opaque_samples < int(total_samples * 0.24): + failures.append("%s should contain substantial generated class 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 generated 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)