public override bool Unload()
        {
            Il2CppTypeRegistry.Unload();
            PatchBase.UnpatchAll();

            return(base.Unload());
        }
Пример #2
0
        public PerfectMode()
        {
            Instance = this;
            Harmony  = new Harmony("com.biendeo.perfectmode");
            PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);

            settingsScrollPosition = new Vector2();
            changelogRect          = new Rect(400.0f, 400.0f, 100.0f, 100.0f);
        }
Пример #3
0
        public AccuracyIndicator()
        {
            Instance = this;
            Harmony  = new Harmony("com.biendeo.accuracyindicator");
            PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);

            lastSongTime  = -5.0;
            changelogRect = new Rect(400.0f, 400.0f, 100.0f, 100.0f);
        }
Пример #4
0
        public ComboIndicator()
        {
            Instance = this;
            Harmony  = new Harmony("com.biendeo.comboindicator");
            PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);

            changelogRect = new Rect(400.0f, 400.0f, 100.0f, 100.0f);

            starPowers = new float[4];
        }
        public override void Load()
        {
            Il2CppTypeRegistry.Load();
            Il2CppTypeRegistry.Register <CoroutineHandler>();
            Il2CppTypeRegistry.Register <LightController>();

            log     = Log;
            harmony = new Harmony(GUID);

            try
            {
                var assembly  = Assembly.GetExecutingAssembly();
                var types     = assembly.GetTypes();
                var patchType = typeof(PatchBase);

                foreach (Type type in types)
                {
                    if (patchType.IsAssignableFrom(type) && !type.IsAbstract)
                    {
                        var constructor = type.GetConstructor(new Type[] { typeof(Harmony) });
                        if (constructor != null)
                        {
                            try
                            {
                                constructor.Invoke(new object[] { harmony });
                                Log.LogInfo($"Created instance of patch '{type.FullName}'");
                            }
                            catch (Exception e)
                            {
                                Log.LogError($"Failed to create instance of Patch type '{type.FullName}'\nException: {e}");
                            }
                        }
                        else
                        {
                            Log.LogWarning($"Skipping '{type.FullName}' as it doesn't have a proper harmony constructor");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogError("Failed getting patches: " + e.StackTrace);
            }

            PatchBase.PatchAll();
        }
Пример #6
0
 public static bool HasAttribute(PatchBase patch, AssemblyDefinition assembly, string attribute)
 {
     return(patch.GetPatchedAttributes(assembly).Any(a => a.Info == attribute));
 }
Пример #7
0
 public ExtraLyrics()
 {
     Instance = this;
     Harmony  = new Harmony("com.joosthoi1.bepinexdebug");
     PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);
 }
Пример #8
0
        public SongUI()
        {
            Instance = this;
            Harmony  = new Harmony("com.biendeo.extrasongui");
            PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);
            changelogRect = new Rect(400.0f, 400.0f, 100.0f, 100.0f);
            labels        = new List <Tuple <SongUILabel, GameObject, Text> >();

            totalNoteCount  = new int[bandIndex + 1];
            totalStarPowers = new int[bandIndex + 1];

            hitNotes            = new int[bandIndex + 1];
            missedNotes         = new int[bandIndex + 1];
            seenNotes           = new int[bandIndex + 1];
            hitNotesPercentage  = new double[bandIndex + 1];
            seenNotesPercentage = new double[bandIndex + 1];
            fcIndicator         = new string[bandIndex + 1];

            starPowersGotten    = new int[bandIndex + 1];
            starPowerPercentage = new double[bandIndex + 1];
            currentStarPower    = new double[bandIndex + 1];

            currentCombo = new int[bandIndex + 1];
            highestCombo = new int[bandIndex + 1];

            formatActions = new Dictionary <string, Func <string, string> > {
                { "songtime", (format) => songTime.ToString(format) },
                { "songlength", (format) => songLength.ToString(format) },
                { "songtimepercentage", (format) => songTimePercentage.ToString(format) },
                { "currentstar", (format) => currentStarCount.ToString(format) },
                { "nextstar", (format) => Math.Min(currentStarCount + 1, 7).ToString(format) },
                { "currentscore", (format) => currentScore.ToString(format) },
                { "currentstarscore", (format) => (currentScore - previousStarScore).ToString(format) },
                { "previousstarscore", (format) => previousStarScore.ToString(format) },
                { "nextstarscore", (format) => nextStarScore.ToString(format) },
                { "currentstarpercentage", (format) => nextStarPercentage.ToString(format) },
                { "sevenstarscore", (format) => sevenStarScore.ToString(format) },
                { "sevenstarpercentage", (format) => sevenStarPercentage.ToString(format) },
                { "hitnotes", (format) => hitNotes[bandIndex].ToString(format) },
                { "hitnotes1", (format) => hitNotes[0].ToString(format) },
                { "hitnotes2", (format) => hitNotes[1].ToString(format) },
                { "hitnotes3", (format) => hitNotes[2].ToString(format) },
                { "hitnotes4", (format) => hitNotes[3].ToString(format) },
                { "seennotes", (format) => seenNotes[bandIndex].ToString(format) },
                { "seennotes1", (format) => seenNotes[0].ToString(format) },
                { "seennotes2", (format) => seenNotes[1].ToString(format) },
                { "seennotes3", (format) => seenNotes[2].ToString(format) },
                { "seennotes4", (format) => seenNotes[3].ToString(format) },
                { "missednotes", (format) => missedNotes[bandIndex].ToString(format) },
                { "missednotes1", (format) => missedNotes[0].ToString(format) },
                { "missednotes2", (format) => missedNotes[1].ToString(format) },
                { "missednotes3", (format) => missedNotes[2].ToString(format) },
                { "missednotes4", (format) => missedNotes[3].ToString(format) },
                { "totalnotes", (format) => totalNoteCount[bandIndex].ToString(format) },
                { "totalnotes1", (format) => totalNoteCount[0].ToString(format) },
                { "totalnotes2", (format) => totalNoteCount[1].ToString(format) },
                { "totalnotes3", (format) => totalNoteCount[2].ToString(format) },
                { "totalnotes4", (format) => totalNoteCount[3].ToString(format) },
                { "hitnotespercentage", (format) => hitNotesPercentage[bandIndex].ToString(format) },
                { "hitnotespercentage1", (format) => hitNotesPercentage[0].ToString(format) },
                { "hitnotespercentage2", (format) => hitNotesPercentage[1].ToString(format) },
                { "hitnotespercentage3", (format) => hitNotesPercentage[2].ToString(format) },
                { "hitnotespercentage4", (format) => hitNotesPercentage[3].ToString(format) },
                { "seennotespercentage", (format) => seenNotesPercentage[bandIndex].ToString(format) },
                { "seennotespercentage1", (format) => seenNotesPercentage[0].ToString(format) },
                { "seennotespercentage2", (format) => seenNotesPercentage[1].ToString(format) },
                { "seennotespercentage3", (format) => seenNotesPercentage[2].ToString(format) },
                { "seennotespercentage4", (format) => seenNotesPercentage[3].ToString(format) },
                { "fcindicator", (format) => fcIndicator[bandIndex] },
                { "fcindicator1", (format) => fcIndicator[0] },
                { "fcindicator2", (format) => fcIndicator[1] },
                { "fcindicator3", (format) => fcIndicator[2] },
                { "fcindicator4", (format) => fcIndicator[3] },
                { "starpowersgotten", (format) => starPowersGotten[bandIndex].ToString(format) },
                { "starpowersgotten1", (format) => starPowersGotten[0].ToString(format) },
                { "starpowersgotten2", (format) => starPowersGotten[1].ToString(format) },
                { "starpowersgotten3", (format) => starPowersGotten[2].ToString(format) },
                { "starpowersgotten4", (format) => starPowersGotten[3].ToString(format) },
                { "totalstarpowers", (format) => totalStarPowers[bandIndex].ToString(format) },
                { "totalstarpowers1", (format) => totalStarPowers[0].ToString(format) },
                { "totalstarpowers2", (format) => totalStarPowers[1].ToString(format) },
                { "totalstarpowers3", (format) => totalStarPowers[2].ToString(format) },
                { "totalstarpowers4", (format) => totalStarPowers[3].ToString(format) },
                { "starpowerpercentage", (format) => starPowerPercentage[bandIndex].ToString(format) },
                { "starpowerpercentage1", (format) => starPowerPercentage[0].ToString(format) },
                { "starpowerpercentage2", (format) => starPowerPercentage[1].ToString(format) },
                { "starpowerpercentage3", (format) => starPowerPercentage[2].ToString(format) },
                { "starpowerpercentage4", (format) => starPowerPercentage[3].ToString(format) },
                { "currentstarpower", (format) => currentStarPower[bandIndex].ToString(format) },
                { "currentstarpower1", (format) => currentStarPower[0].ToString(format) },
                { "currentstarpower2", (format) => currentStarPower[1].ToString(format) },
                { "currentstarpower3", (format) => currentStarPower[2].ToString(format) },
                { "currentstarpower4", (format) => currentStarPower[3].ToString(format) },
                { "currentcombo", (format) => currentCombo[bandIndex].ToString(format) },
                { "currentcombo1", (format) => currentCombo[0].ToString(format) },
                { "currentcombo2", (format) => currentCombo[1].ToString(format) },
                { "currentcombo3", (format) => currentCombo[2].ToString(format) },
                { "currentcombo4", (format) => currentCombo[3].ToString(format) },
                { "highestcombo", (format) => highestCombo[bandIndex].ToString(format) },
                { "highestcombo1", (format) => highestCombo[0].ToString(format) },
                { "highestcombo2", (format) => highestCombo[1].ToString(format) },
                { "highestcombo3", (format) => highestCombo[2].ToString(format) },
                { "highestcombo4", (format) => highestCombo[3].ToString(format) }
            };
        }
Пример #9
0
 public GigChallenges()
 {
     Instance = this;
     Harmony  = new Harmony("com.biendeo.gigchallenges");
     PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);
 }
Пример #10
0
        public override void LoadPatches()
        {
            string[] dlls = Directory.GetFiles(PatchesDir, "*.dll", SearchOption.AllDirectories);
            Logger.Log(LogLevel.Info, $"Found {dlls.Length} DLLs");
            Logger.Log(LogLevel.Info, "Loading patches...");

            List <PatchBase> patches = new List <PatchBase>();
            Dictionary <string, Exception> exceptions = new Dictionary <string, Exception>();

            foreach (string dllFile in dlls)
            {
                Assembly assembly = Assembly.LoadFile(dllFile);

                List <Type> patchClasses =
                    assembly.GetTypes()
                    .Where(
                        type =>
                        !type.IsAbstract && type.IsClass && !type.IsInterface &&
                        typeof(PatchBase).IsAssignableFrom(type))
                    .ToList();

                if (patchClasses.Count == 0)
                {
                    continue;
                }
                Logger.Log(LogLevel.Info, $"Loading patches from {Path.GetFileNameWithoutExtension(dllFile)}:");

                foreach (Type patchClass in patchClasses)
                {
                    try
                    {
                        PatchBase patch = (PatchBase)Activator.CreateInstance(patchClass);
                        Logger.LogColor(LogLevel.Info,
                                        $"  + [$(Green)OK$]   {patchClass.Name} -- {patch.Name} {patch.Version}");
                        patches.Add(patch);
                    }
                    catch (Exception e)
                    {
                        Logger.LogColor(LogLevel.Info, $"  + [$(Red)FAIL$] {patchClass.Name}");
                        exceptions.Add($"{patchClass.Name} from {dllFile}", e);
                    }
                }
            }

            if (exceptions.Count != 0)
            {
                Logger.Log(LogLevel.Error, "One or more errors occurred while attempting to load patches:");

                foreach (KeyValuePair <string, Exception> exception in exceptions)
                {
                    Logger.Log(LogLevel.Error, $"Exception at {exception.Key}:\n{exception.Value}");
                }

                if (!Configuration.ContinueWithErrors)
                {
                    Logger.Log(LogLevel.Error, "Closing UULauncher because of the above errors");
                    if (Configuration.PauseOnError)
                    {
                        Console.WriteLine("Press any key to exit...");
                        Console.ReadKey(true);
                    }
                    Environment.Exit(-1);
                }
            }

            Logger.Log(LogLevel.Info, $"Loaded {patches.Count} patches");

            Patches = patches;
        }
Пример #11
0
        public override void PrePatch()
        {
            List <PatchBase> patches = (List <PatchBase>)Patches;

            Logger.Log(LogLevel.Info, "Pre-patch:");

            for (int index = 0; index < patches.Count; index++)
            {
                PatchBase patch = patches[index];
                try
                {
                    patch.PrePatch();
                    Logger.LogColor(LogLevel.Info, $"[$(Green)PRE-PATCH$] {patch.Name}");
                }
                catch (Exception e)
                {
                    Logger.LogColor(LogLevel.Info, $"[$(Red)PRE-PATCH$] {patch.Name}");
                    Logger.Log(LogLevel.Error, $"Failed to run pre-patch on {patch.Name}! Error info:\n{e}");
                    if (Configuration.ContinueWithErrors)
                    {
                        patches.Remove(patch);
                        index--;
                    }
                    else
                    {
                        if (Configuration.PauseOnError)
                        {
                            Console.WriteLine("Press any key to exit...");
                            Console.ReadKey(true);
                        }
                        Environment.Exit(-1);
                    }
                }
            }

            Patches = patches;

            if (!RPConfig.ConfigFile.HasSection("Assemblies"))
            {
                return;
            }

            Logger.Log(LogLevel.Info, "Requesting assemblies to patch:");
            List <string> assemblies = new List <string>();

            Assemblies = new List <PatcherArguments>();
            foreach (IniKey key in RPConfig.ConfigFile["Assemblies"].Keys)
            {
                if (!assemblies.Contains(key.Value))
                {
                    assemblies.Add(key.Value);

                    string path = Path.Combine(AssembliesDir, key.Value);
                    DefaultAssemblyResolver assemblyResolver = new DefaultAssemblyResolver();
                    assemblyResolver.AddSearchDirectory(AssembliesDir);
                    assemblyResolver.AddSearchDirectory(PatchesDir);
                    assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(path));
                    ReaderParameters rp = new ReaderParameters {
                        AssemblyResolver = assemblyResolver
                    };
                    AssemblyDefinition ass;
                    using (FileStream fs = File.OpenRead(path))
                    {
                        ass = AssemblyDefinition.ReadAssembly(fs, rp);
                    }
                    Assemblies.Add(new PatcherArguments(ass, path, false));
                    Logger.Log(LogLevel.Info, $"{key.Value}");
                }
            }

            FileUtils.BackupAssemblies(AssembliesDir, assemblies);
            Logger.Log(LogLevel.Info, "Done");
        }
Пример #12
0
 public MoveLyrics()
 {
     Instance = this;
     Harmony  = new Harmony("com.joosthoi1.movelyrics");
     PatchBase.InitializePatches(Harmony, Assembly.GetExecutingAssembly(), Logger);
 }