Example #1
0
    def SettingsInputPressed(self, name: str) -> None:
        if name == "Load":
            self.SettingsInputs = {
                "R": "Reload From File",
                "N": "New Seed",
                "Delete": "Delete All",
                "O": "Open Seed File"
            }
            self.Status = "<font color='#00FF00'>Loaded</font>"

            # Save the default mission dependencies, so that we're able to restore them
            # We can't do this in __init__() cause they're not all loaded at that point
            self.DefaultDependencies = {}
            self.DefaultObjectiveDependencies = {}
            for mission in unrealsdk.FindAll("MissionDefinition"):
                # Filter out the default MissionDefinition and all main missions
                if mission.bPlotCritical or not mission.MissionName:
                    continue

                # Need to convert this to a list because the default FArray returned is a reference
                self.DefaultDependencies[mission] = list(mission.Dependencies)
                self.DefaultObjectiveDependencies[mission] = (
                    mission.ObjectiveDependency.Objective,
                    mission.ObjectiveDependency.Status
                )

            self.LoadFromFile()

        elif name == "Reload From File":
            self.LoadFromFile()

        elif name == "New Seed":
            seed = random.randrange(0xFFFFFFFF)
            smr_seed = SideMissionRandomizerSeed(seed, str(seed))
            self.SeedInfo.append(smr_seed)
            self.SaveSeedInfo()

            new_mod = SideMissionRandomizerChild(smr_seed)
            Mods.append(new_mod)
            self.EnableChild(new_mod)

        elif name == "Delete All":
            if path.exists(self.SEED_PATH):
                remove(self.SEED_PATH)
            self.LoadFromFile()

        elif name == "Open Seed File":
            if not path.exists(self.SEED_PATH):
                self.SaveSeedInfo()
            startfile(self.SEED_PATH)
Example #2
0
    def LoadFromFile(self) -> None:
        # Clear out any existing mods in the list
        to_remove = set()
        for mod in unrealsdk.Mods:
            if isinstance(mod, SideMissionRandomizerChild):
                to_remove.add(mod)
        for mod in to_remove:
            Mods.remove(mod)
        self.RevertMissionsToDefaults()
        self.CurrentlyEnabledChild = None

        # Create all of the child mods
        self.SeedInfo = self.LoadSeedInfo()
        for seed in self.SeedInfo:
            Mods.append(SideMissionRandomizerChild(seed))
Example #3
0
        if self.CurrentlyEnabledChild is not None:
            self.DisableChild(self.CurrentlyEnabledChild)
        self.CurrentlyEnabledChild = child

        child.Status = "Enabled"
        child.SettingsInputs["Enter"] = "Disable"
        child.Enable()

    def DisableChild(self, child: SideMissionRandomizerChild) -> None:
        child.Status = "Disabled"
        child.SettingsInputs["Enter"] = "Enable"
        # Just in case for some reason this isn't the same as 'child'
        if self.CurrentlyEnabledChild is not None:
            self.CurrentlyEnabledChild.Status = "Disabled"
            self.CurrentlyEnabledChild.SettingsInputs["Enter"] = "Enable"

        self.CurrentlyEnabledChild = None
        self.RevertMissionsToDefaults()

    def RemoveChild(self, child: SideMissionRandomizerChild) -> None:
        if self.CurrentlyEnabledChild == child:
            self.DisableChild(child)
        unrealsdk.Mods.remove(child)

        self.SeedInfo.remove(child.SMRSeed)
        self.SaveSeedInfo()


parent_instance: SideMissionRandomizerParent = SideMissionRandomizerParent()
Mods.append(parent_instance)
Example #4
0
                cheat.OnPress()
        for preset in self.CheatPresetManager.PresetList:
            if bind.Name == preset.Name:
                preset.ApplySettings()

    def Enable(self) -> None:
        for hook, func_list in ALL_HOOKS.items():
            for i, func in enumerate(func_list):
                unrealsdk.RunHook(hook, f"{self.Name}{i}", func)

    def Disable(self) -> None:
        for hook, func_list in ALL_HOOKS.items():
            for i, _ in enumerate(func_list):
                unrealsdk.RemoveHook(hook, f"{self.Name}{i}")


instance = ApplesBorderlandsCheats()
if __name__ == "__main__":
    unrealsdk.Log(f"[{instance.Name}] Manually loaded")
    for mod in Mods:
        if mod.Name == instance.Name:
            if mod.IsEnabled:
                mod.Disable()
            Mods.remove(mod)
            unrealsdk.Log(f"[{instance.Name}] Removed last instance")

            # Fixes inspect.getfile()
            instance.__class__.__module__ = mod.__class__.__module__
            break
Mods.append(instance)