papermario/tools/splat/util/palettes.py
Ethan Roseman 4c787f68c1
Effect_6 done, splat, diff updates (#451)
* fx_6_appendGfx

* update_effects

* effect_6 done

* Update diff.py

* update configure for new splat

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "0efa552c5d"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "0efa552c5d"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* nu stuff / undefined_syms org
2021-09-30 18:48:03 +09:00

35 lines
1.2 KiB
Python

from typing import Dict
from segtypes.n64.palette import N64SegPalette as Palette
from segtypes.n64.ci8 import N64SegCi8 as Raster
from segtypes.common.group import CommonSegGroup
# Resolve Raster#palette and Palette#raster links
def initialize(all_segments):
global palettes_remaining
def process(segments):
raster_map: Dict[str, Raster] = {}
palette_map: Dict[str, Palette] = {}
for segment in segments:
if isinstance(segment, Palette):
palette_map[segment.name] = segment
if isinstance(segment, Raster):
raster_map[segment.name] = segment
if isinstance(segment, CommonSegGroup):
process(segment.subsegments)
for raster_name in raster_map:
raster = raster_map[raster_name]
#print(f"{raster_name} -> {raster.palette_name}")
raster.palette = palette_map.get(raster.palette_name)
for palette_name in palette_map:
palette = palette_map[palette_name]
#print(f"{palette_name} -> {palette.raster_name}")
palette.raster = raster_map.get(palette.raster_name)
process(all_segments)