def SettingsInputPressed(self, name: str) -> None: if name == "Enable": self.Status = "Enabled" self.SettingsInputs["Enter"] = "Disable" self.Enable() elif name == "Disable": self.Status = "Disabled" self.SettingsInputs["Enter"] = "Enable" self.Disable() elif name == "Reset Options": self.SetDefaultOptions() storeModSettings()
def __init__(self) -> None: # Hopefully I can remove this in a future SDK update self.Author += "\nVersion: " + str(self.Version) # type: ignore self.SettingsInputs = { "Enter": "Enable", "P": "Configure Presets", "R": "Reset Keybinds" } self.CheatPresetManager = PresetManager(self.PRESET_PATH, ALL_CHEATS) # This is a kind of hacky way for the preset manager to interface with the keybinds system # It's because the keybinds system is badly made and requires the main mod instance to # register all binds itself, just so that it can use the single callback on that instance # It would be much better if you could provide a custom callback per keybind - even if # you're not using something like my preset system, with any decent amount of binds you're # going to split up the callbacks anyway, it just gets too messy all being in one function # Hooks already work in this way too so it'd only help standardize code more # Output from the preset manager is html-escaped, the keybind menu doesn't use html, so this # stuff all has to convert it def AddPresetKeybind(name: str) -> None: self.Keybinds.append(Keybind(html.unescape(name))) storeModSettings() def RenamePresetKeybind(oldName: str, newName: str) -> None: for bind in self.Keybinds: if bind.Name == html.unescape(oldName): bind.Name = html.unescape(newName) storeModSettings() def RemovePresetKeybind(name: str) -> None: for bind in self.Keybinds: if bind.Name == html.unescape(name): self.Keybinds.remove(bind) storeModSettings() self.CheatPresetManager.AddKeybind = AddPresetKeybind # type: ignore self.CheatPresetManager.RenameKeybind = RenamePresetKeybind # type: ignore self.CheatPresetManager.RemoveKeybind = RemovePresetKeybind # type: ignore self.Keybinds = [] for cheat in ALL_CHEATS: self.Keybinds.append(Keybind(cheat.KeybindName)) for preset in self.CheatPresetManager.PresetList: self.Keybinds.append(Keybind(html.unescape(preset.Name))) storeModSettings()
def SettingsInputPressed(self, name: str) -> None: if name == "Enable": self.Status = "Enabled" self.SettingsInputs["Enter"] = "Disable" self.Enable() elif name == "Disable": self.Status = "Disabled" self.SettingsInputs["Enter"] = "Enable" self.Disable() elif name == "Configure Presets": self.CheatPresetManager.StartConfiguring() elif name == "Reset Keybinds": for bind in self.Keybinds: bind.Key = "None" storeModSettings()
def RemovePresetKeybind(name: str) -> None: for bind in self.Keybinds: if bind.Name == html.unescape(name): self.Keybinds.remove(bind) storeModSettings()
def RenamePresetKeybind(oldName: str, newName: str) -> None: for bind in self.Keybinds: if bind.Name == html.unescape(oldName): bind.Name = html.unescape(newName) storeModSettings()
def AddPresetKeybind(name: str) -> None: self.Keybinds.append(Keybind(html.unescape(name))) storeModSettings()
def CurrentValue(self, val: Any) -> None: self._CurrentValue = val storeModSettings()
def CurrentValue(self, val: Any) -> None: # The sdk options handler will convert an int to a float, so convert it back self._CurrentValue = int(val) storeModSettings()