diff --git a/gui/randomize/gameoptions.py b/gui/randomize/gameoptions.py index 5f12f8be..966bc3d4 100644 --- a/gui/randomize/gameoptions.py +++ b/gui/randomize/gameoptions.py @@ -2,7 +2,8 @@ from tkinter import ttk, IntVar, StringVar, Button, Checkbutton, Entry, Frame, L from functools import partial import classes.SpriteSelector as spriteSelector import gui.widgets as widgets - +import json +import os def gameoptions_page(top, parent): # Game Options @@ -11,82 +12,24 @@ def gameoptions_page(top, parent): # Game Options options self.widgets = {} - myDict = { - ## Hints: Useful/Not useful - "hints": { - "type": "checkbox", - "label": { - "text": "Include Helpful Hints" - } - }, - ## Disable BGM - "nobgm": { - "type": "checkbox", - "label": { - "text": "Disable Music & MSU-1" - } - }, - ## L/R Quickswap - "quickswap": { - "type": "checkbox", - "label": { - "text": "L/R Quickswapping" - } - } - } - dictWidgets = widgets.make_widgets_from_dict(self, myDict, self) - for key in dictWidgets: - self.widgets[key] = dictWidgets[key] - self.widgets[key].pack(anchor=W) + with open(os.path.join("resources","app","gui","randomize","gameoptions","checkboxes.json")) as checkboxes: + myDict = json.load(checkboxes) + dictWidgets = widgets.make_widgets_from_dict(self, myDict, self) + for key in dictWidgets: + self.widgets[key] = dictWidgets[key] + self.widgets[key].pack(anchor=W) leftRomOptionsFrame = Frame(self) rightRomOptionsFrame = Frame(self) leftRomOptionsFrame.pack(side=LEFT) rightRomOptionsFrame.pack(side=RIGHT) - myDict = { - ## Heart Color - "heartcolor": { - "type": "selectbox", - "label": { - "text": "Heart Color" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Red": "red", - "Blue": "blue", - "Green": "green", - "Yellow": "yellow", - "Random": "random" - } - }, - ## Heart Beep speed - "heartbeep": { - "type": "selectbox", - "label": { - "text": "Heart Beep sound rate" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT}, - "default": "Normal" - }, - "options": { - "Double": "double", - "Normal": "normal", - "Half": "half", - "Quarter": "quarter", - "Off": "off" - } - } - } - dictWidgets = widgets.make_widgets_from_dict(self, myDict, leftRomOptionsFrame) - for key in dictWidgets: - self.widgets[key] = dictWidgets[key] - self.widgets[key].pack(anchor=E) + with open(os.path.join("resources","app","gui","randomize","gameoptions","leftRomOptionsFrame.json")) as leftRomOptionsFrameItems: + myDict = json.load(leftRomOptionsFrameItems) + dictWidgets = widgets.make_widgets_from_dict(self, myDict, leftRomOptionsFrame) + for key in dictWidgets: + self.widgets[key] = dictWidgets[key] + self.widgets[key].pack(anchor=E) ## Sprite selection spriteDialogFrame = Frame(leftRomOptionsFrame) @@ -114,64 +57,12 @@ def gameoptions_page(top, parent): spriteSelectButton.pack(side=LEFT) spriteDialogFrame.pack(anchor=E) - myDict = { - ## Menu Speed - "menuspeed": { - "type": "selectbox", - "label": { - "text": "Menu Speed" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT }, - "default": "Normal" - }, - "options": { - "Instant": "instant", - "Quadruple": "quadruple", - "Triple": "triple", - "Double": "double", - "Normal": "normal", - "Half": "half" - } - }, - ## Overworld Palettes (not Enemizer) - "owpalettes": { - "type": "selectbox", - "label": { - "text": "Overworld Palettes" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Default": "default", - "Random": "random", - "Blackout": "blackout" - } - }, - ## Underworld Palettes (not Enemizer) - "uwpalettes": { - "type": "selectbox", - "label": { - "text": "Underworld Palettes" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Default": "default", - "Random": "random", - "Blackout": "blackout" - } - } - } - dictWidgets = widgets.make_widgets_from_dict(self, myDict, rightRomOptionsFrame) - for key in dictWidgets: - self.widgets[key] = dictWidgets[key] - self.widgets[key].pack(anchor=E) + with open(os.path.join("resources","app","gui","randomize","gameoptions","rightRomOptionsFrame.json")) as rightRomOptionsFrameItems: + myDict = json.load(rightRomOptionsFrameItems) + dictWidgets = widgets.make_widgets_from_dict(self, myDict, rightRomOptionsFrame) + for key in dictWidgets: + self.widgets[key] = dictWidgets[key] + self.widgets[key].pack(anchor=E) return self diff --git a/resources/app/gui/randomize/gameoptions/checkboxes.json b/resources/app/gui/randomize/gameoptions/checkboxes.json new file mode 100644 index 00000000..e531d2e9 --- /dev/null +++ b/resources/app/gui/randomize/gameoptions/checkboxes.json @@ -0,0 +1,20 @@ +{ + "hints": { + "type": "checkbox", + "label": { + "text": "Include Helpful Hints" + } + }, + "nobgm": { + "type": "checkbox", + "label": { + "text": "Disable Music & MSU-1" + } + }, + "quickswap": { + "type": "checkbox", + "label": { + "text": "L/R Quickswapping" + } + } +} diff --git a/resources/app/gui/randomize/gameoptions/leftRomOptionsFrame.json b/resources/app/gui/randomize/gameoptions/leftRomOptionsFrame.json new file mode 100644 index 00000000..ce8a5b32 --- /dev/null +++ b/resources/app/gui/randomize/gameoptions/leftRomOptionsFrame.json @@ -0,0 +1,45 @@ +{ + "heartcolor": { + "type": "selectbox", + "label": { + "text": "Heart Color" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Red": "red", + "Blue": "blue", + "Green": "green", + "Yellow": "yellow", + "Random": "random" + } + }, + "heartbeep": { + "type": "selectbox", + "label": { + "text": "Heart Beep sound rate" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + }, + "default": "Normal" + }, + "options": { + "Double": "double", + "Normal": "normal", + "Half": "half", + "Quarter": "quarter", + "Off": "off" + } + } +} diff --git a/resources/app/gui/randomize/gameoptions/rightRomOptionsFrame.json b/resources/app/gui/randomize/gameoptions/rightRomOptionsFrame.json new file mode 100644 index 00000000..0e3b510b --- /dev/null +++ b/resources/app/gui/randomize/gameoptions/rightRomOptionsFrame.json @@ -0,0 +1,63 @@ +{ + "menuspeed": { + "type": "selectbox", + "label": { + "text": "Menu Speed" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + }, + "default": "Normal" + }, + "options": { + "Instant": "instant", + "Quadruple": "quadruple", + "Triple": "triple", + "Double": "double", + "Normal": "normal", + "Half": "half" + } + }, + "owpalettes": { + "type": "selectbox", + "label": { + "text": "Overworld Palettes" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Default": "default", + "Random": "random", + "Blackout": "blackout" + } + }, + "uwpalettes": { + "type": "selectbox", + "label": { + "text": "Underworld Palettes" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Default": "default", + "Random": "random", + "Blackout": "blackout" + } + } +}