feat(ui): T-1118 climate overlay + T-1119 quarter glyphs — client halves, with file-size extractions
T-1118: gen_region_grid overlay (label TMP) — _draw_gen_region_grid copies _draw_gen_district's self-contained mapping (dims from the layer dict); mean-temp cold-to-hot ramp over -50..+50 C; REGION_TEMP_NONE_DC airless sentinel = skip-cell (undrawn, never an invented color); legend entry. T-1119 (touch points 3-6): quarter_footprints protocol passthrough; gen_l4_quarters overlay (label QTR) — density-scaled glyph anchored on the L3 settlement dot joined by city_id, shape = dominant district type (corner-tab/diamond marks for Commercial/Industrial/ Administrative), color = density ramp on the settlement-gold family, zoom-gated at SETTLEMENT_LABEL_MIN_ZOOM; landmark/corridor counts never drawn (D-226(d) tooltip-only ceiling); legend entry. Structure: atlas_viewer.gd and protocol.gd were over gdlint's 1000-line cap before this batch; cleanly-separable responsibilities extracted on existing precedent — atlas_generation_state.gd (per-layer data + accessors), atlas_generation_proxy.gd (polling/retry/pending machinery), atlas_overlay_colors.gd (pure ramp/shape lookups), atlas_map_protocol.gd (atlas/starmap/citynames codec, the browse_protocol.gd delegate pattern). Public APIs preserved exactly; _gen_state stays a field default (RefCounted, pre-_ready safe) because _ready()-construction breaks every bare AtlasViewer.new() test — documented inline. Tests: registration + round-trip for both overlays; pure-function suites for the temp ramp (endpoints/midpoint/clamp/sentinel) and quarter glyph (scaling, zoom gate, ramp, notch across all 9 DistrictTypes); Tier-2 replay asserts exact literals from the real server-generated fixture incl. the airless sentinel. Color.lerp(a,b, 1.0) is not bit-exact to b — endpoint assertions use per-component is_equal_approx. Full suite 3094/3094; gdlint zero warnings incl. the two previously-over-cap files. Live capture: legend grows to 7 sections, TMP/QTR toggles clean against a live server. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
extends Node
|
||||
|
||||
## Generation-cascade layer-stream proxy client for AtlasViewer (#960, D-225).
|
||||
## Extracted from atlas_viewer.gd (T-1118) to keep that file under the gdlint
|
||||
## max-file-lines cap — this is the whole "poll the proxy, retry on Pending,
|
||||
## show the diegetic GENERATING indicator, dispatch each layer field to
|
||||
## AtlasGenerationState on Ready" responsibility, self-contained apart from
|
||||
## reading the owning viewer's `_body`/`size` and calling its
|
||||
## set_generation_*() accessors.
|
||||
##
|
||||
## This script has no `class_name` on purpose, matching atlas_overlay_bar.gd/
|
||||
## atlas_legend_panel.gd (review #8 there): the owner (AtlasViewer) passes the
|
||||
## viewer reference to _init(), and a `class_name` + required-arg _init()
|
||||
## combo is a Godot editor footgun. `extends Node` (not RefCounted) because
|
||||
## this owns a child Control (the pending indicator) and needs get_tree() for
|
||||
## the retry timer — added as a child via
|
||||
## load("res://ui/implant/apps/atlas/atlas_generation_proxy.gd").new(self).
|
||||
|
||||
# #960: Layer-1 proxy re-poll. The proxy returns Pending on a cache miss and
|
||||
# generates in the background (D-225); the client re-requests until Ready.
|
||||
const GEN_RETRY_DELAY: float = 0.5
|
||||
const GEN_MAX_RETRIES: int = 20 # ~10s ceiling before giving up
|
||||
|
||||
var _viewer = null # AtlasViewer (untyped to avoid cyclic ref)
|
||||
var _pending: bool = false # awaiting a Layer1 response (re-polls on Pending)
|
||||
var _retries: int = 0
|
||||
var _indicator = null # ImplantPending — loaded by path, not a class_name dep
|
||||
|
||||
|
||||
func _init(viewer_ref = null) -> void:
|
||||
_viewer = viewer_ref
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if _viewer == null:
|
||||
return
|
||||
# Loaded by path (not `ImplantPending.new()`) so a stale global-class cache
|
||||
# — e.g. a running session that hasn't re-imported after this class was
|
||||
# added — can't fail to parse AtlasViewer and break the atlas from opening
|
||||
# (#960).
|
||||
_indicator = load("res://ui/implant/implant_pending.gd").new()
|
||||
_indicator.name = "GenPending"
|
||||
_viewer.add_child(_indicator)
|
||||
_indicator.apply_implant_theme(_viewer.get_implant_theme())
|
||||
_viewer.resized.connect(reposition_indicator)
|
||||
reposition_indicator()
|
||||
|
||||
|
||||
## Reset polling state for a fresh show_body() call — the caller is
|
||||
## responsible for also resetting the layer data itself
|
||||
## (AtlasGenerationState.reset_layer1()).
|
||||
func reset() -> void:
|
||||
_pending = false
|
||||
_retries = 0
|
||||
if _indicator:
|
||||
_indicator.stop()
|
||||
|
||||
|
||||
## Request the body's Layer-1 cascade output from the server proxy. No-op in
|
||||
## test mode (SimBridge has no server connection) — the overlays simply stay
|
||||
## empty, which is the correct serverless behavior.
|
||||
func request(body_id: String) -> void:
|
||||
if body_id.is_empty():
|
||||
return
|
||||
_pending = true
|
||||
SimBridge.request_atlas_layers(body_id)
|
||||
|
||||
|
||||
## Handle a Layer-1 response. Ignores responses for a stale body (the user
|
||||
## navigated away). On Pending the proxy is still generating, so we re-request
|
||||
## after a short delay until Ready or the retry ceiling.
|
||||
func on_response(response: Dictionary, current_body_id: String) -> void:
|
||||
if str(response.get("body_id", "")) != current_body_id:
|
||||
return
|
||||
match str(response.get("status", "")):
|
||||
"Ready":
|
||||
_pending = false
|
||||
_retries = 0
|
||||
_set_indicator(false)
|
||||
_viewer.set_generation_layer1(response.get("layer1"))
|
||||
_viewer.set_generation_district_grid(response.get("district_grid"))
|
||||
_viewer.set_generation_road_graph(response.get("road_graph"))
|
||||
_viewer.set_generation_settlements(response.get("settlements"))
|
||||
_viewer.set_generation_region_grid(response.get("region_grid"))
|
||||
_viewer.set_generation_quarter_footprints(response.get("quarter_footprints"))
|
||||
"Pending":
|
||||
if _retries < GEN_MAX_RETRIES:
|
||||
_retries += 1
|
||||
_set_indicator(true)
|
||||
_schedule_retry(current_body_id)
|
||||
else:
|
||||
_pending = false # gave up — overlays stay empty
|
||||
_set_indicator(false)
|
||||
_:
|
||||
_pending = false # NotFound / Error — nothing to draw
|
||||
_set_indicator(false)
|
||||
|
||||
|
||||
func _schedule_retry(body_id: String) -> void:
|
||||
var timer := get_tree().create_timer(GEN_RETRY_DELAY)
|
||||
timer.timeout.connect(
|
||||
func() -> void:
|
||||
# Re-request only if still on the same body and still waiting.
|
||||
if _pending and _viewer.get_body_id() == body_id:
|
||||
SimBridge.request_atlas_layers(body_id)
|
||||
)
|
||||
|
||||
|
||||
## Show/hide the diegetic pending indicator. Starting only when not already
|
||||
## visible avoids resetting the sweep on every re-poll.
|
||||
func _set_indicator(on: bool) -> void:
|
||||
if _indicator == null:
|
||||
return
|
||||
if on:
|
||||
if not _indicator.visible:
|
||||
reposition_indicator()
|
||||
_indicator.start("GENERATING LAYER 1")
|
||||
else:
|
||||
_indicator.stop()
|
||||
|
||||
|
||||
func reposition_indicator() -> void:
|
||||
if _indicator == null or _viewer == null:
|
||||
return
|
||||
var sz: Vector2 = _viewer.size
|
||||
_indicator.position = Vector2((sz.x - _indicator.DEFAULT_WIDTH) * 0.5, sz.y * 0.45)
|
||||
@@ -0,0 +1,105 @@
|
||||
extends RefCounted
|
||||
## Generation-cascade layer state for AtlasViewer (#960, D-225).
|
||||
##
|
||||
## Extracted from atlas_viewer.gd (T-1118/T-1119) to keep that file under the
|
||||
## gdlint max-file-lines cap while it keeps growing a new field+accessor pair
|
||||
## per generation layer (layer1, district_grid, road_graph, settlements,
|
||||
## region_grid, quarter_footprints — the AtlasLayerResponse growth-ceiling
|
||||
## note in the D-226 T-1112 amendment names region_grid/quarter_footprints as
|
||||
## the last two candidate sibling Option fields). One `_generation_*` field +
|
||||
## one get/set pair per layer, all following the same "store + redraw the
|
||||
## overlay" shape — collecting them here means that shape is written once
|
||||
## (in _set) instead of once per accessor pair.
|
||||
##
|
||||
## AtlasViewer holds one instance (`_gen_state`) and exposes the SAME public
|
||||
## get_generation_*()/set_generation_*() method names it always has —
|
||||
## external callers (atlas_marker_overlay.gd, test_atlas_overlays.gd) are
|
||||
## unaffected; only the storage moved. Consumed via explicit load() by path
|
||||
## (no class_name), matching atlas_legend_panel.gd/atlas_overlay_bar.gd
|
||||
## (review #8 there): AtlasViewer is itself referenced by class_name in
|
||||
## other scripts, and a second global class_name in this cluster is an
|
||||
## unnecessary addition to the global class cache.
|
||||
|
||||
var _overlay_node: Node2D = null # set once by AtlasViewer._ready() (the redraw target)
|
||||
|
||||
var _layer1: Variant = null # #960: Layer1Output from the proxy (D-225)
|
||||
var _district_grid: Variant = null # T-1046: coarse DistrictGridLayer (D-226)
|
||||
var _road_graph: Variant = null # T-960: RoadGraph layer from the proxy (D-225)
|
||||
var _settlements: Variant = null # T-960: settlement placements from the proxy (D-225)
|
||||
var _region_grid: Variant = null # T-1118: RegionGridLayer climate grid (D-226/T-1113)
|
||||
var _quarter_footprints: Variant = null # T-1119: QuarterFootprintLayer (D-226 T-1112 amendment)
|
||||
|
||||
|
||||
func bind_overlay_node(overlay_node: Node2D) -> void:
|
||||
_overlay_node = overlay_node
|
||||
|
||||
|
||||
func _redraw() -> void:
|
||||
if _overlay_node:
|
||||
_overlay_node.queue_redraw()
|
||||
|
||||
|
||||
## Reset every layer to its pre-body-load default. Called from
|
||||
## AtlasViewer.show_body() so a body switch doesn't inherit the previous
|
||||
## body's generation data.
|
||||
func reset_layer1() -> void:
|
||||
_layer1 = null
|
||||
|
||||
|
||||
func set_layer1(layer1: Variant) -> void:
|
||||
_layer1 = layer1
|
||||
_redraw()
|
||||
|
||||
|
||||
func get_layer1() -> Variant:
|
||||
return _layer1
|
||||
|
||||
|
||||
func set_district_grid(grid: Variant) -> void:
|
||||
_district_grid = grid
|
||||
_redraw()
|
||||
|
||||
|
||||
func get_district_grid() -> Variant:
|
||||
return _district_grid
|
||||
|
||||
|
||||
func set_road_graph(graph: Variant) -> void:
|
||||
_road_graph = graph
|
||||
_redraw()
|
||||
|
||||
|
||||
func get_road_graph() -> Variant:
|
||||
return _road_graph
|
||||
|
||||
|
||||
func set_settlements(settlements: Variant) -> void:
|
||||
_settlements = settlements
|
||||
_redraw()
|
||||
|
||||
|
||||
func get_settlements() -> Variant:
|
||||
return _settlements
|
||||
|
||||
|
||||
## T-1118: store the region climate grid (RegionGridLayer) from the proxy and
|
||||
## redraw. The marker overlay reads it via AtlasViewer.get_generation_region_grid().
|
||||
func set_region_grid(grid: Variant) -> void:
|
||||
_region_grid = grid
|
||||
_redraw()
|
||||
|
||||
|
||||
func get_region_grid() -> Variant:
|
||||
return _region_grid
|
||||
|
||||
|
||||
## T-1119: store the L4 quarter-footprint aggregates (QuarterFootprintLayer)
|
||||
## from the proxy and redraw. The marker overlay reads it via
|
||||
## AtlasViewer.get_generation_quarter_footprints().
|
||||
func set_quarter_footprints(footprints: Variant) -> void:
|
||||
_quarter_footprints = footprints
|
||||
_redraw()
|
||||
|
||||
|
||||
func get_quarter_footprints() -> Variant:
|
||||
return _quarter_footprints
|
||||
@@ -34,6 +34,15 @@ const COLOR_ROAD_TRADE: Color = Color(0.85, 0.60, 0.30, 0.85)
|
||||
const COLOR_ROAD_ABANDONED: Color = Color(0.45, 0.42, 0.38, 0.65)
|
||||
const COLOR_SETTLEMENT_GEN: Color = Color(0.94, 0.82, 0.38, 1.0)
|
||||
const COLOR_SETTLEMENT_CAPITAL_GEN: Color = Color(1.0, 0.92, 0.55, 1.0)
|
||||
# T-1118 — region climate grid cold/hot ramp endpoints (matches
|
||||
# atlas_overlay_colors.gd's COLOR_REGION_TEMP_COLD/COLOR_REGION_TEMP_HOT).
|
||||
const COLOR_REGION_TEMP_COLD_GEN: Color = Color(0.25, 0.45, 0.85, 0.60)
|
||||
const COLOR_REGION_TEMP_HOT_GEN: Color = Color(0.90, 0.25, 0.20, 0.60)
|
||||
# T-1119 — quarter-footprint density ramp endpoints, D-226 T-1112 amendment
|
||||
# SS3's literal legend spec (matches atlas_overlay_colors.gd's
|
||||
# COLOR_QUARTER_LOW_DENSITY/COLOR_QUARTER_HIGH_DENSITY).
|
||||
const COLOR_QUARTER_LOW_DENSITY_GEN: Color = Color(0.55, 0.48, 0.30, 0.6)
|
||||
const COLOR_QUARTER_HIGH_DENSITY_GEN: Color = Color(0.94, 0.82, 0.38, 1.0)
|
||||
|
||||
## One entry per generation-overlay id. "color": Color.TRANSPARENT means
|
||||
## "shape/style carries the meaning here, let the theme's dim text color
|
||||
@@ -79,6 +88,15 @@ const GENERATION_LEGEND: Array = [
|
||||
{"glyph": "●", "color": Color(0.55, 0.68, 0.82, 0.90), "label": "cold"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"overlay_id": "gen_region_grid",
|
||||
"title": "REGION CLIMATE — mean temperature (~205 km cells)",
|
||||
"rows": [
|
||||
{"glyph": "▦", "color": COLOR_REGION_TEMP_COLD_GEN, "label": "cold"},
|
||||
{"glyph": "▦", "color": COLOR_REGION_TEMP_HOT_GEN, "label": "hot"},
|
||||
{"glyph": "▦", "color": Color.TRANSPARENT, "label": "airless — no reading (skipped)"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"overlay_id": "gen_district",
|
||||
"title": "DISTRICT MORPHOLOGY — coarse",
|
||||
@@ -114,6 +132,17 @@ const GENERATION_LEGEND: Array = [
|
||||
{"glyph": "★", "color": COLOR_SETTLEMENT_CAPITAL_GEN, "label": "capital / major hub"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"overlay_id": "gen_l4_quarters",
|
||||
"title": "QUARTER FOOTPRINT — L4 (color = density, shape = dominant type)",
|
||||
"rows": [
|
||||
{"glyph": "▪", "color": COLOR_QUARTER_LOW_DENSITY_GEN, "label": "low density"},
|
||||
{"glyph": "▪", "color": COLOR_QUARTER_HIGH_DENSITY_GEN, "label": "high density"},
|
||||
{"glyph": "◪", "color": Color.TRANSPARENT, "label": "commercial (corner tab, top-right)"},
|
||||
{"glyph": "◩", "color": Color.TRANSPARENT, "label": "industrial (corner tab, bottom-right)"},
|
||||
{"glyph": "◈", "color": Color.TRANSPARENT, "label": "administrative (diamond cutout)"},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
var _viewer = null # AtlasViewer (untyped to avoid cyclic ref)
|
||||
|
||||
@@ -43,44 +43,15 @@ const COLOR_GEN_BASIN_FILL: Color = Color(0.20, 0.35, 0.55, 0.06)
|
||||
const COLOR_GEN_BASIN_LINE: Color = Color(0.45, 0.65, 0.85, 0.45)
|
||||
const GEN_ATTRACTOR_MIN_STRENGTH: float = 0.15
|
||||
|
||||
## Sub-biome → marker color (Araminta's palette, D-226). Grouped pairs share a
|
||||
## color since they read the same on the map; see _sub_biome_color.
|
||||
const SUB_BIOME_COLORS: Dictionary = {
|
||||
"TropicalWet": Color(0.25, 0.72, 0.65, 0.90), # teal — coastal/tropical
|
||||
"CoastalLowland": Color(0.25, 0.72, 0.65, 0.90),
|
||||
"TemperateForest": Color(0.45, 0.68, 0.45, 0.90), # sage — temperate
|
||||
"TemperateGrassland": Color(0.45, 0.68, 0.45, 0.90),
|
||||
"Desert": Color(0.78, 0.62, 0.35, 0.90), # sand — arid
|
||||
"Savanna": Color(0.78, 0.62, 0.35, 0.90),
|
||||
"Alpine": Color(0.52, 0.58, 0.72, 0.90), # slate — alpine
|
||||
"Wetland": Color(0.40, 0.60, 0.52, 0.90), # muted teal — wetland
|
||||
"Tundra": Color(0.55, 0.68, 0.82, 0.90), # cool grey-blue — cold
|
||||
"BorealForest": Color(0.55, 0.68, 0.82, 0.90),
|
||||
}
|
||||
const COLOR_SUB_BIOME_DEFAULT: Color = Color(0.72, 0.72, 0.76, 0.90) # default grey
|
||||
|
||||
## MorphologyZone discriminant → overlay colour (D-239 §6 order, T-1046).
|
||||
## ~0.55 alpha so the heightmap shows through: water blues, plains greens,
|
||||
## uplands greys/browns, volcanic dark red.
|
||||
const MORPHOLOGY_COLORS: Array = [
|
||||
Color(0.10, 0.20, 0.45, 0.55), # 0 OpenOcean
|
||||
Color(0.20, 0.40, 0.65, 0.55), # 1 Lake
|
||||
Color(0.45, 0.55, 0.50, 0.55), # 2 TidalFlat
|
||||
Color(0.85, 0.78, 0.45, 0.55), # 3 DuneStrand
|
||||
Color(0.50, 0.50, 0.55, 0.55), # 4 CliffCoast
|
||||
Color(0.30, 0.40, 0.50, 0.55), # 5 Fjord
|
||||
Color(0.40, 0.65, 0.60, 0.55), # 6 Delta
|
||||
Color(0.30, 0.55, 0.55, 0.55), # 7 Estuarine
|
||||
Color(0.30, 0.60, 0.30, 0.55), # 8 AlluvialPlain
|
||||
Color(0.45, 0.70, 0.40, 0.55), # 9 RiverBank
|
||||
Color(0.35, 0.60, 0.50, 0.55), # 10 MeanderReach
|
||||
Color(0.55, 0.60, 0.45, 0.55), # 11 BraidedPlain
|
||||
Color(0.50, 0.55, 0.30, 0.55), # 12 ValleyFloor
|
||||
Color(0.55, 0.45, 0.30, 0.55), # 13 MountainPass
|
||||
Color(0.80, 0.82, 0.85, 0.55), # 14 Alpine
|
||||
Color(0.45, 0.15, 0.12, 0.55), # 15 Volcanic
|
||||
Color(0.25, 0.45, 0.40, 0.55), # 16 Wetland
|
||||
]
|
||||
## Pure color-ramp/shape-selection helpers (morphology, sub-biome, road
|
||||
## authority, region temp, quarter density/notch) — factored into
|
||||
## atlas_overlay_colors.gd (T-1118) to stay under gdlint's max-file-lines,
|
||||
## same rationale as atlas_format.gd's static-function + preload pattern.
|
||||
## That file owns the actual constant tables; this file only keeps constants
|
||||
## with no decision function wrapping them (e.g. COLOR_SETTLEMENT — used
|
||||
## directly, not looked up).
|
||||
const AtlasOverlayColors := preload("res://ui/implant/apps/atlas/atlas_overlay_colors.gd")
|
||||
const REGION_TEMP_NONE_DC: int = AtlasOverlayColors.REGION_TEMP_NONE_DC
|
||||
|
||||
# Province boundaries (D-205, #927)
|
||||
const COLOR_PROVINCE_BORDER: Color = Color(0.45, 0.65, 0.85, 0.55)
|
||||
@@ -92,11 +63,6 @@ const PROVINCE_BORDER_WIDTH: float = 1.2
|
||||
# COLOR_ROAD tan (long-haul trade routes ARE the base "road" concept, now
|
||||
# split out by authority) so the new encoding stays visually consistent with
|
||||
# the existing overlay palette instead of introducing an unrelated hue set.
|
||||
const COLOR_ROAD_ADMINISTRATIVE: Color = Color(0.45, 0.65, 0.90, 0.85)
|
||||
const COLOR_ROAD_CORPORATE: Color = Color(0.85, 0.65, 0.20, 0.85)
|
||||
const COLOR_ROAD_COMMUNAL: Color = Color(0.45, 0.75, 0.50, 0.85)
|
||||
const COLOR_ROAD_TRADE: Color = Color(0.85, 0.60, 0.30, 0.85)
|
||||
const COLOR_ROAD_ABANDONED: Color = Color(0.45, 0.42, 0.38, 0.65)
|
||||
const COLOR_ROAD_JUNCTION: Color = Color(0.85, 0.85, 0.90, 0.80)
|
||||
const ROAD_JUNCTION_MIN_DEGREE: int = 3 # mirrors server's JUNCTION_DEGREE (road_graph.rs)
|
||||
|
||||
@@ -180,6 +146,15 @@ func _draw() -> void:
|
||||
if viewer.is_overlay_visible("corp_presence"):
|
||||
_draw_corp_presence(markers)
|
||||
|
||||
# Generation: region climate grid (T-1118, D-243) — the coarsest area fill
|
||||
# (~205 km cells), drawn first among generation overlays so the district
|
||||
# morphology grid and every finer layer below reads on top of it as
|
||||
# background climate context.
|
||||
if viewer.is_overlay_visible("gen_region_grid"):
|
||||
var region_grid: Variant = viewer.get_generation_region_grid()
|
||||
if region_grid is Dictionary:
|
||||
_draw_gen_region_grid(region_grid, tex_w, tex_h)
|
||||
|
||||
# Generation: district morphology grid (T-1046, D-226) — coarse area fill,
|
||||
# drawn under the Layer-1 line/point overlays.
|
||||
if viewer.is_overlay_visible("gen_district"):
|
||||
@@ -215,6 +190,15 @@ func _draw() -> void:
|
||||
var settlements: Variant = viewer.get_generation_settlements()
|
||||
if settlements != null:
|
||||
_draw_gen_settlements(settlements)
|
||||
# T-1119: drawn immediately after gen_l3_settlements so it reads
|
||||
# as "on top of" the city dot it annotates (D-226 T-1112 SS3),
|
||||
# and needs the SAME settlements payload for the city_id->
|
||||
# position join (quarter footprints carry no position of
|
||||
# their own).
|
||||
if viewer.is_overlay_visible("gen_l4_quarters"):
|
||||
var quarters: Variant = viewer.get_generation_quarter_footprints()
|
||||
if quarters is Dictionary:
|
||||
_draw_gen_quarter_footprints(quarters, settlements)
|
||||
|
||||
# POIs (non-gate first, then gates on top if enabled)
|
||||
_draw_pois(markers)
|
||||
@@ -491,13 +475,49 @@ func _draw_gen_district(grid: Dictionary, tex_w: float, tex_h: float) -> void:
|
||||
if i >= n:
|
||||
continue
|
||||
# +0.5 overdraw avoids hairline seams between adjacent cells.
|
||||
draw_rect(Rect2(rx * cw, ry * ch, cw + 0.5, ch + 0.5), _morphology_color(int(morphology[i])))
|
||||
draw_rect(
|
||||
Rect2(rx * cw, ry * ch, cw + 0.5, ch + 0.5),
|
||||
AtlasOverlayColors.morphology_color(int(morphology[i]))
|
||||
)
|
||||
|
||||
|
||||
func _morphology_color(zone: int) -> Color:
|
||||
if zone >= 0 and zone < MORPHOLOGY_COLORS.size():
|
||||
return MORPHOLOGY_COLORS[zone]
|
||||
return Color(0.5, 0.5, 0.5, 0.4)
|
||||
## Region climate grid (T-1118, D-243 SS"region"). A coarse `cols x rows` area
|
||||
## fill mirroring _draw_gen_district's SELF-CONTAINED coordinate mapping above
|
||||
## (dims come from the layer dict itself, cw/ch = tex/cols|rows) — this is a
|
||||
## dense row-major grid keyed by its OWN cols/rows, NOT a Layer-1 point
|
||||
## position, so it does NOT use _gen_pos()/_gen_grid_w (that path is for
|
||||
## Layer-1 river/basin/attractor points and the L2/L3 graphs, which share one
|
||||
## working-grid coordinate space; the region grid is its own dense array with
|
||||
## its own extent, exactly like district_grid).
|
||||
##
|
||||
## Channel: mean_temp_dc only (season/weather/moisture deferred to a future
|
||||
## tooltip/variant overlay per the ticket scope — D-226 "one visual channel
|
||||
## first"). Airless-body cells (REGION_TEMP_NONE_DC sentinel) are skipped
|
||||
## entirely, not colored — see the REGION_TEMP_NONE_DC comment above.
|
||||
func _draw_gen_region_grid(grid: Dictionary, tex_w: float, tex_h: float) -> void:
|
||||
var cols: int = int(grid.get("cols", 0))
|
||||
var rows: int = int(grid.get("rows", 0))
|
||||
if cols <= 0 or rows <= 0:
|
||||
return
|
||||
var mean_temp_dc: Variant = grid.get("mean_temp_dc")
|
||||
if not (mean_temp_dc is Array or mean_temp_dc is PackedByteArray):
|
||||
return
|
||||
var cw: float = tex_w / float(cols)
|
||||
var ch: float = tex_h / float(rows)
|
||||
var n: int = mean_temp_dc.size()
|
||||
for ry in range(rows):
|
||||
for rx in range(cols):
|
||||
var i: int = ry * cols + rx
|
||||
if i >= n:
|
||||
continue
|
||||
var temp_dc: int = int(mean_temp_dc[i])
|
||||
if temp_dc == REGION_TEMP_NONE_DC:
|
||||
continue # airless — no temperature to show
|
||||
# +0.5 overdraw avoids hairline seams between adjacent cells.
|
||||
draw_rect(
|
||||
Rect2(rx * cw, ry * ch, cw + 0.5, ch + 0.5),
|
||||
AtlasOverlayColors.region_temp_color(temp_dc)
|
||||
)
|
||||
|
||||
|
||||
func _draw_gen_rivers(layer1: Dictionary) -> void:
|
||||
@@ -548,18 +568,10 @@ func _draw_gen_attractors(layer1: Dictionary) -> void:
|
||||
if not pos_rc is Array or pos_rc.size() < 2:
|
||||
continue
|
||||
var size: float = 5.0 + strength * 4.0
|
||||
var color: Color = _sub_biome_color(str(a.get("sub_biome", "")))
|
||||
var color: Color = AtlasOverlayColors.sub_biome_color(str(a.get("sub_biome", "")))
|
||||
_draw_attractor_shape(str(a.get("attractor_type", "")), _gen_pos(pos_rc), size, color)
|
||||
|
||||
|
||||
## Sub-biome → marker color (Araminta's palette). Color is additive info; shape
|
||||
## carries the attractor-type identity (survives monochrome capture). Table
|
||||
## lookup (SUB_BIOME_COLORS) rather than a multi-return match — same pattern
|
||||
## as MORPHOLOGY_COLORS/_morphology_color below.
|
||||
func _sub_biome_color(sub_biome: String) -> Color:
|
||||
return SUB_BIOME_COLORS.get(sub_biome, COLOR_SUB_BIOME_DEFAULT)
|
||||
|
||||
|
||||
## Attractor type → marker shape (Araminta's vocabulary, 7 types).
|
||||
func _draw_attractor_shape(atype: String, pos: Vector2, size: float, color: Color) -> void:
|
||||
match atype:
|
||||
@@ -599,25 +611,6 @@ func _draw_triangle(pos: Vector2, size: float, color: Color, point_down: bool) -
|
||||
# =============================================================================
|
||||
|
||||
|
||||
## MaintenanceAuthority (D-211/D-212) → line color. The one color-coded axis
|
||||
## on this overlay — road vs rail is told apart by line style/width instead
|
||||
## (_draw_gen_roads), so authority stays legible on its own.
|
||||
func _road_authority_color(maintenance: String) -> Color:
|
||||
match maintenance:
|
||||
"Administrative":
|
||||
return COLOR_ROAD_ADMINISTRATIVE
|
||||
"Corporate":
|
||||
return COLOR_ROAD_CORPORATE
|
||||
"Communal":
|
||||
return COLOR_ROAD_COMMUNAL
|
||||
"Trade":
|
||||
return COLOR_ROAD_TRADE
|
||||
"Abandoned":
|
||||
return COLOR_ROAD_ABANDONED
|
||||
_:
|
||||
return COLOR_ROAD_TRADE
|
||||
|
||||
|
||||
## Inter-settlement road/rail graph (RoadGraphLayer — D-211, T-1038). Edges
|
||||
## colored by MaintenanceAuthority; rail vs road told apart by line style/
|
||||
## width (dashed + thin = rail, solid + wider = road) rather than a second
|
||||
@@ -645,7 +638,7 @@ func _draw_gen_roads(road_graph: Dictionary) -> void:
|
||||
points.append(_gen_pos(pt))
|
||||
if points.size() < 2:
|
||||
continue
|
||||
var color: Color = _road_authority_color(str(e.get("maintenance", "")))
|
||||
var color: Color = AtlasOverlayColors.road_authority_color(str(e.get("maintenance", "")))
|
||||
if bool(e.get("is_rail", false)):
|
||||
_draw_dashed_polyline(points, color, 1.1)
|
||||
else:
|
||||
@@ -742,6 +735,92 @@ func _draw_star(pos: Vector2, size: float, color: Color) -> void:
|
||||
draw_colored_polygon(pts, color)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Generation-cascade overlays — L4 quarter footprints (T-1119, D-226 T-1112 amendment)
|
||||
# =============================================================================
|
||||
|
||||
|
||||
## Quarter-footprint aggregates (QuarterFootprintLayer — D-226 T-1112 amendment
|
||||
## SS1/SS4), one density-scaled glyph per city_id anchored at the SAME position
|
||||
## the L3 settlement dot already drew (`_gen_pos` on the settlement's
|
||||
## `position` — quarter footprints carry no independent spatial position per
|
||||
## the amendment, only a `city_id` join key). `entries` is keyed by city_id
|
||||
## (BTreeMap<u64,_> on the wire, decodes to a Dictionary with int keys) and is
|
||||
## a SUBSET of settlements — a placement can exist with no quarter entry yet
|
||||
## (async per-city generation), so a missing city_id is silently skipped, not
|
||||
## an error. `landmark_count`/`corridor_count` are tooltip-only per the D-226
|
||||
## SS2 hard ceiling — never drawn here (city-click sidebar addition, out of
|
||||
## this overlay's scope). Draw call MUST come from the same `settlements`
|
||||
## payload gen_l3_settlements just drew, so this needs the raw settlements
|
||||
## data threaded in from _draw() rather than re-fetching it here.
|
||||
func _draw_gen_quarter_footprints(footprints: Variant, settlements: Variant) -> void:
|
||||
var entries: Dictionary = {}
|
||||
if footprints is Dictionary:
|
||||
entries = footprints.get("entries", {})
|
||||
if entries.is_empty():
|
||||
return
|
||||
|
||||
var settlement_entries: Array = []
|
||||
if settlements is Array:
|
||||
settlement_entries = settlements
|
||||
elif settlements is Dictionary:
|
||||
settlement_entries = settlements.get("settlements", [])
|
||||
if settlement_entries.is_empty():
|
||||
return
|
||||
|
||||
var show_notch: bool = viewer.get_view_zoom() >= SETTLEMENT_LABEL_MIN_ZOOM
|
||||
for s: Variant in settlement_entries:
|
||||
if not s is Dictionary:
|
||||
continue
|
||||
var city_id: int = int(s.get("city_id", -1))
|
||||
if city_id < 0 or not entries.has(city_id):
|
||||
continue
|
||||
var entry: Dictionary = entries[city_id]
|
||||
var pos_rc: Variant = s.get("position")
|
||||
if not pos_rc is Array or pos_rc.size() < 2:
|
||||
continue
|
||||
_draw_quarter_glyph(_gen_pos(pos_rc), entry, show_notch)
|
||||
|
||||
|
||||
## One density-scaled square glyph. Below SETTLEMENT_LABEL_MIN_ZOOM, draws at
|
||||
## minimum size with color only (the notch is illegible at a few px anyway,
|
||||
## per the amendment); at/above it, full size with the dominant-type notch.
|
||||
## Size/color/shape decisions live in AtlasOverlayColors (unit tested there
|
||||
## directly via test_atlas_overlays.gd) — this function is just the
|
||||
## draw_rect/notch calls.
|
||||
func _draw_quarter_glyph(pos: Vector2, entry: Dictionary, show_notch: bool) -> void:
|
||||
var density_pct: int = int(entry.get("density_avg_pct", 0))
|
||||
var side: float = AtlasOverlayColors.quarter_glyph_size(density_pct, show_notch)
|
||||
var color: Color = AtlasOverlayColors.quarter_glyph_color(density_pct)
|
||||
var half: Vector2 = Vector2(side, side) * 0.5
|
||||
draw_rect(Rect2(pos - half, Vector2(side, side)), color)
|
||||
if not show_notch:
|
||||
return
|
||||
var district_type: String = str(entry.get("dominant_district_type", ""))
|
||||
_draw_quarter_notch(pos, half, AtlasOverlayColors.quarter_notch_kind(district_type))
|
||||
|
||||
|
||||
## Draws the notch glyph for a resolved AtlasOverlayColors.quarter_notch_kind() result.
|
||||
func _draw_quarter_notch(pos: Vector2, half: Vector2, kind: String) -> void:
|
||||
var notch_color := Color(0.08, 0.08, 0.08, 0.55)
|
||||
match kind:
|
||||
"commercial":
|
||||
# Corner tab, top-right.
|
||||
var tab: float = half.x * 0.7
|
||||
draw_rect(Rect2(pos + Vector2(half.x - tab, -half.y), Vector2(tab, tab)), notch_color)
|
||||
"industrial":
|
||||
# Corner tab, bottom-right.
|
||||
var tab: float = half.x * 0.7
|
||||
draw_rect(
|
||||
Rect2(pos + Vector2(half.x - tab, half.y - tab), Vector2(tab, tab)), notch_color
|
||||
)
|
||||
"administrative":
|
||||
# Small diamond cutout, center (civic/landmark read).
|
||||
_draw_diamond(pos, half.x * 0.45, notch_color)
|
||||
_:
|
||||
pass # plain square — mixed / no clear dominant
|
||||
|
||||
|
||||
func _path_to_canvas(path: Array) -> PackedVector2Array:
|
||||
var out: PackedVector2Array = PackedVector2Array()
|
||||
for pt: Variant in path:
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
extends RefCounted
|
||||
## Pure color-ramp / shape-selection helpers for the Atlas generation overlays
|
||||
## (T-1118) — factored out of atlas_marker_overlay.gd to keep that file under
|
||||
## gdlint's max-file-lines cap. draw_rect()/draw_circle()/etc are CanvasItem
|
||||
## instance methods called implicitly on `self`, so the actual draw calls
|
||||
## can't move here — only the pure lookups that decide WHAT color/shape to
|
||||
## draw, matching atlas_format.gd's static-function + preload pattern:
|
||||
## const AtlasOverlayColors := preload("res://ui/implant/apps/atlas/atlas_overlay_colors.gd")
|
||||
##
|
||||
## Every constant/function here is duplicated FROM atlas_marker_overlay.gd
|
||||
## (not the other way — that file still owns the same constants for its own
|
||||
## draw calls and the legend's own copies, matching the existing
|
||||
## COLOR_ROAD_*/COLOR_SETTLEMENT_* "each file owns its own reading of the
|
||||
## palette" precedent, atlas_legend_panel.gd's own header comment). Consumers
|
||||
## needing the DECISION (not just the constant) call the static functions
|
||||
## below instead of re-deriving the same match/lerp logic a third time.
|
||||
##
|
||||
## gdlint's class-definitions-order requires all consts before all funcs at
|
||||
## file scope (no interleaving) — hence every table up top, decisions below.
|
||||
|
||||
## MorphologyZone discriminant -> overlay colour (D-239 SS6 order, T-1046).
|
||||
const MORPHOLOGY_COLORS: Array = [
|
||||
Color(0.10, 0.20, 0.45, 0.55), # 0 OpenOcean
|
||||
Color(0.20, 0.40, 0.65, 0.55), # 1 Lake
|
||||
Color(0.45, 0.55, 0.50, 0.55), # 2 TidalFlat
|
||||
Color(0.85, 0.78, 0.45, 0.55), # 3 DuneStrand
|
||||
Color(0.50, 0.50, 0.55, 0.55), # 4 CliffCoast
|
||||
Color(0.30, 0.40, 0.50, 0.55), # 5 Fjord
|
||||
Color(0.40, 0.65, 0.60, 0.55), # 6 Delta
|
||||
Color(0.30, 0.55, 0.55, 0.55), # 7 Estuarine
|
||||
Color(0.30, 0.60, 0.30, 0.55), # 8 AlluvialPlain
|
||||
Color(0.45, 0.70, 0.40, 0.55), # 9 RiverBank
|
||||
Color(0.35, 0.60, 0.50, 0.55), # 10 MeanderReach
|
||||
Color(0.55, 0.60, 0.45, 0.55), # 11 BraidedPlain
|
||||
Color(0.50, 0.55, 0.30, 0.55), # 12 ValleyFloor
|
||||
Color(0.55, 0.45, 0.30, 0.55), # 13 MountainPass
|
||||
Color(0.80, 0.82, 0.85, 0.55), # 14 Alpine
|
||||
Color(0.45, 0.15, 0.12, 0.55), # 15 Volcanic
|
||||
Color(0.25, 0.45, 0.40, 0.55), # 16 Wetland
|
||||
]
|
||||
|
||||
## Sub-biome -> marker color (Araminta's palette, D-226). Grouped pairs share
|
||||
## a color since they read the same on the map.
|
||||
const SUB_BIOME_COLORS: Dictionary = {
|
||||
"TropicalWet": Color(0.25, 0.72, 0.65, 0.90), # teal — coastal/tropical
|
||||
"CoastalLowland": Color(0.25, 0.72, 0.65, 0.90),
|
||||
"TemperateForest": Color(0.45, 0.68, 0.45, 0.90), # sage — temperate
|
||||
"TemperateGrassland": Color(0.45, 0.68, 0.45, 0.90),
|
||||
"Desert": Color(0.78, 0.62, 0.35, 0.90), # sand — arid
|
||||
"Savanna": Color(0.78, 0.62, 0.35, 0.90),
|
||||
"Alpine": Color(0.52, 0.58, 0.72, 0.90), # slate — alpine
|
||||
"Wetland": Color(0.40, 0.60, 0.52, 0.90), # muted teal — wetland
|
||||
"Tundra": Color(0.55, 0.68, 0.82, 0.90), # cool grey-blue — cold
|
||||
"BorealForest": Color(0.55, 0.68, 0.82, 0.90),
|
||||
}
|
||||
const COLOR_SUB_BIOME_DEFAULT: Color = Color(0.72, 0.72, 0.76, 0.90) # default grey
|
||||
|
||||
## T-960 L2 — MaintenanceAuthority (D-211/D-212) -> line color.
|
||||
const COLOR_ROAD_ADMINISTRATIVE: Color = Color(0.45, 0.65, 0.90, 0.85)
|
||||
const COLOR_ROAD_CORPORATE: Color = Color(0.85, 0.65, 0.20, 0.85)
|
||||
const COLOR_ROAD_COMMUNAL: Color = Color(0.45, 0.75, 0.50, 0.85)
|
||||
const COLOR_ROAD_TRADE: Color = Color(0.85, 0.60, 0.30, 0.85)
|
||||
const COLOR_ROAD_ABANDONED: Color = Color(0.45, 0.42, 0.38, 0.65)
|
||||
|
||||
## T-1118 — region climate grid (D-243 SS"region", D-226). Cold->hot ramp over
|
||||
## the realistic surface mean-annual band (~ -50C to +50C); REGION_TEMP_NONE_DC
|
||||
## (i16::MIN, server/src/atlas/layer_proxy.rs) is the airless-body sentinel —
|
||||
## the caller (atlas_marker_overlay.gd's _draw_gen_region_grid) skips those
|
||||
## cells entirely rather than calling this function for them.
|
||||
const REGION_TEMP_MIN_DC: int = -500 # -50.0 C, deci-degC
|
||||
const REGION_TEMP_MAX_DC: int = 500 # +50.0 C, deci-degC
|
||||
const REGION_TEMP_NONE_DC: int = -32768 # i16::MIN sentinel (airless — skip cell)
|
||||
const COLOR_REGION_TEMP_COLD: Color = Color(0.25, 0.45, 0.85, 0.60) # blue
|
||||
const COLOR_REGION_TEMP_MID: Color = Color(0.85, 0.85, 0.55, 0.55) # pale warm
|
||||
const COLOR_REGION_TEMP_HOT: Color = Color(0.90, 0.25, 0.20, 0.60) # red
|
||||
|
||||
## T-1119 — L4 quarter-footprint glyph (D-226 T-1112 amendment SS3). Square
|
||||
## side [QUARTER_GLYPH_MIN_SIZE, QUARTER_GLYPH_MAX_SIZE] scales off
|
||||
## density_avg_pct; color is a single-hue intensity ramp WITHIN the
|
||||
## settlement-gold family so the layer reads as part of the settlement-marker
|
||||
## family, not a competing hue.
|
||||
const QUARTER_GLYPH_MIN_SIZE: float = 4.0
|
||||
const QUARTER_GLYPH_MAX_SIZE: float = 12.0
|
||||
const QUARTER_GLYPH_BASE_SIZE: float = 4.0
|
||||
const QUARTER_GLYPH_DENSITY_SCALE: float = 6.0
|
||||
const COLOR_QUARTER_LOW_DENSITY: Color = Color(0.55, 0.48, 0.30, 0.6) # dim gold
|
||||
const COLOR_QUARTER_HIGH_DENSITY: Color = Color(0.94, 0.82, 0.38, 1.0) # COLOR_SETTLEMENT gold
|
||||
|
||||
|
||||
static func morphology_color(zone: int) -> Color:
|
||||
if zone >= 0 and zone < MORPHOLOGY_COLORS.size():
|
||||
return MORPHOLOGY_COLORS[zone]
|
||||
return Color(0.5, 0.5, 0.5, 0.4)
|
||||
|
||||
|
||||
static func sub_biome_color(sub_biome: String) -> Color:
|
||||
return SUB_BIOME_COLORS.get(sub_biome, COLOR_SUB_BIOME_DEFAULT)
|
||||
|
||||
|
||||
static func road_authority_color(maintenance: String) -> Color:
|
||||
match maintenance:
|
||||
"Administrative":
|
||||
return COLOR_ROAD_ADMINISTRATIVE
|
||||
"Corporate":
|
||||
return COLOR_ROAD_CORPORATE
|
||||
"Communal":
|
||||
return COLOR_ROAD_COMMUNAL
|
||||
"Trade":
|
||||
return COLOR_ROAD_TRADE
|
||||
"Abandoned":
|
||||
return COLOR_ROAD_ABANDONED
|
||||
_:
|
||||
return COLOR_ROAD_TRADE
|
||||
|
||||
|
||||
## Cold->hot ramp over [REGION_TEMP_MIN_DC, REGION_TEMP_MAX_DC], clamped at
|
||||
## the ends (a real reading outside the band still renders, just capped to
|
||||
## the extreme color rather than clipping to nothing).
|
||||
static func region_temp_color(temp_dc: int) -> Color:
|
||||
var clamped: int = clampi(temp_dc, REGION_TEMP_MIN_DC, REGION_TEMP_MAX_DC)
|
||||
var t: float = (
|
||||
float(clamped - REGION_TEMP_MIN_DC) / float(REGION_TEMP_MAX_DC - REGION_TEMP_MIN_DC)
|
||||
)
|
||||
if t <= 0.5:
|
||||
return COLOR_REGION_TEMP_COLD.lerp(COLOR_REGION_TEMP_MID, t / 0.5)
|
||||
return COLOR_REGION_TEMP_MID.lerp(COLOR_REGION_TEMP_HOT, (t - 0.5) / 0.5)
|
||||
|
||||
|
||||
## Density-scaled side length, clamped to [QUARTER_GLYPH_MIN_SIZE,
|
||||
## QUARTER_GLYPH_MAX_SIZE]. Below SETTLEMENT_LABEL_MIN_ZOOM the glyph always
|
||||
## draws at minimum size (color-only read, per the amendment) regardless of
|
||||
## density — `show_notch` is the zoom gate, not a density input.
|
||||
static func quarter_glyph_size(density_avg_pct: int, show_notch: bool) -> float:
|
||||
if not show_notch:
|
||||
return QUARTER_GLYPH_MIN_SIZE
|
||||
var density_frac: float = clampf(float(density_avg_pct) / 100.0, 0.0, 1.0)
|
||||
return clampf(
|
||||
QUARTER_GLYPH_BASE_SIZE + density_frac * QUARTER_GLYPH_DENSITY_SCALE,
|
||||
QUARTER_GLYPH_MIN_SIZE,
|
||||
QUARTER_GLYPH_MAX_SIZE
|
||||
)
|
||||
|
||||
|
||||
## Single-hue intensity ramp within the settlement-gold family (D-226 T-1112
|
||||
## amendment SS3's literal legend colors).
|
||||
static func quarter_glyph_color(density_avg_pct: int) -> Color:
|
||||
var density_frac: float = clampf(float(density_avg_pct) / 100.0, 0.0, 1.0)
|
||||
return COLOR_QUARTER_LOW_DENSITY.lerp(COLOR_QUARTER_HIGH_DENSITY, density_frac)
|
||||
|
||||
|
||||
## Shape = dominant_district_type, capped at 3 marked variants + plain (D-226
|
||||
## SS3: "a coarse skeleton read, not a legend of every DistrictType"). Only
|
||||
## Commercial/Industrial/Administrative get a distinct mark; every other
|
||||
## DistrictType (LogisticsHub, Residential, Entertainment, MixedUse, Transit,
|
||||
## Specialized) — including an unrecognized/empty string — reads as "plain"
|
||||
## (mixed / no clear dominant), matching the legend. Returns a lowercase kind
|
||||
## string ("commercial"|"industrial"|"administrative"|"plain") the caller
|
||||
## switches on to pick the actual draw call.
|
||||
static func quarter_notch_kind(district_type: String) -> String:
|
||||
match district_type:
|
||||
"Commercial", "Industrial", "Administrative":
|
||||
return district_type.to_lower()
|
||||
_:
|
||||
return "plain"
|
||||
@@ -31,11 +31,6 @@ const MIN_ZOOM: float = 0.5
|
||||
const MAX_ZOOM: float = 8.0
|
||||
const ZOOM_STEP: float = 1.15
|
||||
|
||||
# #960: Layer-1 proxy re-poll. The proxy returns Pending on a cache miss and
|
||||
# generates in the background (D-225); the client re-requests until Ready.
|
||||
const GEN_RETRY_DELAY: float = 0.5
|
||||
const GEN_MAX_RETRIES: int = 20 # ~10s ceiling before giving up
|
||||
|
||||
const PANEL_WIDTH: float = 320.0
|
||||
const PANEL_MARGIN: float = 16.0
|
||||
|
||||
@@ -164,6 +159,18 @@ const OVERLAY_DEFS: Array = [
|
||||
"group": "toggle",
|
||||
"tooltip": "Layer 3 — settlement placements, sized by population (generation overlay, T-960)."
|
||||
},
|
||||
{
|
||||
"id": "gen_region_grid",
|
||||
"label": "TMP",
|
||||
"group": "toggle",
|
||||
"tooltip": "Region climate grid — mean temperature (generation overlay, T-1118/D-243)."
|
||||
},
|
||||
{
|
||||
"id": "gen_l4_quarters",
|
||||
"label": "QTR",
|
||||
"group": "toggle",
|
||||
"tooltip": "Layer 4 — quarter footprint, color=density shape=type (generation overlay, T-1119)."
|
||||
},
|
||||
]
|
||||
|
||||
# ── Context (set by show_body) ─────────────────────────────────────────────────
|
||||
@@ -174,12 +181,25 @@ var _implant_theme = null
|
||||
# ── Heightmap + markers ───────────────────────────────────────────────────────
|
||||
var _heightmap_texture: Texture2D = null
|
||||
var _markers: Dictionary = {}
|
||||
var _generation_layer1: Variant = null # #960: Layer1Output from the proxy (D-225)
|
||||
var _generation_district_grid: Variant = null # T-1046: coarse DistrictGridLayer (D-226)
|
||||
var _generation_road_graph: Variant = null # T-960: RoadGraph layer from the proxy (D-225)
|
||||
var _generation_settlements: Variant = null # T-960: settlement placements from the proxy (D-225)
|
||||
var _gen_pending: bool = false # #960: awaiting a Layer1 response (re-polls on Pending)
|
||||
var _gen_retries: int = 0
|
||||
# Generation-cascade state (#960, D-225) is split into two companion objects,
|
||||
# both extracted from this file (T-1118) to keep it under the gdlint
|
||||
# max-file-lines cap: AtlasGenerationState owns the per-layer data
|
||||
# (get/set_generation_*() accessors below delegate to it) and AtlasGenerationProxy
|
||||
# owns the proxy-polling/retry/pending-indicator machinery.
|
||||
#
|
||||
# _gen_state is built as a FIELD DEFAULT (not in _ready()) — it is a pure
|
||||
# RefCounted with no tree dependency, and get/set_generation_*() must work on
|
||||
# a bare `AtlasViewer.new()` that never enters the scene tree (the
|
||||
# established test pattern throughout this suite — auto_free(AtlasViewer.new())
|
||||
# with no add_child(), so _ready() never fires). _overlay_node isn't bound
|
||||
# until _ready() (bind_overlay_node() below), so a redraw is a safe no-op
|
||||
# until then — see atlas_generation_state.gd's _redraw() null-guard.
|
||||
#
|
||||
# _gen_proxy is a Node (needs get_tree() for its retry timer, owns the
|
||||
# pending-indicator child Control) and is built in _ready() like every other
|
||||
# child node on this class — nothing calls into it before the tree exists.
|
||||
var _gen_state = load("res://ui/implant/apps/atlas/atlas_generation_state.gd").new()
|
||||
var _gen_proxy = null
|
||||
var _grid_w: float = 512.0
|
||||
var _grid_h: float = 256.0
|
||||
var _tex_w: float = 1024.0
|
||||
@@ -217,7 +237,6 @@ var _city_panel = null # ImplantPanel sidebar (city data)
|
||||
var _empty_notice = null # ImplantPanel shown when heightmap missing
|
||||
var _overlay_bar = null # #836 overlay toggle bar (no class_name, review #8)
|
||||
var _screen_header: ImplantHeader = null # top-left title/hint (D-169 composition)
|
||||
var _gen_pending_indicator = null # ImplantPending — loaded by path, not a class_name dep
|
||||
var _legend_panel = null # ImplantPanel — D-226 item 3, left-side generation-overlay legend
|
||||
|
||||
|
||||
@@ -247,6 +266,17 @@ func _ready() -> void:
|
||||
_overlay_node.viewer = self
|
||||
_canvas.add_child(_overlay_node)
|
||||
|
||||
# _gen_state itself was already constructed as a field default (see the
|
||||
# comment there) — bind its redraw target now that _overlay_node exists.
|
||||
_gen_state.bind_overlay_node(_overlay_node)
|
||||
|
||||
# #960: proxy-polling + diegetic "generating" indicator (D-225). Added as a
|
||||
# child Node (not RefCounted) so it can own the indicator Control and use
|
||||
# get_tree() for the retry timer; see atlas_generation_proxy.gd.
|
||||
_gen_proxy = load("res://ui/implant/apps/atlas/atlas_generation_proxy.gd").new(self)
|
||||
_gen_proxy.name = "GenerationProxy"
|
||||
add_child(_gen_proxy)
|
||||
|
||||
_build_screen_header()
|
||||
_build_city_panel()
|
||||
_build_empty_notice()
|
||||
@@ -261,17 +291,6 @@ func _ready() -> void:
|
||||
SimBridge.city_names_received.connect(_on_city_names_received)
|
||||
SimBridge.connection_state_changed.connect(_on_connection_state_changed)
|
||||
|
||||
# #960: diegetic "generating" indicator, shown only while the proxy is Pending.
|
||||
# Loaded by path (not `ImplantPending.new()`) so a stale global-class cache —
|
||||
# e.g. a running session that hasn't re-imported after this class was added —
|
||||
# can't fail to parse AtlasViewer and break the atlas from opening (#960).
|
||||
_gen_pending_indicator = load("res://ui/implant/implant_pending.gd").new()
|
||||
_gen_pending_indicator.name = "GenPending"
|
||||
add_child(_gen_pending_indicator)
|
||||
_gen_pending_indicator.apply_implant_theme(_implant_theme)
|
||||
resized.connect(_position_pending_indicator)
|
||||
_position_pending_indicator()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if SimBridge.atlas_layers_received.is_connected(_on_atlas_layers_received):
|
||||
@@ -294,12 +313,9 @@ func show_body(body: Dictionary, system: Dictionary) -> void:
|
||||
_refresh_screen_header()
|
||||
_city_panel.visible = false
|
||||
_empty_notice.visible = (_heightmap_texture == null)
|
||||
_generation_layer1 = null
|
||||
_gen_pending = false
|
||||
_gen_retries = 0
|
||||
if _gen_pending_indicator:
|
||||
_gen_pending_indicator.stop()
|
||||
_request_generation_layers()
|
||||
_gen_state.reset_layer1()
|
||||
_gen_proxy.reset()
|
||||
_gen_proxy.request(_dict_str(_body, "body_id", ""))
|
||||
grab_focus()
|
||||
queue_redraw()
|
||||
_overlay_node.queue_redraw()
|
||||
@@ -361,123 +377,75 @@ func set_view(zoom: float, offset: Vector2) -> void:
|
||||
_apply_transform()
|
||||
|
||||
|
||||
## #960: store the Layer-1 generation output (from atlas_layers_received) and
|
||||
## redraw the overlay. The marker overlay reads it via get_generation_layer1().
|
||||
## Per-layer generation accessors (#960, D-225; region_grid T-1118, quarter_footprints
|
||||
## T-1119) — thin delegates onto AtlasGenerationState (see atlas_generation_state.gd
|
||||
## for what each layer is and its store-then-redraw contract). Same public method
|
||||
## names as before the T-1118 extraction; callers (atlas_marker_overlay.gd,
|
||||
## test_atlas_overlays.gd) are unaffected.
|
||||
func set_generation_layer1(layer1: Variant) -> void:
|
||||
_generation_layer1 = layer1
|
||||
if _overlay_node:
|
||||
_overlay_node.queue_redraw()
|
||||
_gen_state.set_layer1(layer1)
|
||||
|
||||
|
||||
func get_generation_layer1() -> Variant:
|
||||
return _generation_layer1
|
||||
return _gen_state.get_layer1()
|
||||
|
||||
|
||||
## T-1046: store the coarse district/morphology grid (DistrictGridLayer) from the
|
||||
## proxy and redraw. The marker overlay reads it via get_generation_district_grid().
|
||||
func set_generation_district_grid(grid: Variant) -> void:
|
||||
_generation_district_grid = grid
|
||||
if _overlay_node:
|
||||
_overlay_node.queue_redraw()
|
||||
_gen_state.set_district_grid(grid)
|
||||
|
||||
|
||||
func get_generation_district_grid() -> Variant:
|
||||
return _generation_district_grid
|
||||
return _gen_state.get_district_grid()
|
||||
|
||||
|
||||
## T-960: store the L2 road/rail graph (RoadGraphLayer) from the proxy and
|
||||
## redraw. The marker overlay reads it via get_generation_road_graph().
|
||||
func set_generation_road_graph(graph: Variant) -> void:
|
||||
_generation_road_graph = graph
|
||||
if _overlay_node:
|
||||
_overlay_node.queue_redraw()
|
||||
_gen_state.set_road_graph(graph)
|
||||
|
||||
|
||||
func get_generation_road_graph() -> Variant:
|
||||
return _generation_road_graph
|
||||
return _gen_state.get_road_graph()
|
||||
|
||||
|
||||
## T-960: store the L3 settlement placements (SettlementLayer) from the proxy
|
||||
## and redraw. The marker overlay reads it via get_generation_settlements().
|
||||
func set_generation_settlements(settlements: Variant) -> void:
|
||||
_generation_settlements = settlements
|
||||
if _overlay_node:
|
||||
_overlay_node.queue_redraw()
|
||||
_gen_state.set_settlements(settlements)
|
||||
|
||||
|
||||
func get_generation_settlements() -> Variant:
|
||||
return _generation_settlements
|
||||
return _gen_state.get_settlements()
|
||||
|
||||
|
||||
## #960: request the body's Layer-1 cascade output from the server proxy.
|
||||
## No-op in test mode (SimBridge has no server connection) — the overlays
|
||||
## simply stay empty, which is the correct serverless behavior.
|
||||
func _request_generation_layers() -> void:
|
||||
var body_id: String = _dict_str(_body, "body_id", "")
|
||||
if body_id.is_empty():
|
||||
return
|
||||
_gen_pending = true
|
||||
SimBridge.request_atlas_layers(body_id)
|
||||
func set_generation_region_grid(grid: Variant) -> void:
|
||||
_gen_state.set_region_grid(grid)
|
||||
|
||||
|
||||
## #960: handle a Layer-1 response. Ignores responses for a stale body (the
|
||||
## user navigated away). On Pending the proxy is still generating, so we
|
||||
## re-request after a short delay until Ready or the retry ceiling.
|
||||
func get_generation_region_grid() -> Variant:
|
||||
return _gen_state.get_region_grid()
|
||||
|
||||
|
||||
func set_generation_quarter_footprints(footprints: Variant) -> void:
|
||||
_gen_state.set_quarter_footprints(footprints)
|
||||
|
||||
|
||||
func get_generation_quarter_footprints() -> Variant:
|
||||
return _gen_state.get_quarter_footprints()
|
||||
|
||||
|
||||
## #960: forward a Layer-1 response to AtlasGenerationProxy, which handles
|
||||
## staleness, retry, indicator, and dispatch to AtlasGenerationState (T-1118
|
||||
## extraction — see atlas_generation_proxy.gd).
|
||||
func _on_atlas_layers_received(response: Dictionary) -> void:
|
||||
var body_id: String = _dict_str(_body, "body_id", "")
|
||||
if str(response.get("body_id", "")) != body_id:
|
||||
return
|
||||
match str(response.get("status", "")):
|
||||
"Ready":
|
||||
_gen_pending = false
|
||||
_gen_retries = 0
|
||||
_set_gen_indicator(false)
|
||||
set_generation_layer1(response.get("layer1"))
|
||||
set_generation_district_grid(response.get("district_grid"))
|
||||
set_generation_road_graph(response.get("road_graph"))
|
||||
set_generation_settlements(response.get("settlements"))
|
||||
"Pending":
|
||||
if _gen_retries < GEN_MAX_RETRIES:
|
||||
_gen_retries += 1
|
||||
_set_gen_indicator(true)
|
||||
_schedule_gen_retry(body_id)
|
||||
else:
|
||||
_gen_pending = false # gave up — overlays stay empty
|
||||
_set_gen_indicator(false)
|
||||
_:
|
||||
_gen_pending = false # NotFound / Error — nothing to draw
|
||||
_set_gen_indicator(false)
|
||||
_gen_proxy.on_response(response, _dict_str(_body, "body_id", ""))
|
||||
|
||||
|
||||
func _schedule_gen_retry(body_id: String) -> void:
|
||||
var timer := get_tree().create_timer(GEN_RETRY_DELAY)
|
||||
timer.timeout.connect(
|
||||
func() -> void:
|
||||
# Re-request only if still on the same body and still waiting.
|
||||
if _gen_pending and _dict_str(_body, "body_id", "") == body_id:
|
||||
SimBridge.request_atlas_layers(body_id)
|
||||
)
|
||||
## Read-only accessors AtlasGenerationProxy needs (it is added as a child, not
|
||||
## a subclass, so it reaches viewer state through the same public surface any
|
||||
## other caller would use).
|
||||
func get_implant_theme() -> Variant:
|
||||
return _implant_theme
|
||||
|
||||
|
||||
## Show/hide the diegetic pending indicator. Starting only when not already
|
||||
## visible avoids resetting the sweep on every re-poll.
|
||||
func _set_gen_indicator(on: bool) -> void:
|
||||
if _gen_pending_indicator == null:
|
||||
return
|
||||
if on:
|
||||
if not _gen_pending_indicator.visible:
|
||||
_position_pending_indicator()
|
||||
_gen_pending_indicator.start("GENERATING LAYER 1")
|
||||
else:
|
||||
_gen_pending_indicator.stop()
|
||||
|
||||
|
||||
func _position_pending_indicator() -> void:
|
||||
if _gen_pending_indicator == null:
|
||||
return
|
||||
_gen_pending_indicator.position = Vector2(
|
||||
(size.x - _gen_pending_indicator.DEFAULT_WIDTH) * 0.5, size.y * 0.45
|
||||
)
|
||||
func get_body_id() -> String:
|
||||
return _dict_str(_body, "body_id", "")
|
||||
|
||||
|
||||
func get_hovered_city() -> Dictionary:
|
||||
|
||||
Reference in New Issue
Block a user