forked from DizzyEggg/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Get rid of gItemIconTable * Move the script to the folder
- Loading branch information
1 parent
b4ece97
commit 4b221b5
Showing
8 changed files
with
1,550 additions
and
831 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import glob | ||
import re | ||
import os | ||
|
||
if not os.path.exists("Makefile"): | ||
print("Please run this script from your root folder.") | ||
quit() | ||
|
||
# Read item_icon_table.h and extract the icon and palette information | ||
for file in glob.glob('./src/data/item_icon_table.h'): | ||
with open(file, 'r') as f: | ||
icon_table_content = f.read() | ||
|
||
# Extract item icon and palette data from item_icon_table.h | ||
icon_table_pattern = re.compile(r'\[(ITEM_[A-Z_0-9]+)\]\s*=\s*\{([^,]+),\s*([^}]+)\}', re.MULTILINE) | ||
icon_table_data = {} | ||
for match in icon_table_pattern.findall(icon_table_content): | ||
if len(match) == 3: | ||
item_name, icon_sprite, icon_palette = match | ||
icon_table_data[item_name] = (icon_sprite, icon_palette) | ||
|
||
# Read items.h content | ||
for file in glob.glob('./src/data/items.h'): | ||
with open(file, 'r') as f: | ||
items_content = f.read() | ||
|
||
# Modify items.h content | ||
def add_icon_data(match): | ||
item_name = match.group(1) | ||
item_content = match.group(2) | ||
if item_name in icon_table_data: | ||
icon_sprite, icon_palette = icon_table_data[item_name] | ||
print(f"Updating {item_name}: adding iconSprite = {icon_sprite}, iconPalette = {icon_palette}") | ||
return f'[{item_name}] =\n {{{item_content} .iconSprite = {icon_sprite},\n .iconPalette = {icon_palette},\n }},' | ||
else: | ||
return match.group(0) | ||
|
||
item_pattern = re.compile(r'\[(ITEM_[A-Z_0-9]+)\]\s*=\s*\{([\s\S]*?)\},', re.DOTALL) | ||
modified_items_content = item_pattern.sub(add_icon_data, items_content) | ||
|
||
# Write the modified content back to items.h | ||
for file in glob.glob('./src/data/items.h'): | ||
with open(file, 'w') as f: | ||
f.write(modified_items_content) | ||
print("items.h has been updated") |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.