forked from ArchipelagoMW/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate dumpSprites.py - and then remove it
- Loading branch information
1 parent
3bfb98a
commit b53c559
Showing
351 changed files
with
54 additions
and
1,762 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
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,41 @@ | ||
import os | ||
import threading | ||
import json | ||
|
||
from Utils import local_path | ||
|
||
|
||
def update_sprites_lttp(): | ||
from Gui import Tk, BackgroundTaskProgress, Sprite, get_image_for_sprite, update_sprites | ||
|
||
# Target directories | ||
input_dir = local_path("data", "sprites", "alttpr") | ||
output_dir = local_path("WebHostLib", "static", "generated") | ||
|
||
os.makedirs(os.path.join(output_dir, "sprites"), exist_ok=True) | ||
# update sprites through gui.py's functions | ||
done = threading.Event() | ||
top = Tk() | ||
top.withdraw() | ||
BackgroundTaskProgress(top, update_sprites, "Updating Sprites", lambda succesful, resultmessage: done.set()) | ||
while not done.isSet(): | ||
top.update() | ||
|
||
spriteData = [] | ||
|
||
for file in os.listdir(input_dir): | ||
sprite = Sprite(os.path.join(input_dir, file)) | ||
|
||
if not sprite.name: | ||
print("Warning:", file, "has no name.") | ||
sprite.name = file.split(".", 1)[0] | ||
if sprite.valid: | ||
with open(os.path.join(output_dir, "sprites", f"{os.path.splitext(file)[0]}.gif"), 'wb') as image: | ||
image.write(get_image_for_sprite(sprite, True)) | ||
spriteData.append({"file": file, "author": sprite.author_name, "name": sprite.name}) | ||
else: | ||
print(file, "dropped, as it has no valid sprite data.") | ||
spriteData.sort(key=lambda entry: entry["name"]) | ||
with open(f'{output_dir}/spriteData.json', 'w') as file: | ||
json.dump({"sprites": spriteData}, file, indent=1) | ||
return spriteData |
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
Oops, something went wrong.