papermario/tools/splat/util/palettes.py
Ethan Roseman ded1be2b17
Effect work and rodata migration (#747)
* bombette_breaking WIP

* bombette_breaking

* migration & stuff

* spr funcs

* btl_state_update_begin_turn

* beginning effect data work

* effect rodata migration

* fix

* fixin

* breaking_junk

* args

* handle gfx

* trim yaml

* yaml cleanup

* gfx stuff

* git subrepo pull --force tools/splat

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

* water_splash gfx

* move decl down

* fix warnings
2022-08-11 00:29:06 +09:00

33 lines
1.2 KiB
Python

from typing import Dict, Union
from segtypes.n64.ci4 import N64SegCi4, N64SegCi8
from segtypes.n64.palette import N64SegPalette as Palette
from segtypes.common.group import CommonSegGroup
# Resolve Raster#palette and Palette#raster links
def initialize(all_segments):
def process(segments):
raster_map: Dict[str, Union[N64SegCi4, N64SegCi8]] = {}
palette_map: Dict[str, Palette] = {}
for segment in segments:
if isinstance(segment, Palette):
palette_map[segment.name] = segment
if isinstance(segment, N64SegCi4) or isinstance(segment, N64SegCi8):
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)