Skip to content

Commit

Permalink
The rest of the changes for 1.1.0 RELEASE!
Browse files Browse the repository at this point in the history
Now in Final Phase of Testing!
  • Loading branch information
MaxLastBreath committed Jul 28, 2023
1 parent 58bd87e commit 8ccd3eb
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 39 deletions.
102 changes: 77 additions & 25 deletions src/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ def __init__(self, window):
shadow_resolution_dropdown_window = canvas.create_window(200, 200, anchor="w", window=shadow_resolution_dropdown)

# Create a Label for camera quality
canvas.create_text(40, 240, text="Camera Quality:", anchor="w", fill="#D1F3FD", font=textfont)
self.camera_var = tk.StringVar(value=self.dfps_options.get("CameraQualityNames", [""])[0]) # Set the default camera quality to "Enable"
# Make exception for camera quality
CameraQ = self.dfps_options.get("CameraQualityNames", [""])
for index, value in enumerate(CameraQ):
if value == "Enable" or value == "Enabled":
CameraQ[index] = "On"
elif value == "Disable" or value == "Disabled":
CameraQ[index] = "Off"

canvas.create_text(40, 240, text="Camera Quality++:", anchor="w", fill="#D1F3FD", font=textfont)
self.camera_var = tk.StringVar(value=CameraQ[0]) # Set the default camera quality to "Enable"
camera_dropdown = ttk.Combobox(window, textvariable=self.camera_var, values=self.dfps_options.get("CameraQualityNames", []))
camera_dropdown_window = canvas.create_window(200, 240, anchor="w", window=camera_dropdown)

Expand All @@ -129,11 +137,11 @@ def __init__(self, window):

# First Person and FOV
canvas.create_text(40, 320, text="Enable First Person:", anchor="w", fill="#D1F3FD", font=textfont)
fp_values = ["Disabled", "70 FOV", "90 FOV", "110 FOV"]
fp_values = ["Off", "70 FOV", "90 FOV", "110 FOV"]
self.fp_var = tk.StringVar(value=ui_values[0])
fp_dropdown = ttk.Combobox(window, textvariable=self.fp_var, values=fp_values)
fp_dropdown_window = canvas.create_window(200, 320, anchor="w", window=fp_dropdown)

# Create labels and enable/disable options for each entry
self.selected_options = {}
row = 320
Expand All @@ -147,8 +155,8 @@ def __init__(self, window):
canvas.create_text(40, row + 40, text=version_option_name, anchor="w", fill="#D1F3FD", font=textfont)

# Create enable/disable dropdown menu
version_option_var = tk.StringVar(value="Enable")
version_option_dropdown = ttk.Combobox(window, textvariable=version_option_var, values=["Enable", "Disable"])
version_option_var = tk.StringVar(value="On")
version_option_dropdown = ttk.Combobox(window, textvariable=version_option_var, values=["On", "Off"])
version_option_dropdown_window = canvas.create_window(200, row + 40, anchor="w", window=version_option_dropdown)

self.selected_options[version_option_name] = version_option_var
Expand Down Expand Up @@ -277,6 +285,16 @@ def apply_selected_preset(self, event=None):
else:
messagebox.showinfo("Saved Preset", "No saved preset found. Please save your current settings first.")
elif selected_preset in self.presets_data:
preset_to_apply = self.presets_data[selected_preset]
for key, value in preset_to_apply.items():
if value == "Enable":
preset_to_apply[key] = "On"
if value == "Enabled":
preset_to_apply[key] = "On"
elif value == "Disable":
preset_to_apply[key] = "Off"
elif value == "Disabled":
preset_to_apply[key] = "Off"
# Apply the selected preset from the online presets
self.apply_preset(self.presets[selected_preset])
#fetch presets
Expand Down Expand Up @@ -358,7 +376,6 @@ def load_dfps_options_from_json(self):
self.dfps_options = json.load(file)
else:
self.dfps_options = {}

return self.dfps_options

def load_version_options_from_json(self):
Expand Down Expand Up @@ -779,12 +796,20 @@ def UpdateVisualImprovements():
file.write(version_option.get("offset", "") + "\n")

for key, value in version_option.items():
if key not in ["Source", "nsobid", "offset", "version"] and key in selected_options and selected_options[key] == "Enable":
if key not in ["Source", "nsobid", "offset", "version"] and key in selected_options and selected_options[key] in ["Enable", "On"]:
file.write(value + "\n")

qtconfig = configparser.ConfigParser(allow_no_value=True, delimiters=('=',), comment_prefixes=('#',), strict=False)
qtconfig.optionxform = lambda option: option
qtconfig.read(self.configdir)
# Ensures that the patches are active
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "DFPS", action="remove")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Mod Manager Patches", action="remove")
# To maximize compatbility with old version of Mod Folders and Mod Manager.
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Visual Improvements", action="add")
# Update Visual Improvements MOD.
with open(ini_file_path, 'w') as configfile:
config.write(configfile)

def UpdateSettings():
Setting_folder = None
SettingGithubFolder = None
Expand Down Expand Up @@ -864,7 +889,14 @@ def UpdateSettings():
config.write(configfile)
else:
print("Selected option has no associated setting folder.")

def DownloadDFPS():
# Make sure DFPS is enabled.
qtconfig = configparser.ConfigParser(allow_no_value=True, delimiters=('=',), comment_prefixes=('#',), strict=False)
qtconfig.optionxform = lambda option: option
qtconfig.read(self.configdir)
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "DFPS", action="remove")

config = configparser.ConfigParser()
config_file = "VisualImprovements.ini"
config.read(config_file)
Expand Down Expand Up @@ -910,34 +942,37 @@ def DownloadDFPS():
config.write(configfile)
else:
print("You already have the latest DFPS version and the folder exists!")
def DownloadUI():

config = configparser.ConfigParser(allow_no_value=True, delimiters=('=',), comment_prefixes=('#',), strict=False)
config.optionxform = lambda option: option # To preserve the case of the options
config.read(self.configdir)
def DownloadUI():
qtconfig = configparser.ConfigParser(allow_no_value=True, delimiters=('=',), comment_prefixes=('#',), strict=False)
qtconfig.optionxform = lambda option: option
qtconfig.read(self.configdir)

ui_mod_folder = None
CurrentFolder = None
ui_selection = self.ui_var.get()
print(f"{self.fp_var.get()}")
if ui_selection == "none":
print("No UI Selected")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Xbox UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Playstation UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "BlackscreenFix", action="add")
print("No UI Selected, Disabling all UI mods!")
elif ui_selection == "PS4":
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "Xbox UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "BlackscreenFix", action="add")
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "Playstation UI", action="remove")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Xbox UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "BlackscreenFix", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Playstation UI", action="remove")
ui_mod_folder = "Playstation UI"
CurrentFolder = "scripts/UI/Playstation%20UI/"
elif ui_selection == "Xbox":
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "Playstation UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "BlackscreenFix", action="add")
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "Xbox UI", action="remove")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Playstation UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "BlackscreenFix", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Xbox UI", action="remove")
ui_mod_folder = "Xbox UI"
CurrentFolder = 'scripts/UI/Xbox%20UI/'
elif ui_selection == "Black Screen Fix":
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "Playstation UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "Xbox UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, config, self.title_id, "BlackscreenFix", action="remove")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Playstation UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "Xbox UI", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "BlackscreenFix", action="remove")
ui_mod_folder = "BlackscreenFix"
CurrentFolder = 'scripts/UI/BlackscreenFix/'

Expand All @@ -960,20 +995,36 @@ def DownloadUI():
print("failed to retrive folder and contents")

def DownloadFP():
qtconfig = configparser.ConfigParser(allow_no_value=True, delimiters=('=',), comment_prefixes=('#',), strict=False)
qtconfig.optionxform = lambda option: option
qtconfig.read(self.configdir)

FP_mod_folder = None
FPCurrentFolder = None
FP_selection = self.fp_var.get()
if FP_selection == "Disabled":
print("Third Person is selected!")
if FP_selection == "Off":
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 110 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 90 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 70 FOV", action="add")
print("Selected Third Person, removing ALL First Person Mods!")
elif FP_selection == "70 FOV":
FP_mod_folder = "First Person 70 FOV"
FPCurrentFolder = "scripts/UI/First%20Person%20FOV%2070/"
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 110 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 90 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 70 FOV", action="remove")
elif FP_selection == "90 FOV":
FP_mod_folder = "First Person 90 FOV"
FPCurrentFolder = 'scripts/UI/First%20Person%20FOV%2090/'
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 110 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 70 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 90 FOV", action="remove")
elif FP_selection == "110 FOV":
FP_mod_folder = "First Person 110 FOV"
FPCurrentFolder = 'scripts/UI/First%20Person%20FOV%20110/'
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 70 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 90 FOV", action="add")
modify_disabled_key(self.configdir, self.load_dir, qtconfig, self.title_id, "First Person 100 FOV", action="remove")
if FP_mod_folder is not None:
repo_url = 'https://api.github.com/repos/MaxLastBreath/TOTK-mods'
FPfolder_path = f'{FPCurrentFolder}'
Expand Down Expand Up @@ -1004,6 +1055,7 @@ def DownloadFP():
x_coordinate = (screen_width - window_width) // 2
y_coordinate = (screen_height - window_height) // 2
progress_window.geometry(f"{window_width}x{window_height}+{x_coordinate}+{y_coordinate}")
progress_window.resizable(False, False)
total_iterations = 100
progress_bar = ttk.Progressbar(progress_window, mode="determinate", maximum=total_iterations)
progress_bar.pack(pady=20)
Expand Down
Binary file removed src/modules/__pycache__/qt_config.cpython-311.pyc
Binary file not shown.
10 changes: 5 additions & 5 deletions src/modules/qt_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def find_and_remove_entry(configdir, directory, config, title_id, entry_to_remov
found = False
for key, value in config.items(section):
if value == entry_to_remove:
print(f"Entry to remove found: {entry_to_remove}")
# print(f"Entry to remove found: {entry_to_remove}")
found = True
break
if not found:
print(f"Entry '{entry_to_remove}' doesn't exist in section with title_id: {title_id}")
# print(f"Entry '{entry_to_remove}' doesn't exist in section with title_id: {title_id}")
return

d_values.remove(f"{entry_to_remove}")
Expand Down Expand Up @@ -135,7 +135,7 @@ def add_entry(configdir, directory, config, title_id, entry_to_add):
# Check if the entry already exists
d_values = sorted(get_d_values(config, properindex))
if entry_to_add in d_values:
print(f"Already exists{entry_to_add}")
# print(f"Already exists{entry_to_add}")
return

d_values.append(f"{entry_to_add}")
Expand All @@ -153,10 +153,10 @@ def add_entry(configdir, directory, config, title_id, entry_to_add):

def modify_disabled_key(configdir, directory, config, title_id, entry, action='add'):
if action == "add":
print("Adding key:", entry)
# print("Adding key:", entry)
add_entry(configdir, directory, config, title_id, entry)
if action == "remove":
print("Adding key:", entry)
# print("Adding key:", entry)
find_and_remove_entry(configdir, directory, config, title_id, entry)

def write_config_file(configdir, config):
Expand Down
40 changes: 31 additions & 9 deletions src/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
import platform
import sys
import subprocess
import tkinter as tk
from tkinter import messagebox

Version = "manager-1.1.0"
textver = Version.strip("manager-")
GITHUB = "TOTK-mods"
OWNER = "MaxLastBreath"
def show_confirmation_dialog(remote_version_str):
result = messagebox.askyesno("Confirmation", f"Mod Manager version {remote_version_str} was found, do you want to apply the update?")
return result

# Check For Update
def check_for_updates():
Expand All @@ -23,8 +28,11 @@ def check_for_updates():
remote_version = parse(remote_version_str)

if remote_version > parse(textver):
print("Update Available")
download_update(release_info["assets"])
confirmation_result = show_confirmation_dialog(remote_version_str)
if confirmation_result:
download_update(release_info["assets"])
else:
return
else:
print("No Updates Found. Your app is up to date.")

Expand Down Expand Up @@ -62,24 +70,38 @@ def download_update(assets):
f.write(response.content)

print("Asset downloaded successfully.")
apply_update()
apply_update(assets)

def apply_update():
def apply_update(assets):
print("Applying Update...")
updated_executable = "TOTK Mod Manager"
current_platform = platform.system()
updated_executable = None

for asset in assets:
asset_name = asset["name"]
if current_platform == "Windows" and asset_name.endswith(".exe"):
updated_executable = asset_name
break

if updated_executable is None:
print("No Windows executable found in the assets.")
return

try:
if sys.platform.startswith("linux"):
subprocess.Popen(["chmod", "+x", updated_executable])
elif sys.platform.startswith("win"):
pass

subprocess.Popen([updated_executable])
os.execl(updated_executable, *([updated_executable] + sys.argv[1:]))
except Exception as e:
print(f"Error applying update: {e}")
return

print("Update Applied. Exiting...")
relaunch()
time.sleep(2)
sys.exit()




def relaunch():
sys.exit()

0 comments on commit 8ccd3eb

Please sign in to comment.