mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
hasBack for player sprites (#1155)
* hasBack for player sprites * these too * bump splat requirement --------- Co-authored-by: HailSanta <Hail2Santa@gmail.com>
This commit is contained in:
parent
f89df67fe4
commit
f1edb83213
@ -13,5 +13,5 @@ rabbitizer
|
|||||||
n64img
|
n64img
|
||||||
python-githooks
|
python-githooks
|
||||||
crunch64>=0.2.0
|
crunch64>=0.2.0
|
||||||
splat64>=0.21.4
|
splat64>=0.21.5
|
||||||
requests
|
requests
|
||||||
|
@ -17,6 +17,7 @@ from splat_ext.pm_sprites import (
|
|||||||
MAX_COMPONENTS_XML,
|
MAX_COMPONENTS_XML,
|
||||||
NPC_SPRITE_MEDADATA_XML_FILENAME,
|
NPC_SPRITE_MEDADATA_XML_FILENAME,
|
||||||
PALETTE_GROUPS_XML,
|
PALETTE_GROUPS_XML,
|
||||||
|
HAS_BACK_XML,
|
||||||
PALETTE_XML,
|
PALETTE_XML,
|
||||||
PLAYER_SPRITE_MEDADATA_XML_FILENAME,
|
PLAYER_SPRITE_MEDADATA_XML_FILENAME,
|
||||||
SPECIAL_RASTER,
|
SPECIAL_RASTER,
|
||||||
@ -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]:
|
def player_xml_to_bytes(xml: ET.Element, asset_stack: Tuple[Path, ...]) -> List[bytes]:
|
||||||
has_back = False
|
|
||||||
|
|
||||||
out_bytes = b""
|
out_bytes = b""
|
||||||
back_out_bytes = b""
|
back_out_bytes = b""
|
||||||
|
|
||||||
max_components = int(xml.attrib[MAX_COMPONENTS_XML])
|
max_components = int(xml.attrib[MAX_COMPONENTS_XML])
|
||||||
num_variations = int(xml.attrib[PALETTE_GROUPS_XML])
|
num_variations = int(xml.attrib[PALETTE_GROUPS_XML])
|
||||||
|
has_back = xml.attrib[HAS_BACK_XML] == "true"
|
||||||
|
|
||||||
# Animations
|
# Animations
|
||||||
animations: List[List[AnimComponent]] = []
|
animations: List[List[AnimComponent]] = []
|
||||||
@ -253,8 +253,6 @@ def player_xml_to_bytes(xml: ET.Element, asset_stack: Tuple[Path, ...]) -> List[
|
|||||||
raster_bytes_back: bytes = b""
|
raster_bytes_back: bytes = b""
|
||||||
raster_offset = 0
|
raster_offset = 0
|
||||||
for raster_xml in xml[1]:
|
for raster_xml in xml[1]:
|
||||||
if "back" in raster_xml.attrib:
|
|
||||||
has_back = True
|
|
||||||
r = player_raster_from_xml(raster_xml, back=False)
|
r = player_raster_from_xml(raster_xml, back=False)
|
||||||
raster_bytes += struct.pack(">IBBBB", raster_offset, r.width, r.height, r.palette_idx, 0xFF)
|
raster_bytes += struct.pack(">IBBBB", raster_offset, r.width, r.height, r.palette_idx, 0xFF)
|
||||||
|
|
||||||
@ -343,13 +341,6 @@ def player_xml_to_bytes(xml: ET.Element, asset_stack: Tuple[Path, ...]) -> List[
|
|||||||
return ret
|
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(
|
def write_player_sprite_header(
|
||||||
sprite_order: List[str],
|
sprite_order: List[str],
|
||||||
out_file: Path,
|
out_file: Path,
|
||||||
@ -365,7 +356,7 @@ def write_player_sprite_header(
|
|||||||
|
|
||||||
for sprite_name in sprite_order:
|
for sprite_name in sprite_order:
|
||||||
sprite_xml = PLAYER_XML_CACHE[sprite_name]
|
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_sprites[f"SPR_{sprite_name}"] = sprite_id
|
||||||
player_rasters[sprite_name] = {}
|
player_rasters[sprite_name] = {}
|
||||||
|
@ -95,6 +95,7 @@ NPC_SPRITE_MEDADATA_XML_FILENAME = "npc.xml"
|
|||||||
|
|
||||||
MAX_COMPONENTS_XML = "maxComponents"
|
MAX_COMPONENTS_XML = "maxComponents"
|
||||||
PALETTE_GROUPS_XML = "paletteGroups"
|
PALETTE_GROUPS_XML = "paletteGroups"
|
||||||
|
HAS_BACK_XML = "hasBack"
|
||||||
PALETTE_XML = "palette"
|
PALETTE_XML = "palette"
|
||||||
BACK_PALETTE_XML = "backPalette"
|
BACK_PALETTE_XML = "backPalette"
|
||||||
|
|
||||||
@ -397,6 +398,7 @@ def write_player_xmls(
|
|||||||
{
|
{
|
||||||
MAX_COMPONENTS_XML: str(cur_sprite.max_components),
|
MAX_COMPONENTS_XML: str(cur_sprite.max_components),
|
||||||
PALETTE_GROUPS_XML: str(cur_sprite.num_variations),
|
PALETTE_GROUPS_XML: str(cur_sprite.num_variations),
|
||||||
|
HAS_BACK_XML: str(has_back).lower(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user