public MainWindow()
        {
            InitializeComponent();
            Log.Instance.MessageLogged += Instance_MessageLogged;

            Log.Output("Welcome to NKHook5 Launcher!");

            if (NKHook.DoesNkhExist())
            {
                DownloadNKH_Button.Content = "  Re-download NKHook  ";
            }


            UpdateHandler update = new UpdateHandler
            {
                GitApiReleasesURL = "https://api.github.com/repos/TDToolbox/NKHook-Launcher/releases",
                ProjectName       = "NKHook5 Launcher",
                ProjectExePath    = Environment.CurrentDirectory + "\\NKHook Launcher.exe",
                UpdaterExeName    = "Updater for NKHook Launcher.exe",
                UpdatedZipName    = "NKHook Launcher.zip"
            };

            Thread thread = new Thread(update.HandleUpdates);

            BgThread.AddToQueue(thread);
        }
        //========================================================

        private void Main_Loaded(object sender, RoutedEventArgs e)
        {
            blinkTimer.Tick    += Console_Timer_Tick;
            blinkTimer.Interval = new TimeSpan(0, 0, 0, 0, 250);

            Lib.Updaters.ModManager_Updater update = new Lib.Updaters.ModManager_Updater();
            DeleteOldUpdaterFiles();
            var game = GameInfo.GetGame(SessionData.currentGame);

            BgThread.AddToQueue(() =>
            {
                update.HandleUpdates();
                string gameD = game.GameDir + "\\MelonLoader\\MelonLoader.dll";
                MelonMod_Handler.HandleUpdates(game.GameDir, gameD);
            });

            // check for mod helper and download if not exists
            var files        = Directory.GetFiles(game.GameDir + "\\Mods");
            var hasModHelper = files.Any(file => file.ToLower().Replace(" ", "").Replace(".", "").Contains("modhelperdll"));

            if (!hasModHelper)
            {
                var result = MessageBox.Show("It seems you don't have Bloons Mod Helper installed. Most mods require this to work." +
                                             " Do you want to download it now?", "Download Bloons Mod Helper?", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    MessageBox.Show("Great! The download will open when you close this popup. To get it, download BloonsTD6_Mod_Helper.zip and extract it to your BTD6 mod's folder");
                    Process.Start("https://github.com/gurrenm3/BTD-Mod-Helper/releases");
                }
            }
        }
Exemple #3
0
        public static void Launch()
        {
            var launcher = new Launcher();

            TempSettings.Instance.SaveSettings();
            BgThread.AddToQueue(() => launcher.LaunchBTD6());
        }
Exemple #4
0
        /// <summary>
        /// Download the latest NKHook from the github releases section
        /// </summary>
        public static void DownloadNKH()
        {
            Log.Output("Downloading latest NKHook5...");

            string git_Text = WebHandler.ReadText_FromURL(gitURL);

            if (!Guard.IsStringValid(git_Text))
            {
                Log.Output("Failed to read release info for NKHook5");
                return;
            }

            BgThread.AddToQueue(new Thread(() =>
            {
                var gitApi = GitApi.FromJson(git_Text);
                foreach (var a in gitApi)
                {
                    foreach (var b in a.Assets)
                    {
                        string link = b.BrowserDownloadUrl.ToString();
                        if (!Guard.IsStringValid(link))
                        {
                            continue;
                        }

                        WebHandler.DownloadFile(link, nkhDir);
                    }
                }
                Log.Output("NKHook5 successfully downloaded!");
            }));
        }
Exemple #5
0
        private void Analyze_Button_Click(object sender, RoutedEventArgs e)
        {
            caseSensitive = CaseSensitive_CB.IsChecked.Value;
            ignoreDup     = IgnoreDup_CB.IsChecked.Value;

            BgThread.AddToQueue(() => Analyze());
        }
 private void DownloadNKH_Button_Click(object sender, RoutedEventArgs e)
 {
     if (!BgThread.IsThreadRunning())
     {
         Log.Output("Downloading NKHook5");
         var thread = new Thread(() => NKHook.DownloadNKH());
         BgThread.AddToQueue(thread);
     }
     else
     {
         MessageBox.Show("Can't run the game, currently doing something. " +
                         "Please wait about 30 seconds and try again");
     }
 }
Exemple #7
0
        /// <summary>
        /// Main updater method for NKHook. Handles all update related functions for ease of use.
        /// </summary>
        public static void HandleUpdates()
        {
            BgThread.AddToQueue(() =>
            {
                UpdateHandler update = new UpdateHandler
                {
                    GitApiReleasesURL = gitURL,
                    ProjectExePath    = nkhEXE,
                    ProjectName       = "NKHook5",
                    InstallDirectory  = nkhDir
                };

                update.HandleUpdates(false, false);
            });
        }
        //========================================================

        private void Main_Loaded(object sender, RoutedEventArgs e)
        {
            blinkTimer.Tick    += Console_Timer_Tick;
            blinkTimer.Interval = new TimeSpan(0, 0, 0, 0, 250);

            Lib.Updaters.ModManager_Updater update = new Lib.Updaters.ModManager_Updater();
            DeleteOldUpdaterFiles();
            var game = GameInfo.GetGame(SessionData.currentGame);

            BgThread.AddToQueue(() =>
            {
                update.HandleUpdates();
                string gameD = game.GameDir + "\\MelonLoader\\MelonLoader.ModHandler.dll";
                MelonMod_Handler.HandleUpdates(game.GameDir, gameD);
            });
        }
Exemple #9
0
        private void TextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (scanRunning)
                {
                    return;
                }

                scanRunning   = true;
                caseSensitive = CaseSensitive_CB.IsChecked.Value;
                ignoreDup     = IgnoreDup_CB.IsChecked.Value;

                BgThread.AddToQueue(() =>
                {
                    Analyze();
                    scanRunning = false;
                });
            }
        }
Exemple #10
0
        private void Main_Loaded(object sender, RoutedEventArgs e)
        {
            blinkTimer.Tick    += Console_Timer_Tick;
            blinkTimer.Interval = new TimeSpan(0, 0, 0, 0, 250);

            BTD6_CrashHandler handler = new BTD6_CrashHandler();

            handler.EnableCrashLog();

            UpdateHandler update = new UpdateHandler()
            {
                GitApiReleasesURL = "https://api.github.com/repos/TDToolbox/BTD6-Mod-Manager/releases",
                ProjectExePath    = Environment.CurrentDirectory + "\\BTD6 Mod Manager.exe",
                InstallDirectory  = Environment.CurrentDirectory,
                ProjectName       = "BTD6 Mod Manager",
                UpdatedZipName    = "BTD6_Mod_Manager.zip",
                UpdaterExeName    = "Updater.exe"
            };

            Thread updater = new Thread(() => update.HandleUpdates());

            updater.IsBackground = true;
            BgThread.AddToQueue(updater);
        }