Add generated terrain feature overlays
This commit is contained in:
@@ -35,6 +35,7 @@ const TILE_MARKER_TEXTURE_PATH_TEMPLATE := "res://art/ui/tiles/tile_marker_%s.pn
|
||||
const CLASS_ICON_TEXTURE_PATH_TEMPLATE := "res://art/ui/class_icons/class_%s.png"
|
||||
const MAP_BADGE_TEXTURE_PATH_TEMPLATE := "res://art/ui/map_badges/map_badge_%s.png"
|
||||
const TERRAIN_TEXTURE_PATH_TEMPLATE := "res://art/terrain/terrain_%s.png"
|
||||
const TERRAIN_FEATURE_TEXTURE_PATH_TEMPLATE := "res://art/terrain/features/terrain_feature_%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"
|
||||
const OPENING_PROLOGUE_XIAHOU_DUN_PATH := "res://art/story/opening/xiahou_dun_joins.png"
|
||||
@@ -4890,6 +4891,13 @@ func _load_terrain_texture(terrain_key: String) -> Texture2D:
|
||||
return _load_art_texture(TERRAIN_TEXTURE_PATH_TEMPLATE % normalized_key)
|
||||
|
||||
|
||||
func _load_terrain_feature_texture(feature_key: String) -> Texture2D:
|
||||
var normalized_key := feature_key.strip_edges().to_lower()
|
||||
if normalized_key.is_empty():
|
||||
return null
|
||||
return _load_art_texture(TERRAIN_FEATURE_TEXTURE_PATH_TEMPLATE % normalized_key)
|
||||
|
||||
|
||||
func _load_tile_marker_texture(marker_key: String) -> Texture2D:
|
||||
var normalized_key := marker_key.strip_edges().to_lower()
|
||||
if normalized_key.is_empty():
|
||||
@@ -4948,6 +4956,17 @@ func _draw_map_badge(badge_key: String, rect: Rect2, modulate: Color = Color.WHI
|
||||
return true
|
||||
|
||||
|
||||
func _draw_terrain_feature(feature_key: String, rect: Rect2, modulate: Color = Color.WHITE, inset: float = 0.0) -> bool:
|
||||
var texture := _load_terrain_feature_texture(feature_key)
|
||||
if texture == null:
|
||||
return false
|
||||
var target_rect := rect.grow(-inset)
|
||||
if target_rect.size.x <= 0.0 or target_rect.size.y <= 0.0:
|
||||
return false
|
||||
draw_texture_rect(texture, target_rect, false, modulate)
|
||||
return true
|
||||
|
||||
|
||||
func _terrain_texture_modulate(cell: Vector2i, terrain_key: String, has_background: bool) -> Color:
|
||||
var alpha := 0.17 if has_background else 0.58
|
||||
if terrain_key == "W":
|
||||
@@ -4982,18 +5001,22 @@ func _draw_terrain_detail(cell: Vector2i, rect: Rect2, terrain_key: String) -> v
|
||||
draw_line(peak, point + Vector2(12, 9), Color(0.20, 0.18, 0.14, 0.42), 2.2)
|
||||
draw_line(point + Vector2(-5, 5), point + Vector2(5, 6), Color(0.10, 0.09, 0.07, 0.20), 1.1)
|
||||
elif terrain_key == "D":
|
||||
_draw_wasteland_detail(cell, rect)
|
||||
if not _draw_terrain_feature("wasteland", rect, Color(1.0, 1.0, 1.0, 0.68)):
|
||||
_draw_wasteland_detail(cell, rect)
|
||||
elif terrain_key == "R":
|
||||
_draw_road_detail(cell, rect)
|
||||
elif terrain_key == "W":
|
||||
for index in range(3):
|
||||
var y := rect.position.y + 15.0 + float(index) * 14.0
|
||||
draw_line(rect.position + Vector2(10, y - rect.position.y), rect.position + Vector2(rect.size.x - 10, y - rect.position.y + 4), Color(0.70, 0.88, 1.0, 0.32), 1.6)
|
||||
_draw_water_shoreline(cell, rect)
|
||||
if not _draw_terrain_feature("water", rect, Color(1.0, 1.0, 1.0, 0.78)):
|
||||
for index in range(3):
|
||||
var y := rect.position.y + 15.0 + float(index) * 14.0
|
||||
draw_line(rect.position + Vector2(10, y - rect.position.y), rect.position + Vector2(rect.size.x - 10, y - rect.position.y + 4), Color(0.70, 0.88, 1.0, 0.32), 1.6)
|
||||
_draw_water_shoreline(cell, rect)
|
||||
elif terrain_key == "C":
|
||||
_draw_castle_detail(rect)
|
||||
if not _draw_terrain_feature("castle", rect, Color(1.0, 1.0, 1.0, 0.74)):
|
||||
_draw_castle_detail(rect)
|
||||
elif terrain_key == "T":
|
||||
_draw_town_detail(rect)
|
||||
if not _draw_terrain_feature("town", rect, Color(1.0, 1.0, 1.0, 0.74)):
|
||||
_draw_town_detail(rect)
|
||||
else:
|
||||
for index in range(2):
|
||||
var point := _terrain_detail_point(cell, rect, index + 15)
|
||||
@@ -5001,6 +5024,8 @@ func _draw_terrain_detail(cell: Vector2i, rect: Rect2, terrain_key: String) -> v
|
||||
|
||||
|
||||
func _draw_road_detail(cell: Vector2i, rect: Rect2) -> void:
|
||||
if _draw_terrain_feature(_road_feature_key(cell), rect, Color(1.0, 1.0, 1.0, 0.82)):
|
||||
return
|
||||
var road_color := Color(0.82, 0.69, 0.48, 0.34)
|
||||
var rut_color := Color(0.36, 0.28, 0.18, 0.24)
|
||||
var center := rect.position + rect.size * 0.5
|
||||
@@ -5024,6 +5049,45 @@ func _draw_road_detail(cell: Vector2i, rect: Rect2) -> void:
|
||||
draw_circle(center, 5.0, Color(0.84, 0.70, 0.48, 0.24))
|
||||
|
||||
|
||||
func _road_feature_key(cell: Vector2i) -> String:
|
||||
var flags := _terrain_connection_flags(cell, "R")
|
||||
var north := bool(flags.get("north", false))
|
||||
var east := bool(flags.get("east", false))
|
||||
var south := bool(flags.get("south", false))
|
||||
var west := bool(flags.get("west", false))
|
||||
if north and east and south and west:
|
||||
return "road_nesw"
|
||||
if north and south and east:
|
||||
return "road_nse"
|
||||
if east and south and west:
|
||||
return "road_esw"
|
||||
if north and south and west:
|
||||
return "road_nsw"
|
||||
if north and east and west:
|
||||
return "road_new"
|
||||
if north and south:
|
||||
return "road_ns"
|
||||
if east and west:
|
||||
return "road_ew"
|
||||
if north and east:
|
||||
return "road_ne"
|
||||
if east and south:
|
||||
return "road_es"
|
||||
if south and west:
|
||||
return "road_sw"
|
||||
if west and north:
|
||||
return "road_wn"
|
||||
if north:
|
||||
return "road_n"
|
||||
if east:
|
||||
return "road_e"
|
||||
if south:
|
||||
return "road_s"
|
||||
if west:
|
||||
return "road_w"
|
||||
return "road_node"
|
||||
|
||||
|
||||
func _draw_water_shoreline(cell: Vector2i, rect: Rect2) -> void:
|
||||
var shore := Color(0.82, 0.88, 0.72, 0.24)
|
||||
if _terrain_key_at(cell + Vector2i(0, -1)) != "W":
|
||||
|
||||
Reference in New Issue
Block a user