2022-10-04 16:09:23 +02:00
|
|
|
from typing import Dict
|
2022-12-11 08:43:29 +01:00
|
|
|
|
|
|
|
from segtypes.common.group import CommonSegGroup
|
2022-09-28 22:52:12 +02:00
|
|
|
from segtypes.n64.ci import N64SegCi
|
2021-04-13 09:47:52 +02:00
|
|
|
from segtypes.n64.palette import N64SegPalette as Palette
|
|
|
|
|
2023-02-08 01:47:26 +01:00
|
|
|
|
2021-09-30 11:48:03 +02:00
|
|
|
# Resolve Raster#palette and Palette#raster links
|
2021-04-13 09:47:52 +02:00
|
|
|
def initialize(all_segments):
|
|
|
|
def process(segments):
|
2022-09-28 22:52:12 +02:00
|
|
|
raster_map: Dict[str, N64SegCi] = {}
|
2021-04-13 09:47:52 +02:00
|
|
|
palette_map: Dict[str, Palette] = {}
|
|
|
|
|
|
|
|
for segment in segments:
|
|
|
|
if isinstance(segment, Palette):
|
|
|
|
palette_map[segment.name] = segment
|
|
|
|
|
2022-09-28 22:52:12 +02:00
|
|
|
if isinstance(segment, N64SegCi):
|
2021-04-13 09:47:52 +02:00
|
|
|
raster_map[segment.name] = segment
|
|
|
|
|
2021-09-30 11:48:03 +02:00
|
|
|
if isinstance(segment, CommonSegGroup):
|
2021-04-13 09:47:52 +02:00
|
|
|
process(segment.subsegments)
|
2021-09-30 11:48:03 +02:00
|
|
|
|
2021-04-13 09:47:52 +02:00
|
|
|
for raster_name in raster_map:
|
|
|
|
raster = raster_map[raster_name]
|
2022-05-05 16:08:16 +02:00
|
|
|
# print(f"{raster_name} -> {raster.palette_name}")
|
2021-04-13 09:47:52 +02:00
|
|
|
raster.palette = palette_map.get(raster.palette_name)
|
|
|
|
|
|
|
|
for palette_name in palette_map:
|
|
|
|
palette = palette_map[palette_name]
|
2022-05-05 16:08:16 +02:00
|
|
|
# print(f"{palette_name} -> {palette.raster_name}")
|
2021-04-13 09:47:52 +02:00
|
|
|
palette.raster = raster_map.get(palette.raster_name)
|
|
|
|
|
|
|
|
process(all_segments)
|