Major GUI reorganization

This commit is contained in:
codemann8
2023-03-29 09:58:48 -05:00
parent 28e5b7503d
commit f1f75ec760
19 changed files with 517 additions and 307 deletions

View File

@@ -23,34 +23,41 @@ def loadcliargs(gui, args, settings=None):
# Cycle through each page
for mainpage in options:
subpage = None
_, v = next(iter(options[mainpage].items()))
if isinstance(v, str):
subpage = ""
# Cycle through each subpage (in case of Item Randomizer)
for subpage in options[mainpage]:
for subpage in (options[mainpage] if subpage is None else [subpage]):
# Cycle through each widget
for widget in options[mainpage][subpage]:
if widget in gui.pages[mainpage].pages[subpage].widgets:
for widget in (options[mainpage][subpage] if subpage != "" else options[mainpage]):
page = gui.pages[mainpage].pages[subpage] if subpage != "" else gui.pages[mainpage]
pagewidgets = page.content.customWidgets if mainpage == "custom" else page.content.startingWidgets if mainpage == "startinventory" else page.widgets
if widget in pagewidgets:
thisType = ""
# Get the value and set it
arg = options[mainpage][subpage][widget]
arg = options[mainpage][subpage][widget] if subpage != "" else options[mainpage][widget]
if args[arg] == None:
args[arg] = ""
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
label_ref = mainpage + ('.' + subpage if subpage != "" else '') + '.' + widget
label = fish.translate("gui","gui", label_ref)
if hasattr(pagewidgets[widget],"type"):
thisType = pagewidgets[widget].type
if thisType == "checkbox":
gui.pages[mainpage].pages[subpage].widgets[widget].checkbox.configure(text=label)
pagewidgets[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)
theseOptions = pagewidgets[widget].selectbox.options
pagewidgets[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 + '.' + str(value))
pagewidgets[widget].selectbox.options["labels"][i] = fish.translate("gui","gui", label_ref + '.' + str(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
pagewidgets[widget].selectbox["menu"].entryconfigure(i, label=theseOptions["labels"][i])
pagewidgets[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])
pagewidgets[widget].label.configure(text=label)
pagewidgets[widget].storageVar.set(args[arg])
# If we're on the Game Options page and it's not about Hints
if subpage == "gameoptions" and widget not in ["hints", "collection_rate"]:
# Check if we've got settings