Add generated terrain feature overlays
This commit is contained in:
@@ -98,6 +98,7 @@ func _init() -> void:
|
||||
_check_generated_class_icon_textures(failures)
|
||||
_check_generated_map_badge_textures(failures)
|
||||
_check_generated_terrain_textures(failures)
|
||||
_check_generated_terrain_feature_textures(failures)
|
||||
_check_scene_texture_loading(failures)
|
||||
_check_hud_focus_text(failures)
|
||||
_check_ancient_ui_theme(failures)
|
||||
@@ -3018,6 +3019,19 @@ func _check_generated_terrain_textures(failures: Array[String]) -> void:
|
||||
_check_terrain_texture_path(failures, "res://art/terrain/terrain_%s.png" % terrain_key, "terrain texture %s" % terrain_key)
|
||||
|
||||
|
||||
func _check_generated_terrain_feature_textures(failures: Array[String]) -> void:
|
||||
var feature_keys := [
|
||||
"road_node",
|
||||
"road_n", "road_s", "road_e", "road_w",
|
||||
"road_ns", "road_ew",
|
||||
"road_ne", "road_es", "road_sw", "road_wn",
|
||||
"road_nse", "road_esw", "road_nsw", "road_new", "road_nesw",
|
||||
"town", "castle", "water", "wasteland"
|
||||
]
|
||||
for feature_key in feature_keys:
|
||||
_check_terrain_feature_texture_path(failures, "res://art/terrain/features/terrain_feature_%s.png" % feature_key, "terrain feature %s" % feature_key)
|
||||
|
||||
|
||||
func _check_scene_texture_loading(failures: Array[String]) -> void:
|
||||
var scene = BattleSceneScript.new()
|
||||
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
|
||||
@@ -3038,6 +3052,8 @@ func _check_scene_texture_loading(failures: Array[String]) -> void:
|
||||
failures.append("battle scene should load generated class icon textures")
|
||||
if scene._load_map_badge_texture("objective") == null or scene._load_map_badge_texture("recover") == null:
|
||||
failures.append("battle scene should load generated map badge textures")
|
||||
if scene._load_terrain_feature_texture("road_ew") == null or scene._load_terrain_feature_texture("town") == null or scene._load_terrain_feature_texture("castle") == null:
|
||||
failures.append("battle scene should load generated terrain feature overlays")
|
||||
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", [])
|
||||
@@ -4451,6 +4467,8 @@ func _check_terrain_and_unit_presentation(failures: Array[String]) -> void:
|
||||
failures.append("Sishui Gate road should connect west/east at 3,5: %s" % str(road_flags))
|
||||
if bool(road_flags.get("north", false)) or bool(road_flags.get("south", false)):
|
||||
failures.append("Sishui Gate road should not connect north/south at 3,5: %s" % str(road_flags))
|
||||
if scene._road_feature_key(Vector2i(2, 4)) != "road_ew":
|
||||
failures.append("Sishui Gate road should use generated east-west road feature: %s" % scene._road_feature_key(Vector2i(2, 4)))
|
||||
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
|
||||
failures.append("could not reload opening battle for unit presentation helpers")
|
||||
scene.free()
|
||||
@@ -5269,6 +5287,57 @@ func _check_terrain_texture_path(failures: Array[String], path: String, context:
|
||||
failures.append("%s should contain visible generated terrain texture variation: %s" % [context, path])
|
||||
|
||||
|
||||
func _check_terrain_feature_texture_path(failures: Array[String], path: String, context: String) -> void:
|
||||
if path.is_empty():
|
||||
failures.append("%s has an empty feature 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 terrain feature texture: %s" % [context, path])
|
||||
return
|
||||
var image := Image.new()
|
||||
var err := image.load(path)
|
||||
if err != OK:
|
||||
failures.append("%s references unreadable terrain feature texture: %s" % [context, path])
|
||||
return
|
||||
if image.get_width() < 512 or image.get_height() < 512:
|
||||
failures.append("%s should keep high-resolution overlay 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
|
||||
var transparent_samples := 0
|
||||
var opaque_samples := 0
|
||||
var green_fringe_samples := 0
|
||||
var min_luma := 999.0
|
||||
var max_luma := -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.32:
|
||||
opaque_samples += 1
|
||||
if pixel.a > 0.05 and pixel.g > 0.92 and pixel.r < 0.08 and pixel.b < 0.08:
|
||||
green_fringe_samples += 1
|
||||
var luma := pixel.r * 0.299 + pixel.g * 0.587 + pixel.b * 0.114
|
||||
min_luma = minf(min_luma, luma)
|
||||
max_luma = maxf(max_luma, luma)
|
||||
if transparent_samples < int(total_samples * 0.18):
|
||||
failures.append("%s should keep transparent padding so the map art shows through: %s (%d/%d sampled pixels)" % [context, path, transparent_samples, total_samples])
|
||||
if opaque_samples < int(total_samples * 0.04):
|
||||
failures.append("%s should contain readable generated feature 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 max_luma - min_luma < 0.06:
|
||||
failures.append("%s should contain visible generated feature variation: %s" % [context, path])
|
||||
|
||||
|
||||
func _check_image_path(failures: Array[String], path: String, context: String) -> void:
|
||||
if path.is_empty():
|
||||
failures.append("%s has an empty image path" % context)
|
||||
|
||||
Reference in New Issue
Block a user