diff --git a/gui/randomize/item.py b/gui/randomize/item.py index 29ca8e86..26a9c8aa 100644 --- a/gui/randomize/item.py +++ b/gui/randomize/item.py @@ -1,5 +1,7 @@ from tkinter import ttk, IntVar, StringVar, Checkbutton, Frame, Label, OptionMenu, E, W, LEFT, RIGHT import gui.widgets as widgets +import json +import os def item_page(parent): # Item Randomizer @@ -8,19 +10,12 @@ def item_page(parent): # Item Randomizer options self.widgets = {} - myDict = { - ## Retro (eventually needs to become a World State) - "retro": { - "type": "checkbox", - "label": { - "text": "Retro mode (universal keys)" - } - } - } - 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","item","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) leftItemFrame = Frame(self) rightItemFrame = Frame(self) @@ -31,214 +26,18 @@ def item_page(parent): vals = [*map(str,range(0,7+1)),"random"] crystalsOptions = {keys[i]: vals[i] for i in range(len(keys))} - myDict = { - ## World State - "worldstate": { - "type": "selectbox", - "label": { - "text": "World State" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT }, - "default": "Open" - }, - "options": { - "Standard": "standard", - "Open": "open", - "Inverted": "inverted" - } - }, - ## Logic Level - "logiclevel": { - "type": "selectbox", - "label": { - "text": "Logic Level" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "No Glitches": "noglitches", - "Minor Glitches": "minorglitches", - "No Logic": "nologic" - } - }, - ## Goal - "goal": { - "type": "selectbox", - "label": { - "text": "Goal" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Defeat Ganon": "ganon", - "Master Sword Pedestal": "pedestal", - "All Dungeons": "dungeons", - "Triforce Hunt": "triforcehunt", - "Crystals": "crystals" - } - }, - ## Number of crystals to open GT - "crystals_gt": { - "type": "selectbox", - "label": { - "text": "Crystals to open GT" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": crystalsOptions - }, - ## Number of crystals to damage Ganon - "crystals_ganon": { - "type": "selectbox", - "label": { - "text": "Crystals to harm Ganon" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": crystalsOptions - }, - ## Weapons - "weapons": { - "type": "selectbox", - "label": { - "text": "Weapons" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Randomized": "random", - "Assured": "assured", - "Swordless": "swordless", - "Vanilla": "vanilla" - } - } - } - dictWidgets = widgets.make_widgets_from_dict(self, myDict, leftItemFrame) - for key in dictWidgets: - self.widgets[key] = dictWidgets[key] - self.widgets[key].pack(anchor=E) + with open(os.path.join("resources","app","gui","randomize","item","leftItemFrame.json")) as leftItemFrameItems: + myDict = json.load(leftItemFrameItems) + dictWidgets = widgets.make_widgets_from_dict(self, myDict, leftItemFrame) + for key in dictWidgets: + self.widgets[key] = dictWidgets[key] + self.widgets[key].pack(anchor=E) - myDict = { - ## Item Pool - "itempool": { - "type": "selectbox", - "label": { - "text": "Item Pool" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Normal": "normal", - "Hard": "hard", - "Expert": "expert" - } - }, - ## Item Functionality - "itemfunction": { - "type": "selectbox", - "label": { - "text": "Item Functionality" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "Normal": "normal", - "Hard": "hard", - "Expert": "expert" - } - }, - ## Timer setting - "timer": { - "type": "selectbox", - "label": { - "text": "Timer Setting" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "No Timer": "none", - "Stopwatch": "display", - "Timed": "timed", - "Timed OHKO": "timed-ohko", - "OHKO": "ohko", - "Timed Countdown": "timed-countdown" - } - }, - ## Progressives: On/Off - "progressives": { - "type": "selectbox", - "label": { - "text": "Progressive Items" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "On": "on", - "Off": "off", - "Random": "random" - } - }, - ## Accessibility - "accessibility": { - "type": "selectbox", - "label": { - "text": "Accessibility" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT } - }, - "options": { - "100% Inventory": "items", - "100% Locations": "locations", - "Beatable": "none" - } - }, - ## Item Sorting Algorithm - "sortingalgo": { - "type": "selectbox", - "label": { - "text": "Item Sorting" - }, - "packAttrs": { - "label": { "side": LEFT }, - "selectbox": { "side": RIGHT }, - "default": "Balanced" - }, - "options": { - "Freshness": "freshness", - "Flood": "flood", - "VT8.21": "vt21", - "VT8.22": "vt22", - "VT8.25": "vt25", - "VT8.26": "vt26", - "Balanced": "balanced" - } - } - } - dictWidgets = widgets.make_widgets_from_dict(self, myDict, rightItemFrame) - for key in dictWidgets: - self.widgets[key] = dictWidgets[key] - self.widgets[key].pack(anchor=E) + with open(os.path.join("resources","app","gui","randomize","item","rightItemFrame.json")) as rightItemFrameItems: + myDict = json.load(rightItemFrameItems) + dictWidgets = widgets.make_widgets_from_dict(self, myDict, rightItemFrame) + for key in dictWidgets: + self.widgets[key] = dictWidgets[key] + self.widgets[key].pack(anchor=E) return self diff --git a/resources/app/gui/randomize/item/checkboxes.json b/resources/app/gui/randomize/item/checkboxes.json new file mode 100644 index 00000000..e75b2daf --- /dev/null +++ b/resources/app/gui/randomize/item/checkboxes.json @@ -0,0 +1,8 @@ +{ + "retro": { + "type": "checkbox", + "label": { + "text": "Retro mode (universal keys)" + } + } +} diff --git a/resources/app/gui/randomize/item/leftItemFrame.json b/resources/app/gui/randomize/item/leftItemFrame.json new file mode 100644 index 00000000..ec3d2a38 --- /dev/null +++ b/resources/app/gui/randomize/item/leftItemFrame.json @@ -0,0 +1,132 @@ +{ + "worldstate": { + "type": "selectbox", + "label": { + "text": "World State" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + }, + "default": "Open" + }, + "options": { + "Standard": "standard", + "Open": "open", + "Inverted": "inverted" + } + }, + "logiclevel": { + "type": "selectbox", + "label": { + "text": "Logic Level" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "No Glitches": "noglitches", + "Minor Glitches": "minorglitches", + "No Logic": "nologic" + } + }, + "goal": { + "type": "selectbox", + "label": { + "text": "Goal" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Defeat Ganon": "ganon", + "Master Sword Pedestal": "pedestal", + "All Dungeons": "dungeons", + "Triforce Hunt": "triforcehunt", + "Crystals": "crystals" + } + }, + "crystals_gt": { + "type": "selectbox", + "label": { + "text": "Crystals to open GT" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "Random": "random" + } + }, + "crystals_ganon": { + "type": "selectbox", + "label": { + "text": "Crystals to harm Ganon" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "0": "0", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6", + "7": "7", + "Random": "random" + } + }, + "weapons": { + "type": "selectbox", + "label": { + "text": "Weapons" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Randomized": "random", + "Assured": "assured", + "Swordless": "swordless", + "Vanilla": "vanilla" + } + } +} diff --git a/resources/app/gui/randomize/item/rightItemFrame.json b/resources/app/gui/randomize/item/rightItemFrame.json new file mode 100644 index 00000000..8773f88b --- /dev/null +++ b/resources/app/gui/randomize/item/rightItemFrame.json @@ -0,0 +1,124 @@ +{ + "itempool": { + "type": "selectbox", + "label": { + "text": "Item Pool" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Normal": "normal", + "Hard": "hard", + "Expert": "expert" + } + }, + "itemfunction": { + "type": "selectbox", + "label": { + "text": "Item Functionality" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "Normal": "normal", + "Hard": "hard", + "Expert": "expert" + } + }, + "timer": { + "type": "selectbox", + "label": { + "text": "Timer Setting" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "No Timer": "none", + "Stopwatch": "display", + "Timed": "timed", + "Timed OHKO": "timed-ohko", + "OHKO": "ohko", + "Timed Countdown": "timed-countdown" + } + }, + "progressives": { + "type": "selectbox", + "label": { + "text": "Progressive Items" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "On": "on", + "Off": "off", + "Random": "random" + } + }, + "accessibility": { + "type": "selectbox", + "label": { + "text": "Accessibility" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + } + }, + "options": { + "100% Inventory": "items", + "100% Locations": "locations", + "Beatable": "none" + } + }, + "sortingalgo": { + "type": "selectbox", + "label": { + "text": "Item Sorting" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "selectbox": { + "side": "right" + }, + "default": "Balanced" + }, + "options": { + "Freshness": "freshness", + "Flood": "flood", + "VT8.21": "vt21", + "VT8.22": "vt22", + "VT8.25": "vt25", + "VT8.26": "vt26", + "Balanced": "balanced" + } + } +}