-
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
Open
Vagabond
wants to merge
13
commits into
master
Choose a base branch
from
adt/palette-and-mods
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5a9e15d
Use better palettes for generated png files
Vagabond d7117a0
Add initial mod asset dumper
Vagabond afe2dee
Fix more mod dumper stuff
Vagabond c137d6d
Fix some more crap with dumping mod assets
Vagabond e595aca
fix some palette errors
Vagabond cb4a726
More cleanups
Vagabond e5caf7e
Fix pilot.ini
Vagabond f1e920e
Remove attr checks
Vagabond 7ec04ec
Palette cleanups
Vagabond 4dbc8fa
Fix sting
Vagabond dcd2ac2
Copy default palette on new palette init
Vagabond ad3f713
Mask out more colors for tournament palettes
Vagabond 3547fde
Uncommited changes
Vagabond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,12 @@ | |
| import typing | ||
| from validx import Dict, List, Str | ||
| import io | ||
| import os | ||
|
|
||
| from .protos import Entrypoint | ||
| from .bkanim import BKAnimation | ||
| from .palette_mapping import PaletteMapping | ||
| from .palette import Palette | ||
|
|
||
| from .utils.parser import BinaryParser | ||
| from .utils.types import EncodedImage | ||
|
|
@@ -95,7 +97,10 @@ def read(self, parser: BinaryParser) -> BKFile: | |
|
|
||
| # Read up all available color palettes | ||
| palette_count = parser.get_uint8() | ||
| self.palettes = [PaletteMapping().read(parser) for _ in range(palette_count)] | ||
| self.palettes = [] | ||
| for _ in range(palette_count): | ||
| palette_mapping = PaletteMapping().read(parser) | ||
| self.palettes.append(palette_mapping) | ||
|
|
||
| # Get sound mappings | ||
| self.sound_table = [parser.get_uint8() for _ in range(30)] | ||
|
|
@@ -140,12 +145,59 @@ def write(self, parser: BinaryParser) -> None: | |
| parser.put_uint8(sound) | ||
|
|
||
| def save_background(self, filename: str) -> None: | ||
| # Apply appropriate palette processing based on the filename | ||
| palette = self.get_processed_palette(filename) | ||
|
|
||
| save_png( | ||
| generate_png( | ||
| self.background_image, | ||
| self.background_width, | ||
| self.background_height, | ||
| self.palettes[0].colors, | ||
| palette, | ||
| ), | ||
| filename, | ||
| ) | ||
|
|
||
| def get_processed_palette(self, filename: str) -> Palette: | ||
| """ | ||
| Get palette with appropriate processing applied based on filename. | ||
|
|
||
| Args: | ||
| filename: File name used to determine palette processing | ||
| """ | ||
| if not self.palettes: | ||
| return Palette() # Return default palette if no palettes are available | ||
|
|
||
| # Start with a copy of the first palette's colors | ||
| palette = Palette() | ||
| for i in range(256): | ||
| palette.data[i] = self.palettes[0].colors.data[i] | ||
|
|
||
| # Extract basename and convert to uppercase for comparison | ||
| basename = os.path.basename(filename).upper() | ||
|
|
||
| # MECHLAB: Reset indices 0-47 and 250-255 to default | ||
| if "MECHLAB" in basename: | ||
| palette.reset_range(0, 48) # Reset indices 0-47 | ||
| palette.reset_range(250, 6) # Reset indices 250-255 | ||
| # ARENA0-ARENA4, VS, MELEE: Reset indices 0-96 and 250-255 to default | ||
| elif any( | ||
| name in basename | ||
| for name in [ | ||
| "ARENA0", | ||
| "ARENA1", | ||
| "ARENA2", | ||
| "ARENA3", | ||
| "ARENA4", | ||
| "VS", | ||
| "MELEE", | ||
| ] | ||
| ): | ||
| palette.mask_range(0, 97) # Blank out 0-96, the HAR colors | ||
| palette.reset_range(250, 6) # Reset indices 250-255 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comments about reset_range() seem to be conflicting. Does |
||
|
|
||
| # NORTH_AM, WAR, KATUSHAI: Extended color slides | ||
| elif any(name in basename for name in ["NORTH_AM", "WAR", "KATUSHAI"]): | ||
| palette.create_extended_slides() | ||
|
|
||
| return palette | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ?