Soften battlefield grid and guard text visibility

This commit is contained in:
2026-06-20 09:53:52 +09:00
parent 91aa912c61
commit 21246c602f
2 changed files with 114 additions and 16 deletions

View File

@@ -5735,20 +5735,20 @@ func _texture_cover_region_source_rect(texture: Texture2D, visible_rect: Rect2,
func _terrain_fill_color(cell: Vector2i, terrain_key: String, has_background: bool) -> Color: func _terrain_fill_color(cell: Vector2i, terrain_key: String, has_background: bool) -> Color:
var color := state.get_terrain_color(cell) var color := state.get_terrain_color(cell)
var alpha := 0.105 if has_background else 0.34 var alpha := 0.056 if has_background else 0.34
if terrain_key == "W": if terrain_key == "W":
alpha += 0.025 alpha += 0.018
elif terrain_key == "C" or terrain_key == "H" or terrain_key == "T": elif terrain_key == "C" or terrain_key == "H" or terrain_key == "T":
alpha += 0.015 alpha += 0.010
elif terrain_key == "D": elif terrain_key == "D":
alpha += 0.012 alpha += 0.008
color.a = alpha color.a = alpha
return color return color
func _map_grid_color(has_background: bool) -> Color: func _map_grid_color(has_background: bool) -> Color:
var color := GRID_COLOR var color := GRID_COLOR
color.a = 0.012 if has_background else 0.28 color.a = 0.006 if has_background else 0.22
return color return color
@@ -5845,13 +5845,13 @@ func _draw_terrain_feature(feature_key: String, rect: Rect2, modulate: Color = C
func _draw_tactical_tile_overlay(marker_key: String, rect: Rect2, fill_color: Color, border_color: Color, marker_alpha: float, fill_alpha_scale: float = 0.48, inset: float = 5.0) -> void: func _draw_tactical_tile_overlay(marker_key: String, rect: Rect2, fill_color: Color, border_color: Color, marker_alpha: float, fill_alpha_scale: float = 0.48, inset: float = 5.0) -> void:
var fill := fill_color var fill := fill_color
fill.a *= fill_alpha_scale fill.a *= fill_alpha_scale * 0.58
if fill.a > 0.0: if fill.a > 0.0:
draw_rect(rect.grow(-inset), fill) draw_rect(rect.grow(-inset), fill)
_draw_tile_marker(marker_key, rect, Color(1.0, 1.0, 1.0, marker_alpha), 0.0) _draw_tile_marker(marker_key, rect, Color(1.0, 1.0, 1.0, marker_alpha * 1.12), 0.0)
var line := border_color var line := border_color
line.a = minf(line.a, 0.68) line.a = minf(line.a * 0.78, 0.48)
_draw_tactical_corner_brackets(rect.grow(-(inset + 2.0)), line, 8.0, 1.35) _draw_tactical_corner_brackets(rect.grow(-(inset + 2.0)), line, 7.0, 1.15)
func _draw_tactical_corner_brackets(rect: Rect2, color: Color, length: float = 8.0, width: float = 1.35) -> void: func _draw_tactical_corner_brackets(rect: Rect2, color: Color, length: float = 8.0, width: float = 1.35) -> void:
@@ -5873,15 +5873,15 @@ func _draw_tactical_corner_brackets(rect: Rect2, color: Color, length: float = 8
func _terrain_texture_modulate(cell: Vector2i, terrain_key: String, has_background: bool) -> Color: func _terrain_texture_modulate(cell: Vector2i, terrain_key: String, has_background: bool) -> Color:
var alpha := 0.26 if has_background else 0.58 var alpha := 0.20 if has_background else 0.58
if terrain_key == "W": if terrain_key == "W":
alpha += 0.07 if has_background else 0.10 alpha += 0.06 if has_background else 0.10
elif terrain_key == "C" or terrain_key == "T": elif terrain_key == "C" or terrain_key == "T":
alpha += 0.08 if has_background else 0.12 alpha += 0.07 if has_background else 0.12
elif terrain_key == "R": elif terrain_key == "R":
alpha += 0.05 if has_background else 0.08 alpha += 0.04 if has_background else 0.08
elif terrain_key == "F" or terrain_key == "H" or terrain_key == "D": elif terrain_key == "F" or terrain_key == "H" or terrain_key == "D":
alpha += 0.03 if has_background else 0.06 alpha += 0.025 if has_background else 0.06
alpha *= 0.94 + _cell_noise(cell, 137) * 0.12 alpha *= 0.94 + _cell_noise(cell, 137) * 0.12
return Color(1.0, 1.0, 1.0, clampf(alpha, 0.0, 0.82)) return Color(1.0, 1.0, 1.0, clampf(alpha, 0.0, 0.82))

View File

@@ -100,6 +100,8 @@ func _init() -> void:
_check_generated_terrain_textures(failures) _check_generated_terrain_textures(failures)
_check_generated_terrain_feature_textures(failures) _check_generated_terrain_feature_textures(failures)
_check_scene_texture_loading(failures) _check_scene_texture_loading(failures)
_check_map_overlay_softness(failures)
_check_core_text_visibility(failures)
_check_hud_focus_text(failures) _check_hud_focus_text(failures)
_check_ancient_ui_theme(failures) _check_ancient_ui_theme(failures)
_check_opening_prologue_presentation(failures) _check_opening_prologue_presentation(failures)
@@ -3235,6 +3237,102 @@ func _check_scenario_background_texture_loading(failures: Array[String]) -> void
scene.free() scene.free()
func _check_map_overlay_softness(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
failures.append("could not load battle scene state for map overlay softness")
scene.free()
return
var grass_fill: Color = scene._terrain_fill_color(Vector2i(1, 1), "G", true)
if grass_fill.a > 0.070:
failures.append("background-backed grass fill should stay subtle, got %.3f" % grass_fill.a)
var water_fill: Color = scene._terrain_fill_color(Vector2i(1, 1), "W", true)
if water_fill.a > 0.086:
failures.append("background-backed water fill should avoid blocky square color, got %.3f" % water_fill.a)
var grid_color: Color = scene._map_grid_color(true)
if grid_color.a > 0.010:
failures.append("background-backed grid should be nearly invisible, got %.3f" % grid_color.a)
var fallback_grid: Color = scene._map_grid_color(false)
if fallback_grid.a > 0.24:
failures.append("fallback grid should not become a harsh square net, got %.3f" % fallback_grid.a)
var grass_texture: Color = scene._terrain_texture_modulate(Vector2i(3, 4), "G", true)
if grass_texture.a > 0.235:
failures.append("background-backed grass texture should blend into the high-res map, got %.3f" % grass_texture.a)
var town_texture: Color = scene._terrain_texture_modulate(Vector2i(7, 5), "T", true)
if town_texture.a > 0.310:
failures.append("background-backed town texture should signal terrain without tiling loudly, got %.3f" % town_texture.a)
var fallback_texture: Color = scene._terrain_texture_modulate(Vector2i(3, 4), "G", false)
if fallback_texture.a < 0.50:
failures.append("fallback terrain texture should remain readable without a background, got %.3f" % fallback_texture.a)
scene.free()
func _check_core_text_visibility(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
scene._ready()
_check_readable_text_control(failures, scene.title_caption_label, "title campaign name", 26)
_check_readable_text_control(failures, scene.title_subtitle_label, "title subtitle", 13)
var title_feature: Node = scene.title_screen_root.find_child("TitleStoryFeaturePanel", true, false) if scene.title_screen_root != null else null
if title_feature == null:
failures.append("title text visibility check could not find story feature panel")
else:
_check_readable_text_control(failures, title_feature.find_child("TitleStoryFeatureTitle", true, false) as Control, "title story feature title", 14)
_check_readable_text_control(failures, title_feature.find_child("TitleStoryFeatureBody", true, false) as Control, "title story feature body", 10)
_check_readable_text_control(failures, scene.title_start_button, "title start button", 12)
_check_readable_text_control(failures, scene.title_load_button, "title load button", 12)
_check_readable_text_control(failures, scene.title_settings_button, "title settings button", 12)
scene._show_opening_prologue()
_check_readable_text_control(failures, scene.opening_prologue_title_label, "opening title", 16)
_check_readable_text_control(failures, scene.opening_prologue_body_label, "opening body", 13)
_check_readable_text_control(failures, scene.opening_prologue_step_label, "opening step", 11)
_check_readable_text_control(failures, scene.opening_prologue_next_button, "opening next button", 12)
_check_readable_text_control(failures, scene.opening_prologue_skip_button, "opening skip button", 11)
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
failures.append("could not load battle scene state for text visibility")
scene.free()
return
scene._hide_opening_prologue()
scene.battle_started = true
scene.briefing_panel.visible = false
scene.result_panel.visible = false
scene._update_hud()
_check_readable_text_control(failures, scene.status_label, "top turn status", 11)
_check_readable_text_control(failures, scene.objective_label, "top objective", 11)
_check_readable_text_control(failures, scene.campaign_status_label, "top campaign status", 11)
var lines := scene._normalized_dialogue_lines([{"speaker": "Cao Cao", "display_speaker": "조조", "text": "영천으로 향한다. 백성이 빠져나갈 길을 연다."}])
scene.active_dialogue_lines = lines
scene.active_dialogue_index = 0
scene._render_dialogue_line()
_check_readable_text_control(failures, scene.dialogue_speaker_label, "dialogue speaker", 14)
_check_readable_text_control(failures, scene.dialogue_text_label, "dialogue body", 13)
scene.free()
func _check_readable_text_control(failures: Array[String], control: Control, context: String, min_font_size: int) -> void:
if control == null:
failures.append("%s text control missing" % context)
return
var text := ""
if control is Label:
text = str((control as Label).text).strip_edges()
elif control is Button:
text = str((control as Button).text).strip_edges()
else:
failures.append("%s should be a label or button for text visibility checks" % context)
return
if text.is_empty():
failures.append("%s should not render empty text" % context)
var font_size := control.get_theme_font_size("font_size")
if font_size < min_font_size:
failures.append("%s text should stay readable: font size %d < %d" % [context, font_size, min_font_size])
var font_color := control.get_theme_color("font_color")
if font_color.a < 0.72:
failures.append("%s text should not be transparent: %s" % [context, str(font_color)])
func _check_hud_focus_text(failures: Array[String]) -> void: func _check_hud_focus_text(failures: Array[String]) -> void:
var scene = BattleSceneScript.new() var scene = BattleSceneScript.new()
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"): if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
@@ -4802,8 +4900,8 @@ func _check_terrain_and_unit_presentation(failures: Array[String]) -> void:
failures.append("fallback terrain fill should be stronger than background fill") failures.append("fallback terrain fill should be stronger than background fill")
var background_texture_modulate: Color = scene._terrain_texture_modulate(Vector2i(0, 0), "G", true) var background_texture_modulate: Color = scene._terrain_texture_modulate(Vector2i(0, 0), "G", true)
var fallback_texture_modulate: Color = scene._terrain_texture_modulate(Vector2i(0, 0), "G", false) var fallback_texture_modulate: Color = scene._terrain_texture_modulate(Vector2i(0, 0), "G", false)
if background_texture_modulate.a < 0.22: if background_texture_modulate.a < 0.18:
failures.append("background terrain texture should be visible enough to make generated cells read as art: %.3f" % background_texture_modulate.a) failures.append("background terrain texture should still leave a visible terrain hint over high-res art: %.3f" % background_texture_modulate.a)
if background_texture_modulate.a >= fallback_texture_modulate.a: if background_texture_modulate.a >= fallback_texture_modulate.a:
failures.append("background terrain texture should stay lighter than fallback terrain texture") failures.append("background terrain texture should stay lighter than fallback terrain texture")
if scene._map_grid_color(true).a >= scene._map_grid_color(false).a: if scene._map_grid_color(true).a >= scene._map_grid_color(false).a: