Strip Bottom

This commit is contained in:
Mike A. Trethewey
2020-03-10 02:57:20 -07:00
parent 014aa3519c
commit 58bb9fffba
3 changed files with 111 additions and 23 deletions

8
Gui.py
View File

@@ -21,6 +21,8 @@ from source.gui.bottom import bottom_frame, create_guiargs
from GuiUtils import set_icon from GuiUtils import set_icon
from Main import __version__ as ESVersion from Main import __version__ as ESVersion
from source.classes.BabelFish import BabelFish
def guiMain(args=None): def guiMain(args=None):
# Save settings to file # Save settings to file
@@ -143,6 +145,12 @@ def guiMain(args=None):
# add randomizer notebook to main window # add randomizer notebook to main window
self.pages["randomizer"].notebook.pack() self.pages["randomizer"].notebook.pack()
settings = get_args_priority(None, None, None)
lang = "en"
if "load" in settings and "lang" in settings["load"]:
lang = settings["load"]["lang"]
self.fish = BabelFish(lang=lang)
# bottom of window: Open Output Directory, Open Documentation (if exists) # bottom of window: Open Output Directory, Open Documentation (if exists)
self.frames["bottom"] = bottom_frame(self, self, None) self.frames["bottom"] = bottom_frame(self, self, None)
## Save Settings Button ## Save Settings Button

View File

@@ -8,6 +8,7 @@ from Main import main
from Utils import local_path, output_path, open_file from Utils import local_path, output_path, open_file
import source.classes.constants as CONST import source.classes.constants as CONST
import source.gui.widgets as widgets import source.gui.widgets as widgets
from source.classes.Empty import Empty
def bottom_frame(self, parent, args=None): def bottom_frame(self, parent, args=None):
@@ -17,19 +18,33 @@ def bottom_frame(self, parent, args=None):
# Bottom Frame options # Bottom Frame options
self.widgets = {} self.widgets = {}
seedCountFrame = Frame(self) # Seed input
seedCountFrame.pack() # widget ID
## Seed # widget = "seed"
seedLabel = Label(self, text='Seed #')
# Empty object
self.widgets[widget] = Empty()
# pieces
self.widgets[widget].pieces = {}
# frame
self.widgets[widget].pieces["frame"] = Frame(self)
# frame: label
self.widgets[widget].pieces["frame"].label = Label(self.widgets[widget].pieces["frame"], text="Seed #")
self.widgets[widget].pieces["frame"].label.pack(side=LEFT)
# storagevar
savedSeed = parent.settings["seed"] savedSeed = parent.settings["seed"]
self.seedVar = StringVar(value=savedSeed) self.widgets[widget].storageVar = StringVar(value=savedSeed)
# textbox
self.widgets[widget].pieces["textbox"] = Entry(self.widgets[widget].pieces["frame"], width=15, textvariable=self.widgets[widget].storageVar)
self.widgets[widget].pieces["textbox"].pack(side=LEFT)
def saveSeed(caller,_,mode): def saveSeed(caller,_,mode):
savedSeed = self.seedVar.get() savedSeed = self.seedVar.get()
parent.settings["seed"] = int(savedSeed) if savedSeed.isdigit() else None parent.settings["seed"] = int(savedSeed) if savedSeed.isdigit() else None
self.seedVar.trace_add("write",saveSeed) self.widgets[widget].storageVar.trace_add("write",saveSeed)
seedEntry = Entry(self, width=15, textvariable=self.seedVar) # frame: pack
seedLabel.pack(side=LEFT) self.widgets[widget].pieces["frame"].pack(side=LEFT)
seedEntry.pack(side=LEFT)
## Number of Generation attempts ## Number of Generation attempts
key = "generationcount" key = "generationcount"
@@ -56,10 +71,10 @@ def bottom_frame(self, parent, args=None):
if guiargs.count is not None: if guiargs.count is not None:
seed = guiargs.seed seed = guiargs.seed
for _ in range(guiargs.count): for _ in range(guiargs.count):
main(seed=seed, args=guiargs) main(seed=seed, args=guiargs, fish=parent.fish)
seed = random.randint(0, 999999999) seed = random.randint(0, 999999999)
else: else:
main(seed=guiargs.seed, args=guiargs) main(seed=guiargs.seed, args=guiargs, fish=parent.fish)
except Exception as e: except Exception as e:
logging.exception(e) logging.exception(e)
messagebox.showerror(title="Error while creating seed", message=str(e)) messagebox.showerror(title="Error while creating seed", message=str(e))
@@ -67,8 +82,18 @@ def bottom_frame(self, parent, args=None):
messagebox.showinfo(title="Success", message="Rom patched successfully") messagebox.showinfo(title="Success", message="Rom patched successfully")
## Generate Button ## Generate Button
generateButton = Button(self, text='Generate Patched Rom', command=generateRom) # widget ID
generateButton.pack(side=LEFT) widget = "go"
# Empty object
self.widgets[widget] = Empty()
# pieces
self.widgets[widget].pieces = {}
# button
self.widgets[widget].pieces["button"] = Button(self, text='Generate Patched Rom', command=generateRom)
# button: pack
self.widgets[widget].pieces["button"].pack(side=LEFT)
def open_output(): def open_output():
if args and args.outputpath: if args and args.outputpath:
@@ -76,15 +101,38 @@ def bottom_frame(self, parent, args=None):
else: else:
open_file(output_path(parent.settings["outputpath"])) open_file(output_path(parent.settings["outputpath"]))
openOutputButton = Button(self, text='Open Output Directory', command=open_output) ## Output Button
openOutputButton.pack(side=RIGHT) # widget ID
widget = "outputdir"
# Empty object
self.widgets[widget] = Empty()
# pieces
self.widgets[widget].pieces = {}
# storagevar
self.widgets[widget].storageVar = StringVar(value=parent.settings["outputpath"])
# button
self.widgets[widget].pieces["button"] = Button(self, text='Open Output Directory', command=open_output)
# button: pack
self.widgets[widget].pieces["button"].pack(side=RIGHT)
## Documentation Button ## Documentation Button
if os.path.exists(local_path('README.html')): if os.path.exists(local_path('README.html')):
def open_readme(): def open_readme():
open_file(local_path('README.html')) open_file(local_path('README.html'))
openReadmeButton = Button(self, text='Open Documentation', command=open_readme) # widget ID
openReadmeButton.pack(side=RIGHT) widget = "docs"
# Empty object
self.widgets[widget] = Empty()
# pieces
self.widgets[widget].pieces = {}
# button
self.widgets[widget].pieces["button"] = Button(self, text='Open Documentation', command=open_readme)
# button: pack
self.widgets[widget].pieces["button"].pack(side=RIGHT)
return self return self
@@ -107,22 +155,26 @@ def create_guiargs(parent):
setattr(guiargs, arg, parent.pages[mainpage].pages[subpage].widgets[widget].storageVar.get()) setattr(guiargs, arg, parent.pages[mainpage].pages[subpage].widgets[widget].storageVar.get())
# Get EnemizerCLI setting # Get EnemizerCLI setting
guiargs.enemizercli = parent.pages["randomizer"].pages["enemizer"].enemizerCLIpathVar.get() guiargs.enemizercli = parent.pages["randomizer"].pages["enemizer"].widgets["enemizercli"].storageVar.get()
# Get Multiworld Worlds count # Get Multiworld Worlds count
guiargs.multi = int(parent.pages["randomizer"].pages["multiworld"].widgets["worlds"].storageVar.get()) guiargs.multi = int(parent.pages["randomizer"].pages["multiworld"].widgets["worlds"].storageVar.get())
# Get baserom path # Get baserom path
guiargs.rom = parent.pages["randomizer"].pages["generation"].romVar.get() guiargs.rom = parent.pages["randomizer"].pages["generation"].widgets["rom"].storageVar.get()
# Get if we're using the Custom Item Pool # Get if we're using the Custom Item Pool
guiargs.custom = bool(parent.pages["randomizer"].pages["generation"].widgets["usecustompool"].storageVar.get()) guiargs.custom = bool(parent.pages["randomizer"].pages["generation"].widgets["usecustompool"].storageVar.get())
# Get Seed ID # Get Seed ID
guiargs.seed = int(parent.frames["bottom"].seedVar.get()) if parent.frames["bottom"].seedVar.get() else None guiargs.seed = None
if parent.frames["bottom"].widgets["seed"].storageVar.get():
guiargs.seed = int(parent.frames["bottom"].widgets["seed"].storageVar.get())
# Get number of generations to run # Get number of generations to run
guiargs.count = int(parent.frames["bottom"].widgets["generationcount"].storageVar.get()) if parent.frames["bottom"].widgets["generationcount"].storageVar.get() != '1' else None guiargs.count = 1
if parent.frames["bottom"].widgets["generationcount"].storageVar.get():
guiargs.count = int(parent.frames["bottom"].widgets["generationcount"].storageVar.get())
# Get Adjust settings # Get Adjust settings
adjustargs = { adjustargs = {

View File

@@ -105,9 +105,13 @@ def loadcliargs(gui, args, settings=None):
# Get Seed ID # Get Seed ID
mainpage = "bottom" mainpage = "bottom"
widget = "seed"
setting = "seed" setting = "seed"
if args[setting]: if args[setting]:
gui.frames[mainpage].seedVar.set(str(args[setting])) gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting]))
# set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget)
gui.frames[mainpage].widgets[widget].pieces["frame"].label.configure(text=label)
# Get number of generations to run # Get number of generations to run
mainpage = "bottom" mainpage = "bottom"
@@ -115,9 +119,33 @@ def loadcliargs(gui, args, settings=None):
setting = "count" setting = "count"
if args[setting]: if args[setting]:
gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting])) gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting]))
# set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget)
gui.frames[mainpage].widgets[widget].label.configure(text=label)
# Set Generate button
mainpage = "bottom"
widget = "go"
# set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget)
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label)
# Set Output Directory button
mainpage = "bottom"
widget = "outputdir"
# set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget)
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label)
# Get output path # Get output path
gui.outputPath.set(args["outputpath"]) gui.frames[mainpage].widgets[widget].storageVar.set(args["outputpath"])
# Set Output Directory button
mainpage = "bottom"
widget = "docs"
# set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget)
if widget in gui.frames[mainpage].widgets:
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label)
# Figure out Sprite Selection # Figure out Sprite Selection
def sprite_setter(spriteObject): def sprite_setter(spriteObject):