Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasBack for player sprites #1155

Merged
merged 3 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ rabbitizer
n64img
python-githooks
crunch64>=0.2.0
splat64>=0.21.4
splat64>=0.21.5
requests
15 changes: 3 additions & 12 deletions tools/build/sprite/sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
MAX_COMPONENTS_XML,
NPC_SPRITE_MEDADATA_XML_FILENAME,
PALETTE_GROUPS_XML,
HAS_BACK_XML,
PALETTE_XML,
PLAYER_SPRITE_MEDADATA_XML_FILENAME,
SPECIAL_RASTER,
Expand Down Expand Up @@ -141,13 +142,12 @@ def player_raster_from_xml(xml: ET.Element, back: bool = False) -> PlayerRaster:


def player_xml_to_bytes(xml: ET.Element, asset_stack: Tuple[Path, ...]) -> List[bytes]:
has_back = False

out_bytes = b""
back_out_bytes = b""

max_components = int(xml.attrib[MAX_COMPONENTS_XML])
num_variations = int(xml.attrib[PALETTE_GROUPS_XML])
has_back = xml.attrib[HAS_BACK_XML] == "true"

# Animations
animations: List[List[AnimComponent]] = []
Expand Down Expand Up @@ -253,8 +253,6 @@ def player_xml_to_bytes(xml: ET.Element, asset_stack: Tuple[Path, ...]) -> List[
raster_bytes_back: bytes = b""
raster_offset = 0
for raster_xml in xml[1]:
if "back" in raster_xml.attrib:
has_back = True
r = player_raster_from_xml(raster_xml, back=False)
raster_bytes += struct.pack(">IBBBB", raster_offset, r.width, r.height, r.palette_idx, 0xFF)

Expand Down Expand Up @@ -343,13 +341,6 @@ def player_xml_to_bytes(xml: ET.Element, asset_stack: Tuple[Path, ...]) -> List[
return ret


def xml_has_back(xml: ET.Element) -> bool:
for raster_xml in xml[1]:
if "back" in raster_xml.attrib:
return True
return False


def write_player_sprite_header(
sprite_order: List[str],
out_file: Path,
Expand All @@ -365,7 +356,7 @@ def write_player_sprite_header(

for sprite_name in sprite_order:
sprite_xml = PLAYER_XML_CACHE[sprite_name]
has_back = xml_has_back(sprite_xml)
has_back = sprite_xml.attrib[HAS_BACK_XML] == "true"

player_sprites[f"SPR_{sprite_name}"] = sprite_id
player_rasters[sprite_name] = {}
Expand Down
2 changes: 2 additions & 0 deletions tools/splat_ext/pm_sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@

MAX_COMPONENTS_XML = "maxComponents"
PALETTE_GROUPS_XML = "paletteGroups"
HAS_BACK_XML = "hasBack"
PALETTE_XML = "palette"
BACK_PALETTE_XML = "backPalette"

Expand Down Expand Up @@ -397,6 +398,7 @@ def get_sprite_name_from_offset(offset: int, offsets: List[int], names: List[str
{
MAX_COMPONENTS_XML: str(cur_sprite.max_components),
PALETTE_GROUPS_XML: str(cur_sprite.num_variations),
HAS_BACK_XML: str(has_back).lower(),
},
)

Expand Down
Loading