Beispiel #1
0
 private void LaunchProgram_Click(object sender, EventArgs e)
 {
     if (!NKHook.CanUseNKH())
     {
         CompileJet("launch");
     }
 }
Beispiel #2
0
        private void TestingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NKHook nkh = new NKHook();

            nkh.DoUpdateTowerPlugin();
            nkh.DoUpdateNKH();
        }
        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);
        }
Beispiel #4
0
        public static ProjectClass.ProjectFile ReadProject(string projFile)
        {
            if (project != null)
            {
                CurrentProjectVariables.ResetProjectVariables();
            }

            if (project == null)
            {
                project = new ProjectClass.ProjectFile();
            }

            if (!File.Exists(projFile))
            {
                ConsoleHandler.append("Something went wrong when trying to read the" +
                                      "project. Project not found...");
                return(null);

                //Create new project
                //CreateProject();  //Commented out until im sure this is what needs to happen next
            }

            if (!IsProjectVald(projFile))
            {
                return(null);
            }

            string json = File.ReadAllText(projFile);

            project = JsonConvert.DeserializeObject <ProjectClass.ProjectFile>(json);

            CurrentProjectVariables.ProjectName            = project.ProjectName.Replace("\\", "");
            CurrentProjectVariables.PathToProjectFiles     = project.PathToProjectFiles.Replace("\\\\", "\\");
            CurrentProjectVariables.PathToProjectClassFile = project.PathToProjectClassFile.Replace("\\\\", "\\");
            CurrentProjectVariables.GameName              = project.GameName;
            CurrentProjectVariables.GamePath              = project.GamePath.Replace("\\\\", "\\");
            CurrentProjectVariables.GameVersion           = project.GameVersion;
            CurrentProjectVariables.JetPassword           = project.JetPassword;
            CurrentProjectVariables.ExportPath            = project.ExportPath;
            CurrentProjectVariables.DateLastOpened        = project.DateLastOpened;
            CurrentProjectVariables.JsonEditor_OpenedTabs = project.JsonEditor_OpenedTabs;
            CurrentProjectVariables.ModifiedFiles         = project.ModifiedFiles;

            CurrentProjectVariables.UseNKHook       = false;
            CurrentProjectVariables.DontAskAboutNKH = false;
            if (CurrentProjectVariables.GameName == "BTD5")
            {
                if (NKHook.DoesNkhExist())
                {
                    CurrentProjectVariables.UseNKHook       = project.UseNKHook;
                    CurrentProjectVariables.DontAskAboutNKH = project.DontAskAboutNKH;
                }
            }

            return(project);
        }
 private void RunNKH_Button_Click(object sender, RoutedEventArgs e)
 {
     if (!BgThread.IsThreadRunning())
     {
         Log.Output("Launching NKHook5");
         NKHook.LaunchNKH();
     }
     else
     {
         MessageBox.Show("Can't run the game, currently doing something. " +
                         "Please wait about 30 seconds and try again");
     }
 }
 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");
     }
 }
Beispiel #7
0
        private void UseNKH_CB_CheckedChanged(object sender, EventArgs e)
        {
            if (!NKHook.DoesNkhExist())
            {
                if (UseNKH_CB.Checked == true)
                {
                    UseNKH_CB.Checked = false;

                    ConsoleHandler.force_append_Notice("You need to have NKHook installed to do that!");
                    MessageBox.Show("You need to have NKHook installed to do that!");
                    NKHook_Message msg = new NKHook_Message();
                    msg.Show();
                }
            }
        }
Beispiel #8
0
        public void PopulateNKHMewnu()
        {
            Launch_Program_ToolStrip.DropDownItems.Clear();

            if (NKHook.CanUseNKH())
            {
                Launch_Program_ToolStrip.DropDownItems.Add("With NKHook");
                Launch_Program_ToolStrip.DropDownItems.Add("Without NKHook");
                Launch_Program_ToolStrip.DropDownItems.Add(new ToolStripSeparator());
                Launch_Program_ToolStrip.DropDownItems.Add("NKHook Plugin Manager");

                NKHook nkh = new NKHook();
                nkh.DoUpdateNKH();
                nkh.DoUpdateTowerPlugin();
            }
        }
Beispiel #9
0
        public SetProjectName()
        {
            InitializeComponent();

            gameName = CurrentProjectVariables.GameName;

            if (!NKHook.CanUseNKH())
            {
                label2.Location   = new Point(12, 120);
                UseNKH_CB.Visible = false;
            }

            this.AcceptButton = CreateProject_Button;
            this.Activate();
            this.Show();
            this.Shown += SetProjectName_Shown;
        }
Beispiel #10
0
        private void Setup()
        {
            this.Size = new Size(350, 500);

            this.canResize        = false;
            this.moveCenterScreen = true;

            EnableSplash.Checked      = Serializer.cfg.enableSplash;
            useExternalEditor.Checked = Serializer.cfg.useExternalEditor;
            DisableUpdates_CB.Checked = Serializer.cfg.disableUpdates;
            AutoFormatJSON_CB.Checked = Serializer.cfg.autoFormatJSON;
            UseDeveloperMode.Checked  = Serializer.cfg.UseDeveloperMode;

            if (!NKHook.CanUseNKH())
            {
                return;
            }

            UseNKH_CB.Checked = CurrentProjectVariables.UseNKHook;
            UseNKH_CB.Visible = true;
            CurrentProjSettings_Label.Visible = true;
        }
Beispiel #11
0
 private void Main_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F5)
     {
         if (NKHook.CanUseNKH() && CurrentProjectVariables.UseNKHook == true)
         {
             CompileJet("launch nkh");
         }
         else
         {
             CompileJet("launch");
         }
     }
     if (e.Control && e.KeyCode == Keys.N)
     {
         SelectGame select = new SelectGame();
         select.Show();
     }
     if (e.Control && e.KeyCode == Keys.S)
     {
         CompileJet("output");
     }
 }
Beispiel #12
0
        private void Launch_Program_ToolStrip_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (!NKHook.CanUseNKH())
            {
                return;
            }

            if (e.ClickedItem.Text == "With NKHook")
            {
                if (NKHook.DoesNkhExist())
                {
                    if (CurrentProjectVariables.UseNKHook == false && CurrentProjectVariables.DontAskAboutNKH == false)
                    {
                        AlwaysUseNKH ask = new AlwaysUseNKH(true);
                        ask.Show();
                    }
                    else
                    {
                        CompileJet("launch nkh");
                    }
                }
                else
                {
                    ConsoleHandler.force_append_Notice("Unable to locate NKHook5-Injector.exe. Opening Get NKHook message... You need to launch without it until you download NKHook.");
                    NKHook_Message msg = new NKHook_Message();
                    msg.Show();
                }
            }
            if (e.ClickedItem.Text == "Without NKHook")
            {
                CompileJet("launch");
            }
            if (e.ClickedItem.Text == "NKHook Plugin Manager")
            {
                NKHPluginMgr mgr = new NKHPluginMgr();
            }
        }
Beispiel #13
0
        public NKHPluginMgr()
        {
            InitializeComponent();


            if (CurrentProjectVariables.GameName != "BTD5")
            {
                this.Close();
            }
            if (!NKHook.DoesNkhExist())
            {
                ConsoleHandler.force_append_Notice("You need to have NKHook downloaded to use this feature.");
                MessageBox.Show("You need to have NKHook downloaded to use this feature.");
                NKHook_Message msg = new NKHook_Message();
                msg.Show();
                this.Close();
            }
            if (IsDisposed)
            {
                return;
            }

            this.MdiParent = Main.getInstance();
            this.canResize = false;
            //this.Size = new Size(800, 450);
            this.moveCenterScreen = true;
            this.Show();


            FileInfo nkhEXE = new FileInfo(NKHook.nkhEXE);

            nkhDir = nkhEXE.FullName.Replace(nkhEXE.Name, "");

            PopulateUnloadedPlugings();
            PopulateLoadedPlugings();
        }
Beispiel #14
0
        private void Compile_OnThread()
        {
            bool cont = true;

            if (launch)
            {
                if (gameDir == null || gameDir == "")
                {
                    cont = false;
                    this.Invoke(new Action(() => this.Close()));
                    ConsoleHandler.append("There was an issue reading your game directory. Go to the \"Help\" tab at the top, browse for your game again, and then try again...");
                    backgroundThread.Abort();
                }
            }

            if (cont)
            {
                string dir = "";
                if (destPath == null || destPath == "")
                {
                    dir = steamJetPath;
                }
                else
                {
                    dir = destPath;
                }

                if (dir != "\\Assets\\" + jetName)
                {
                    if (!Guard.IsStringValid(Serializer.cfg.LastProject))
                    {
                        Serializer.SaveSettings();
                    }

                    DirectoryInfo projDir = new DirectoryInfo(CurrentProjectVariables.PathToProjectFiles);
                    if (Directory.Exists(projDir.ToString()))
                    {
                        ConsoleHandler.append("Compiling jet...");
                        int numFiles   = Directory.GetFiles((projDir.ToString()), "*", SearchOption.AllDirectories).Length;
                        int numFolders = Directory.GetDirectories(projDir.ToString(), "*", SearchOption.AllDirectories).Count();
                        totalFiles      = numFiles + numFolders;
                        filesTransfered = 0;

                        ZipFile toExport = new ZipFile();
                        toExport.Password     = password;
                        toExport.AddProgress += ZipCompileProgress;
                        toExport.AddDirectory(projDir.FullName);
                        toExport.Encryption       = EncryptionAlgorithm.PkzipWeak;
                        toExport.Name             = dir;
                        toExport.CompressionLevel = CompressionLevel.Level6;

                        try
                        {
                            toExport.Save();
                            toExport.Dispose();
                        }
                        catch (System.IO.IOException)
                        {
                            ConsoleHandler.force_append_Notice("Something went wrong... Is your jet file opened?");
                            this.Invoke(new Action(() => this.Close()));
                        }

                        //Commented this out for now

                        /*if (CurrentProjectVariables.GameName == "BMC")
                         * {
                         *  var d = new DirectoryInfo(CurrentProjectVariables.PathToProjectFiles).GetDirectories();
                         *  foreach(var a in d)
                         *  {
                         *      if (a.Name.Contains("AssetBundles"))
                         *      {
                         *          Invoke((MethodInvoker)delegate { Filename_TB.Text = "AssetBundles"; });
                         *          CompileAssetBundles();
                         *          break;
                         *      }
                         *  }
                         * }*/

                        ConsoleHandler.append("Jet was successfully exported to: " + dir);

                        if (launch == true)
                        {
                            if (!launchNKH)
                            {
                                LaunchGame(gameName);
                            }
                            else
                            {
                                NKHook.LaunchNKH();
                            }
                        }
                        try
                        {
                            this.Invoke(new Action(() => this.Close()));
                        }
                        catch (Exception ex)
                        {
                            PrintError(ex.Message);
                            backgroundThread.Abort();
                        }
                        backgroundThread.Abort();
                    }
                    else
                    {
                        ConsoleHandler.append("Output directory not found... Failed to compile...");
                    }
                }
                else
                {
                    ConsoleHandler.append("Something went wrong with the export. The export path might have been invalid, or it might have been cancelled...");
                    try
                    {
                        this.Invoke(new Action(() => this.Close()));
                    }
                    catch (Exception ex)
                    {
                        PrintError(ex.Message);
                    }
                    backgroundThread.Abort();
                }
            }
        }
 private void OpenNkhDir_Button_Click(object sender, RoutedEventArgs e)
 {
     Log.Output("Opening NKHook5 directory...");
     NKHook.OpenNkhDir();
 }
Beispiel #16
0
 private void GetNKHook_Button_Click(object sender, EventArgs e)
 {
     NKHook.OpenMainWebsite();
     this.Close();
 }