Add generated tactical tile markers
This commit is contained in:
@@ -94,6 +94,7 @@ func _init() -> void:
|
||||
_check_generated_toolbar_icons(failures)
|
||||
_check_generated_panel_textures(failures)
|
||||
_check_generated_button_textures(failures)
|
||||
_check_generated_tile_marker_textures(failures)
|
||||
_check_generated_terrain_textures(failures)
|
||||
_check_scene_texture_loading(failures)
|
||||
_check_hud_focus_text(failures)
|
||||
@@ -2991,6 +2992,12 @@ func _check_generated_button_textures(failures: Array[String]) -> void:
|
||||
_check_button_texture_path(failures, "res://art/ui/buttons/button_%s.png" % button_key, "button texture %s" % button_key)
|
||||
|
||||
|
||||
func _check_generated_tile_marker_textures(failures: Array[String]) -> void:
|
||||
var marker_keys := ["move", "attack", "select", "target", "objective", "recover"]
|
||||
for marker_key in marker_keys:
|
||||
_check_tile_marker_texture_path(failures, "res://art/ui/tiles/tile_marker_%s.png" % marker_key, "tile marker %s" % marker_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:
|
||||
@@ -3011,6 +3018,8 @@ func _check_scene_texture_loading(failures: Array[String]) -> void:
|
||||
var panacea: Dictionary = scene.state.get_item_def("panacea")
|
||||
if scene._load_art_texture(str(panacea.get("icon", ""))) == null:
|
||||
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")
|
||||
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", [])
|
||||
@@ -5035,6 +5044,61 @@ func _check_button_texture_path(failures: Array[String], path: String, context:
|
||||
failures.append("%s should contain visible material contrast: %s" % [context, path])
|
||||
|
||||
|
||||
func _check_tile_marker_texture_path(failures: Array[String], path: String, context: String) -> void:
|
||||
if path.is_empty():
|
||||
failures.append("%s has an empty marker 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 tile marker texture: %s" % [context, path])
|
||||
return
|
||||
var image := Image.new()
|
||||
var err := image.load(path)
|
||||
if err != OK:
|
||||
failures.append("%s references unreadable tile marker 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 a square tactical marker: %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.50):
|
||||
failures.append("%s should keep the map visible through transparent center space: %s (%d/%d sampled pixels)" % [context, path, transparent_samples, total_samples])
|
||||
if opaque_samples < int(total_samples * 0.16):
|
||||
failures.append("%s should contain readable generated marker 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)
|
||||
|
||||
Reference in New Issue
Block a user