Skip to content

Commit

Permalink
Fix Icons.xml not respecting asset stack (#1160)
Browse files Browse the repository at this point in the history
* fix Icons.xml not respecting asset stack

* resolve xml path in icons.py rather than configure

* I think fix

---------

Co-authored-by: Ethan <[email protected]>
  • Loading branch information
bates64 and ethteck authored Feb 3, 2024
1 parent 540757c commit 9f0452d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions tools/build/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def write_ninja_rules(

ninja.rule(
"icons",
command=f"$python {BUILD_TOOLS}/icons.py $out $list_path $header_path $asset_stack",
command=f"$python {BUILD_TOOLS}/icons.py $out $header_path $asset_stack",
)

ninja.rule(
Expand Down Expand Up @@ -941,7 +941,6 @@ def build(
entry.src_paths,
"icons",
variables={
"list_path": entry.src_paths[0],
"header_path": header_path,
"asset_stack": ",".join(self.asset_stack),
},
Expand Down
9 changes: 4 additions & 5 deletions tools/build/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def pack_color(r, g, b, a):
palette = img.palette(alpha="force")
for rgba in palette:
if rgba[3] not in (0, 0xFF):
self.warn("alpha mask mode but translucent pixels used")
print("alpha mask mode but translucent pixels used")

color = pack_color(*rgba)
out_pal += color.to_bytes(2, byteorder="big")

return (out_img, out_pal, out_w, out_h)


def build(out_bin: Path, in_xml: Path, out_header: Path, asset_stack: Tuple[Path, ...]):
def build(out_bin: Path, out_header: Path, asset_stack: Tuple[Path, ...]):
out_bytes = bytearray()
offsets: Dict[str, int] = {}

xml = ET.parse(in_xml)
xml = ET.parse(get_asset_path(Path("icon/Icons.xml"), asset_stack))
IconList = xml.getroot()

for Icon in IconList.findall("Icon"):
Expand Down Expand Up @@ -100,11 +100,10 @@ def build(out_bin: Path, in_xml: Path, out_header: Path, asset_stack: Tuple[Path
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Icon archive")
parser.add_argument("out_bin", type=Path, help="output binary file path")
parser.add_argument("list_path", type=Path, help="input xml file path")
parser.add_argument("header_path", type=Path, help="output header file to generate")
parser.add_argument("asset_stack", help="comma-separated asset stack")
args = parser.parse_args()

asset_stack = tuple(Path(d) for d in args.asset_stack.split(","))

build(args.out_bin, args.list_path, args.header_path, asset_stack)
build(args.out_bin, args.header_path, asset_stack)

0 comments on commit 9f0452d

Please sign in to comment.