-
Notifications
You must be signed in to change notification settings - Fork 2
Switch to a better palette for all png files and add a mod dumper tool #25
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
base: master
Are you sure you want to change the base?
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already a list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was doing a copy
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
|
|
||
| # Create extended red slide (0x00-0x1F) | ||
| for i in range(32): | ||
| if i > 0: # Skip the first color |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in these
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.