Merge branch 'gui-improvements-update' into ci-dev
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, filedialog, messagebox, IntVar, StringVar, Button, Checkbutton, Entry, Frame, Label, OptionMenu, E, W, LEFT, RIGHT, X, BOTTOM
|
||||
from tkinter import ttk, filedialog, messagebox, StringVar, Button, Entry, Frame, Label, E, W, LEFT, RIGHT, X, BOTTOM
|
||||
from AdjusterMain import adjust
|
||||
from argparse import Namespace
|
||||
from source.classes.SpriteSelector import SpriteSelector
|
||||
@@ -19,6 +19,7 @@ def adjust_page(top, parent, settings):
|
||||
self.frames["checkboxes"] = Frame(self)
|
||||
self.frames["checkboxes"].pack(anchor=W)
|
||||
|
||||
# Adjust option frames
|
||||
self.frames["selectOptionsFrame"] = Frame(self)
|
||||
self.frames["leftAdjustFrame"] = Frame(self.frames["selectOptionsFrame"])
|
||||
self.frames["rightAdjustFrame"] = Frame(self.frames["selectOptionsFrame"])
|
||||
@@ -28,6 +29,8 @@ def adjust_page(top, parent, settings):
|
||||
self.frames["rightAdjustFrame"].pack(side=RIGHT)
|
||||
self.frames["bottomAdjustFrame"].pack(fill=X)
|
||||
|
||||
# Load Adjust option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
with open(os.path.join("resources","app","gui","adjust","overview","widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
@@ -40,6 +43,7 @@ def adjust_page(top, parent, settings):
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
# Sprite Selection
|
||||
# This one's more-complicated, build it and stuff it
|
||||
self.spriteNameVar2 = StringVar()
|
||||
spriteDialogFrame2 = Frame(self.frames["leftAdjustFrame"])
|
||||
baseSpriteLabel2 = Label(spriteDialogFrame2, text='Sprite:')
|
||||
@@ -65,6 +69,8 @@ def adjust_page(top, parent, settings):
|
||||
spriteSelectButton2.pack(side=LEFT)
|
||||
spriteDialogFrame2.pack(anchor=E)
|
||||
|
||||
# Path to game file to Adjust
|
||||
# This one's more-complicated, build it and stuff it
|
||||
adjustRomFrame = Frame(self.frames["bottomAdjustFrame"])
|
||||
adjustRomLabel = Label(adjustRomFrame, text='Rom to adjust: ')
|
||||
self.romVar2 = StringVar(value=settings["rom"])
|
||||
@@ -82,6 +88,7 @@ def adjust_page(top, parent, settings):
|
||||
romSelectButton2.pack(side=LEFT)
|
||||
adjustRomFrame.pack(fill=X)
|
||||
|
||||
# These are the options to Adjust
|
||||
def adjustRom():
|
||||
options = {
|
||||
"heartbeep": "heartbeep",
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
from tkinter import ttk, messagebox, StringVar, Button, Entry, Frame, Label, Spinbox, E, W, LEFT, RIGHT, X
|
||||
from tkinter import ttk, messagebox, StringVar, Button, Entry, Frame, Label, E, W, LEFT, RIGHT, X
|
||||
from argparse import Namespace
|
||||
from functools import partial
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
from CLI import parse_arguments, get_settings
|
||||
from CLI import parse_arguments
|
||||
from Main import main
|
||||
from Utils import local_path, output_path, open_file
|
||||
import source.classes.constants as CONST
|
||||
@@ -97,22 +96,35 @@ def create_guiargs(parent):
|
||||
# Page::Subpage::GUI-id::param-id
|
||||
options = CONST.SETTINGSTOPROCESS
|
||||
|
||||
# Cycle through each page
|
||||
for mainpage in options:
|
||||
# Cycle through each subpage (in case of Item Randomizer)
|
||||
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]
|
||||
setattr(guiargs, arg, parent.pages[mainpage].pages[subpage].widgets[widget].storageVar.get())
|
||||
|
||||
# Get EnemizerCLI setting
|
||||
guiargs.enemizercli = parent.pages["randomizer"].pages["enemizer"].enemizerCLIpathVar.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()
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
# Get Adjust settings
|
||||
adjustargs = {
|
||||
"nobgm": "disablemusic",
|
||||
"quickswap": "quickswap",
|
||||
@@ -126,22 +138,29 @@ def create_guiargs(parent):
|
||||
internal = adjustargs[adjustarg]
|
||||
setattr(guiargs,"adjust." + internal, parent.pages["adjust"].content.widgets[adjustarg].storageVar.get())
|
||||
|
||||
# Get Custom Items and Starting Inventory Items
|
||||
customitems = CONST.CUSTOMITEMS
|
||||
guiargs.startinventory = []
|
||||
guiargs.customitemarray = {}
|
||||
guiargs.startinventoryarray = {}
|
||||
for customitem in customitems:
|
||||
if customitem not in ["triforcepiecesgoal", "triforce", "rupoor", "rupoorcost"]:
|
||||
if customitem not in CONST.CANTSTARTWITH:
|
||||
# Starting Inventory is a CSV
|
||||
amount = int(parent.pages["startinventory"].content.startingWidgets[customitem].storageVar.get())
|
||||
guiargs.startinventoryarray[customitem] = amount
|
||||
for i in range(0, amount):
|
||||
for _ in range(0, amount):
|
||||
label = CONST.CUSTOMITEMLABELS[customitems.index(customitem)]
|
||||
guiargs.startinventory.append(label)
|
||||
# Custom Item Pool is a dict of ints
|
||||
guiargs.customitemarray[customitem] = int(parent.pages["custom"].content.customWidgets[customitem].storageVar.get())
|
||||
|
||||
# Starting Inventory is a CSV
|
||||
guiargs.startinventory = ','.join(guiargs.startinventory)
|
||||
|
||||
# Get Sprite Selection (set or random)
|
||||
guiargs.sprite = parent.pages["randomizer"].pages["gameoptions"].widgets["sprite"]["spriteObject"]
|
||||
guiargs.randomSprite = parent.randomSprite.get()
|
||||
|
||||
# Get output path
|
||||
guiargs.outputpath = parent.outputPath.get()
|
||||
return guiargs
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, StringVar, Entry, Frame, Label, N, E, W, LEFT, RIGHT, X, VERTICAL, Y
|
||||
from tkinter import ttk, Frame, N, E, W, LEFT, X, VERTICAL, Y
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -9,16 +9,19 @@ def custom_page(top,parent):
|
||||
# Custom Item Pool
|
||||
self = ttk.Frame(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
|
||||
|
||||
# Create a vertical rule to help with splitting columns visually
|
||||
def create_vertical_rule(num=1):
|
||||
for i in range(0,num):
|
||||
for _ in range(0,num):
|
||||
ttk.Separator(self, orient=VERTICAL).pack(side=LEFT, anchor=N, fill=Y)
|
||||
|
||||
# This was in here, I have no idea what it was but I left it just in case: MikeT
|
||||
def validation(P):
|
||||
if str.isdigit(P) or P == "":
|
||||
return True
|
||||
@@ -31,23 +34,27 @@ def custom_page(top,parent):
|
||||
|
||||
# Custom Item Pool option sections
|
||||
self.frames = {}
|
||||
create_list_frame(self,"itemList1")
|
||||
# Create 5 columns with 2 vertical rules in between each
|
||||
create_list_frame(self, "itemList1")
|
||||
create_vertical_rule(2)
|
||||
create_list_frame(self,"itemList2")
|
||||
create_list_frame(self, "itemList2")
|
||||
create_vertical_rule(2)
|
||||
create_list_frame(self,"itemList3")
|
||||
create_list_frame(self, "itemList3")
|
||||
create_vertical_rule(2)
|
||||
create_list_frame(self,"itemList4")
|
||||
create_list_frame(self, "itemList4")
|
||||
create_vertical_rule(2)
|
||||
create_list_frame(self,"itemList5")
|
||||
create_list_frame(self, "itemList5")
|
||||
|
||||
with open(os.path.join("resources","app","gui","custom","overview","widgets.json")) as widgetDefns:
|
||||
# Load Custom option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
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]
|
||||
|
||||
# Load Custom Item Pool settings from settings file
|
||||
for key in CONST.CUSTOMITEMS:
|
||||
self.customWidgets[key].storageVar.set(top.settings["customitemarray"][key])
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from source.gui.randomize.gameoptions import set_sprite
|
||||
from Rom import Sprite, get_sprite_from_name
|
||||
import source.classes.constants as CONST
|
||||
|
||||
# Load args/settings for most tabs
|
||||
def loadcliargs(gui, args, settings=None):
|
||||
if args is not None:
|
||||
# for k, v in vars(args).items():
|
||||
@@ -14,28 +15,47 @@ def loadcliargs(gui, args, settings=None):
|
||||
# Page::Subpage::GUI-id::param-id
|
||||
options = CONST.SETTINGSTOPROCESS
|
||||
|
||||
# Cycle through each page
|
||||
for mainpage in options:
|
||||
# Cycle through each subpage (in case of Item Randomizer)
|
||||
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]
|
||||
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
|
||||
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
|
||||
gui.pages["randomizer"].pages["enemizer"].enemizerCLIpathVar.set(args["enemizercli"])
|
||||
|
||||
# Get baserom path
|
||||
gui.pages["randomizer"].pages["generation"].romVar.set(args["rom"])
|
||||
|
||||
# Get Multiworld Worlds count
|
||||
if args["multi"]:
|
||||
gui.pages["randomizer"].pages["multiworld"].widgets["worlds"].storageVar.set(str(args["multi"]))
|
||||
|
||||
# Get Seed ID
|
||||
if args["seed"]:
|
||||
gui.frames["bottom"].seedVar.set(str(args["seed"]))
|
||||
|
||||
# Get number of generations to run
|
||||
if args["count"]:
|
||||
gui.frames["bottom"].widgets["generationcount"].storageVar.set(str(args["count"]))
|
||||
|
||||
# Get output path
|
||||
gui.outputPath.set(args["outputpath"])
|
||||
|
||||
# Figure out Sprite Selection
|
||||
def sprite_setter(spriteObject):
|
||||
gui.pages["randomizer"].pages["gameoptions"].widgets["sprite"]["spriteObject"] = spriteObject
|
||||
if args["sprite"] is not None:
|
||||
@@ -52,6 +72,7 @@ def loadcliargs(gui, args, settings=None):
|
||||
spriteNameVar=gui.pages["adjust"].content.spriteNameVar2,
|
||||
randomSpriteVar=gui.randomSprite)
|
||||
|
||||
# Load args/settings for Adjust tab
|
||||
def loadadjustargs(gui, settings):
|
||||
options = {
|
||||
"adjust": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, IntVar, StringVar, Checkbutton, Frame, Label, OptionMenu, E, W, LEFT, RIGHT
|
||||
from tkinter import ttk, Frame, Label, E, W, LEFT, RIGHT
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -19,6 +19,9 @@ def dungeon_page(parent):
|
||||
mscbLabel = Label(self.frames["keysanity"], text="Shuffle: ")
|
||||
mscbLabel.pack(side=LEFT)
|
||||
|
||||
# Load Dungeon Shuffle option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
# This first set goes in the Keysanity frame
|
||||
with open(os.path.join("resources","app","gui","randomize","dungeon","keysanity.json")) as keysanityItems:
|
||||
myDict = json.load(keysanityItems)
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, myDict, self.frames["keysanity"])
|
||||
@@ -26,6 +29,7 @@ def dungeon_page(parent):
|
||||
self.widgets[key] = dictWidgets[key]
|
||||
self.widgets[key].pack(side=LEFT)
|
||||
|
||||
# These get split left & right
|
||||
self.frames["widgets"] = Frame(self)
|
||||
self.frames["widgets"].pack(anchor=W)
|
||||
with open(os.path.join("resources","app","gui","randomize","dungeon","widgets.json")) as dungeonWidgets:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
from tkinter import ttk, filedialog, IntVar, StringVar, Button, Checkbutton, Entry, Frame, Label, LabelFrame, OptionMenu, N, E, W, LEFT, RIGHT, BOTTOM, X
|
||||
from tkinter import ttk, filedialog, StringVar, Button, Entry, Frame, Label, N, E, W, LEFT, RIGHT, BOTTOM, X
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -18,6 +17,7 @@ def enemizer_page(parent,settings):
|
||||
# Enemizer option sections
|
||||
self.frames = {}
|
||||
|
||||
# Enemizer option frames
|
||||
self.frames["checkboxes"] = Frame(self)
|
||||
self.frames["checkboxes"].pack(anchor=W)
|
||||
|
||||
@@ -30,6 +30,9 @@ def enemizer_page(parent,settings):
|
||||
self.frames["rightEnemizerFrame"].pack(side=RIGHT)
|
||||
self.frames["bottomEnemizerFrame"].pack(fill=X)
|
||||
|
||||
# Load Enemizer option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
# These get split left & right
|
||||
with open(os.path.join("resources","app","gui","randomize","enemizer","widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
@@ -42,6 +45,7 @@ def enemizer_page(parent,settings):
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
## Enemizer CLI Path
|
||||
# This one's more-complicated, build it and stuff it
|
||||
enemizerPathFrame = Frame(self.frames["bottomEnemizerFrame"])
|
||||
enemizerCLIlabel = Label(enemizerPathFrame, text="EnemizerCLI path: ")
|
||||
enemizerCLIlabel.pack(side=LEFT)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, IntVar, StringVar, Checkbutton, Frame, Label, OptionMenu, E, W, LEFT, RIGHT
|
||||
from tkinter import ttk, Frame, E, W, LEFT, RIGHT
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -15,6 +15,11 @@ def entrando_page(parent):
|
||||
self.frames["widgets"] = Frame(self)
|
||||
self.frames["widgets"].pack(anchor=W)
|
||||
|
||||
# Load Entrance Randomizer option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
# Checkboxes go West
|
||||
# Everything else goes East
|
||||
# They also get split left & right
|
||||
with open(os.path.join("resources","app","gui","randomize","entrando","widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, IntVar, StringVar, Button, Checkbutton, Entry, Frame, Label, OptionMenu, E, W, LEFT, RIGHT
|
||||
from tkinter import ttk, StringVar, Button, Entry, Frame, Label, E, W, LEFT, RIGHT
|
||||
from functools import partial
|
||||
import source.classes.SpriteSelector as spriteSelector
|
||||
import source.gui.widgets as widgets
|
||||
@@ -17,11 +17,17 @@ def gameoptions_page(top, parent):
|
||||
self.frames["checkboxes"] = Frame(self)
|
||||
self.frames["checkboxes"].pack(anchor=W)
|
||||
|
||||
# Game Options frames
|
||||
self.frames["leftRomOptionsFrame"] = Frame(self)
|
||||
self.frames["rightRomOptionsFrame"] = Frame(self)
|
||||
self.frames["leftRomOptionsFrame"].pack(side=LEFT)
|
||||
self.frames["rightRomOptionsFrame"].pack(side=RIGHT)
|
||||
|
||||
# Load Game Options widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
# Checkboxes go West
|
||||
# Everything else goes East
|
||||
# They also get split left & right
|
||||
with open(os.path.join("resources","app","gui","randomize","gameoptions","widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
@@ -34,6 +40,7 @@ def gameoptions_page(top, parent):
|
||||
self.widgets[key].pack(packAttrs)
|
||||
|
||||
## Sprite selection
|
||||
# This one's more-complicated, build it and stuff it
|
||||
spriteDialogFrame = Frame(self.frames["leftRomOptionsFrame"])
|
||||
baseSpriteLabel = Label(spriteDialogFrame, text='Sprite:')
|
||||
|
||||
@@ -75,4 +82,3 @@ def set_sprite(sprite_param, random_sprite=False, spriteSetter=None, spriteNameV
|
||||
spriteNameVar.set(sprite_param.name)
|
||||
if randomSpriteVar:
|
||||
randomSpriteVar.set(random_sprite)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
from tkinter import ttk, filedialog, IntVar, StringVar, Button, Checkbutton, Entry, Frame, Label, E, W, LEFT, RIGHT, X
|
||||
from tkinter import ttk, filedialog, StringVar, Button, Entry, Frame, Label, E, W, LEFT, X
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -16,6 +15,8 @@ def generation_page(parent,settings):
|
||||
self.frames["checkboxes"] = Frame(self)
|
||||
self.frames["checkboxes"].pack(anchor=W)
|
||||
|
||||
# Load Generation Setup option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
with open(os.path.join("resources","app","gui","randomize","generation","checkboxes.json")) as checkboxes:
|
||||
myDict = json.load(checkboxes)
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, myDict, self.frames["checkboxes"])
|
||||
@@ -26,6 +27,7 @@ def generation_page(parent,settings):
|
||||
self.frames["baserom"] = Frame(self)
|
||||
self.frames["baserom"].pack(anchor=W, fill=X)
|
||||
## Locate base ROM
|
||||
# This one's more-complicated, build it and stuff it
|
||||
baseRomFrame = Frame(self.frames["baserom"])
|
||||
baseRomLabel = Label(baseRomFrame, text='Base Rom: ')
|
||||
self.romVar = StringVar()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from tkinter import ttk, IntVar, StringVar, Checkbutton, Frame, Label, OptionMenu, E, W, LEFT, RIGHT
|
||||
from tkinter import ttk, Frame, E, W, LEFT, RIGHT
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def item_page(parent):
|
||||
# Item Randomizer
|
||||
self = ttk.Frame(parent)
|
||||
@@ -13,6 +13,7 @@ def item_page(parent):
|
||||
# Item Randomizer option sections
|
||||
self.frames = {}
|
||||
|
||||
# Item Randomizer option frames
|
||||
self.frames["checkboxes"] = Frame(self)
|
||||
self.frames["checkboxes"].pack(anchor=W)
|
||||
|
||||
@@ -21,6 +22,10 @@ def item_page(parent):
|
||||
self.frames["leftItemFrame"].pack(side=LEFT)
|
||||
self.frames["rightItemFrame"].pack(side=RIGHT)
|
||||
|
||||
# Load Item Randomizer option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
# Checkboxes go West
|
||||
# Everything else goes East
|
||||
with open(os.path.join("resources","app","gui","randomize","item","widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for framename,theseWidgets in myDict.items():
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, StringVar, Entry, Frame, Label, Spinbox, N, E, W, X, LEFT, RIGHT
|
||||
from tkinter import ttk, StringVar, Entry, Frame, Label, N, E, W, X, LEFT
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -15,6 +15,8 @@ def multiworld_page(parent,settings):
|
||||
self.frames["widgets"] = Frame(self)
|
||||
self.frames["widgets"].pack(anchor=W, fill=X)
|
||||
|
||||
# Load Multiworld option widgets as defined by JSON file
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
with open(os.path.join("resources","app","gui","randomize","multiworld","widgets.json")) as multiworldItems:
|
||||
myDict = json.load(multiworldItems)
|
||||
dictWidgets = widgets.make_widgets_from_dict(self, myDict, self.frames["widgets"])
|
||||
@@ -23,6 +25,7 @@ def multiworld_page(parent,settings):
|
||||
self.widgets[key].pack(side=LEFT, anchor=N)
|
||||
|
||||
## List of Player Names
|
||||
# This one's more-complicated, build it and stuff it
|
||||
key = "names"
|
||||
self.widgets[key] = Frame(self.frames["widgets"])
|
||||
self.widgets[key].label = Label(self.widgets[key], text='Player names')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from tkinter import ttk, StringVar, Entry, Frame, Label, N, E, W, LEFT, RIGHT, X, VERTICAL, Y
|
||||
from tkinter import ttk, Frame, N, E, W, LEFT, X, VERTICAL, Y
|
||||
import source.gui.widgets as widgets
|
||||
import json
|
||||
import os
|
||||
@@ -9,16 +9,19 @@ def startinventory_page(top,parent):
|
||||
# Starting Inventory
|
||||
self = ttk.Frame(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
|
||||
|
||||
# Create a vertical rule to help with splitting columns visually
|
||||
def create_vertical_rule(num=1):
|
||||
for i in range(0,num):
|
||||
for _ in range(0,num):
|
||||
ttk.Separator(self, orient=VERTICAL).pack(side=LEFT, anchor=N, fill=Y)
|
||||
|
||||
# This was in Custom Item Pool, I have no idea what it was but I left it just in case: MikeT
|
||||
def validation(P):
|
||||
if str.isdigit(P) or P == "":
|
||||
return True
|
||||
@@ -31,6 +34,7 @@ def startinventory_page(top,parent):
|
||||
|
||||
# Starting Inventory option sections
|
||||
self.frames = {}
|
||||
# Create 5 columns with 2 vertical rules in between each
|
||||
create_list_frame(self,"itemList1")
|
||||
create_vertical_rule(2)
|
||||
create_list_frame(self,"itemList2")
|
||||
@@ -41,6 +45,8 @@ def startinventory_page(top,parent):
|
||||
create_vertical_rule(2)
|
||||
create_list_frame(self,"itemList5")
|
||||
|
||||
# Load Starting Inventory option widgets as defined by JSON file, ignoring the ones to be excluded
|
||||
# Defns include frame name, widget type, widget options, widget placement attributes
|
||||
with open(os.path.join("resources","app","gui","custom","overview","widgets.json")) as widgetDefns:
|
||||
myDict = json.load(widgetDefns)
|
||||
for key in CONST.CANTSTARTWITH:
|
||||
@@ -53,6 +59,7 @@ def startinventory_page(top,parent):
|
||||
for key in dictWidgets:
|
||||
self.startingWidgets[key] = dictWidgets[key]
|
||||
|
||||
# Load Custom Starting Inventory settings from settings file, ignoring ones to be excluded
|
||||
for key in CONST.CUSTOMITEMS:
|
||||
if key not in CONST.CANTSTARTWITH:
|
||||
val = 0
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from tkinter import Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, Spinbox, StringVar, RIGHT, X
|
||||
|
||||
# Need a dummy class
|
||||
class Empty():
|
||||
pass
|
||||
|
||||
# Override Spinbox to include mousewheel support for changing value
|
||||
class mySpinbox(Spinbox):
|
||||
def __init__(self, *args, **kwargs):
|
||||
Spinbox.__init__(self, *args, **kwargs)
|
||||
@@ -16,6 +18,7 @@ class mySpinbox(Spinbox):
|
||||
elif event.num == 4 or event.delta == 120:
|
||||
self.invoke('buttonup')
|
||||
|
||||
# Make a Checkbutton with a label
|
||||
def make_checkbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
self = Frame(parent, name="checkframe-" + label.lower())
|
||||
self.storageVar = storageVar
|
||||
@@ -26,6 +29,7 @@ def make_checkbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
self.checkbox.pack()
|
||||
return self
|
||||
|
||||
# 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()])
|
||||
@@ -54,6 +58,7 @@ def make_selectbox(self, parent, label, options, storageVar, manager, managerAtt
|
||||
self.selectbox.pack()
|
||||
return self
|
||||
|
||||
# Make a Spinbox with a label, limit 1-100
|
||||
def make_spinbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
self = Frame(parent, name="spinframe-" + label.lower())
|
||||
self.storageVar = storageVar
|
||||
@@ -76,6 +81,8 @@ def make_spinbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
self.spinbox.pack()
|
||||
return self
|
||||
|
||||
# Make an Entry box with a label
|
||||
# Support for Grid or Pack so that the Custom Item Pool & Starting Inventory pages don't look ugly
|
||||
def make_textbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
widget = Empty()
|
||||
widget.storageVar = storageVar
|
||||
@@ -98,7 +105,7 @@ def make_textbox(self, parent, label, storageVar, manager, managerAttrs):
|
||||
widget.textbox.pack(managerAttrs["textbox"] if managerAttrs is not None and "textbox" in managerAttrs else None)
|
||||
return widget
|
||||
|
||||
|
||||
# Make a generic widget
|
||||
def make_widget(self, type, parent, label, storageVar=None, manager=None, managerAttrs=dict(), options=None):
|
||||
widget = None
|
||||
if manager is None:
|
||||
@@ -129,6 +136,7 @@ def make_widget(self, type, parent, label, storageVar=None, manager=None, manage
|
||||
widget.type = type
|
||||
return widget
|
||||
|
||||
# Make a generic widget from a dict
|
||||
def make_widget_from_dict(self, defn, parent):
|
||||
type = defn["type"] if "type" in defn else None
|
||||
label = defn["label"]["text"] if "label" in defn and "text" in defn["label"] else ""
|
||||
@@ -138,8 +146,9 @@ def make_widget_from_dict(self, defn, parent):
|
||||
widget = make_widget(self, type, parent, label, None, manager, managerAttrs, options)
|
||||
return widget
|
||||
|
||||
# Make a set of generic widgets from a dict
|
||||
def make_widgets_from_dict(self, defns, parent):
|
||||
widgets = {}
|
||||
for key,defn in defns.items():
|
||||
widgets[key] = make_widget_from_dict(self, defn, parent)
|
||||
return widgets
|
||||
return widgets
|
||||
|
||||
Reference in New Issue
Block a user