From 58bb9fffba94cae1069b5c4bb3180f421e79c819 Mon Sep 17 00:00:00 2001 From: "Mike A. Trethewey" Date: Tue, 10 Mar 2020 02:57:20 -0700 Subject: [PATCH] Strip Bottom --- Gui.py | 8 ++++ source/gui/bottom.py | 94 ++++++++++++++++++++++++++++++--------- source/gui/loadcliargs.py | 32 ++++++++++++- 3 files changed, 111 insertions(+), 23 deletions(-) diff --git a/Gui.py b/Gui.py index c2f871a5..4c4c2959 100755 --- a/Gui.py +++ b/Gui.py @@ -21,6 +21,8 @@ from source.gui.bottom import bottom_frame, create_guiargs from GuiUtils import set_icon from Main import __version__ as ESVersion +from source.classes.BabelFish import BabelFish + def guiMain(args=None): # Save settings to file @@ -143,6 +145,12 @@ def guiMain(args=None): # add randomizer notebook to main window 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) self.frames["bottom"] = bottom_frame(self, self, None) ## Save Settings Button diff --git a/source/gui/bottom.py b/source/gui/bottom.py index aeb26c94..54b859ec 100644 --- a/source/gui/bottom.py +++ b/source/gui/bottom.py @@ -8,6 +8,7 @@ from Main import main from Utils import local_path, output_path, open_file import source.classes.constants as CONST import source.gui.widgets as widgets +from source.classes.Empty import Empty def bottom_frame(self, parent, args=None): @@ -17,19 +18,33 @@ def bottom_frame(self, parent, args=None): # Bottom Frame options self.widgets = {} - seedCountFrame = Frame(self) - seedCountFrame.pack() - ## Seed # - seedLabel = Label(self, text='Seed #') + # Seed input + # widget ID + widget = "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"] - 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): savedSeed = self.seedVar.get() parent.settings["seed"] = int(savedSeed) if savedSeed.isdigit() else None - self.seedVar.trace_add("write",saveSeed) - seedEntry = Entry(self, width=15, textvariable=self.seedVar) - seedLabel.pack(side=LEFT) - seedEntry.pack(side=LEFT) + self.widgets[widget].storageVar.trace_add("write",saveSeed) + # frame: pack + self.widgets[widget].pieces["frame"].pack(side=LEFT) ## Number of Generation attempts key = "generationcount" @@ -56,10 +71,10 @@ def bottom_frame(self, parent, args=None): if guiargs.count is not None: seed = guiargs.seed for _ in range(guiargs.count): - main(seed=seed, args=guiargs) + main(seed=seed, args=guiargs, fish=parent.fish) seed = random.randint(0, 999999999) else: - main(seed=guiargs.seed, args=guiargs) + main(seed=guiargs.seed, args=guiargs, fish=parent.fish) except Exception as e: logging.exception(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") ## Generate Button - generateButton = Button(self, text='Generate Patched Rom', command=generateRom) - generateButton.pack(side=LEFT) + # widget ID + 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(): if args and args.outputpath: @@ -76,15 +101,38 @@ def bottom_frame(self, parent, args=None): else: open_file(output_path(parent.settings["outputpath"])) - openOutputButton = Button(self, text='Open Output Directory', command=open_output) - openOutputButton.pack(side=RIGHT) + ## Output Button + # 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 if os.path.exists(local_path('README.html')): def open_readme(): open_file(local_path('README.html')) - openReadmeButton = Button(self, text='Open Documentation', command=open_readme) - openReadmeButton.pack(side=RIGHT) + # widget ID + 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 @@ -107,22 +155,26 @@ def create_guiargs(parent): setattr(guiargs, arg, parent.pages[mainpage].pages[subpage].widgets[widget].storageVar.get()) # 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 guiargs.multi = int(parent.pages["randomizer"].pages["multiworld"].widgets["worlds"].storageVar.get()) # 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 guiargs.custom = bool(parent.pages["randomizer"].pages["generation"].widgets["usecustompool"].storageVar.get()) # 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 - 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 adjustargs = { diff --git a/source/gui/loadcliargs.py b/source/gui/loadcliargs.py index f8a52483..84cb3e10 100644 --- a/source/gui/loadcliargs.py +++ b/source/gui/loadcliargs.py @@ -105,9 +105,13 @@ def loadcliargs(gui, args, settings=None): # Get Seed ID mainpage = "bottom" + widget = "seed" setting = "seed" 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 mainpage = "bottom" @@ -115,9 +119,33 @@ def loadcliargs(gui, args, settings=None): setting = "count" if 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 - 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 def sprite_setter(spriteObject):