Pretty Item Rando options

This commit is contained in:
Mike A. Trethewey
2020-02-08 23:59:58 -08:00
parent cc8ce4a623
commit 18e0008a99
4 changed files with 286 additions and 126 deletions

View File

@@ -35,19 +35,19 @@ def bottom_frame(self,parent,args=None):
guiargs.names = parent.multiworldWindow.namesVar.get() guiargs.names = parent.multiworldWindow.namesVar.get()
guiargs.seed = int(parent.farBottomFrame.seedVar.get()) if parent.farBottomFrame.seedVar.get() else None guiargs.seed = int(parent.farBottomFrame.seedVar.get()) if parent.farBottomFrame.seedVar.get() else None
guiargs.count = int(parent.farBottomFrame.countVar.get()) if parent.farBottomFrame.countVar.get() != '1' else None guiargs.count = int(parent.farBottomFrame.countVar.get()) if parent.farBottomFrame.countVar.get() != '1' else None
guiargs.mode = parent.itemWindow.modeVar.get() guiargs.mode = parent.itemWindow.itemWidgets["worldState"].storageVar.get()
guiargs.logic = parent.itemWindow.logicVar.get() guiargs.logic = parent.itemWindow.itemWidgets["logicLevel"].storageVar.get()
guiargs.goal = parent.itemWindow.goalVar.get() guiargs.goal = parent.itemWindow.itemWidgets["goal"].storageVar.get()
guiargs.crystals_gt = parent.itemWindow.crystalsGTVar.get() guiargs.crystals_gt = parent.itemWindow.itemWidgets["crystals_gt"].storageVar.get()
guiargs.crystals_ganon = parent.itemWindow.crystalsGanonVar.get() guiargs.crystals_ganon = parent.itemWindow.itemWidgets["crystals_ganon"].storageVar.get()
guiargs.swords = parent.itemWindow.swordVar.get() guiargs.swords = parent.itemWindow.itemWidgets["weapons"].storageVar.get()
guiargs.difficulty = parent.itemWindow.difficultyVar.get() guiargs.difficulty = parent.itemWindow.itemWidgets["itempool"].storageVar.get()
guiargs.item_functionality = parent.itemWindow.itemfunctionVar.get() guiargs.item_functionality = parent.itemWindow.itemWidgets["itemfunction"].storageVar.get()
guiargs.timer = parent.itemWindow.timerVar.get() guiargs.timer = parent.itemWindow.itemWidgets["timer"].storageVar.get()
guiargs.progressive = parent.itemWindow.progressiveVar.get() guiargs.progressive = parent.itemWindow.itemWidgets["progressives"].storageVar.get()
guiargs.accessibility = parent.itemWindow.accessibilityVar.get() guiargs.accessibility = parent.itemWindow.itemWidgets["accessibility"].storageVar.get()
guiargs.algorithm = parent.itemWindow.algorithmVar.get() guiargs.algorithm = parent.itemWindow.itemWidgets["sortingalgo"].storageVar.get()
guiargs.shuffle = parent.entrandoWindow.shuffleVar.get() guiargs.shuffle = parent.entrandoWindow.shuffleVar.get()
guiargs.door_shuffle = parent.dungeonRandoWindow.doorShuffleVar.get() guiargs.door_shuffle = parent.dungeonRandoWindow.doorShuffleVar.get()
guiargs.heartbeep = parent.gameOptionsWindow.heartbeepVar.get() guiargs.heartbeep = parent.gameOptionsWindow.heartbeepVar.get()
@@ -61,7 +61,7 @@ def bottom_frame(self,parent,args=None):
guiargs.compassshuffle = bool(parent.dungeonRandoWindow.compassshuffleVar.get()) guiargs.compassshuffle = bool(parent.dungeonRandoWindow.compassshuffleVar.get())
guiargs.keyshuffle = bool(parent.dungeonRandoWindow.keyshuffleVar.get()) guiargs.keyshuffle = bool(parent.dungeonRandoWindow.keyshuffleVar.get())
guiargs.bigkeyshuffle = bool(parent.dungeonRandoWindow.bigkeyshuffleVar.get()) guiargs.bigkeyshuffle = bool(parent.dungeonRandoWindow.bigkeyshuffleVar.get())
guiargs.retro = bool(parent.itemWindow.retroVar.get()) guiargs.retro = bool(parent.itemWindow.itemWidgets["retro"].storageVar.get())
guiargs.quickswap = bool(parent.gameOptionsWindow.quickSwapVar.get()) guiargs.quickswap = bool(parent.gameOptionsWindow.quickSwapVar.get())
guiargs.disablemusic = bool(parent.gameOptionsWindow.disableMusicVar.get()) guiargs.disablemusic = bool(parent.gameOptionsWindow.disableMusicVar.get())
guiargs.ow_palettes = parent.gameOptionsWindow.owPalettesVar.get() guiargs.ow_palettes = parent.gameOptionsWindow.owPalettesVar.get()

View File

@@ -10,7 +10,7 @@ def loadcliargs(gui,args):
gui.dungeonRandoWindow.compassshuffleVar.set(args.compassshuffle) gui.dungeonRandoWindow.compassshuffleVar.set(args.compassshuffle)
gui.dungeonRandoWindow.keyshuffleVar.set(args.keyshuffle) gui.dungeonRandoWindow.keyshuffleVar.set(args.keyshuffle)
gui.dungeonRandoWindow.bigkeyshuffleVar.set(args.bigkeyshuffle) gui.dungeonRandoWindow.bigkeyshuffleVar.set(args.bigkeyshuffle)
gui.itemWindow.retroVar.set(args.retro) gui.itemWindow.itemWidgets["retro"].storageVar.set(args.retro)
gui.entrandoWindow.openpyramidVar.set(args.openpyramid) gui.entrandoWindow.openpyramidVar.set(args.openpyramid)
gui.gameOptionsWindow.quickSwapVar.set(int(args.quickswap)) gui.gameOptionsWindow.quickSwapVar.set(int(args.quickswap))
gui.gameOptionsWindow.disableMusicVar.set(int(args.disablemusic)) gui.gameOptionsWindow.disableMusicVar.set(int(args.disablemusic))
@@ -20,23 +20,23 @@ def loadcliargs(gui,args):
gui.farBottomFrame.countVar.set(str(args.count)) gui.farBottomFrame.countVar.set(str(args.count))
if args.seed: if args.seed:
gui.farBottomFrame.seedVar.set(str(args.seed)) gui.farBottomFrame.seedVar.set(str(args.seed))
gui.itemWindow.modeVar.set(args.mode) gui.itemWindow.itemWidgets["worldState"].storageVar.set(args.mode)
gui.itemWindow.swordVar.set(args.swords) gui.itemWindow.itemWidgets["weapons"].storageVar.set(args.swords)
gui.itemWindow.difficultyVar.set(args.difficulty) gui.itemWindow.itemWidgets["itempool"].storageVar.set(args.difficulty)
gui.itemWindow.itemfunctionVar.set(args.item_functionality) gui.itemWindow.itemWidgets["itemfunction"].storageVar.set(args.item_functionality)
gui.itemWindow.timerVar.set(args.timer) gui.itemWindow.itemWidgets["timer"].storageVar.set(args.timer)
gui.itemWindow.progressiveVar.set(args.progressive) gui.itemWindow.itemWidgets["progressives"].storageVar.set(args.progressive)
gui.itemWindow.accessibilityVar.set(args.accessibility) gui.itemWindow.itemWidgets["accessibility"].storageVar.set(args.accessibility)
gui.itemWindow.goalVar.set(args.goal) gui.itemWindow.itemWidgets["goal"].storageVar.set(args.goal)
gui.itemWindow.crystalsGTVar.set(args.crystals_gt) gui.itemWindow.itemWidgets["crystals_gt"].storageVar.set(args.crystals_gt)
gui.itemWindow.crystalsGanonVar.set(args.crystals_ganon) gui.itemWindow.itemWidgets["crystals_ganon"].storageVar.set(args.crystals_ganon)
gui.itemWindow.algorithmVar.set(args.algorithm) gui.itemWindow.itemWidgets["sortingalgo"].storageVar.set(args.algorithm)
gui.entrandoWindow.shuffleVar.set(args.shuffle) gui.entrandoWindow.shuffleVar.set(args.shuffle)
gui.dungeonRandoWindow.doorShuffleVar.set(args.door_shuffle) gui.dungeonRandoWindow.doorShuffleVar.set(args.door_shuffle)
gui.gameOptionsWindow.heartcolorVar.set(args.heartcolor) gui.gameOptionsWindow.heartcolorVar.set(args.heartcolor)
gui.gameOptionsWindow.heartbeepVar.set(args.heartbeep) gui.gameOptionsWindow.heartbeepVar.set(args.heartbeep)
gui.gameOptionsWindow.fastMenuVar.set(args.fastmenu) gui.gameOptionsWindow.fastMenuVar.set(args.fastmenu)
gui.itemWindow.logicVar.set(args.logic) gui.itemWindow.itemWidgets["logicLevel"].storageVar.set(args.logic)
gui.generationSetupWindow.romVar.set(args.rom) gui.generationSetupWindow.romVar.set(args.rom)
gui.entrandoWindow.shuffleGanonVar.set(args.shuffleganon) gui.entrandoWindow.shuffleGanonVar.set(args.shuffleganon)
gui.gameOptionsWindow.hintsVar.set(args.hints) gui.gameOptionsWindow.hintsVar.set(args.hints)

View File

@@ -1,4 +1,5 @@
from tkinter import ttk, IntVar, StringVar, Checkbutton, Frame, Label, OptionMenu, E, W, LEFT, RIGHT from tkinter import ttk, IntVar, StringVar, Checkbutton, Frame, Label, OptionMenu, E, W, LEFT, RIGHT
import gui.widgets as widgets
def item_page(parent): def item_page(parent):
# Item Randomizer # Item Randomizer
@@ -6,9 +7,16 @@ def item_page(parent):
# Item Randomizer options # Item Randomizer options
## Retro (eventually needs to become a World State) ## Retro (eventually needs to become a World State)
self.retroVar = IntVar() self.itemWidgets = {}
retroCheckbutton = Checkbutton(self, text="Retro mode (universal keys)", variable=self.retroVar)
retroCheckbutton.pack(anchor=W) self.itemWidgets["retro"] = widgets.make_widget(
self,
"checkbox",
self,
"Retro mode (universal keys)",
None
)
self.itemWidgets["retro"].pack(anchor=W)
leftItemFrame = Frame(self) leftItemFrame = Frame(self)
rightItemFrame = Frame(self) rightItemFrame = Frame(self)
@@ -16,124 +24,215 @@ def item_page(parent):
rightItemFrame.pack(side=RIGHT) rightItemFrame.pack(side=RIGHT)
## World State ## World State
modeFrame = Frame(leftItemFrame) key = "worldState"
self.modeVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.modeVar.set('open') self,
modeOptionMenu = OptionMenu(modeFrame, self.modeVar, 'standard', 'open', 'inverted') "selectbox",
modeOptionMenu.pack(side=RIGHT) leftItemFrame,
modeLabel = Label(modeFrame, text='World State') "World State",
modeLabel.pack(side=LEFT) None,
modeFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}, "default": "Open"},
{
"Standard": "standard",
"Open": "open",
"Inverted": "inverted"
}
)
self.itemWidgets[key].pack(anchor=E)
## Logic Level ## Logic Level
logicFrame = Frame(leftItemFrame) key = "logicLevel"
self.logicVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.logicVar.set('noglitches') self,
logicOptionMenu = OptionMenu(logicFrame, self.logicVar, 'noglitches', 'minorglitches', 'nologic') "selectbox",
logicOptionMenu.pack(side=RIGHT) leftItemFrame,
logicLabel = Label(logicFrame, text='Game Logic') "Logic Level",
logicLabel.pack(side=LEFT) None,
logicFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"No Glitches": "noglitches",
"Minor Glitches": "minorglitches",
"No Logic": "nologic"
}
)
self.itemWidgets[key].pack(anchor=E)
## Goal ## Goal
goalFrame = Frame(leftItemFrame) key = "goal"
self.goalVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.goalVar.set('ganon') self,
goalOptionMenu = OptionMenu(goalFrame, self.goalVar, 'ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals') "selectbox",
goalOptionMenu.pack(side=RIGHT) leftItemFrame,
goalLabel = Label(goalFrame, text='Goal') "Goal",
goalLabel.pack(side=LEFT) None,
goalFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"Defeat Ganon": "ganon",
"Master Sword Pedestal": "pedestal",
"All Dungeons": "dungeons",
"Triforce Hunt": "triforcehunt",
"Crystals": "crystals"
}
)
self.itemWidgets[key].pack(anchor=E)
## Number of crystals to open GT ## Number of crystals to open GT
crystalsGTFrame = Frame(leftItemFrame) key = "crystals_gt"
self.crystalsGTVar = StringVar() keys = [*map(str,range(0,7+1)),"Random"]
self.crystalsGTVar.set('7') vals = [*map(str,range(0,7+1)),"random"]
crystalsGTOptionMenu = OptionMenu(crystalsGTFrame, self.crystalsGTVar, '0', '1', '2', '3', '4', '5', '6', '7', 'random') options = {keys[i]: vals[i] for i in range(len(keys))}
crystalsGTOptionMenu.pack(side=RIGHT) self.itemWidgets[key] = widgets.make_widget(
crystalsGTLabel = Label(crystalsGTFrame, text='Crystals to open Ganon\'s Tower') self,
crystalsGTLabel.pack(side=LEFT) "selectbox",
crystalsGTFrame.pack(anchor=E) leftItemFrame,
"Crystals to open GT",
None,
{"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
options
)
self.itemWidgets[key].pack(anchor=E)
## Number of crystals to damage Ganon ## Number of crystals to damage Ganon
crystalsGanonFrame = Frame(leftItemFrame) key = "crystals_ganon"
self.crystalsGanonVar = StringVar() keys = [*map(str,range(0,7+1)),"Random"]
self.crystalsGanonVar.set('7') vals = [*map(str,range(0,7+1)),"random"]
crystalsGanonOptionMenu = OptionMenu(crystalsGanonFrame, self.crystalsGanonVar, '0', '1', '2', '3', '4', '5', '6', '7', 'random') options = {keys[i]: vals[i] for i in range(len(keys))}
crystalsGanonOptionMenu.pack(side=RIGHT) self.itemWidgets[key] = widgets.make_widget(
crystalsGanonLabel = Label(crystalsGanonFrame, text='Crystals to fight Ganon') self,
crystalsGanonLabel.pack(side=LEFT) "selectbox",
crystalsGanonFrame.pack(anchor=E) leftItemFrame,
"Crystals to harm Ganon",
None,
{"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
options
)
self.itemWidgets[key].pack(anchor=E)
## Weapons ## Weapons
swordFrame = Frame(leftItemFrame) key = "weapons"
self.swordVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.swordVar.set('random') self,
swordOptionMenu = OptionMenu(swordFrame, self.swordVar, 'random', 'assured', 'swordless', 'vanilla') "selectbox",
swordOptionMenu.pack(side=RIGHT) leftItemFrame,
swordLabel = Label(swordFrame, text='Sword availability') "Weapons",
swordLabel.pack(side=LEFT) None,
swordFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"Randomized": "random",
"Assured": "assured",
"Swordless": "swordless",
"Vanilla": "vanilla"
}
)
self.itemWidgets[key].pack(anchor=E)
## Item Pool ## Item Pool
difficultyFrame = Frame(rightItemFrame) key = "itempool"
self.difficultyVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.difficultyVar.set('normal') self,
difficultyOptionMenu = OptionMenu(difficultyFrame, self.difficultyVar, 'normal', 'hard', 'expert') "selectbox",
difficultyOptionMenu.pack(side=RIGHT) rightItemFrame,
difficultyLabel = Label(difficultyFrame, text='Difficulty: item pool') "Item Pool",
difficultyLabel.pack(side=LEFT) None,
difficultyFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"Normal": "normal",
"Hard": "hard",
"Expert": "expert"
}
)
self.itemWidgets[key].pack(anchor=E)
## Item Functionality ## Item Functionality
itemfunctionFrame = Frame(rightItemFrame) key = "itemfunction"
self.itemfunctionVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.itemfunctionVar.set('normal') self,
itemfunctionOptionMenu = OptionMenu(itemfunctionFrame, self.itemfunctionVar, 'normal', 'hard', 'expert') "selectbox",
itemfunctionOptionMenu.pack(side=RIGHT) rightItemFrame,
itemfunctionLabel = Label(itemfunctionFrame, text='Difficulty: item functionality') "Item Functionality",
itemfunctionLabel.pack(side=LEFT) None,
itemfunctionFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"Normal": "normal",
"Hard": "hard",
"Expert": "expert"
}
)
self.itemWidgets[key].pack(anchor=E)
## Timer setting ## Timer setting
timerFrame = Frame(rightItemFrame) key = "timer"
self.timerVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.timerVar.set('none') self,
timerOptionMenu = OptionMenu(timerFrame, self.timerVar, 'none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown') "selectbox",
timerOptionMenu.pack(side=RIGHT) rightItemFrame,
timerLabel = Label(timerFrame, text='Timer setting') "Timer Setting",
timerLabel.pack(side=LEFT) None,
timerFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"No Timer": "none",
"Stopwatch": "display",
"Timed": "timed",
"Timed OHKO": "timed-ohko",
"OHKO": "ohko",
"Timed Countdown": "timed-countdown"
}
)
self.itemWidgets[key].pack(anchor=E)
## Progressives: On/Off ## Progressives: On/Off
progressiveFrame = Frame(rightItemFrame) key = "progressives"
self.progressiveVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.progressiveVar.set('on') self,
progressiveOptionMenu = OptionMenu(progressiveFrame, self.progressiveVar, 'on', 'off', 'random') "selectbox",
progressiveOptionMenu.pack(side=RIGHT) rightItemFrame,
progressiveLabel = Label(progressiveFrame, text='Progressive equipment') "Progressive Items",
progressiveLabel.pack(side=LEFT) None,
progressiveFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
{
"On": "on",
"Off": "off",
"Random": "random"
}
)
self.itemWidgets[key].pack(anchor=E)
## Accessibilty ## Accessibilty
accessibilityFrame = Frame(rightItemFrame) key = "accessibility"
self.accessibilityVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.accessibilityVar.set('items') self,
accessibilityOptionMenu = OptionMenu(accessibilityFrame, self.accessibilityVar, 'items', 'locations', 'none') "selectbox",
accessibilityOptionMenu.pack(side=RIGHT) rightItemFrame,
accessibilityLabel = Label(accessibilityFrame, text='Item accessibility') "Accessibility",
accessibilityLabel.pack(side=LEFT) None,
accessibilityFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}},
accessibilityFrame.pack(anchor=E) {
"100% Inventory": "items",
"100% Locations": "locations",
"Beatable": "none"
}
)
self.itemWidgets[key].pack(anchor=E)
## Item Sorting Algorithm ## Item Sorting Algorithm
algorithmFrame = Frame(rightItemFrame) key = "sortingalgo"
self.algorithmVar = StringVar() self.itemWidgets[key] = widgets.make_widget(
self.algorithmVar.set('balanced') self,
algorithmOptionMenu = OptionMenu(algorithmFrame, self.algorithmVar, 'freshness', 'flood', 'vt21', 'vt22', 'vt25', 'vt26', 'balanced') "selectbox",
algorithmOptionMenu.pack(side=RIGHT) rightItemFrame,
algorithmLabel = Label(algorithmFrame, text='Item distribution algorithm') "Item Sorting",
algorithmLabel.pack(side=LEFT) None,
algorithmFrame.pack(anchor=E) {"label": {"side": LEFT}, "selectbox": {"side": RIGHT}, "default": "Balanced"},
{
"Freshness": "freshness",
"Flood": "flood",
"VT8.21": "vt21",
"VT8.22": "vt22",
"VT8.25": "vt25",
"VT8.26": "vt26",
"Balanced": "balanced"
}
)
self.itemWidgets[key].pack(anchor=E)
return self return self

61
gui/widgets.py Normal file
View File

@@ -0,0 +1,61 @@
from tkinter import Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, StringVar
def make_checkbox(self, parent, label, storageVar, packAttrs):
self = Frame(parent)
self.storageVar = storageVar
self.checkbox = Checkbutton(self, text=label, variable=self.storageVar)
self.checkbox.pack(packAttrs)
return self
def make_selectbox(self, parent, label, options, storageVar, packAttrs):
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)
self.storageVar = storageVar
self.storageVar.trace_add("write",change_selected)
self.labelVar = StringVar()
self.labelVar.trace_add("write",change_storage)
self.label = Label(self, text=label)
self.label.pack(packAttrs["label"])
self.selectbox = OptionMenu(self, self.labelVar, *options.keys())
self.labelVar.set(packAttrs["default"] if "default" in packAttrs else list(options.keys())[0])
self.selectbox.pack(packAttrs["selectbox"])
return self
def make_textbox(self, parent, label, storageVar, packAttrs):
self = Frame(parent)
self.storageVar = storageVar
self.label = Label(self, text=label)
self.label.pack(packAttrs["label"])
self.textbox = Entry(self)
self.textbox.pack(packAttrs["textbox"])
return self
def make_widget(self, type, parent, label, storageVar=None, packAttrs=dict(), options=None):
widget = None
thisStorageVar = None
if isinstance(storageVar,str):
if storageVar == "int" or storageVar == "integer":
thisStorageVar = IntVar()
elif storageVar == "str" or storageVar == "string":
thisStorageVar = StringVar()
if type == "checkbox":
if thisStorageVar is None:
thisStorageVar = IntVar()
widget = make_checkbox(self, parent, label, thisStorageVar, packAttrs)
elif type == "selectbox":
if thisStorageVar is None:
thisStorageVar = StringVar()
widget = make_selectbox(self, parent, label, options, thisStorageVar, packAttrs)
elif type == "textbox":
if thisStorageVar is None:
thisStorageVar = StringVar()
widget = make_textbox(self, parent, label, thisStorageVar, packAttrs)
return widget