From 9628407f5ddc86877923a5cb547113fae6f6e9d3 Mon Sep 17 00:00:00 2001 From: MaxLastBreath Date: Sat, 5 Oct 2024 19:43:49 +0300 Subject: [PATCH] New stuff. - Mod Creator new functions - UCAutoPatcher - UCResolutionPatcher - Fixed configs to work with multiple games now :) --- src/Patches/Breath Of The Wild/Options.json | 236 ++++++++++++++++++ src/Patches/Breath Of The Wild/PatchInfo.json | 4 +- src/form.py | 4 +- src/modules/GameManager/FileManager.py | 82 +----- src/modules/GameManager/ModCreator.py | 96 +++++++ src/modules/config.py | 203 ++++++++------- 6 files changed, 447 insertions(+), 178 deletions(-) create mode 100644 src/Patches/Breath Of The Wild/Options.json diff --git a/src/Patches/Breath Of The Wild/Options.json b/src/Patches/Breath Of The Wild/Options.json new file mode 100644 index 0000000..bff4a44 --- /dev/null +++ b/src/Patches/Breath Of The Wild/Options.json @@ -0,0 +1,236 @@ +{ + "Keys": { + "freecam": { + "Name": "FreeCam NEW", + "Class": "bool", + "Section": "main", + "Auto": false, + "Default": true, + "Description": "UltraCam Beyond Freecam! NEWLY IMPROVED FREECAM from 2.0\nTurning this off will, not let you trigger freecam with controller.\n", + "Config_Class": [ + "UltraCam", + "TriggerWithController" + ] + }, + "fps": { + "Name": "FPS", + "Class": "scale", + "Section": "main", + "Auto": false, + "Values": [ + 20, + 240 + ], + "Type": "s32", + "Default": 60, + "Increments": 5, + "Description": "UltraCam Beyond New FPS setting.\nLet's you set to any FPS\nWARNING: SET TO 120 FPS FOR UNCAPPED.\nRecommended 30, 60 FPS caps for best FRAMETIMES.", + "Config_Class": [ + "Resolution", + "MaxFramerate" + ] + }, + "menu fps": { + "Name": "Menu FPS", + "Class": "scale", + "Section": "main", + "Auto": false, + "Values": [ + 20, + 120 + ], + "Type": "s32", + "Default": 60, + "Increments": 5, + "Description": "UltraCam Beyond NEW MENU FPS CAP. Set to your desire.", + "Config_Class": [ + "Features", + "MenuFPSLock" + ] + }, + "fov": { + "Name": "FOV", + "Class": "scale", + "Section": "main", + "Auto": false, + "Values": [ + 20, + 120 + ], + "Type": "s32", + "Default": 50, + "Increments": 5, + "Description": "UltraCam Beyond NEW FOV setting, allows you to set FOV to anything\nThis now also scales up everything related to FOV.", + "Config_Class": [ + "Features", + "Fov" + ] + }, + "quality improvements": { + "Name": "Quality Improvements", + "Class": "bool", + "Section": "main", + "Auto": false, + "Default": true, + "Description": "UltraCam Beyond Quality Improvements. This disables FXAA, FSR and Dynamic Resolution\nWARNING: SHOULD ALWAYS BE TURNED ON WITH HIGH RESOLUTION", + "Config_Class": [ + "Resolution", + "QualityImprovements" + ] + }, + "resolution": { + "Name": "Resolution", + "Class": "dropdown", + "Section": "main", + "Auto": false, + "Name_Values": [ + "720p", + "900p", + "1080p", + "1152p" + ], + "Values": [ + "1280x720", + "1600x900", + "1920x1080", + "2048x1152" + ], + "Default": 2, + "Description": "UltraCam Beyond NEW Resolution Scaling uses internal resolution\nWARNING: ANYTHING OVER 1440P REQUIRES EXTENDED MEMORY", + "Config_Class": [ + "Resolution", + "Width", + "Height" + ] + }, + "render distance": { + "Name": "Render Distance", + "Class": "dropdown", + "Section": "main", + "Auto": false, + "Name_Values": [ + "VERY LOW", + "LOW", + "MEDIUM", + "DEFAULT", + "(EXPERIMENTAL) HAS ISSUES" + ], + "Values": [ + 1000, + 5000, + 12500, + 25000, + 35000 + ], + "Default": 3, + "Description": "UltraCam Beyond Render Distance.\nDefault is 25000. Increased is 50000.\nMay see a small benefit on low, up to 20% fps.\nExpect the game to use fog like rendering Minecraft.", + "Config_Class": [ + "Resolution", + "RenderDistance" + ] + }, + "hide ui": { + "Name": "Auto Hide UI in FreeCam", + "Class": "bool", + "Section": "extra", + "Auto": false, + "Default": true, + "Description": "UltraCam Beyond AUTO Hide UI, this will automatically hide the UI in freecam mode.", + "Config_Class": [ + "UltraCam", + "AutoHideUI" + ] + }, + "freecam sens": { + "Name": "Freecam Sensitivity", + "Class": "scale", + "Section": "extra", + "Auto": false, + "Values": [ + 10, + 100 + ], + "Type": "s32", + "Default": 30, + "Increments": 5, + "Description": "Increase Freecam Sensitivity.", + "Config_Class": [ + "UltraCam", + "CameraSpeed" + ] + }, + "freecam speed": { + "Name": "Freecam Speed", + "Class": "scale", + "Section": "extra", + "Auto": false, + "Values": [ + 1, + 20 + ], + "Type": "s32", + "Default": 5, + "Increments": 1, + "Description": "Increase Camera Movement Speed.", + "Config_Class": [ + "UltraCam", + "Speed" + ] + }, + "ani smoothing": { + "Name": "Sequence Smoothing", + "Class": "scale", + "Section": "extra", + "Auto": true, + "Values": [ + 0.1, + 0.5 + ], + "Type": "f32", + "Default": 0.25, + "Increments": 0.05, + "Description": "Animation Smoothing set to auto for now.", + "Config_Class": [ + "UltraCam", + "AnimationSmoothing" + ] + }, + "animationfadeout": { + "Name": "Last Keyframe Fadeout", + "Class": "bool", + "Section": "extra", + "Auto": false, + "Default": false, + "Description": "Improves the smoothness of the last Keyframe for UltraCam sequencer.", + "Config_Class": [ + "UltraCam", + "AnimationFadeout" + ] + }, + "benchmark": { + "Name": "Benchmark Selection", + "Class": "dropdown", + "Section": "extra", + "Auto": false, + "Name_Values": [ + "Kakariko", + "Great Sky Island", + "Lookout Landing", + "Goron City", + "Korok Forest" + ], + "Values": [ + 0, + 1, + 2, + 3 + ], + "Default": 1, + "Description": "UltraCam Beyond preset default benchmark.\nTrigger when you press G", + "Config_Class": [ + "Benchmark", + "Benchmark" + ] + } + } +} \ No newline at end of file diff --git a/src/Patches/Breath Of The Wild/PatchInfo.json b/src/Patches/Breath Of The Wild/PatchInfo.json index da2676a..668d7e9 100644 --- a/src/Patches/Breath Of The Wild/PatchInfo.json +++ b/src/Patches/Breath Of The Wild/PatchInfo.json @@ -1,7 +1,7 @@ { "Name" : "Breath of The Wild", - "ID" : "0100F2C0115B6000", - "ModName" : "!!!TOTK Optimizer", + "ID" : "01007EF00011E000", + "ModName" : "!!!BOTW Optimizer", "ModConfig" : "UltraCam/maxlastbreath.ini", "Config" : "Options.json", "Versions" : ["1.1.0", "1.1.1", "1.1.2", "1.2.0", "1.2.1"] diff --git a/src/form.py b/src/form.py index 5f3cf3f..ddff123 100644 --- a/src/form.py +++ b/src/form.py @@ -94,7 +94,6 @@ 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): @@ -182,6 +181,7 @@ def LoadPatches(self, canvas, pos_dict): self.BEYOND_Patches[name] = patch_var def DeletePatches(self): + self.BEYOND_Patches.clear() self.all_canvas[0].delete("patchinfo") def create_canvas(self): @@ -256,7 +256,7 @@ def onCanvasClick(event): master=self._window, canvas=canvas, text="Select Game:", variable=value[0], values=value, - row=row, cul=340, drop_cul=480, + row=row, cul=340, drop_cul=430, tags=["text"], tag="GameSelect", description_name="GameSelect", command= lambda event: self.LoadNewGameInfo() diff --git a/src/modules/GameManager/FileManager.py b/src/modules/GameManager/FileManager.py index 02455a7..c61cdb4 100644 --- a/src/modules/GameManager/FileManager.py +++ b/src/modules/GameManager/FileManager.py @@ -382,6 +382,9 @@ def Create_Mod_Patch(mode=None): cls.add_list.append("Mod Manager Patch") cls.add_list.append("UltraCam") + + # THIS NEEDS TO BE CHANGED SOON. + ini_file_directory = os.path.join(cls.load_dir, "!!!TOTK Optimizer", "romfs", "UltraCam") os.makedirs(ini_file_directory, exist_ok=True) ini_file_path = os.path.join(ini_file_directory, "maxlastbreath.ini") @@ -392,83 +395,8 @@ def Create_Mod_Patch(mode=None): config.read(ini_file_path) ## TOTK UC BEYOND AUTO PATCHER - patch_info = cls._frontend.ultracam_beyond.get("Keys", [""]) - for patch in cls._frontend.BEYOND_Patches: - if patch.lower() in ["resolution", "aspect ratio"]: - continue - - patch_dict = patch_info[patch] - patch_class = patch_dict["Class"] - patch_Config = patch_dict["Config_Class"] - patch_Default = patch_dict["Default"] - - # Ensure we have the section required. - if not config.has_section(patch_Config[0]): - config[patch_Config[0]] = {} - - # In case we have an auto patch. - if cls._frontend.BEYOND_Patches[patch] == "auto" or cls._frontend.BEYOND_Patches[patch].get() == "auto": - if patch_class.lower() == "dropdown": - patch_Names = patch_dict["Values"] - config[patch_Config[0]][patch_Config[1]] = str(patch_Names[patch_Default]) - else: - config[patch_Config[0]][patch_Config[1]] = str(patch_Default) - continue - - if patch_class.lower() == "bool" or patch_class.lower() == "scale": - config[patch_Config[0]][patch_Config[1]] = cls._frontend.BEYOND_Patches[patch].get() - - if patch_class.lower() == "dropdown": - # exclusive to dropdown. - patch_Names = patch_dict["Name_Values"] - patch_Values = patch_dict["Values"] - index = patch_Names.index(cls._frontend.BEYOND_Patches[patch].get()) - config[patch_Config[0]][patch_Config[1]] = str(patch_Values[index]) - - resolution = cls._frontend.BEYOND_Patches["resolution"].get() - shadows = int(cls._frontend.BEYOND_Patches["shadow resolution"].get().split("x")[0]) - - # ARR = cls._frontend.BEYOND_Patches["aspect ratio"].get().split("x") - ARR = [16, 9] - New_Resolution = patch_info["resolution"]["Values"][patch_info["resolution"]["Name_Values"].index(resolution)].split("x") - New_Resolution = convert_resolution(int(New_Resolution[0]), int(New_Resolution[1]), int(ARR[0]), int(ARR[1])) - - scale_1080 = 1920*1080 - scale_shadows = round(shadows / 1024) - New_Resolution_scale = int(New_Resolution[0]) * int(New_Resolution[1]) - new_scale = New_Resolution_scale / scale_1080 - - if (scale_shadows > new_scale): - new_scale = scale_shadows - log.info(f"scale:{new_scale}") - - layout = 0 - if(new_scale < 0): - layout = 0 - if(new_scale > 1): - layout = 1 - if(new_scale > 6): - layout = 2 - - if cls.mode == "Legacy": - write_Legacy_config(cls._frontend, cls.TOTKconfig, cls._frontend.title_id, "Renderer", "resolution_setup", "2") - write_Legacy_config(cls._frontend, cls.TOTKconfig, cls._frontend.title_id, "Core", "memory_layout_mode", f"{layout}") - write_Legacy_config(cls._frontend, cls.TOTKconfig, cls._frontend.title_id, "System", "use_docked_mode", "true") - - if layout > 0: - write_Legacy_config(cls._frontend, cls.TOTKconfig, cls._frontend.title_id, "Renderer", "vram_usage_mode", "1") - else: - write_Legacy_config(cls._frontend, cls.TOTKconfig, cls._frontend.title_id, "Renderer", "vram_usage_mode", "0") - - if cls.mode == "Ryujinx": - write_ryujinx_config(cls._frontend, cls.ryujinx_config, "res_scale", 1) - if (layout > 0): - write_ryujinx_config(cls._frontend, cls.ryujinx_config, "expand_ram", True) - else: - write_ryujinx_config(cls._frontend, cls.ryujinx_config, "expand_ram", False) - - config["Resolution"]["Width"] = str(New_Resolution[0]) - config["Resolution"]["Height"] = str(New_Resolution[1]) + ModCreator.UCAutoPatcher(cls._frontend, config) + ModCreator.UCResolutionPatcher(cls._frontend, config) ## WRITE IN CONFIG FILE FOR UC 2.0 with open(ini_file_path, 'w+', encoding="utf-8") as configfile: diff --git a/src/modules/GameManager/ModCreator.py b/src/modules/GameManager/ModCreator.py index 889c64e..c57031d 100644 --- a/src/modules/GameManager/ModCreator.py +++ b/src/modules/GameManager/ModCreator.py @@ -67,3 +67,99 @@ def CreateExefs(cls, patchinfo, directory, version_options, selected_options): else: file.write(" ") file.write("\n@stop\n") + + @classmethod + def UCAutoPatcher(cls, manager, config): + patch_info = manager.ultracam_beyond.get("Keys", [""]) + + for patch in manager.BEYOND_Patches: + if patch.lower() in ["resolution", "aspect ratio"]: + continue + + patch_dict = patch_info[patch] + patch_class = patch_dict["Class"] + patch_Config = patch_dict["Config_Class"] + patch_Default = patch_dict["Default"] + + # Ensure we have the section required. + if not config.has_section(patch_Config[0]): + config[patch_Config[0]] = {} + + # In case we have an auto patch. + if manager.BEYOND_Patches[patch] == "auto" or manager.BEYOND_Patches[patch].get() == "auto": + if patch_class.lower() == "dropdown": + patch_Names = patch_dict["Values"] + config[patch_Config[0]][patch_Config[1]] = str(patch_Names[patch_Default]) + else: + config[patch_Config[0]][patch_Config[1]] = str(patch_Default) + continue + + if patch_class.lower() == "bool" or patch_class.lower() == "scale": + config[patch_Config[0]][patch_Config[1]] = manager.BEYOND_Patches[patch].get() + + if patch_class.lower() == "dropdown": + # exclusive to dropdown. + patch_Names = patch_dict["Name_Values"] + patch_Values = patch_dict["Values"] + index = patch_Names.index(manager.BEYOND_Patches[patch].get()) + config[patch_Config[0]][patch_Config[1]] = str(patch_Values[index]) + + @classmethod + def UCResolutionPatcher(cls, manager, config): + patch_info = manager.ultracam_beyond.get("Keys", [""]) + + try: + resolution = manager.BEYOND_Patches["resolution"].get() + except Exception as e : + resolution = 1 + + try: + shadows = int(manager.BEYOND_Patches["shadow resolution"].get().split("x")[0]) + except Exception as e : + shadows = 1024 + + if patch_info != ["resolution"]: + return + + # ARR = manager.BEYOND_Patches["aspect ratio"].get().split("x") + ARR = [16, 9] + New_Resolution = patch_info["resolution"]["Values"][patch_info["resolution"]["Name_Values"].index(resolution)].split("x") + New_Resolution = convert_resolution(int(New_Resolution[0]), int(New_Resolution[1]), int(ARR[0]), int(ARR[1])) + + scale_1080 = 1920*1080 + scale_shadows = round(shadows / 1024) + New_Resolution_scale = int(New_Resolution[0]) * int(New_Resolution[1]) + new_scale = New_Resolution_scale / scale_1080 + + if (scale_shadows > new_scale): + new_scale = scale_shadows + log.info(f"scale:{new_scale}") + + layout = 0 + if(new_scale < 0): + layout = 0 + if(new_scale > 1): + layout = 1 + if(new_scale > 6): + layout = 2 + + if cls.mode == "Legacy": + write_Legacy_config(manager, cls.TOTKconfig, manager.title_id, "Renderer", "resolution_setup", "2") + write_Legacy_config(manager, cls.TOTKconfig, manager.title_id, "Core", "memory_layout_mode", f"{layout}") + write_Legacy_config(manager, cls.TOTKconfig, manager.title_id, "System", "use_docked_mode", "true") + + if layout > 0: + write_Legacy_config(manager, cls.TOTKconfig, manager.title_id, "Renderer", "vram_usage_mode", "1") + else: + write_Legacy_config(manager, cls.TOTKconfig, manager.title_id, "Renderer", "vram_usage_mode", "0") + + if cls.mode == "Ryujinx": + write_ryujinx_config(manager, cls.ryujinx_config, "res_scale", 1) + if (layout > 0): + write_ryujinx_config(manager, cls.ryujinx_config, "expand_ram", True) + else: + write_ryujinx_config(manager, cls.ryujinx_config, "expand_ram", False) + + config["Resolution"]["Width"] = str(New_Resolution[0]) + config["Resolution"]["Height"] = str(New_Resolution[1]) + \ No newline at end of file diff --git a/src/modules/config.py b/src/modules/config.py index 27d64f6..eb39c98 100644 --- a/src/modules/config.py +++ b/src/modules/config.py @@ -1,59 +1,122 @@ from configuration.settings import * import os, json -def apply_preset(self, preset_options): - # self.fetch_var(self.ui_var, preset_options, "UI") - # self.fetch_var(self.fp_var, preset_options, "First Person") - self.fetch_var(self.selected_settings, preset_options, "Settings") - patch_info = self.ultracam_beyond.get("Keys", [""]) +def apply_preset(Manager, preset_options): + # Manager.fetch_var(Manager.ui_var, preset_options, "UI") + # Manager.fetch_var(Manager.fp_var, preset_options, "First Person") + Manager.fetch_var(Manager.selected_settings, preset_options, "Settings") + patch_info = Manager.ultracam_beyond.get("Keys", [""]) for option_key, option_value in preset_options.items(): - if option_key in self.selected_options: - self.selected_options[option_key].set(option_value) + if option_key in Manager.selected_options: + Manager.selected_options[option_key].set(option_value) else: continue - selected_preset = self.selected_preset.get() + selected_preset = Manager.selected_preset.get() if selected_preset.lower() == "default": - for option_key in self.BEYOND_Patches: + for option_key in Manager.BEYOND_Patches: patch_dict = patch_info[option_key.lower()] patch_class = patch_dict["Class"] patch_default = patch_dict["Default"] if patch_class == "dropdown": patch_names = patch_dict["Name_Values"] - self.BEYOND_Patches[option_key.lower()].set(patch_names[patch_default]) + Manager.BEYOND_Patches[option_key.lower()].set(patch_names[patch_default]) elif patch_class == "scale": - self.maincanvas.itemconfig(patch_dict["Name"], text=patch_default) - self.BEYOND_Patches[option_key.lower()].set(patch_default) + Manager.maincanvas.itemconfig(patch_dict["Name"], text=patch_default) + Manager.BEYOND_Patches[option_key.lower()].set(patch_default) else: if patch_class == "bool": if patch_default is True: patch_default = "On" if patch_default is False: patch_default = "Off" - self.BEYOND_Patches[option_key.lower()].set(patch_default) + Manager.BEYOND_Patches[option_key.lower()].set(patch_default) for option_key, option_value in preset_options.items(): - if option_key.lower() in self.BEYOND_Patches: + if option_key.lower() in Manager.BEYOND_Patches: patch_dict = patch_info[option_key.lower()] patch_class = patch_dict["Class"] patch_default = patch_dict["Default"] if patch_class == "dropdown": patch_Names = patch_dict["Name_Values"] - self.BEYOND_Patches[option_key.lower()].set(patch_Names[int(option_value)]) + Manager.BEYOND_Patches[option_key.lower()].set(patch_Names[int(option_value)]) elif patch_class == "scale": - self.maincanvas.itemconfig(patch_dict["Name"], text=option_value) - self.BEYOND_Patches[option_key.lower()].set(option_value) + Manager.maincanvas.itemconfig(patch_dict["Name"], text=option_value) + Manager.BEYOND_Patches[option_key.lower()].set(option_value) else: if patch_class == "bool": if option_value is True: option_value = "On" if option_value is False: option_value = "Off" - self.BEYOND_Patches[option_key.lower()].set(option_value) + Manager.BEYOND_Patches[option_key.lower()].set(option_value) else: continue -def save_user_choices(self, config_file, Legacy_path=None, mode=None): +def setGameConfig(Manager, config): + # UltraCam Beyond new patches. + patch_info = Manager.ultracam_beyond.get("Keys", [""]) + sectionName = Manager._patchInfo.ID + + if not config.has_section(sectionName): + config.add_section(sectionName) + + for patch in Manager.BEYOND_Patches: + patch_dict = patch_info[patch] + patch_class = patch_dict["Class"] + + if Manager.BEYOND_Patches[patch] == "auto": + config.set(sectionName, patch, str(patch_dict["Default"])) + continue + elif Manager.BEYOND_Patches[patch].get() == "auto": + config.set(sectionName, patch, str(patch_dict["Default"])) + continue + + if patch_class.lower() == "dropdown": + patch_Names = patch_dict["Name_Values"] + index = patch_Names.index(Manager.BEYOND_Patches[patch].get()) + config.set(sectionName, patch, str(index)) + continue + + config.set(sectionName, patch, Manager.BEYOND_Patches[patch].get()) + +def loadGameConfig(Manager, config): + # Load UltraCam Beyond new patches. + patch_info = Manager.ultracam_beyond.get("Keys", [""]) + for patch in Manager.BEYOND_Patches: + patch_dict = patch_info[patch] + patch_class = patch_dict["Class"] + patch_default = patch_dict["Default"] + if patch_class.lower() == "dropdown": + patch_Names = patch_dict["Name_Values"] + try: + Manager.BEYOND_Patches[patch].set(patch_Names[int(config["Beyond"][patch])]) + except KeyError: + pass + except ValueError: + if config["Beyond"][patch] == "auto": + Manager.BEYOND_Patches[patch].set(patch_Names[int(patch_default)]) + continue + continue + if patch_class.lower() == "scale": + # use name for tag accuracy + Manager.maincanvas.itemconfig(patch_dict["Name"], text=Manager.BEYOND_Patches[patch].get()) + try: + patch_type = patch_dict["Type"] + + if patch_type == "f32": + Manager.BEYOND_Patches[patch].set(float(config[config[Manager._patchInfo.Name]][patch])) + else: + Manager.BEYOND_Patches[patch].set(config[config[Manager._patchInfo.Name]][patch]) + except KeyError: + pass + try: + if patch_class.lower() == "bool": + Manager.BEYOND_Patches[patch].set(config[config[Manager._patchInfo.Name]][patch]) + except KeyError: + pass + +def save_user_choices(Manager, config_file, Legacy_path=None, mode=None): log.info(f"Saving user choices in {localconfig}") config = configparser.ConfigParser() if os.path.exists(config_file): @@ -61,59 +124,38 @@ def save_user_choices(self, config_file, Legacy_path=None, mode=None): if mode == "Cheats": config["Cheats"] = {} - for option_name, option_var in self.selected_cheats.items(): + for option_name, option_var in Manager.selected_cheats.items(): config['Cheats'][option_name] = option_var.get() with open(config_file, 'w', encoding="utf-8") as file: config["Manager"] = {} - config["Manager"]["Cheat_Version"] = self.cheat_version.get() + config["Manager"]["Cheat_Version"] = Manager.cheat_version.get() config.write(file) return # This is only required for the UI and FP mods. if not config.has_section("Options"): config["Options"] = {} - # config['Options']['UI'] = self.ui_var.get() - # config['Options']['First Person'] = self.fp_var.get() + # config['Options']['UI'] = Manager.ui_var.get() + # config['Options']['First Person'] = Manager.fp_var.get() + + setGameConfig(Manager, config) # Save the enable/disable choices - for option_name, option_var in self.selected_options.items(): + for option_name, option_var in Manager.selected_options.items(): config['Options'][option_name] = option_var.get() # Save the Legacy.exe path if provided if not config.has_section("Paths"): config["Paths"] = {} - if self.mode == "Legacy": + if Manager.mode == "Legacy": if Legacy_path: config['Paths']['LegacyPath'] = Legacy_path - if self.mode == "Ryujinx": + if Manager.mode == "Ryujinx": if Legacy_path: config['Paths']['RyujinxPath'] = Legacy_path # Save the manager selected mode I.E Ryujinx/Legacy - config["Mode"] = {"ManagerMode": self.mode} - - if not config.has_section("Beyond"): - config["Beyond"] = {} - - # UltraCam Beyond new patches. - patch_info = self.ultracam_beyond.get("Keys", [""]) - for patch in self.BEYOND_Patches: - patch_dict = patch_info[patch] - patch_class = patch_dict["Class"] - - if self.BEYOND_Patches[patch] == "auto": - config["Beyond"][patch] = str(patch_dict["Default"]) - continue - elif self.BEYOND_Patches[patch].get() == "auto": - config["Beyond"][patch] = str(patch_dict["Default"]) - continue - - if patch_class.lower() == "dropdown": - patch_Names = patch_dict["Name_Values"] - index = patch_Names.index(self.BEYOND_Patches[patch].get()) - config["Beyond"][patch] = str(index) - continue - config["Beyond"][patch] = self.BEYOND_Patches[patch].get() + config["Mode"] = {"ManagerMode": Manager.mode} log.info("User choices saved in Memory," "Attempting to write into file.") @@ -122,78 +164,45 @@ def save_user_choices(self, config_file, Legacy_path=None, mode=None): config.write(file) log.info("Successfully written into log file") -def load_user_choices(self, config_file, mode=None): +def load_user_choices(Manager, config_file, mode=None): config = configparser.ConfigParser() config.read(config_file, encoding="utf-8") if mode == "Cheats": - self.cheat_version.set(config.get("Manager", "Cheat_Version", fallback="Version - 1.2.1")) + Manager.cheat_version.set(config.get("Manager", "Cheat_Version", fallback="Version - 1.2.1")) try: - for option_name, option_var in self.selected_cheats.items(): + for option_name, option_var in Manager.selected_cheats.items(): option_value = config.get('Cheats', option_name, fallback="Off") option_var.set(option_value) except AttributeError: pass - # Load UltraCam Beyond new patches. - patch_info = self.ultracam_beyond.get("Keys", [""]) - for patch in self.BEYOND_Patches: - patch_dict = patch_info[patch] - patch_class = patch_dict["Class"] - patch_default = patch_dict["Default"] - if patch_class.lower() == "dropdown": - patch_Names = patch_dict["Name_Values"] - try: - self.BEYOND_Patches[patch].set(patch_Names[int(config["Beyond"][patch])]) - except KeyError: - pass - except ValueError: - if config["Beyond"][patch] == "auto": - self.BEYOND_Patches[patch].set(patch_Names[int(patch_default)]) - continue - continue - if patch_class.lower() == "scale": - # use name for tag accuracy - self.maincanvas.itemconfig(patch_dict["Name"], text=self.BEYOND_Patches[patch].get()) - try: - patch_type = patch_dict["Type"] - - if patch_type == "f32": - self.BEYOND_Patches[patch].set(float(config["Beyond"][patch])) - else: - self.BEYOND_Patches[patch].set(config["Beyond"][patch]) - except KeyError: - pass - try: - if patch_class.lower() == "bool": - self.BEYOND_Patches[patch].set(config["Beyond"][patch]) - except KeyError: - pass + # loadGameConfig(Manager, config) # Load the enable/disable choices - for option_name, option_var in self.selected_options.items(): + for option_name, option_var in Manager.selected_options.items(): option_value = config.get('Options', option_name, fallback="Off") option_var.set(option_value) # Load the enable/disabled cheats try: - for option_name, option_var in self.selected_cheats.items(): + for option_name, option_var in Manager.selected_cheats.items(): option_value = config.get('Cheats', option_name, fallback="Off") option_var.set(option_value) except AttributeError as e: # continue, not important. handle = e -def apply_selected_preset(self, event=None): +def apply_selected_preset(Manager, event=None): try: - selected_preset = self.selected_preset.get() + selected_preset = Manager.selected_preset.get() except AttributeError as e: selected_preset = "Saved" log.error(f"Failed to apply selected preset: {e}") if selected_preset.lower() == "saved": - load_user_choices(self, self.config) - elif selected_preset in self.presets: - preset_to_apply = self.presets[selected_preset] + load_user_choices(Manager, Manager.config) + elif selected_preset in Manager.presets: + preset_to_apply = Manager.presets[selected_preset] for key, value in preset_to_apply.items(): if value is True: preset_to_apply[key] = "On" @@ -204,9 +213,9 @@ def apply_selected_preset(self, event=None): elif not isinstance(value, int) and not isinstance(value, float) and value.lower() in ["disable", "disabled", "off"]: preset_to_apply[key] = "Off" # Apply the selected preset from the online presets - apply_preset(self, self.presets[selected_preset]) + apply_preset(Manager, Manager.presets[selected_preset]) -def write_Legacy_config(self, configfile, title_id, section, setting, selection): +def write_Legacy_config(Manager, configfile, title_id, section, setting, selection): os.makedirs(configfile, exist_ok=True) Custom_Config = os.path.join(configfile, f"{title_id}.ini") Legacyconfig = configparser.ConfigParser() @@ -219,7 +228,7 @@ def write_Legacy_config(self, configfile, title_id, section, setting, selection) with open(Custom_Config, "w", encoding="utf-8") as configfile: Legacyconfig.write(configfile, space_around_delimiters=False) -def write_ryujinx_config(self, configfile, setting, selection): +def write_ryujinx_config(Manager, configfile, setting, selection): with open(configfile, "r", encoding="utf-8") as file: data = json.load(file) data[setting] = selection