Ugh, I think I did it
This commit is contained in:
@@ -36,11 +36,12 @@ def bottom_frame(self, parent, args=None):
|
||||
savedSeed = parent.settings["seed"]
|
||||
self.widgets[widget].storageVar = StringVar(value=savedSeed)
|
||||
# textbox
|
||||
self.widgets[widget].type = "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()
|
||||
savedSeed = self.widgets["seed"].storageVar.get()
|
||||
parent.settings["seed"] = int(savedSeed) if savedSeed.isdigit() else None
|
||||
self.widgets[widget].storageVar.trace_add("write",saveSeed)
|
||||
# frame: pack
|
||||
@@ -91,6 +92,7 @@ def bottom_frame(self, parent, args=None):
|
||||
self.widgets[widget].pieces = {}
|
||||
|
||||
# button
|
||||
self.widgets[widget].type = "button"
|
||||
self.widgets[widget].pieces["button"] = Button(self, text='Generate Patched Rom', command=generateRom)
|
||||
# button: pack
|
||||
self.widgets[widget].pieces["button"].pack(side=LEFT)
|
||||
@@ -114,22 +116,26 @@ def bottom_frame(self, parent, args=None):
|
||||
self.widgets[widget].storageVar = StringVar(value=parent.settings["outputpath"])
|
||||
|
||||
# button
|
||||
self.widgets[widget].type = "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
|
||||
# widget ID
|
||||
widget = "docs"
|
||||
|
||||
# Empty object
|
||||
self.widgets[widget] = Empty()
|
||||
# pieces
|
||||
self.widgets[widget].pieces = {}
|
||||
# button
|
||||
self.widgets[widget].type = "button"
|
||||
self.widgets[widget].selectbox = Empty()
|
||||
self.widgets[widget].selectbox.storageVar = Empty()
|
||||
if os.path.exists(local_path('README.html')):
|
||||
def open_readme():
|
||||
open_file(local_path('README.html'))
|
||||
# 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)
|
||||
|
||||
@@ -24,36 +24,46 @@ def loadcliargs(gui, args, settings=None):
|
||||
for subpage in options[mainpage]:
|
||||
# Cycle through each widget
|
||||
for widget in options[mainpage][subpage]:
|
||||
# Get the value and set it
|
||||
arg = options[mainpage][subpage][widget]
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
if hasattr(gui.pages[mainpage].pages[subpage].widgets[widget],"type"):
|
||||
type = gui.pages[mainpage].pages[subpage].widgets[widget].type
|
||||
if type == "checkbox":
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].checkbox.configure(text=label)
|
||||
elif type == "selectbox":
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
|
||||
elif type == "spinbox":
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args[arg])
|
||||
# If we're on the Game Options page and it's not about Hints
|
||||
if subpage == "gameoptions" and not widget == "hints":
|
||||
# Check if we've got settings
|
||||
# Check if we've got the widget in Adjust settings
|
||||
hasSettings = settings is not None
|
||||
hasWidget = ("adjust." + widget) in settings if hasSettings else None
|
||||
label = fish.translate("gui","gui","adjust." + widget)
|
||||
if ("adjust." + widget) in label:
|
||||
label = fish.translate("gui","gui","randomizer.gameoptions." + widget)
|
||||
if hasattr(gui.pages["adjust"].content.widgets[widget],"type"):
|
||||
type = gui.pages["adjust"].content.widgets[widget].type
|
||||
if type == "checkbox":
|
||||
gui.pages["adjust"].content.widgets[widget].checkbox.configure(text=label)
|
||||
elif type == "selectbox":
|
||||
gui.pages["adjust"].content.widgets[widget].label.configure(text=label)
|
||||
if hasWidget is None:
|
||||
# If we've got a Game Options val and we don't have an Adjust val, use the Game Options val
|
||||
gui.pages["adjust"].content.widgets[widget].storageVar.set(args[arg])
|
||||
if widget in gui.pages[mainpage].pages[subpage].widgets:
|
||||
thisType = ""
|
||||
# Get the value and set it
|
||||
arg = options[mainpage][subpage][widget]
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
if hasattr(gui.pages[mainpage].pages[subpage].widgets[widget],"type"):
|
||||
thisType = gui.pages[mainpage].pages[subpage].widgets[widget].type
|
||||
if thisType == "checkbox":
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].checkbox.configure(text=label)
|
||||
elif thisType == "selectbox":
|
||||
theseOptions = gui.pages[mainpage].pages[subpage].widgets[widget].selectbox.options
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
|
||||
i = 0
|
||||
for value in theseOptions["values"]:
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].selectbox.options["labels"][i] = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget + '.' + value)
|
||||
i += 1
|
||||
for i in range(0, len(theseOptions["values"])):
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].selectbox["menu"].entryconfigure(i, label=theseOptions["labels"][i])
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].selectbox.options = theseOptions
|
||||
elif thisType == "spinbox":
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args[arg])
|
||||
# If we're on the Game Options page and it's not about Hints
|
||||
if subpage == "gameoptions" and not widget == "hints":
|
||||
# Check if we've got settings
|
||||
# Check if we've got the widget in Adjust settings
|
||||
hasSettings = settings is not None
|
||||
hasWidget = ("adjust." + widget) in settings if hasSettings else None
|
||||
label = fish.translate("gui","gui","adjust." + widget)
|
||||
if ("adjust." + widget) in label:
|
||||
label = fish.translate("gui","gui","randomizer.gameoptions." + widget)
|
||||
if hasattr(gui.pages["adjust"].content.widgets[widget],"type"):
|
||||
type = gui.pages["adjust"].content.widgets[widget].type
|
||||
if type == "checkbox":
|
||||
gui.pages["adjust"].content.widgets[widget].checkbox.configure(text=label)
|
||||
elif type == "selectbox":
|
||||
gui.pages["adjust"].content.widgets[widget].label.configure(text=label)
|
||||
if hasWidget is None:
|
||||
# If we've got a Game Options val and we don't have an Adjust val, use the Game Options val
|
||||
gui.pages["adjust"].content.widgets[widget].storageVar.set(args[arg])
|
||||
|
||||
# Get EnemizerCLI setting
|
||||
mainpage = "randomizer"
|
||||
@@ -105,47 +115,53 @@ def loadcliargs(gui, args, settings=None):
|
||||
|
||||
# Get Seed ID
|
||||
mainpage = "bottom"
|
||||
subpage = "content"
|
||||
widget = "seed"
|
||||
setting = "seed"
|
||||
if args[setting]:
|
||||
gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting]))
|
||||
gui.pages[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)
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["frame"].label.configure(text=label)
|
||||
|
||||
# Get number of generations to run
|
||||
mainpage = "bottom"
|
||||
subpage = "content"
|
||||
widget = "generationcount"
|
||||
setting = "count"
|
||||
if args[setting]:
|
||||
gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting]))
|
||||
gui.pages[mainpage].pages[subpage].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)
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
|
||||
|
||||
# Set Generate button
|
||||
mainpage = "bottom"
|
||||
subpage = "content"
|
||||
widget = "go"
|
||||
# set textbox/frame label
|
||||
label = fish.translate("gui","gui",mainpage + '.' + widget)
|
||||
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label)
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["button"].configure(text=label)
|
||||
|
||||
# Set Output Directory button
|
||||
mainpage = "bottom"
|
||||
subpage = "content"
|
||||
widget = "outputdir"
|
||||
# set textbox/frame label
|
||||
label = fish.translate("gui","gui",mainpage + '.' + widget)
|
||||
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label)
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["button"].configure(text=label)
|
||||
# Get output path
|
||||
gui.frames[mainpage].widgets[widget].storageVar.set(args["outputpath"])
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args["outputpath"])
|
||||
|
||||
# Set Output Directory button
|
||||
# Set Documentation button
|
||||
mainpage = "bottom"
|
||||
subpage = "content"
|
||||
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)
|
||||
if widget in gui.pages[mainpage].pages[subpage].widgets:
|
||||
if "button" in gui.pages[mainpage].pages[subpage].widgets[widget].pieces:
|
||||
# set textbox/frame label
|
||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["button"].configure(text=label)
|
||||
|
||||
# Figure out Sprite Selection
|
||||
def sprite_setter(spriteObject):
|
||||
|
||||
@@ -28,27 +28,81 @@ def make_checkbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
|
||||
# Make an OptionMenu with a label and pretty option labels
|
||||
def make_selectbox(self, parent, label, options, storageVar, manager, managerAttrs):
|
||||
def change_storage(*args):
|
||||
self.storageVar.set(options[self.labelVar.get()])
|
||||
def change_selected(*args):
|
||||
keys = options.keys()
|
||||
vals = options.values()
|
||||
keysList = list(keys)
|
||||
valsList = list(vals)
|
||||
self.labelVar.set(keysList[valsList.index(str(self.storageVar.get()))])
|
||||
self = Frame(parent, name="selectframe-" + label.lower())
|
||||
self.storageVar = storageVar
|
||||
self.storageVar.trace_add("write",change_selected)
|
||||
|
||||
labels = options
|
||||
|
||||
if isinstance(options,dict):
|
||||
labels = options.keys()
|
||||
|
||||
self.labelVar = StringVar()
|
||||
self.storageVar = storageVar
|
||||
self.selectbox = OptionMenu(self, self.labelVar, *labels)
|
||||
self.selectbox.options = {}
|
||||
|
||||
if isinstance(options,dict):
|
||||
self.selectbox.options["labels"] = list(options.keys())
|
||||
self.selectbox.options["values"] = list(options.values())
|
||||
else:
|
||||
self.selectbox.options["labels"] = ["" for i in range(0,len(options))]
|
||||
self.selectbox.options["values"] = options
|
||||
|
||||
def change_thing(thing, *args):
|
||||
labels = self.selectbox.options["labels"]
|
||||
values = self.selectbox.options["values"]
|
||||
check = ""
|
||||
lbl = ""
|
||||
val = ""
|
||||
idx = 0
|
||||
|
||||
if thing == "storage":
|
||||
check = self.labelVar.get()
|
||||
elif thing == "label":
|
||||
check = self.storageVar.get()
|
||||
|
||||
if check in labels:
|
||||
idx = labels.index(check)
|
||||
if check in values:
|
||||
idx = values.index(check)
|
||||
|
||||
lbl = labels[idx]
|
||||
val = values[idx]
|
||||
|
||||
if thing == "storage":
|
||||
self.storageVar.set(val)
|
||||
elif thing == "label":
|
||||
self.labelVar.set(lbl)
|
||||
self.selectbox["menu"].entryconfigure(idx,label=lbl)
|
||||
self.selectbox.configure(state="active")
|
||||
|
||||
|
||||
def change_storage(*args):
|
||||
change_thing("storage", *args)
|
||||
def change_selected(*args):
|
||||
change_thing("label", *args)
|
||||
|
||||
self.storageVar.trace_add("write",change_selected)
|
||||
self.labelVar.trace_add("write",change_storage)
|
||||
self.label = Label(self, text=label)
|
||||
|
||||
if managerAttrs is not None and "label" in managerAttrs:
|
||||
self.label.pack(managerAttrs["label"])
|
||||
else:
|
||||
self.label.pack()
|
||||
self.selectbox = OptionMenu(self, self.labelVar, *options.keys())
|
||||
|
||||
self.selectbox.config(width=20)
|
||||
self.labelVar.set(managerAttrs["default"] if "default" in managerAttrs else list(options.keys())[0])
|
||||
idx = 0
|
||||
default = self.selectbox.options["values"][idx]
|
||||
if "default" in managerAttrs:
|
||||
default = managerAttrs["default"]
|
||||
labels = self.selectbox.options["labels"]
|
||||
values = self.selectbox.options["values"]
|
||||
if default in values:
|
||||
idx = values.index(default)
|
||||
default = labels[idx]
|
||||
self.labelVar.set(default)
|
||||
self.selectbox["menu"].entryconfigure(idx,label=default)
|
||||
|
||||
if managerAttrs is not None and "selectbox" in managerAttrs:
|
||||
self.selectbox.pack(managerAttrs["selectbox"])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user