Skip to content

Commit

Permalink
Multi Game Patch info.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLastBreath committed Oct 5, 2024
1 parent 936be30 commit d8381e2
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 95 deletions.
2 changes: 1 addition & 1 deletion src/Patches/Breath Of The Wild/PatchInfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Name" : "Tears Of The Kingdom",
"Name" : "Breath of The Wild",
"ID" : "0100F2C0115B6000",
"ModName" : "!!!TOTK Optimizer",
"ModConfig" : "UltraCam/maxlastbreath.ini",
Expand Down
2 changes: 1 addition & 1 deletion src/Patches/Echoes of Wisdom/PatchInfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Name" : "Tears Of The Kingdom",
"Name" : "Echoes of Wisdom",
"ID" : "0100F2C0115B6000",
"ModName" : "!!!TOTK Optimizer",
"ModConfig" : "UltraCam/maxlastbreath.ini",
Expand Down
212 changes: 122 additions & 90 deletions src/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
from modules.TOTK_Optimizer_Modules import * # imports all needed files.
from modules.GameManager.GameManager import *
from modules.GameManager.FileManager import *
import threading
import webbrowser
import threading, webbrowser, os, copy
import ttkbootstrap as ttk

def increase_row(row, cul_sel, cul_tex):
row += 40
if row >= 480:
row = 160
cul_tex += 180
cul_sel += 180
return row, cul_sel, cul_tex

class Manager:

patches = []
_patchInfo = None
_window = ttk.Window
constyle = Style
os_platform = platform.system()

def __init__(self, window):

Expand Down Expand Up @@ -86,6 +94,96 @@ def __init__(self, window):
def warning(self, e):
messagebox.showwarning(f"{e}")


def LoadNewGameInfo(self):
for item in self.patches:
if (self.PatchName.get() == item.Name):
self._patchInfo = item
self.ultracam_beyond = self._patchInfo.LoadJson()
pos_dict = copy.deepcopy(self.Back_Pos)
self.DeletePatches()
self.LoadPatches(self.all_canvas[0], pos_dict)
self.toggle_page(0, "main")

def LoadPatches(self, canvas, pos_dict):
keys = self.ultracam_beyond.get("Keys", [""])

for name in keys:
dicts = keys[name]

patch_var = None
patch_list = dicts.get("Name_Values", [""])
patch_values = dicts.get("Values")
patch_name = dicts.get("Name")
patch_auto = dicts.get("Auto")
section_auto = dicts.get("Section")
patch_description = dicts.get("Description")
patch_default_index = dicts.get("Default")
pos = pos_dict[section_auto]
if patch_auto is True:
self.BEYOND_Patches[name] = ttk.StringVar(master=self._window, value="auto")
continue

if dicts["Class"].lower() == "dropdown":
patch_var = self.on_canvas.create_combobox(
master=self._window, canvas=canvas,
text=patch_name,
values=patch_list, variable=patch_list[patch_default_index],
row=pos[0], cul=pos[1], drop_cul=pos[2], width=100,
tags=["dropdown", "patchinfo"], tag=section_auto,
text_description=patch_description
)
new_pos = increase_row(pos[0], pos[1], pos[2])
pos[0] = new_pos[0]
pos[1] = new_pos[1]
pos[2] = new_pos[2]

if dicts["Class"].lower() == "scale":
patch_type = dicts.get("Type")
patch_increments = dicts.get("Increments")
patch_var = self.on_canvas.create_scale(
master=self._window, canvas=canvas,
text=patch_name,
scale_from=patch_values[0], scale_to=patch_values[1], type=patch_type,
row=pos[0], cul=pos[1], drop_cul=pos[2], width=100, increments=float(patch_increments),
tags=["scale", "patchinfo"], tag=section_auto,
text_description=patch_description
)
if patch_type == "f32":
print(f"{patch_name} - {patch_default_index}")
patch_var.set(float(patch_default_index))
else:
patch_var.set(patch_default_index)

canvas.itemconfig(patch_name, text=f"{float(patch_default_index)}")
new_pos = increase_row(pos[0], pos[1], pos[2])
pos[0] = new_pos[0]
pos[1] = new_pos[1]
pos[2] = new_pos[2]

if dicts["Class"].lower() == "bool":
patch_var = self.on_canvas.create_checkbutton(
master=self._window, canvas=canvas,
text=patch_name,
variable="Off",
row=pos[3], cul=pos[4], drop_cul=pos[5],
tags=["bool", "patchinfo"], tag=section_auto,
text_description=patch_description
)
if patch_default_index:
patch_var.set("On")
new_pos = increase_row(pos[3], pos[4], pos[5])
pos[3] = new_pos[0]
pos[4] = new_pos[1]
pos[5] = new_pos[2]

if patch_var is None:
continue
self.BEYOND_Patches[name] = patch_var

def DeletePatches(self):
self.all_canvas[0].delete("patchinfo")

def create_canvas(self):

# clear list.
Expand Down Expand Up @@ -113,14 +211,6 @@ def create_canvas(self):
cul_tex_2 = 400
cul_sel_2 = 550

def increase_row(row, cul_sel, cul_tex):
row += 40
if row >= 480:
row = 160
cul_tex += 180
cul_sel += 180
return row, cul_sel, cul_tex

# Run Scripts for checking OS and finding location
FileManager.checkpath(self.mode)
FileManager.DetectOS(self.mode)
Expand All @@ -147,16 +237,29 @@ def onCanvasClick(event):

# Setting Preset - returns variable.

value = ["No Change"]
for item in self.Legacy_settings:
value.append(item)
self.selected_settings = self.on_canvas.create_combobox(
# value = ["No Change"]
# for item in self.Legacy_settings:
# value.append(item)
# self.selected_settings = self.on_canvas.create_combobox(
# master=self._window, canvas=canvas,
# text="Legacy SETTINGS:",
# variable=value[0], values=value,
# row=row, cul=340, drop_cul=480,
# tags=["text"], tag="Legacy",
# description_name="Settings"
# )

value = []
for item in self.patches:
value.append(item.Name)
self.PatchName = self.on_canvas.create_combobox(
master=self._window, canvas=canvas,
text="Legacy SETTINGS:",
text="Select Game:",
variable=value[0], values=value,
row=row, cul=340, drop_cul=480,
tags=["text"], tag="Legacy",
description_name="Settings"
tags=["text"], tag="GameSelect",
description_name="GameSelect",
command= lambda event: self.LoadNewGameInfo()
)

row += 40
Expand Down Expand Up @@ -277,80 +380,9 @@ def Legacy_appdata():
"extra": [row, cul_tex, cul_sel, row_2, cul_tex_2, cul_sel_2]
}

keys = self.ultracam_beyond.get("Keys", [""])

for name in keys:
dicts = keys[name]
self.Back_Pos = copy.deepcopy(pos_dict)

patch_var = None
patch_list = dicts.get("Name_Values", [""])
patch_values = dicts.get("Values")
patch_name = dicts.get("Name")
patch_auto = dicts.get("Auto")
section_auto = dicts.get("Section")
patch_description = dicts.get("Description")
patch_default_index = dicts.get("Default")
pos = pos_dict[section_auto]
if patch_auto is True:
self.BEYOND_Patches[name] = ttk.StringVar(master=self._window, value="auto")
continue

if dicts["Class"].lower() == "dropdown":
patch_var = self.on_canvas.create_combobox(
master=self._window, canvas=canvas,
text=patch_name,
values=patch_list, variable=patch_list[patch_default_index],
row=pos[0], cul=pos[1], drop_cul=pos[2], width=100,
tags=["dropdown"], tag=section_auto,
text_description=patch_description
)
new_pos = increase_row(pos[0], pos[1], pos[2])
pos[0] = new_pos[0]
pos[1] = new_pos[1]
pos[2] = new_pos[2]

if dicts["Class"].lower() == "scale":
patch_type = dicts.get("Type")
patch_increments = dicts.get("Increments")
patch_var = self.on_canvas.create_scale(
master=self._window, canvas=canvas,
text=patch_name,
scale_from=patch_values[0], scale_to=patch_values[1], type=patch_type,
row=pos[0], cul=pos[1], drop_cul=pos[2], width=100, increments=float(patch_increments),
tags=["scale"], tag=section_auto,
text_description=patch_description
)
if patch_type == "f32":
print(f"{patch_name} - {patch_default_index}")
patch_var.set(float(patch_default_index))
else:
patch_var.set(patch_default_index)

canvas.itemconfig(patch_name, text=f"{float(patch_default_index)}")
new_pos = increase_row(pos[0], pos[1], pos[2])
pos[0] = new_pos[0]
pos[1] = new_pos[1]
pos[2] = new_pos[2]

if dicts["Class"].lower() == "bool":
patch_var = self.on_canvas.create_checkbutton(
master=self._window, canvas=canvas,
text=patch_name,
variable="Off",
row=pos[3], cul=pos[4], drop_cul=pos[5],
tags=["bool"], tag=section_auto,
text_description=patch_description
)
if patch_default_index:
patch_var.set("On")
new_pos = increase_row(pos[3], pos[4], pos[5])
pos[3] = new_pos[0]
pos[4] = new_pos[1]
pos[5] = new_pos[2]

if patch_var is None:
continue
self.BEYOND_Patches[name] = patch_var
self.LoadPatches(canvas, pos_dict)

row = pos_dict["main"][0]
row_2 = pos_dict["main"][3]
Expand Down
1 change: 1 addition & 0 deletions src/modules/GameManager/FileManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def Create_Mod_Patch(mode=None):
config.write(configfile)

def UpdateSettings():
return # return early, this is no longer used but want to keep order of execution.
log.info("Checking for Settings...")
ProgressBar.string.set("Creating Settings..")
if cls._frontend.selected_settings.get() == "No Change":
Expand Down
19 changes: 16 additions & 3 deletions src/modules/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def create_combobox(self, canvas,

# add outline and user-tag to the outlined text.
outline_tag = ["outline", tag]

for item in tags:
outline_tag.append(item)

# create an outline to the text.
canvas.create_text(
scale(cul) + scale(1),
Expand Down Expand Up @@ -118,7 +122,7 @@ def create_combobox(self, canvas,
window=dropdown,
width=scale(width),
height=CBHEIGHT,
tags=tag
tags=tags
)
# bind canvas
dropdown.bind("<<ComboboxSelected>>", command)
Expand Down Expand Up @@ -151,6 +155,10 @@ def create_scale(self, canvas,

# add outline and user-tag to the outlined text.
outline_tag = ["outline", tag]

for item in tags:
outline_tag.append(item)

# create an outline to the text.
canvas.create_text(
scale(cul) + scale(1),
Expand Down Expand Up @@ -193,7 +201,7 @@ def create_scale(self, canvas,
window=scale_box,
width=scale(width),
height=scale(12),
tags=tag,
tags=tags,
)

# bind canvas
Expand Down Expand Up @@ -284,8 +292,13 @@ def create_checkbutton(
active_color_new = None
elif is_active is True:
tags.append("active_text")

# add outline and user-tag to the outlined text.
outline_tag = ["outline", tag]

for item in tags:
outline_tag.append(item)

# create an outline to the text.
canvas.create_text(
scale(cul) + scale(1),
Expand Down Expand Up @@ -330,7 +343,7 @@ def create_checkbutton(
window=checkbutton,
width = scale(11),
height = scale(11),
tags=tag
tags=tags
)
# attempt to make a Hover tip
canvas.tag_bind(text_line, "<Button-1>", lambda event: toggle(event, new_variable))
Expand Down

0 comments on commit d8381e2

Please sign in to comment.