papermario/tools/splat/util/palettes.py
Ethan Roseman 179998098c
Misc decomp 53 (#703)
* some btl_state work

* msg_draw_speech_bubble

* cleaners

* btl_state_stuff

* btl_state_update_next_enemy wip

* btl_state stuff

* disable_x fx + cleanup

* wip

* fxstuff

* path funcs & cleanup

* clean

* model_api funcs

* two action commands

* action_cmd progress

* UnkFunc001

* air raid func

* cleanup, data migration, goodies

* remove data file

* git subrepo pull --force tools/splat

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

* fix build

* more cleanup

* clean

* PR comments
2022-05-05 23:08:16 +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)