Switch to a better palette for all png files and add a mod dumper tool#25
Switch to a better palette for all png files and add a mod dumper tool#25
Conversation
056c0e8 to
c137d6d
Compare
|
I talked to claude as ordered, and it responded with: Code Review: PR #25 - Switch to Better Palette for PNG Files and Add Mod Dumper ToolOverviewThis PR introduces two major improvements:
Stats: +1135/-13 lines across 7 files Code Quality & Style✅ Strengths
|
omftools/pyshadowdive/palette.py
Outdated
|
|
||
| def __init__(self) -> None: | ||
| self.data: list[Color] = [(0, 0, 0) for _ in range(256)] | ||
| self.data: list[Color] = list(DEFAULT_PALETTE) |
omftools/pyshadowdive/bk.py
Outdated
| self.palettes = [] | ||
| for _ in range(palette_count): | ||
| palette_mapping = PaletteMapping().read(parser) | ||
| self.palettes.append(palette_mapping) |
There was a problem hiding this comment.
Unneeded change -- some remnant ?
| Self for method chaining | ||
| """ | ||
| for m in range(start, start + length): | ||
| if 0 <= m < 256: |
There was a problem hiding this comment.
Might be nicer to just limit the range instead
| Self for method chaining | ||
| """ | ||
| for m in range(start, start + length): | ||
| if 0 <= m < 256 and m < len(DEFAULT_PALETTE): |
|
|
||
| # Create extended red slide (0x00-0x1F) | ||
| for i in range(32): | ||
| if i > 0: # Skip the first color |
| f.write(f"forward_speed = {af.forward_speed}\n") | ||
| f.write(f"reverse_speed = {af.reverse_speed}\n") | ||
| f.write(f"jump_speed = {af.jump_speed}\n") | ||
| f.write(f"fall_speed = {af.fall_speed}\n") |
There was a problem hiding this comment.
note that af and others have serialize(), so you could also just:
for key, value in af.serialize().items():
f.write(f"{key} = {value}")
There was a problem hiding this comment.
that assumes the keys always match the mod format
| ): | ||
| palette.mask_range(0, 97) # Blank out 0-96, the HAR colors | ||
| palette.reset_range(0, 96) # Blank out 0-96, the HAR colors | ||
| palette.reset_range(250, 6) # Reset indices 250-255 |
There was a problem hiding this comment.
The comments about reset_range() seem to be conflicting. Does reset_range(0, 96) include the last index? Since palette.reset_range(250, 6) seems to indicate the last index is not included.
I've tried to generate a "good" palette for every context (scenes, AF files, PICs, etc) such that the generated PNGs should dither properly if edited, or if someone is using the palette from them to convert images.
Additionally there's now a tool to dump the assets into the mod formats.