Major GUI reorganization
This commit is contained in:
@@ -56,25 +56,36 @@ SETTINGSTOPROCESS = {
|
||||
"randomizer": {
|
||||
"item": {
|
||||
"hints": "hints",
|
||||
"retro": "retro",
|
||||
"bombbag": "bombbag",
|
||||
"shopsanity": "shopsanity",
|
||||
"pseudoboots": "pseudoboots",
|
||||
"race": "race",
|
||||
|
||||
"worldstate": "mode",
|
||||
"logiclevel": "logic",
|
||||
"goal": "goal",
|
||||
"crystals_gt": "crystals_gt",
|
||||
"crystals_ganon": "crystals_ganon",
|
||||
"weapons": "swords",
|
||||
"itempool": "difficulty",
|
||||
|
||||
"sortingalgo": "algorithm",
|
||||
"accessibility": "accessibility",
|
||||
"restrict_boss_items": "restrict_boss_items",
|
||||
"itemfunction": "item_functionality",
|
||||
"timer": "timer",
|
||||
|
||||
"shopsanity": "shopsanity",
|
||||
"bonk_drops": "bonk_drops",
|
||||
"pottery": "pottery",
|
||||
"colorizepots": "colorizepots",
|
||||
"potshuffle": "shufflepots",
|
||||
"dropshuffle": "dropshuffle",
|
||||
"keydropshuffle": "keydropshuffle",
|
||||
"take_any": "take_any",
|
||||
|
||||
"itempool": "difficulty",
|
||||
"flute_mode": "flute_mode",
|
||||
"bow_mode": "bow_mode",
|
||||
"timer": "timer",
|
||||
"accessibility": "accessibility",
|
||||
"sortingalgo": "algorithm",
|
||||
"beemizer": "beemizer",
|
||||
"restrict_boss_items": "restrict_boss_items"
|
||||
"bombbag": "bombbag"
|
||||
},
|
||||
"overworld": {
|
||||
"overworldshuffle": "ow_shuffle",
|
||||
@@ -83,17 +94,31 @@ SETTINGSTOPROCESS = {
|
||||
"keepsimilar": "ow_keepsimilar",
|
||||
"mixed": "ow_mixed",
|
||||
"whirlpool": "ow_whirlpool",
|
||||
"bonk_drops": "bonk_drops",
|
||||
"overworldflute": "ow_fluteshuffle"
|
||||
},
|
||||
"entrance": {
|
||||
"openpyramid": "openpyramid",
|
||||
"entranceshuffle": "shuffle",
|
||||
"shuffleganon": "shuffleganon",
|
||||
"shufflelinks": "shufflelinks",
|
||||
"shuffletavern": "shuffletavern",
|
||||
"entranceshuffle": "shuffle",
|
||||
"openpyramid": "openpyramid",
|
||||
"overworld_map": "overworld_map",
|
||||
"take_any": "take_any",
|
||||
},
|
||||
"dungeon": {
|
||||
"smallkeyshuffle": "keyshuffle",
|
||||
"mapshuffle": "mapshuffle",
|
||||
"compassshuffle": "compassshuffle",
|
||||
"bigkeyshuffle": "bigkeyshuffle",
|
||||
"key_logic_algorithm": "key_logic_algorithm",
|
||||
"dungeondoorshuffle": "door_shuffle",
|
||||
"dungeonintensity": "intensity",
|
||||
"door_type_mode": "door_type_mode",
|
||||
"trap_door_mode": "trap_door_mode",
|
||||
"decoupledoors": "decoupledoors",
|
||||
"experimental": "experimental",
|
||||
"dungeon_counters": "dungeon_counters",
|
||||
"mixed_travel": "mixed_travel",
|
||||
"standardize_palettes": "standardize_palettes"
|
||||
},
|
||||
"enemizer": {
|
||||
"enemyshuffle": "shuffleenemies",
|
||||
@@ -101,27 +126,6 @@ SETTINGSTOPROCESS = {
|
||||
"enemydamage": "enemy_damage",
|
||||
"enemyhealth": "enemy_health"
|
||||
},
|
||||
"dungeon": {
|
||||
"mapshuffle": "mapshuffle",
|
||||
"compassshuffle": "compassshuffle",
|
||||
"smallkeyshuffle": "keyshuffle",
|
||||
"bigkeyshuffle": "bigkeyshuffle",
|
||||
"dungeondoorshuffle": "door_shuffle",
|
||||
"dungeonintensity": "intensity",
|
||||
"door_type_mode": "door_type_mode",
|
||||
"trap_door_mode": "trap_door_mode",
|
||||
"key_logic_algorithm": "key_logic_algorithm",
|
||||
"decoupledoors": "decoupledoors",
|
||||
"keydropshuffle": "keydropshuffle",
|
||||
"dropshuffle": "dropshuffle",
|
||||
"pottery": "pottery",
|
||||
"colorizepots": "colorizepots",
|
||||
"potshuffle": "shufflepots",
|
||||
"experimental": "experimental",
|
||||
"dungeon_counters": "dungeon_counters",
|
||||
"mixed_travel": "mixed_travel",
|
||||
"standardize_palettes": "standardize_palettes"
|
||||
},
|
||||
"gameoptions": {
|
||||
"nobgm": "disablemusic",
|
||||
"quickswap": "quickswap",
|
||||
@@ -141,12 +145,15 @@ SETTINGSTOPROCESS = {
|
||||
"createrom": "create_rom",
|
||||
"calcplaythrough": "calc_playthrough",
|
||||
"print_custom_yaml": "print_custom_yaml",
|
||||
"usestartinventory": "usestartinventory",
|
||||
"usecustompool": "custom",
|
||||
"race": "race",
|
||||
"saveonexit": "saveonexit"
|
||||
}
|
||||
},
|
||||
"startinventory": {
|
||||
"usestartinventory": "usestartinventory"
|
||||
},
|
||||
"custom": {
|
||||
"usecustompool": "custom"
|
||||
},
|
||||
"bottom": {
|
||||
"content": {
|
||||
"names": "names",
|
||||
|
||||
@@ -203,13 +203,19 @@ def create_guiargs(parent):
|
||||
|
||||
# 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]:
|
||||
for widget in (options[mainpage][subpage] if subpage != "" else options[mainpage]):
|
||||
# Get the value and set it
|
||||
arg = options[mainpage][subpage][widget]
|
||||
setattr(guiargs, arg, parent.pages[mainpage].pages[subpage].widgets[widget].storageVar.get())
|
||||
arg = options[mainpage][subpage][widget] if subpage != "" else options[mainpage][widget]
|
||||
page = parent.pages[mainpage].pages[subpage] if subpage != "" else parent.pages[mainpage]
|
||||
pagewidgets = page.content.customWidgets if mainpage == "custom" else page.content.startingWidgets if mainpage == "startinventory" else page.widgets
|
||||
setattr(guiargs, arg, pagewidgets[widget].storageVar.get())
|
||||
|
||||
# Get EnemizerCLI setting
|
||||
guiargs.enemizercli = parent.pages["randomizer"].pages["enemizer"].widgets["enemizercli"].storageVar.get()
|
||||
@@ -226,7 +232,7 @@ def create_guiargs(parent):
|
||||
guiargs.customizer = customizer_value
|
||||
|
||||
# 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["custom"].content.customWidgets["usecustompool"].storageVar.get())
|
||||
|
||||
# Get Seed ID
|
||||
guiargs.seed = None
|
||||
@@ -285,7 +291,7 @@ def create_guiargs(parent):
|
||||
guiargs.dropshuffle = 1
|
||||
guiargs.pottery = 'keys' if guiargs.pottery == 'none' else guiargs.pottery
|
||||
|
||||
if guiargs.retro or guiargs.mode == 'retro':
|
||||
if (hasattr(guiargs, 'retro') and guiargs.retro) or guiargs.mode == 'retro':
|
||||
if guiargs.bow_mode == 'progressive':
|
||||
guiargs.bow_mode = 'retro'
|
||||
elif guiargs.bow_mode == 'silvers':
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, Frame, N, E, W, LEFT, X, VERTICAL, Y
|
||||
from tkinter import ttk, Frame, N, E, W, LEFT, TOP, X, VERTICAL, Y
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -11,10 +11,10 @@ def custom_page(top,parent):
|
||||
|
||||
# Create uniform list columns
|
||||
def create_list_frame(parent, framename):
|
||||
parent.frames[framename] = Frame(parent)
|
||||
parent.frames[framename].pack(side=LEFT, padx=(0,0), anchor=N)
|
||||
parent.frames[framename].thisRow = 0
|
||||
parent.frames[framename].thisCol = 0
|
||||
self.frames[framename] = Frame(parent)
|
||||
self.frames[framename].pack(side=LEFT, padx=(0,0), anchor=N)
|
||||
self.frames[framename].thisRow = 0
|
||||
self.frames[framename].thisCol = 0
|
||||
|
||||
# Create a vertical rule to help with splitting columns visually
|
||||
def create_vertical_rule(num=1):
|
||||
@@ -34,6 +34,8 @@ def custom_page(top,parent):
|
||||
|
||||
# Custom Item Pool option sections
|
||||
self.frames = {}
|
||||
self.frames["customHeader"] = Frame(self)
|
||||
self.frames["customHeader"].pack(side=TOP, anchor=W)
|
||||
# Create 5 columns with 2 vertical rules in between each
|
||||
create_list_frame(self, "itemList1")
|
||||
create_vertical_rule(2)
|
||||
@@ -50,9 +52,14 @@ def custom_page(top,parent):
|
||||
with open(os.path.join("resources", "app", "gui", "custom", "overview", "widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, theseWidgets, self.frames[framename])
|
||||
for key in dictWidgets:
|
||||
self.customWidgets[key] = dictWidgets[key]
|
||||
if framename in self.frames:
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, theseWidgets, self.frames[framename])
|
||||
for key in dictWidgets:
|
||||
self.customWidgets[key] = dictWidgets[key]
|
||||
if framename == "customHeader":
|
||||
packAttrs = {"anchor":W}
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, theseWidgets[key])
|
||||
self.customWidgets[key].pack(packAttrs)
|
||||
|
||||
# Load Custom Item Pool settings from settings file
|
||||
for key in CONST.CUSTOMITEMS:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, Frame, Label, E, W, LEFT, RIGHT
|
||||
from tkinter import ttk, Frame, Label, E, W, LEFT, RIGHT, TOP
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -16,8 +16,8 @@ def dungeon_page(parent):
|
||||
self.frames["keysanity"].pack(anchor=W)
|
||||
|
||||
## Dungeon Item Shuffle
|
||||
mscbLabel = Label(self.frames["keysanity"], text="Shuffle: ")
|
||||
mscbLabel.pack(side=LEFT)
|
||||
mscbLabel = Label(self.frames["keysanity"], text="Dungeon Items: ")
|
||||
mscbLabel.pack(side=TOP, anchor=W)
|
||||
|
||||
# Load Dungeon Shuffle option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
@@ -28,7 +28,9 @@ def dungeon_page(parent):
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, myDict, self.frames["keysanity"])
|
||||
for key in dictWidgets:
|
||||
self.widgets[key] = dictWidgets[key]
|
||||
self.widgets[key].pack(side=LEFT)
|
||||
packAttrs = {"side":LEFT}
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, myDict[key])
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
# These get split left & right
|
||||
self.frames["widgets"] = Frame(self)
|
||||
@@ -39,6 +41,8 @@ def dungeon_page(parent):
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, myDict, self.frames["widgets"])
|
||||
for key in dictWidgets:
|
||||
self.widgets[key] = dictWidgets[key]
|
||||
self.widgets[key].pack(anchor=W)
|
||||
packAttrs = {"anchor":W}
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, myDict[key])
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
return self
|
||||
|
||||
@@ -26,9 +26,8 @@ def entrando_page(parent):
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, theseWidgets, self.frames[framename])
|
||||
for key in dictWidgets:
|
||||
self.widgets[key] = dictWidgets[key]
|
||||
packAttrs = {"anchor":E}
|
||||
if self.widgets[key].type == "checkbox" or key in ["openpyramid", "take_any"]:
|
||||
packAttrs["anchor"] = W
|
||||
packAttrs = {"anchor":W}
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, theseWidgets[key])
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
return self
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, Frame, E, W, LEFT, RIGHT, Label
|
||||
from tkinter import ttk, font, Frame, E, W, NW, TOP, LEFT, RIGHT, Y, Label
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -17,13 +17,39 @@ def item_page(parent):
|
||||
self.frames["checkboxes"] = Frame(self)
|
||||
self.frames["checkboxes"].pack(anchor=W)
|
||||
|
||||
various_options = Label(self.frames["checkboxes"], text="")
|
||||
various_options = Label(self.frames["checkboxes"], text="Options: ")
|
||||
various_options.pack(side=LEFT)
|
||||
|
||||
self.frames["leftItemFrame"] = Frame(self)
|
||||
self.frames["rightItemFrame"] = Frame(self)
|
||||
self.frames["mainFrame"] = Frame(self)
|
||||
self.frames["mainFrame"].pack(side=TOP, pady=(20,0))
|
||||
|
||||
self.frames["poolFrame"] = Frame(self)
|
||||
self.frames["poolFrame"].pack(fill=Y)
|
||||
|
||||
self.frames["leftItemFrame"] = Frame(self.frames["mainFrame"])
|
||||
self.frames["leftItemFrame"].pack(side=LEFT)
|
||||
self.frames["rightItemFrame"] = Frame(self.frames["mainFrame"])
|
||||
self.frames["rightItemFrame"].pack(side=RIGHT)
|
||||
|
||||
self.frames["leftPoolContainer"] = Frame(self.frames["poolFrame"])
|
||||
self.frames["leftPoolContainer"].pack(side=LEFT, padx=(0,20))
|
||||
|
||||
base_font = font.nametofont('TkTextFont').actual()
|
||||
underline_font = f'"{base_font["family"]}" {base_font["size"]} underline'
|
||||
various_options = Label(self.frames["leftPoolContainer"], text="Pool Expansions", font=underline_font)
|
||||
various_options.pack(side=TOP, pady=(20,0))
|
||||
|
||||
self.frames["leftPoolHeader"] = Frame(self.frames["leftPoolContainer"])
|
||||
self.frames["leftPoolHeader"].pack(side=TOP, anchor=W)
|
||||
|
||||
self.frames["leftPoolFrame"] = Frame(self.frames["leftPoolContainer"])
|
||||
self.frames["leftPoolFrame"].pack(side=LEFT, fill=Y)
|
||||
|
||||
self.frames["rightPoolFrame"] = Frame(self.frames["poolFrame"])
|
||||
self.frames["rightPoolFrame"].pack(side=RIGHT)
|
||||
|
||||
various_options = Label(self.frames["rightPoolFrame"], text="Pool Modifications", font=underline_font)
|
||||
various_options.pack(side=TOP, pady=(20,0))
|
||||
|
||||
# Load Item Randomizer option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
@@ -36,8 +62,15 @@ def item_page(parent):
|
||||
for key in dictWidgets:
|
||||
self.widgets[key] = dictWidgets[key]
|
||||
packAttrs = {"anchor":E}
|
||||
if self.widgets[key].type == "checkbox":
|
||||
if self.widgets[key].type == "checkbox" or framename == "leftPoolFrame":
|
||||
packAttrs["anchor"] = W
|
||||
if framename == "checkboxes":
|
||||
packAttrs["side"] = LEFT
|
||||
packAttrs["padx"] = (10,0)
|
||||
elif framename == "leftPoolHeader":
|
||||
packAttrs["side"] = LEFT
|
||||
packAttrs["padx"] = (0,20)
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, theseWidgets[key])
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
return self
|
||||
|
||||
@@ -15,33 +15,24 @@ def overworld_page(parent):
|
||||
|
||||
# Load Overworld Shuffle option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
self.frames["topOverworldFrame"] = Frame(self)
|
||||
self.frames["leftOverworldFrame"] = Frame(self)
|
||||
self.frames["rightOverworldFrame"] = Frame(self)
|
||||
|
||||
self.frames["topOverworldFrame"].pack(side=TOP, anchor=NW)
|
||||
self.frames["leftOverworldFrame"].pack(side=LEFT, anchor=NW, fill=Y)
|
||||
self.frames["rightOverworldFrame"].pack(anchor=NW, fill=Y)
|
||||
|
||||
shuffleLabel = Label(self.frames["topOverworldFrame"], text="Shuffle: ")
|
||||
shuffleLabel.pack(side=LEFT)
|
||||
|
||||
with open(os.path.join("resources","app","gui","randomize","overworld","widgets.json")) as overworldWidgets:
|
||||
myDict = json.load(overworldWidgets)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
if not theseWidgets:
|
||||
continue
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, theseWidgets, self.frames[framename])
|
||||
for key in dictWidgets:
|
||||
self.widgets[key] = dictWidgets[key]
|
||||
packAttrs = {"anchor":E}
|
||||
if key == "terrain":
|
||||
packAttrs = {"anchor":W, "pady":(3,0)}
|
||||
elif key == "keepsimilar":
|
||||
packAttrs = {"anchor":W, "pady":(6,0)}
|
||||
elif key == "overworldflute":
|
||||
packAttrs["pady"] = (20,0)
|
||||
elif key in ["mixed", "whirlpool"]:
|
||||
packAttrs = {"anchor":W, "padx":(79,0)}
|
||||
|
||||
packAttrs = {"anchor":W}
|
||||
if self.widgets[key].type != "checkbox":
|
||||
packAttrs["anchor"] = E
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, theseWidgets[key])
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
return self
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, Frame, N, E, W, LEFT, X, VERTICAL, Y
|
||||
from tkinter import ttk, Frame, N, E, W, LEFT, TOP, X, VERTICAL, Y
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -11,10 +11,10 @@ def startinventory_page(top,parent):
|
||||
|
||||
# Create uniform list columns
|
||||
def create_list_frame(parent, framename):
|
||||
parent.frames[framename] = Frame(parent)
|
||||
parent.frames[framename].pack(side=LEFT, padx=(0,0), anchor=N)
|
||||
parent.frames[framename].thisRow = 0
|
||||
parent.frames[framename].thisCol = 0
|
||||
self.frames[framename] = Frame(parent)
|
||||
self.frames[framename].pack(side=LEFT, padx=(0,0), anchor=N)
|
||||
self.frames[framename].thisRow = 0
|
||||
self.frames[framename].thisCol = 0
|
||||
|
||||
# Create a vertical rule to help with splitting columns visually
|
||||
def create_vertical_rule(num=1):
|
||||
@@ -34,6 +34,8 @@ def startinventory_page(top,parent):
|
||||
|
||||
# Starting Inventory option sections
|
||||
self.frames = {}
|
||||
self.frames["startHeader"] = Frame(self)
|
||||
self.frames["startHeader"].pack(side=TOP, anchor=W)
|
||||
# Create 5 columns with 2 vertical rules in between each
|
||||
create_list_frame(self,"itemList1")
|
||||
create_vertical_rule(2)
|
||||
@@ -55,9 +57,14 @@ def startinventory_page(top,parent):
|
||||
if key in myDict[thisList]:
|
||||
del myDict[thisList][key]
|
||||
for framename,theseWidgets in myDict.items():
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, theseWidgets, self.frames[framename])
|
||||
for key in dictWidgets:
|
||||
self.startingWidgets[key] = dictWidgets[key]
|
||||
if framename in self.frames:
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, theseWidgets, self.frames[framename])
|
||||
for key in dictWidgets:
|
||||
self.startingWidgets[key] = dictWidgets[key]
|
||||
if framename == "startHeader":
|
||||
packAttrs = {"anchor":W}
|
||||
packAttrs = widgets.add_padding_from_config(packAttrs, theseWidgets[key])
|
||||
self.startingWidgets[key].pack(packAttrs)
|
||||
|
||||
# Load Custom Starting Inventory settings from settings file, ignoring ones to be excluded
|
||||
for key in CONST.CUSTOMITEMS:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, Spinbox, StringVar, LEFT, RIGHT, X
|
||||
from tkinter import messagebox, Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, Spinbox, StringVar, LEFT, RIGHT, X
|
||||
from source.classes.Empty import Empty
|
||||
|
||||
# Override Spinbox to include mousewheel support for changing value
|
||||
@@ -16,7 +16,7 @@ class mySpinbox(Spinbox):
|
||||
self.invoke('buttonup')
|
||||
|
||||
# Make a Checkbutton with a label
|
||||
def make_checkbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
def make_checkbox(self, parent, label, storageVar, manager, managerAttrs, config):
|
||||
self = Frame(parent)
|
||||
self.storageVar = storageVar
|
||||
if managerAttrs is not None and "default" in managerAttrs:
|
||||
@@ -25,7 +25,10 @@ def make_checkbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
elif managerAttrs["default"] == "false" or managerAttrs["default"] == False:
|
||||
self.storageVar.set(False)
|
||||
del managerAttrs["default"]
|
||||
self.checkbox = Checkbutton(self, text=label, variable=self.storageVar)
|
||||
options = {"text":label, "variable":self.storageVar}
|
||||
if config and "command" in config:
|
||||
options.update({"command":lambda m=config["command"]: widget_command(self, m)})
|
||||
self.checkbox = Checkbutton(self, options)
|
||||
if managerAttrs is not None:
|
||||
self.checkbox.pack(managerAttrs)
|
||||
else:
|
||||
@@ -43,7 +46,11 @@ def make_selectbox(self, parent, label, options, storageVar, manager, managerAtt
|
||||
|
||||
self.labelVar = StringVar()
|
||||
self.storageVar = storageVar
|
||||
self.selectbox = OptionMenu(self, self.labelVar, *labels)
|
||||
if config and "command" in config:
|
||||
self.command = config["command"]
|
||||
self.selectbox = OptionMenu(self, self.labelVar, *labels, command=lambda m: widget_command(self, self.command))
|
||||
else:
|
||||
self.selectbox = OptionMenu(self, self.labelVar, *labels)
|
||||
self.selectbox.options = {}
|
||||
|
||||
if isinstance(options,dict):
|
||||
@@ -96,7 +103,7 @@ def make_selectbox(self, parent, label, options, storageVar, manager, managerAtt
|
||||
else:
|
||||
self.label.pack(side=LEFT)
|
||||
|
||||
self.selectbox.config(width=config['width'] if config and config['width'] else 20)
|
||||
self.selectbox.config(width=config['width'] if config and 'width' in config else 20)
|
||||
idx = 0
|
||||
default = self.selectbox.options["values"][idx]
|
||||
if managerAttrs is not None and "default" in managerAttrs:
|
||||
@@ -181,7 +188,7 @@ def make_widget(self, type, parent, label, storageVar=None, manager=None, manage
|
||||
if type == "checkbox":
|
||||
if thisStorageVar is None:
|
||||
thisStorageVar = IntVar()
|
||||
widget = make_checkbox(self, parent, label, thisStorageVar, manager, managerAttrs)
|
||||
widget = make_checkbox(self, parent, label, thisStorageVar, manager, managerAttrs, config)
|
||||
elif type == "selectbox":
|
||||
if thisStorageVar is None:
|
||||
thisStorageVar = StringVar()
|
||||
@@ -221,3 +228,51 @@ def make_widgets_from_dict(self, defns, parent):
|
||||
for key,defn in defns.items():
|
||||
widgets[key] = make_widget_from_dict(self, defn, parent)
|
||||
return widgets
|
||||
|
||||
# Add padding to widget
|
||||
def add_padding_from_config(packAttrs, defn):
|
||||
if "config" in defn:
|
||||
config = defn["config"]
|
||||
if 'padx' in config:
|
||||
packAttrs["padx"] = config['padx']
|
||||
if 'pady' in config:
|
||||
packAttrs["pady"] = config['pady']
|
||||
return packAttrs
|
||||
|
||||
# Callback when a widget issues a command
|
||||
def widget_command(widget, command=""):
|
||||
root = widget.winfo_toplevel()
|
||||
text_output = ""
|
||||
if command == "worldstate":
|
||||
if widget.storageVar.get() == 'retro':
|
||||
temp_widget = root.pages["randomizer"].pages["dungeon"].widgets["smallkeyshuffle"]
|
||||
text_output += f'\n {temp_widget.label.cget("text")}'
|
||||
temp_widget.storageVar.set('universal')
|
||||
|
||||
temp_widget = root.pages["randomizer"].pages["item"].widgets["bow_mode"]
|
||||
text_output += f'\n {temp_widget.label.cget("text")}'
|
||||
if temp_widget.storageVar.get() == 'progressive':
|
||||
temp_widget.storageVar.set('retro')
|
||||
elif temp_widget.storageVar.get() == 'silvers':
|
||||
temp_widget.storageVar.set('retro_silvers')
|
||||
|
||||
temp_widget = root.pages["randomizer"].pages["item"].widgets["take_any"]
|
||||
text_output += f'\n {temp_widget.label.cget("text")}'
|
||||
if temp_widget.storageVar.get() == 'none':
|
||||
temp_widget.storageVar.set('random')
|
||||
|
||||
widget.storageVar.set('open')
|
||||
messagebox.showinfo('', f'The following settings were changed:{text_output}')
|
||||
elif command == "keydropshuffle":
|
||||
if widget.storageVar.get() > 0:
|
||||
temp_widget = root.pages["randomizer"].pages["item"].widgets["pottery"]
|
||||
text_output += f'\n {temp_widget.label.cget("text")}'
|
||||
if temp_widget.storageVar.get() == 'none':
|
||||
temp_widget.storageVar.set('keys')
|
||||
|
||||
temp_widget = root.pages["randomizer"].pages["item"].widgets["dropshuffle"]
|
||||
temp_widget.storageVar.set(1)
|
||||
text_output += f'\n {temp_widget.checkbox.cget("text")}'
|
||||
|
||||
widget.storageVar.set(0)
|
||||
messagebox.showinfo('', f'The following settings were changed:{text_output}')
|
||||
|
||||
Reference in New Issue
Block a user