Use os.path more
Add Enemizer note
This commit is contained in:
@@ -5,6 +5,8 @@ import sys
|
||||
block_cipher = None
|
||||
console = True
|
||||
|
||||
BINARY_SLUG = "DungeonRandomizer"
|
||||
|
||||
def recurse_for_py_files(names_so_far):
|
||||
returnvalue = []
|
||||
for name in os.listdir(os.path.join(*names_so_far)):
|
||||
@@ -29,6 +31,7 @@ binaries = []
|
||||
# binaries.append(("ucrtbase.dll","."))
|
||||
|
||||
a = Analysis(['DungeonRandomizer.py'],
|
||||
a = Analysis([f"../{BINARY_SLUG}.py"],
|
||||
pathex=[],
|
||||
binaries=binaries,
|
||||
datas=[],
|
||||
@@ -56,7 +59,7 @@ exe = EXE(pyz,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='DungeonRandomizer',
|
||||
name=BINARY_SLUG,
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
|
||||
4
Gui.spec
4
Gui.spec
@@ -7,6 +7,7 @@ console = True
|
||||
|
||||
if sys.platform.find("mac") or sys.platform.find("osx"):
|
||||
console = False
|
||||
BINARY_SLUG = "Gui"
|
||||
|
||||
def recurse_for_py_files(names_so_far):
|
||||
returnvalue = []
|
||||
@@ -32,6 +33,7 @@ binaries = []
|
||||
# binaries.append(("ucrtbase.dll","."))
|
||||
|
||||
a = Analysis(['DungeonRandomizer.py'],
|
||||
a = Analysis([f"../{BINARY_SLUG}.py"],
|
||||
pathex=[],
|
||||
binaries=binaries,
|
||||
datas=[],
|
||||
@@ -59,7 +61,7 @@ exe = EXE(pyz,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='Gui',
|
||||
name=BINARY_SLUG,
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
|
||||
@@ -5,9 +5,9 @@ import tkinter as tk
|
||||
from Utils import local_path
|
||||
|
||||
def set_icon(window):
|
||||
er16 = tk.PhotoImage(file=local_path('data/ER16.gif'))
|
||||
er32 = tk.PhotoImage(file=local_path('data/ER32.gif'))
|
||||
er48 = tk.PhotoImage(file=local_path('data/ER32.gif'))
|
||||
er16 = tk.PhotoImage(file=local_path(os.path.join("data","ER16.gif")))
|
||||
er32 = tk.PhotoImage(file=local_path(os.path.join("data","ER32.gif")))
|
||||
er48 = tk.PhotoImage(file=local_path(os.path.join("data","ER48.gif")))
|
||||
window.tk.call('wm', 'iconphoto', window._w, er16, er32, er48) # pylint: disable=protected-access
|
||||
|
||||
# Although tkinter is intended to be thread safe, there are many reports of issues
|
||||
|
||||
3
Main.py
3
Main.py
@@ -186,12 +186,12 @@ def main(args, seed=None, fish=None):
|
||||
|
||||
rom_names = []
|
||||
jsonout = {}
|
||||
enemized = False
|
||||
if not args.suppress_rom:
|
||||
logger.info(world.fish.translate("cli","cli","patching.rom"))
|
||||
for team in range(world.teams):
|
||||
for player in range(1, world.players + 1):
|
||||
sprite_random_on_hit = type(args.sprite[player]) is str and args.sprite[player].lower() == 'randomonhit'
|
||||
enemized = False
|
||||
use_enemizer = (world.boss_shuffle[player] != 'none' or world.enemy_shuffle[player] != 'none'
|
||||
or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default'
|
||||
or args.shufflepots[player] or sprite_random_on_hit)
|
||||
@@ -313,6 +313,7 @@ def main(args, seed=None, fish=None):
|
||||
logger.info(world.fish.translate("cli","cli","made.rom") % (YES if (args.create_rom) else NO))
|
||||
logger.info(world.fish.translate("cli","cli","made.playthrough") % (YES if (args.calc_playthrough) else NO))
|
||||
logger.info(world.fish.translate("cli","cli","made.spoiler") % (YES if (not args.jsonout and args.create_spoiler) else NO))
|
||||
logger.info(world.fish.translate("cli","cli","used.enemizer") % (YES if enemized else NO))
|
||||
logger.info(world.fish.translate("cli","cli","seed") + ": %d", world.seed)
|
||||
logger.info(world.fish.translate("cli","cli","total.time"), time.perf_counter() - start)
|
||||
|
||||
|
||||
4
Rom.py
4
Rom.py
@@ -162,7 +162,7 @@ def read_rom(stream):
|
||||
|
||||
def patch_enemizer(world, player, rom, baserom_path, enemizercli, shufflepots, random_sprite_on_hit):
|
||||
baserom_path = os.path.abspath(baserom_path)
|
||||
basepatch_path = os.path.abspath(local_path('data/base2current.json'))
|
||||
basepatch_path = os.path.abspath(local_path(os.path.join("data","base2current.json")))
|
||||
enemizer_basepatch_path = os.path.join(os.path.dirname(enemizercli), "enemizerBasePatch.json")
|
||||
randopatch_path = os.path.abspath(output_path('enemizer_randopatch.json'))
|
||||
options_path = os.path.abspath(output_path('enemizer_options.json'))
|
||||
@@ -305,7 +305,7 @@ def patch_enemizer(world, player, rom, baserom_path, enemizercli, shufflepots, r
|
||||
_sprite_table = {}
|
||||
def _populate_sprite_table():
|
||||
if not _sprite_table:
|
||||
for dir in [local_path('data/sprites/official'), local_path('data/sprites/unofficial')]:
|
||||
for dir in [local_path(os.path.join("data","sprites","official")), local_path(os.path.join("data","sprites","unofficial"))]:
|
||||
for file in os.listdir(dir):
|
||||
filepath = os.path.join(dir, file)
|
||||
if not os.path.isfile(filepath):
|
||||
|
||||
@@ -3,6 +3,9 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
# Spec file
|
||||
SPEC_FILE = os.path.join("DungeonRandomizer.spec")
|
||||
|
||||
# Destination is current dir
|
||||
DEST_DIRECTORY = '.'
|
||||
|
||||
@@ -16,7 +19,7 @@ if os.path.isdir("build") and not sys.platform.find("mac") and not sys.platform.
|
||||
shutil.rmtree("build")
|
||||
|
||||
# Run pyinstaller for DungeonRandomizer
|
||||
subprocess.run(" ".join(["pyinstaller DungeonRandomizer.spec ",
|
||||
subprocess.run(" ".join([f"pyinstaller {SPEC_FILE} ",
|
||||
upx_string,
|
||||
"-y ",
|
||||
"--onefile ",
|
||||
|
||||
@@ -3,6 +3,9 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
# Spec file
|
||||
SPEC_FILE = os.path.join("Gui.spec")
|
||||
|
||||
# Destination is current dir
|
||||
DEST_DIRECTORY = '.'
|
||||
|
||||
@@ -16,7 +19,7 @@ if os.path.isdir("build") and not sys.platform.find("mac") and not sys.platform.
|
||||
shutil.rmtree("build")
|
||||
|
||||
# Run pyinstaller for Gui
|
||||
subprocess.run(" ".join(["pyinstaller Gui.spec ",
|
||||
subprocess.run(" ".join([f"pyinstaller {SPEC_FILE} ",
|
||||
upx_string,
|
||||
"-y ",
|
||||
"--onefile ",
|
||||
|
||||
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
aioconsole==0.1.15
|
||||
colorama==0.4.3
|
||||
websockets==8.1
|
||||
@@ -40,6 +40,7 @@
|
||||
"made.rom": "Patched ROM: %s",
|
||||
"made.playthrough": "Printed Playthrough: %s",
|
||||
"made.spoiler": "Printed Spoiler: %s",
|
||||
"used.enemizer": "Enemized: %s",
|
||||
"done": "Done. Enjoy.",
|
||||
"total.time": "Total Time: %s",
|
||||
"finished.run": "Finished run",
|
||||
|
||||
@@ -23,7 +23,7 @@ def prepare_env():
|
||||
|
||||
# get app version
|
||||
APP_VERSION = ""
|
||||
APP_VERSION_FILE = "./resources/app/meta/manifests/app_version.txt"
|
||||
APP_VERSION_FILE = os.path.join(".","resources","app","meta","manifests","app_version.txt")
|
||||
if os.path.isfile(APP_VERSION_FILE):
|
||||
with open(APP_VERSION_FILE,"r") as f:
|
||||
APP_VERSION = f.readlines()[0].strip()
|
||||
|
||||
@@ -6,7 +6,7 @@ from shutil import unpack_archive
|
||||
|
||||
# only do stuff if we don't have a UPX folder
|
||||
|
||||
if not os.path.isdir("./upx"):
|
||||
if not os.path.isdir(os.path.join(".","upx")):
|
||||
# get env vars
|
||||
env = common.prepare_env()
|
||||
# set up download url
|
||||
@@ -25,7 +25,7 @@ if not os.path.isdir("./upx"):
|
||||
|
||||
print("Getting UPX: " + UPX_FILE)
|
||||
|
||||
with open("./" + UPX_FILE,"wb") as upx:
|
||||
with open(os.path.join(".",UPX_FILE),"wb") as upx:
|
||||
UPX_REQ = urllib.request.Request(
|
||||
UPX_URL,
|
||||
data=None
|
||||
@@ -34,9 +34,9 @@ if not os.path.isdir("./upx"):
|
||||
UPX_DATA = UPX_REQ.read()
|
||||
upx.write(UPX_DATA)
|
||||
|
||||
unpack_archive(UPX_FILE,"./")
|
||||
unpack_archive(UPX_FILE,os.path.join("."))
|
||||
|
||||
os.rename("./" + UPX_SLUG,"./upx")
|
||||
os.remove("./" + UPX_FILE)
|
||||
os.rename(os.path.join(".",UPX_SLUG),os.path.join(".","upx"))
|
||||
os.remove(os.path.join(".",UPX_FILE))
|
||||
|
||||
print("UPX should " + ("not " if not os.path.isdir("./upx") else "") + "be available.")
|
||||
print("UPX should " + ("not " if not os.path.isdir(os.path.join(".","upx")) else "") + "be available.")
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
import subprocess # do stuff at the shell level
|
||||
import os
|
||||
|
||||
def git_clean():
|
||||
def git_clean(clean_ignored=True, clean_user=False):
|
||||
excludes = [
|
||||
".vscode", # vscode IDE files
|
||||
".idea", # idea IDE files
|
||||
"*.json", # keep JSON files for that one time I just nuked all that I was working on, oops
|
||||
"*app*version.*", # keep appversion files
|
||||
"EnemizerCLI" # keep EnemizerCLI
|
||||
"EnemizerCLI" # keep EnemizerCLI files
|
||||
]
|
||||
|
||||
if not clean_user:
|
||||
excludes.append(os.path.join("resources","user*")) # keep user resources
|
||||
|
||||
excludes = ['--exclude={0}'.format(exclude) for exclude in excludes]
|
||||
|
||||
# d: directories, f: files, x: ignored files
|
||||
switches = "df" + ("x" if clean_ignored else "")
|
||||
|
||||
# clean the git slate
|
||||
subprocess.check_call([
|
||||
"git", # run a git command
|
||||
"clean", # clean command
|
||||
"-dfx", # d: directories, f: files, x: ignored files
|
||||
"-" + switches,
|
||||
*excludes])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
3
resources/ci/common/git_cleanest.py
Normal file
3
resources/ci/common/git_cleanest.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from git_clean import git_clean
|
||||
|
||||
git_clean(clean_user=True)
|
||||
@@ -32,12 +32,13 @@ class SpriteSelector(object):
|
||||
webbrowser.open("http://alttpr.com/sprite_preview")
|
||||
|
||||
def open_unofficial_sprite_dir(_evt):
|
||||
if not os.path.isdir(self.unofficial_sprite_dir):
|
||||
os.makedirs(self.unofficial_sprite_dir)
|
||||
open_file(self.unofficial_sprite_dir)
|
||||
|
||||
# Open SpriteSomething directory for Link sprites
|
||||
def open_spritesomething_listing(_evt):
|
||||
webbrowser.open("https://artheau.github.io/SpriteSomething/?mode=zelda3/link")
|
||||
# webbrowser.open("https://artheau.github.io/SpriteSomething/resources/app/snes/zelda3/link/sprites.html")
|
||||
webbrowser.open("https://artheau.github.io/SpriteSomething/resources/app/snes/zelda3/link/sprites.html")
|
||||
|
||||
official_frametitle = Frame(self.window)
|
||||
official_title_text = Label(official_frametitle, text="Official Sprites")
|
||||
@@ -57,8 +58,8 @@ class SpriteSelector(object):
|
||||
spritesomething_title_link.pack(side=LEFT)
|
||||
spritesomething_title_link.bind("<Button-1>", open_spritesomething_listing)
|
||||
|
||||
self.icon_section(official_frametitle, self.official_sprite_dir+'/*', 'Official sprites not found. Click "Update official sprites" to download them.')
|
||||
self.icon_section(unofficial_frametitle, self.unofficial_sprite_dir+'/*', 'Put sprites in the unofficial sprites folder (see open link above) to have them appear here.')
|
||||
self.icon_section(official_frametitle, os.path.join(self.official_sprite_dir,"*"), 'Official sprites not found. Click "Update official sprites" to download them.')
|
||||
self.icon_section(unofficial_frametitle, os.path.join(self.unofficial_sprite_dir,"*"), 'Put sprites in the unofficial sprites folder (see open link above) to have them appear here.')
|
||||
|
||||
frame = Frame(self.window)
|
||||
frame.pack(side=BOTTOM, fill=X, pady=5)
|
||||
@@ -150,10 +151,10 @@ class SpriteSelector(object):
|
||||
|
||||
try:
|
||||
task.update_status("Determining needed sprites")
|
||||
current_sprites = [os.path.basename(file) for file in glob(self.official_sprite_dir+'/*')]
|
||||
current_sprites = [os.path.basename(file) for file in glob(os.path.join(self.official_sprite_dir,"*"))]
|
||||
official_sprites = [(sprite['file'], os.path.basename(urlparse(sprite['file']).path)) for sprite in sprites_arr]
|
||||
needed_sprites = [(sprite_url, filename) for (sprite_url, filename) in official_sprites if filename not in current_sprites]
|
||||
bundled_sprites = [os.path.basename(file) for file in glob(self.local_official_sprite_dir+'/*')]
|
||||
bundled_sprites = [os.path.basename(file) for file in glob(os.path.join(self.unofficial_sprite_dir,"*"))]
|
||||
# todo: eventually use the above list to avoid downloading any sprites that we already have cached in the bundle.
|
||||
|
||||
official_filenames = [filename for (_, filename) in official_sprites]
|
||||
@@ -230,23 +231,23 @@ class SpriteSelector(object):
|
||||
|
||||
@property
|
||||
def official_sprite_dir(self):
|
||||
if is_bundled():
|
||||
return output_path("sprites/official")
|
||||
# if is_bundled():
|
||||
# return output_path(os.path.join("sprites","official"))
|
||||
return self.local_official_sprite_dir
|
||||
|
||||
@property
|
||||
def local_official_sprite_dir(self):
|
||||
return local_path("data/sprites/official")
|
||||
return local_path(os.path.join("data","sprites","official"))
|
||||
|
||||
@property
|
||||
def unofficial_sprite_dir(self):
|
||||
if is_bundled():
|
||||
return output_path("sprites/unofficial")
|
||||
# if is_bundled():
|
||||
# return output_path(os.path.join("sprites","unofficial"))
|
||||
return self.local_unofficial_sprite_dir
|
||||
|
||||
@property
|
||||
def local_unofficial_sprite_dir(self):
|
||||
return local_path("data/sprites/unofficial")
|
||||
return local_path(os.path.join("data","sprites","unofficial"))
|
||||
|
||||
|
||||
def get_image_for_sprite(sprite):
|
||||
|
||||
@@ -115,6 +115,7 @@ def bottom_frame(self, parent, args=None):
|
||||
made = {}
|
||||
for k in [ "rom", "playthrough", "spoiler" ]:
|
||||
made[k] = parent.fish.translate("cli","cli","made." + k)
|
||||
made["enemizer"] = parent.fish.translate("cli","cli","used.enemizer")
|
||||
for k in made:
|
||||
v = made[k]
|
||||
pattern = "([\w]+)(:)([\s]+)(.*)"
|
||||
@@ -123,6 +124,7 @@ def bottom_frame(self, parent, args=None):
|
||||
successMsg += (made["rom"] % (YES if (guiargs.create_rom) else NO)) + "\n"
|
||||
successMsg += (made["playthrough"] % (YES if (guiargs.calc_playthrough) else NO)) + "\n"
|
||||
successMsg += (made["spoiler"] % (YES if (not guiargs.jsonout and guiargs.create_spoiler) else NO)) + "\n"
|
||||
successMsg += (made["enemizer"] % (YES if needEnemizer else NO)) + "\n"
|
||||
# FIXME: English
|
||||
successMsg += ("Seed%s: %s" % ('s' if len(seeds) > 1 else "", ','.join(str(x) for x in seeds)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user