mirror of
https://github.com/Skeli789/Dynamic-Pokemon-Expansion.git
synced 2026-09-06 17:17:28 -05:00
More Image Building Polish
This commit is contained in:
@@ -191,44 +191,56 @@ def ProcessSpriteGraphics():
|
||||
frontsprites = [file for file in glob(GRAPHICS + "/frontspr" + "**/*.png", recursive=True)]
|
||||
iconsprites = [file for file in glob(GRAPHICS + "/pokeicon" + "**/*.png", recursive=True)]
|
||||
|
||||
print("Processing Front Sprites")
|
||||
combinedFile = open(os.path.join('SRC', 'generated', 'frontsprites.s'), 'w')
|
||||
for sprite in frontsprites:
|
||||
assembled = sprite.split('.png')[0] + '.s'
|
||||
assembledFrontSprites = os.path.join('SRC', 'generated', 'frontsprites.s')
|
||||
if (not os.path.isfile(assembledFrontSprites)
|
||||
or max(os.path.getmtime(file) for file in frontsprites) > os.path.getmtime(assembledFrontSprites)): #If a front sprite has been modified
|
||||
print("Processing Front Sprites")
|
||||
combinedFile = open(assembledFrontSprites, 'w')
|
||||
combinedFile.write('@THIS IS A GENERATED FILE! DO NOT MODIFY IT!\n')
|
||||
for sprite in frontsprites:
|
||||
assembled = sprite.split('.png')[0] + '.s'
|
||||
|
||||
if (not os.path.isfile(assembled)
|
||||
or os.path.getmtime(sprite) > os.path.getmtime(assembled)):
|
||||
run_command([GR, sprite] + frontflags + ['-o', assembled])
|
||||
if (not os.path.isfile(assembled)
|
||||
or os.path.getmtime(sprite) > os.path.getmtime(assembled)):
|
||||
run_command([GR, sprite] + frontflags + ['-o', assembled])
|
||||
|
||||
with open(assembled, 'r') as tempFile:
|
||||
combinedFile.write(tempFile.read())
|
||||
combinedFile.close()
|
||||
with open(assembled, 'r') as tempFile:
|
||||
combinedFile.write(tempFile.read())
|
||||
combinedFile.close()
|
||||
|
||||
print("Processing Back Sprites")
|
||||
combinedFile = open(os.path.join('SRC', 'generated', 'backsprites.s'), 'w')
|
||||
for sprite in backsprites:
|
||||
assembled = sprite.split('.png')[0] + '.s'
|
||||
assembledBackSprites = os.path.join('SRC', 'generated', 'backsprites.s')
|
||||
if (not os.path.isfile(assembledBackSprites)
|
||||
or max(os.path.getmtime(file) for file in backsprites) > os.path.getmtime(assembledBackSprites)): #If a back sprite has been modified
|
||||
print("Processing Back Sprites")
|
||||
combinedFile = open(assembledBackSprites, 'w')
|
||||
combinedFile.write('@THIS IS A GENERATED FILE! DO NOT MODIFY IT!\n')
|
||||
for sprite in backsprites:
|
||||
assembled = sprite.split('.png')[0] + '.s'
|
||||
|
||||
if (not os.path.isfile(assembled)
|
||||
or os.path.getmtime(sprite) > os.path.getmtime(assembled)):
|
||||
run_command([GR, sprite] + backflags + ['-o', assembled])
|
||||
if (not os.path.isfile(assembled)
|
||||
or os.path.getmtime(sprite) > os.path.getmtime(assembled)):
|
||||
run_command([GR, sprite] + backflags + ['-o', assembled])
|
||||
|
||||
with open(assembled, 'r') as tempFile:
|
||||
combinedFile.write(tempFile.read())
|
||||
combinedFile.close()
|
||||
|
||||
print("Processing Icon Sprites")
|
||||
combinedFile = open(os.path.join('SRC', 'generated', 'iconsprites.s'), 'w')
|
||||
for sprite in iconsprites:
|
||||
assembled = sprite.split('.png')[0] + '.s'
|
||||
with open(assembled, 'r') as tempFile:
|
||||
combinedFile.write(tempFile.read())
|
||||
combinedFile.close()
|
||||
|
||||
if (not os.path.isfile(assembled)
|
||||
or os.path.getmtime(sprite) > os.path.getmtime(assembled)):
|
||||
run_command([GR, sprite] + iconflags + ['-o', assembled])
|
||||
assembledIconSprites = os.path.join('SRC', 'generated', 'iconsprites.s')
|
||||
if (not os.path.isfile(assembledIconSprites)
|
||||
or max(os.path.getmtime(file) for file in iconsprites) > os.path.getmtime(assembledIconSprites)): #If a icon sprite has been modified
|
||||
print("Processing Icon Sprites")
|
||||
combinedFile = open(assembledIconSprites, 'w')
|
||||
combinedFile.write('@THIS IS A GENERATED FILE! DO NOT MODIFY IT!\n')
|
||||
for sprite in iconsprites:
|
||||
assembled = sprite.split('.png')[0] + '.s'
|
||||
|
||||
with open(assembled, 'r') as tempFile:
|
||||
combinedFile.write(tempFile.read())
|
||||
combinedFile.close()
|
||||
if (not os.path.isfile(assembled)
|
||||
or os.path.getmtime(sprite) > os.path.getmtime(assembled)):
|
||||
run_command([GR, sprite] + iconflags + ['-o', assembled])
|
||||
|
||||
with open(assembled, 'r') as tempFile:
|
||||
combinedFile.write(tempFile.read())
|
||||
combinedFile.close()
|
||||
|
||||
def process_audio(in_file):
|
||||
'''Compile Audio'''
|
||||
|
||||
@@ -32,6 +32,25 @@ def PutFileNameInRightFormat(filename):
|
||||
|
||||
return newFileName
|
||||
|
||||
def TryRemoveGeneratedRepoints():
|
||||
try:
|
||||
os.remove('generatedrepoints')
|
||||
except:
|
||||
pass
|
||||
|
||||
def TryRemoveGeneratedImageAssembly():
|
||||
try:
|
||||
shutil.rmtree(GENERATED)
|
||||
|
||||
os.chdir("graphics")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if file.endswith('.h') or file.endswith('.s'):
|
||||
os.remove(os.path.join(root, file))
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
try:
|
||||
@@ -44,7 +63,6 @@ if len(sys.argv) > 1:
|
||||
if len(sys.argv) > 2 and sys.argv[1].upper() == 'FILE':
|
||||
try:
|
||||
filename = PutFileNameInRightFormat(sys.argv[2])
|
||||
print(filename)
|
||||
m = hashlib.md5()
|
||||
m.update(filename.encode())
|
||||
newfilename = os.path.join(BUILD, m.hexdigest() + '.o')
|
||||
@@ -53,6 +71,9 @@ if len(sys.argv) > 1:
|
||||
os.remove(newfilename)
|
||||
except FileNotFoundError:
|
||||
os.remove(BUILD + "\\IMG_" + newfilename.split('\\')[1])
|
||||
except FileNotFoundError:
|
||||
os.remove(BUILD + "\\SND_" + newfilename.split('\\')[1])
|
||||
|
||||
print('"Build for ' + sys.argv[2] + '" removed successfully!')
|
||||
sys.exit(1)
|
||||
except:
|
||||
@@ -60,16 +81,11 @@ if len(sys.argv) > 1:
|
||||
sys.exit(1)
|
||||
|
||||
#Don't remove generated repoints if the user only wants to remove the build.
|
||||
elif sys.argv[1].upper() != 'BUILD' and sys.argv[1].upper() != 'GRAPHICS':
|
||||
try:
|
||||
os.remove('generatedrepoints')
|
||||
except:
|
||||
pass
|
||||
elif sys.argv[1].upper() != 'BUILD' and sys.argv[1].upper() != 'GRAPHICS' and sys.argv[1].upper() != 'AUDIO':
|
||||
TryRemoveGeneratedRepoints()
|
||||
|
||||
else:
|
||||
try:
|
||||
os.remove('generatedrepoints')
|
||||
except:
|
||||
pass
|
||||
TryRemoveGeneratedRepoints()
|
||||
|
||||
try:
|
||||
os.remove('offsets.ini')
|
||||
@@ -82,36 +98,39 @@ if (len(sys.argv) > 1) and sys.argv[1].upper() == 'ALL':
|
||||
except:
|
||||
pass
|
||||
|
||||
os.chdir("graphics")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if file.endswith('.h'):
|
||||
os.remove(os.path.join(root, file))
|
||||
TryRemoveGeneratedImageAssembly()
|
||||
|
||||
elif (len(sys.argv) > 1) and sys.argv[1].upper() == 'GRAPHICS':
|
||||
try:
|
||||
shutil.rmtree(GENERATED)
|
||||
TryRemoveGeneratedImageAssembly()
|
||||
|
||||
os.chdir(dir_path.split('\\scripts')[0])
|
||||
os.chdir("build")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if file.startswith('IMG_'): #Remove image file
|
||||
os.remove(os.path.join(root, file))
|
||||
except:
|
||||
pass
|
||||
|
||||
elif (len(sys.argv) > 1) and sys.argv[1].upper() == 'AUDIO':
|
||||
try:
|
||||
os.chdir("build")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if file.startswith('SND_'): #Remove sound file
|
||||
os.remove(os.path.join(root, file))
|
||||
except:
|
||||
pass
|
||||
|
||||
os.chdir("graphics")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if file.endswith('.h'):
|
||||
os.remove(os.path.join(root, file))
|
||||
|
||||
os.chdir(dir_path.split('\\scripts')[0])
|
||||
os.chdir("build")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if file.startswith('IMG_'): #Remove image file
|
||||
os.remove(os.path.join(root, file))
|
||||
|
||||
else:
|
||||
os.chdir("build")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if not file.startswith('IMG_') and not file.startswith('SND_'): #Don't remove image or cry file
|
||||
os.remove(os.path.join(root, file))
|
||||
try:
|
||||
os.chdir("build")
|
||||
for root, dirs, files in os.walk(".", topdown = False):
|
||||
for file in files:
|
||||
if not file.startswith('IMG_') and not file.startswith('SND_'): #Don't remove image or cry file
|
||||
os.remove(os.path.join(root, file))
|
||||
except:
|
||||
pass
|
||||
|
||||
print("Directory cleaned!")
|
||||
@@ -8,7 +8,7 @@ import binascii
|
||||
import textwrap
|
||||
import sys
|
||||
|
||||
OFFSET_TO_PUT = 0x1a00000
|
||||
OFFSET_TO_PUT = 0x1800000
|
||||
SOURCE_ROM = "BPRE0.gba"
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
@@ -9,7 +9,7 @@ import os
|
||||
############
|
||||
|
||||
ROM_NAME = "BPRE0.gba" #The name of your rom
|
||||
OFFSET_TO_PUT = 0x1A00000
|
||||
OFFSET_TO_PUT = 0x1800000
|
||||
SEARCH_FREE_SPACE = False #Set to True if you want the script to search for free space;Set to False if you don't want to search for free space as you for example update the engine
|
||||
|
||||
#############
|
||||
|
||||
Reference in New Issue
Block a user