Automate dumpSprites.py - and then remove it
|
@ -38,6 +38,7 @@ success.txt
|
|||
output/
|
||||
Output Logs/
|
||||
/factorio/
|
||||
/WebHostLib/static/generated
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
|
|
@ -1111,16 +1111,18 @@ class Location():
|
|||
def hint_text(self):
|
||||
return getattr(self, "_hint_text", self.name.replace("_", " ").replace("-", " "))
|
||||
|
||||
|
||||
class Item():
|
||||
location: Optional[Location] = None
|
||||
world: Optional[MultiWorld] = None
|
||||
game: str = "Generic"
|
||||
type: str = None
|
||||
pedestal_credit_text = "and the Unknown Item"
|
||||
sickkid_credit_text = None
|
||||
magicshop_credit_text = None
|
||||
zora_credit_text = None
|
||||
fluteboy_credit_text = None
|
||||
pedestal_credit_text: str = "and the Unknown Item"
|
||||
sickkid_credit_text: Optional[str] = None
|
||||
magicshop_credit_text: Optional[str] = None
|
||||
zora_credit_text: Optional[str] = None
|
||||
fluteboy_credit_text: Optional[str] = None
|
||||
code: Optional[str] = None # an item with ID None is called an Event, and does not get written to multidata
|
||||
|
||||
def __init__(self, name: str, advancement: bool, code: Optional[int], player: int):
|
||||
self.name = name
|
||||
|
|
|
@ -11,6 +11,7 @@ from waitress import serve
|
|||
|
||||
from WebHostLib.models import db
|
||||
from WebHostLib.autolauncher import autohost
|
||||
from WebHostLib.lttpsprites import update_sprites_lttp
|
||||
|
||||
configpath = os.path.abspath("config.yaml")
|
||||
|
||||
|
@ -30,6 +31,7 @@ if __name__ == "__main__":
|
|||
multiprocessing.freeze_support()
|
||||
multiprocessing.set_start_method('spawn')
|
||||
logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.INFO)
|
||||
update_sprites_lttp()
|
||||
app = get_app()
|
||||
if app.config["SELFLAUNCH"]:
|
||||
autohost(app.config)
|
||||
|
|
|
@ -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
|
|
@ -93,7 +93,7 @@ const fetchSpriteData = () => new Promise((resolve, reject) => {
|
|||
}
|
||||
resolve(ajax.responseText);
|
||||
};
|
||||
ajax.open('GET', `${window.location.origin}/static/static/spriteData.json`, true);
|
||||
ajax.open('GET', `${window.location.origin}/static/generated/spriteData.json`, true);
|
||||
ajax.send();
|
||||
});
|
||||
|
||||
|
@ -446,7 +446,7 @@ const buildSpritePicker = (spriteData) => {
|
|||
let spriteGifFile = sprite.file.split('.');
|
||||
spriteGifFile.pop();
|
||||
spriteGifFile = spriteGifFile.join('.') + '.gif';
|
||||
spriteImg.setAttribute('src', `static/static/sprites/${spriteGifFile}`);
|
||||
spriteImg.setAttribute('src', `static/generated/sprites/${spriteGifFile}`);
|
||||
spriteImg.setAttribute('data-sprite', sprite.file.split('.')[0]);
|
||||
spriteImg.setAttribute('alt', sprite.name);
|
||||
|
||||
|
|
|
@ -189,6 +189,6 @@ const fetchSpriteData = () => new Promise((resolve, reject) => {
|
|||
}
|
||||
resolve(ajax.responseText);
|
||||
};
|
||||
ajax.open('GET', `${window.location.origin}/static/static/spriteData.json`, true);
|
||||
ajax.open('GET', `${window.location.origin}/static/generated/spriteData.json`, true);
|
||||
ajax.send();
|
||||
});
|
||||
|
|
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 541 B |