-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexcel_to_src_data_graphics_pokemon.py
41 lines (33 loc) · 1.87 KB
/
excel_to_src_data_graphics_pokemon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pandas as pd
import re
import sys
def sanitize_string(s):
"""Replace all spaces and non-alphanumeric characters with an underscore."""
return re.sub(r'[^a-zA-Z0-9]', '_', s)
def excel_to_src_data_graphics_pokemon(input_file, output_file):
# Read the Excel file
df = pd.read_excel(input_file)
# Specify the columns to use
column_names = df.columns
with open(output_file, 'w') as file:
# Iterate over the rows of the DataFrame
for index, row in df.iterrows():
original_name = str(row[column_names[0]])
sanitized_name = sanitize_string(original_name).upper()
folder_name = original_name.lower()
# Write the formatted string to the file
file.write(f"// {original_name}\n")
file.write(f"const u32 gMonFrontPic_{original_name}[] = INCBIN_U32(\"graphics/pokemon/{folder_name}/front.4bpp.lz\");\n")
file.write(f"const u32 gMonPalette_{original_name}[] = INCBIN_U32(\"graphics/pokemon/{folder_name}/normal.gbapal.lz\");\n")
file.write(f"const u32 gMonBackPic_{original_name}[] = INCBIN_U32(\"graphics/pokemon/{folder_name}/back.4bpp.lz\");\n")
file.write(f"const u32 gMonShinyPalette_{original_name}[] = INCBIN_U32(\"graphics/pokemon/{folder_name}/shiny.gbapal.lz\");\n")
file.write(f"const u8 gMonIcon_{original_name}[] = INCBIN_U8(\"graphics/pokemon/{folder_name}/icon.4bpp\");\n")
file.write(f"const u8 gMonFootprint_{original_name}[] = INCBIN_U8(\"graphics/pokemon/{folder_name}/footprint.1bpp\");\n")
file.write("\n")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python excel_to_src_data_graphics_pokemon.py <input_file> <output_file>")
sys.exit(1)
input_file = sys.argv[1]
output_file = sys.argv[2]
excel_to_src_data_graphics_pokemon(input_file, output_file)