Example #1
0
 public abstract void Apply(Kanojo Kanojo);
Example #2
0
        static void Main(string[] args)
        {
            Console.WindowWidth = 200;
            Console.WriteLine(@" ______   _______  _______  ___   _  _______  _______  _______    ___   _  _______  __    _  _______      ___  _______    _______  _______  _______  _______  __   __  _______  ______   ");
            Console.WriteLine(@"|      | |       ||       ||   | | ||       ||       ||       |  |   | | ||   _   ||  |  | ||       |    |   ||       |  |       ||   _   ||       ||       ||  | |  ||       ||    _ |  ");
            Console.WriteLine(@"|  _    ||    ___||  _____||   |_| ||_     _||   _   ||    _  |  |   |_| ||  |_|  ||   |_| ||   _   |    |   ||   _   |  |    _  ||  |_|  ||_     _||       ||  |_|  ||    ___||   | ||  ");
            Console.WriteLine(@"| | |   ||   |___ | |_____ |      _|  |   |  |  | |  ||   |_| |  |      _||       ||       ||  | |  |    |   ||  | |  |  |   |_| ||       |  |   |  |       ||       ||   |___ |   |_||_ ");
            Console.WriteLine(@"| |_|   ||    ___||_____  ||     |_   |   |  |  |_|  ||    ___|  |     |_ |       ||  _    ||  |_|  | ___|   ||  |_|  |  |    ___||       |  |   |  |      _||       ||    ___||    __  |");
            Console.WriteLine(@"|       ||   |___  _____| ||    _  |  |   |  |       ||   |      |    _  ||   _   || | |   ||       ||       ||       |  |   |    |   _   |  |   |  |     |_ |   _   ||   |___ |   |  | |");
            Console.WriteLine(@"|______| |_______||_______||___| |_|  |___|  |_______||___|      |___| |_||__| |__||_|  |__||_______||_______||_______|  |___|    |__| |__|  |___|  |_______||__| |__||_______||___|  |_|");
            Console.WriteLine();
            Console.WriteLine("==========================================================================================================================================================================================");
            const int AppID = 1284820;

            foreach (var proc in Process.GetProcesses())
            {
                try
                {
                    if (proc.MainModule.FileName.Contains("DesktopKanojo.exe"))
                    {
                        proc.Kill();
                    }
                }
                catch
                {
                }
            }
            do
            {
                bool PatchMove = false;
                Console.WriteLine("Input the FPS you want:");
                var input = Console.ReadLine();
                Console.WriteLine("Do you want increase character next move time? (Y or any key to abort)");
                var yn = Console.ReadLine();
                int minPatch = 30, maxPatch = 60;
                if (yn == "y" || yn == "Y")
                {
                    PatchMove = true;
                    Console.WriteLine("Please input the minimum delay time: ");
                    var min = Console.ReadLine();
                    Console.WriteLine("Please input the maximum delay time: ");
                    var max = Console.ReadLine();
                    if (!int.TryParse(min, out minPatch) || !int.TryParse(max, out maxPatch))
                    {
                        Console.WriteLine("Are you kidding me? Is this a number for FPS?");
                        Console.ReadLine();
                    }
                    if (minPatch <= 0)
                    {
                        minPatch = 30;
                    }
                    if (maxPatch <= minPatch)
                    {
                        maxPatch = minPatch + 1;
                    }
                }
                if (int.TryParse(input, out int result))
                {
                    if (result <= 0)
                    {
                        result = 60;
                    }
                    var sw = Stopwatch.StartNew();
                    Console.WriteLine(" Searching for Steam installation...");
                    var steamPath = default(string);
                    try { steamPath = Steam.Path; }
                    catch (DirectoryNotFoundException)
                    {
                        Console.Error.WriteLine(" Unable to find Steam installation.");
                        Console.ReadLine();
                        return;
                    }
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Path -> " + steamPath);
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Searching for Desktop Kanojo installation...");
                    var Kanojo = default(SteamApp);
                    if (!Steam.Apps.TryGetValue(AppID, out Kanojo))
                    {
                        Console.WriteLine(" Unable to find Desktop Kanojo manifest.");
                        Console.ReadLine();
                        return;
                    }
                    var kanojoPath = default(string);
                    try
                    {
                        kanojoPath = Kanojo.Path;
                    }
                    catch
                    {
                        Console.WriteLine(" Unable to parse Desktop Kanojo manifest.");
                        Console.ReadLine();
                        return;
                    }
                    if (!Directory.Exists(kanojoPath))
                    {
                        Console.WriteLine(" Unable to find Desktop Kanojo installation directory.");
                        Console.ReadLine();
                        return;
                    }
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Path -> " + kanojoPath);
                    var DesktopKanojo = new Kanojo(kanojoPath);
                    if (!Directory.Exists(Path.Combine(DesktopKanojo.ManagedPath, "backup")))
                    {
                        Console.WriteLine(" Backups -> ");
                        var dlls = Directory.GetFiles(DesktopKanojo.ManagedPath, "*.dll");
                        Directory.CreateDirectory(Path.Combine(DesktopKanojo.ManagedPath, "backup"));
                        foreach (var dll in dlls)
                        {
                            var fileName = Path.GetFileName(dll);
                            var dst      = Path.Combine(DesktopKanojo.ManagedPath, "backup", fileName);
                            File.Copy(dll, dst, true);
                            Console.WriteLine(new string(' ', " Games -> ".Length) + fileName + " -> " + "backup/" + fileName);
                        }
                    }
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Patches -> ");
                    PatchFPS patch = new PatchFPS();
                    patch.FPS = result;
                    patch.Apply(DesktopKanojo);
                    if (PatchMove)
                    {
                        PatchMovement patchMove = new PatchMovement();
                        patchMove.Sys = new int[] { minPatch, maxPatch };
                        patchMove.Apply(DesktopKanojo);
                    }
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Writing new assemblies...");
                    try { DesktopKanojo.Save("patched"); }
                    catch (Exception ex) { Console.Error.WriteLine("Failed to write." + ex.ToString()); }
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Removing Temp files...");
                    DesktopKanojo.Dispose();
                    foreach (var file in Directory.GetFiles("patched"))
                    {
                        var destination = Path.Combine(kanojoPath, "DesktopKanojo_Data", "Managed") + file.Substring(file.LastIndexOf('\\'));
                        File.Delete(destination);
                        File.Copy(file, destination);
                        File.Delete(file);
                    }
                    Directory.Delete("patched");
                    Console.WriteLine(" Done patched!");
                    Process.Start(Path.Combine(kanojoPath, "DesktopKanojo.exe"));
                    Console.WriteLine(" -----------------------------------");
                    Console.WriteLine(" Brought to you by PoH98!");
                    break;
                }
                else
                {
                    Console.WriteLine("Are you kidding me? Is this a number for FPS?");
                    Console.ReadLine();
                }
            }while (true);
            Console.ReadLine();
        }