private void LaunchWoTLauncher_Click(object sender, System.EventArgs e)
        {
            if (TanksLocation.Equals("none"))
            {
                return;
            }
            Logging.Manager("Starting WoTLauncher with argument \"-integrity_default_client\"");
            StartWoTLauncherResult.Text = Translations.GetTranslatedString("startingLauncherRepairMode");
            string filename           = Path.Combine(TanksLocation, "WoTLauncher.exe");
            string formattedArguement = "-integrity_default_client";

            Logging.Manager("Complete Command line: " + filename + " " + formattedArguement);
            try
            {
                Process.Start(filename, formattedArguement);
            }
            catch (Exception ex)
            {
                Utils.ExceptionLog("LaunchWoTLauncher_Click", ex);
                System.Windows.Forms.MessageBox.Show(Translations.GetTranslatedString("failedStartLauncherRepairMode"));
                StartWoTLauncherResult.Text = "";
                return;
            }
            StartWoTLauncherResult.Text = Translations.GetTranslatedString("launcherRepairModeStarted");
        }
示例#2
0
 private void InitSettingsAndLogging()
 {
     CommandLineSettings = new CommandLineSettings(Environment.GetCommandLineArgs().Skip(1).ToArray());
     modpackSettings     = new ModpackSettings();
     if (!Logging.Init(Logfiles.Application, false, !CommandLineSettings.ArgsOpenCustomWindow()))
     {
         //check if it's because the file already exists, or some other actual reason
         //if the file exists, and it's locked (init failed), then check if also the command line is creating a new window
         if (File.Exists(Logging.GetLogfile(Logfiles.Application).Filepath) && CommandLineSettings.ArgsOpenCustomWindow())
         {
             //getting here means the main window is open, but in this instance, a custom window will be open. We can temporarily
             //open the log in a custom name (with the application mode), and when opening the 'real' logfile for the custom window,
             //we'll transfer the text over then
             Logging.DisposeLogging(Logfiles.Application);
             if (!Logging.Init(Logfiles.Application, false, false, Logging.ApplicationTempLogFilename))
             {
                 MessageBox.Show(string.Format("Failed to initialize logfile {0}, check file permissions", Logging.ApplicationTempLogFilename));
                 Shutdown((int)ReturnCodes.LogfileError);
                 return;
             }
         }
         else
         {
             if (!Translations.TranslationsLoaded)
             {
                 Translations.LoadTranslations(false);
             }
             //old message from Logging.Init
             //MessageBox.Show(string.Format("Failed to initialize logfile {0}, check file permissions", logfilePath));
             MessageBox.Show(Translations.GetTranslatedString("appFailedCreateLogfile"));
             Shutdown((int)ReturnCodes.LogfileError);
             return;
         }
     }
 }
示例#3
0
 //use load to move the location of the form
 private void GifPreview_Load(object sender, EventArgs e)
 {
     Logging.Manager("GifPreview: opening at x: " + x + ", y: " + y);
     this.Location = new Point(x, y);
     this.Text     = Translations.GetTranslatedString("loadingGifpreview");
     SetLoadingImage();
 }
 public DeleteBackupFolder(List <BackupFolder> bfl)
 {
     InitializeComponent();
     this.Text = Translations.GetTranslatedString("DeleteBackupFolder");
     CancelCloseButton.Text = Translations.GetTranslatedString("cancel");
     DeleteButton.Text      = Translations.GetTranslatedString("delete");
     DeleteBackupFolder_Load(bfl);
 }
示例#5
0
 //handler for before the window is displayed
 private void VersionInfo_Load(object sender, EventArgs e)
 {
     updateAcceptButton.Text       = Translations.GetTranslatedString(updateAcceptButton.Name);
     updateDeclineButton.Text      = Translations.GetTranslatedString(updateDeclineButton.Name);
     newVersionAvailableLabel.Text = Translations.GetTranslatedString(newVersionAvailableLabel.Name);
     updateQuestionLabel.Text      = Translations.GetTranslatedString(updateQuestionLabel.Name);
     problemsUpdatingLabel.Text    = Translations.GetTranslatedString(problemsUpdatingLabel.Name);
     clickHereUpdateLabel.Text     = Translations.GetTranslatedString(clickHereUpdateLabel.Name);
     downloadedVersionInfo.Text    = Settings.BetaApplication ? Utils.GetStringFromZip(Settings.ManagerInfoDatFile, "releaseNotes_beta.txt") : Utils.GetStringFromZip(Settings.ManagerInfoDatFile, "releaseNotes.txt");
     clickHereUpdateLabel.Left     = problemsUpdatingLabel.Left + problemsUpdatingLabel.Width;
 }
示例#6
0
 private void OldFilesToDelete_Load(object sender, EventArgs e)
 {
     deleteFilesHeader.Text   = Translations.GetTranslatedString("foundOldFilesDelete1");
     deleteFilesQuestion.Text = Translations.GetTranslatedString("foundOldFilesDelete2");
     noDeleteButton.Text      = Translations.GetTranslatedString("no");
     yesDeleteButton.Text     = Translations.GetTranslatedString("yes");
     if (Program.autoInstall)
     {
         yesDeleteButton_Click(null, null);
     }
 }
 private void Diagnostics_Load(object sender, System.EventArgs e)
 {
     MainTextBox.Text = MainWindowHeader;
     if (TanksLocation == null || TanksLocation.Equals(""))
     {
         TanksLocation = "none";
     }
     SelectedInstallation.Text = Translations.GetTranslatedString(SelectedInstallation.Name) + TanksLocation;
     LaunchWoTLauncher.Text    = Translations.GetTranslatedString(LaunchWoTLauncher.Name);
     CollectLogInfo.Text       = Translations.GetTranslatedString(CollectLogInfo.Name);
     ChangeInstall.Text        = Translations.GetTranslatedString(ChangeInstall.Name);
 }
示例#8
0
 private void Preview_Load(object sender, EventArgs e)
 {
     if (Medias == null)
     {
         Medias = new List <Media>();
     }
     //update for translations
     NextPicButton.Text     = Translations.GetTranslatedString(NextPicButton.Name);
     PreviousPicButton.Text = Translations.GetTranslatedString(PreviousPicButton.Name);
     DevLinkLabel.Text      = Translations.GetTranslatedString(DevLinkLabel.Name);
     //check if devURL should be visable or not
     if (DBO.DevURL == null || DBO.DevURL.Equals(""))
     {
         DevLinkLabel.Enabled = false;
         DevLinkLabel.Visible = false;
     }
     //set default loading images and image properties
     LoadingImage = RelhaxModpack.Properties.Resources.loading;
     PreviewPicture.WaitOnLoad   = false;
     PreviewPicture.InitialImage = Settings.GetLoadingImage();
     Text = DBO.NameFormatted;
     for (int i = 0; i < Medias.Count; i++)
     {
         MakeLinkedLabel(i);
     }
     if (Medias != null)
     {
         CurrentlySelected = 0;
         if (Medias.Count > 0)
         {
             DisplayMedia(Medias[CurrentlySelected]);
         }
     }
     DescriptionBox.Text = (DBO.Description == null || DBO.Description.Equals(""))? Translations.GetTranslatedString("noDescription"): DBO.Description;
     DateFormat          = DBO.Timestamp == 0 ? "" : Utils.ConvertFiletimeTimestampToDate(DBO.Timestamp);
     UpdateBox.Text      = (DBO.UpdateComment == null || DBO.UpdateComment.Equals("")) ? Translations.GetTranslatedString("noUpdateInfo") : DBO.UpdateComment;
     UpdateBox.Text      = UpdateBox.Text + "\n" + LastUpdated + DateFormat;
     //specify the start location
     if (Utils.PointWithinScreen(Settings.PreviewX, Settings.PreviewY))
     {
         StartPosition = FormStartPosition.Manual;
         Location      = new Point(Settings.PreviewX, Settings.PreviewY);
     }
     if (Settings.SView == SelectionView.Legacy)
     {
         if (Program.Version == Program.ProgramVersion.Alpha)
         {
             Logging.Manager(string.Format("DEBUG: from Preview load: Legacy view, p.ContainsFocus={0}", this.ContainsFocus));
         }
         LegacyHotfixTimer.Start();
     }
 }
 private void ChangeInstallation_Click(object sender, EventArgs e)
 {
     //attempt to locate the tanks directory
     if (ParentWindow.ManuallyFindTanks() == null)
     {
         return;
     }
     //parse all strings
     ParentWindow.tanksLocation = ParentWindow.tanksLocation.Substring(0, ParentWindow.tanksLocation.Length - 17);
     ParentWindow.tanksLocation = ParentWindow.tanksLocation.Replace("\\win32", string.Empty).Replace("\\win64", string.Empty);
     TanksLocation             = ParentWindow.tanksLocation;
     SelectedInstallation.Text = Translations.GetTranslatedString(SelectedInstallation.Name) + TanksLocation;
     Logging.Manager(string.Format("tanksLocation parsed as {0}", ParentWindow.tanksLocation));
 }
示例#10
0
 private void PleaseWait_Load(object sender, EventArgs e)
 {
     if (startY != -1 && startX != -1)
     {
         this.Location = new System.Drawing.Point(startX + 10, startY);
     }
     label1.Text = Translations.GetTranslatedString(label1.Name);
     //align the text box to the middle of the forum
     label1.Location          = new System.Drawing.Point((this.Size.Width / 2) - (label1.Size.Width / 2), label1.Location.Y);
     PGMAX                    = forgroundPanel.Size.Width;
     forgroundPanel.BackColor = System.Drawing.Color.Blue;
     forgroundPanel.ForeColor = System.Drawing.Color.Blue;
     forgroundPanel.Size      = new System.Drawing.Size(0, forgroundPanel.Size.Height);
 }
示例#11
0
        private void ApplyControlTranslations(Control.ControlCollection conts)
        {
            foreach (Control c in conts)
            {
                //only apply for common controls
                if (c is RadioButton || c is CheckBox || c is GroupBox || c is Label || c is LinkLabel || c is Button)
                {
                    c.Text = Translations.GetTranslatedString(c.Name);
                }

                if (c is Panel || c is GroupBox || c is TableLayoutPanel)
                {
                    ApplyControlTranslations(c.Controls);
                }
            }
        }
        public void DeleteButton_Click(object sender, System.EventArgs e)
        {
            long  files          = 0;
            ulong size           = 0;
            int   backupsChecked = 0;

            foreach (Control bf in this.SelectBackupFolderPanel.Controls)
            {
                if (bf is SelectionCheckBox scb)
                {
                    if (scb.Checked)
                    {
                        files += scb.NameList.Count;
                        size  += scb.SizeOnDisk;
                        backupsChecked++;
                    }
                }
            }
            if (MessageBox.Show(string.Format(Translations.GetTranslatedString("BackupDeleteWarning"), files, Utils.SizeSuffix(size, 2, true)), Translations.GetTranslatedString("warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
            {
                return;
            }

            List <SelectionCheckBox> bftd = new List <SelectionCheckBox>();

            foreach (Control bf in this.SelectBackupFolderPanel.Controls)
            {
                if (bf is SelectionCheckBox scb)
                {
                    if (scb.Checked)
                    {
                        bftd.Add(scb);
                    }
                }
            }

            Installer bud = new Installer()
            {
                BackupFolderToDelete = bftd
            };

            // bud.InstallProgressChanged += I_InstallProgressChanged;
            bud.StartBackupFolderDelete();
        }
示例#13
0
        private void SelectionViewer_Load(object sender, EventArgs e)
        {
            this.Location          = new Point(x, y);
            SelectConfigLabel.Text = Translations.GetTranslatedString(SelectConfigLabel.Name);
            SelectButton.Text      = Translations.GetTranslatedString("select");
            CancelCloseButton.Text = Translations.GetTranslatedString("cancel");

            SelectionRadioButton b = new SelectionRadioButton
            {
                XMLURL   = "localFile",
                Text     = Translations.GetTranslatedString("localFile"),
                AutoSize = true
            };

            b.Location = new Point(6, GetYLocation(SelectConfigPanel.Controls));
            SelectConfigPanel.Controls.Add(b);

            foreach (var node in XMLUtils.developerSelections)
            {
                SelectionRadioButton bb = new SelectionRadioButton
                {
                    XMLURL   = node.internalName,
                    Text     = node.displayName,
                    AutoSize = true
                };
                bb.Location = new Point(6, GetYLocation(SelectConfigPanel.Controls));
                // add ToolTip to the develeopersSelections
                ToolTip rbToolTip = new ToolTip
                {
                    // Set up the delays for the ToolTip.
                    AutoPopDelay = 5000,
                    InitialDelay = 1000,
                    ReshowDelay  = 500,
                    // Force the ToolTip text to be displayed whether or not the form is active.
                    ShowAlways = true
                };
                // create Date and Time with local syntax
                Utils.ConvertDateToLocalCultureFormat(node.date, out string cultureDate);
                // Set up the ToolTip text for the Button and Checkbox.
                rbToolTip.SetToolTip(bb, string.Format(Translations.GetTranslatedString("createdAt"), cultureDate));
                SelectConfigPanel.Controls.Add(bb);
            }
        }
示例#14
0
 private void InstallFinished_Load(object sender, EventArgs e)
 {
     //apply translations
     InstallCompleteLabel.Text   = Translations.GetTranslatedString(InstallCompleteLabel.Name);
     StartTanksButton.Text       = Translations.GetTranslatedString(StartTanksButton.Name);
     StartWoTLauncherButton.Text = Translations.GetTranslatedString(StartWoTLauncherButton.Name);
     StartXVMStatButton.Text     = Translations.GetTranslatedString(StartXVMStatButton.Name);
     CloseApplicationButton.Text = Translations.GetTranslatedString(CloseApplicationButton.Name);
     //check if files are available to launch before actually displaying them
     WoTEXELocation      = Path.Combine(TanksLocation, "WorldOfTanks.exe");
     WoTLauncherLocation = Path.Combine(TanksLocation, "WoTLauncher.exe");
     if (!File.Exists(WoTEXELocation))
     {
         StartTanksButton.Enabled = false;
     }
     if (!File.Exists(WoTLauncherLocation))
     {
         StartWoTLauncherButton.Enabled = false;
     }
 }
示例#15
0
 public OldFilesToDelete()
 {
     InitializeComponent();
     this.Text = Translations.GetTranslatedString("foundOldFilesHeader");
 }
示例#16
0
        //when application is starting for first time
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //handle any assembly resolves
            //https://stackoverflow.com/a/19806004/3128017
            AppDomain.CurrentDomain.AssemblyResolve += (sender2, bargs) =>
            {
                string   dllName      = new AssemblyName(bargs.Name).Name + ".dll";
                Assembly assem        = Assembly.GetExecutingAssembly();
                string   resourceName = assem.GetManifestResourceNames().FirstOrDefault(rn => rn.EndsWith(dllName));
                using (Stream stream = assem.GetManifestResourceStream(resourceName))
                {
                    byte[] assemblyData = new byte[stream.Length];
                    stream.Read(assemblyData, 0, assemblyData.Length);
                    Logging.Debug("an assembly was loaded via AssemblyResolve: {0}", dllName);
                    return(Assembly.Load(assemblyData));
                }
            };
            //init logging here
            //"The application failed to open a logfile. Either check your file permissions or move the application to a folder with write access"
            if (!Logging.Init(Logfiles.Application))
            {
                MessageBox.Show(Translations.GetTranslatedString("appFailedCreateLogfile"));
                Shutdown((int)ReturnCodes.LogfileError);
            }
            Logging.WriteHeader(Logfiles.Application);
            Logging.Info(string.Format("| Relhax Modpack version {0}", Utils.GetApplicationVersion()));
            Logging.Info(string.Format("| Build version {0}, from date {1}", Settings.ApplicationVersion.ToString(), Utils.GetCompileTime()));
            Logging.Info(string.Format("| Running on OS {0}", Environment.OSVersion.ToString()));
            //parse command line arguments here
            //get the command line args for testing of auto install
            CommandLineSettings.ParseCommandLine(Environment.GetCommandLineArgs());
            Logging.Debug("starting application in {0} mode", CommandLineSettings.ApplicationMode.ToString());
            //switch into application modes based on mode enum
            switch (CommandLineSettings.ApplicationMode)
            {
            case ApplicationMode.Updater:
                DatabaseUpdater updater = new DatabaseUpdater();
                CloseApplicationLog(true);

                //start updater logging system
                if (!Logging.Init(Logfiles.Updater))
                {
                    MessageBox.Show("Failed to initialize logfile for updater");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.Updater);
                updater.ShowDialog();

                //stop updater logging system
                CloseLog(Logfiles.Updater);
                updater = null;
                Current.Shutdown(0);
                break;

            case ApplicationMode.Editor:
                DatabaseEditor editor = new DatabaseEditor();
                CloseApplicationLog(true);

                //start updater logging system
                if (!Logging.Init(Logfiles.Editor))
                {
                    MessageBox.Show("Failed to initialize logfile for editor");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.Editor);
                editor.ShowDialog();
                //stop updater logging system
                CloseLog(Logfiles.Editor);
                editor = null;
                Current.Shutdown(0);
                break;

            case ApplicationMode.PatchDesigner:
                PatchDesigner patcher = new PatchDesigner();
                CloseApplicationLog(true);

                //start updater logging system
                if (!Logging.Init(Logfiles.PatchDesigner))
                {
                    MessageBox.Show("Failed to initialize logfile for patcher");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.PatchDesigner);
                patcher.ShowDialog();

                //stop updater logging system
                CloseLog(Logfiles.PatchDesigner);
                patcher = null;
                Current.Shutdown(0);
                break;

            case ApplicationMode.Patcher:
                Logging.Info("Running patch mode");
                if (CommandLineSettings.PatchFilenames.Count == 0)
                {
                    Logging.Error("0 patch files parsed from command line!");
                    Current.Shutdown(-3);
                }
                else
                {
                    List <Patch> patchList = new List <Patch>();
                    foreach (string file in CommandLineSettings.PatchFilenames)
                    {
                        if (!File.Exists(file))
                        {
                            Logging.Warning("skipping file path {0}, not found", file);
                            continue;
                        }
                        Logging.Info("adding patches from file {0}", file);
                        XmlUtils.AddPatchesFromFile(patchList, file);
                    }
                    if (patchList.Count == 0)
                    {
                        Logging.Error("0 patches parsed from files!");
                        Current.Shutdown(-4);
                    }
                    PatchExitCode exitCode = PatchExitCode.Success;
                    //always return on worst condition
                    int i = 1;
                    foreach (Patch p in patchList)
                    {
                        Logging.Info("running patch {0} of {1}", i++, patchList.Count);
                        PatchExitCode exitCodeTemp = PatchUtils.RunPatch(p);
                        if ((int)exitCodeTemp < (int)exitCode)
                        {
                            exitCode = exitCodeTemp;
                        }
                    }
                    Logging.Info("patching finished, exit code {0} ({1})", (int)exitCode, exitCode.ToString());
                    CloseApplicationLog(true);
                    Current.Shutdown((int)exitCode);
                }
                break;
            }
        }
示例#17
0
        //when application is starting for first time
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (!Logging.Init(Logfiles.Application))
            {
                //check if it's because the file already exists, or some other actual reason
                //if the file exists, and it's locked (init failed), then check if also the command line is creating a new window
                if (File.Exists(Logging.GetLogfile(Logfiles.Application).Filepath) && CommandLineSettings.ArgsOpenCustomWindow)
                {
                    //a custom window will be open, so open the log in a custom name (with the application mode). it's ok in this case, because the likely cause
                    //is that the modpack is open in a regular window and now we want to open a custom window
                    Logging.DisposeLogging(Logfiles.Application);
                    if (!Logging.Init(Logfiles.Application, Logging.ApplicationTempLogFilename))
                    {
                        MessageBox.Show(string.Format("Failed to initialize logfile {0}, check file permissions", Logging.ApplicationTempLogFilename));
                        Shutdown((int)ReturnCodes.LogfileError);
                        return;
                    }
                }
                else
                {
                    if (!Translations.TranslationsLoaded)
                    {
                        Translations.LoadTranslations(false);
                    }
                    //old message from Logging.Init
                    //MessageBox.Show(string.Format("Failed to initialize logfile {0}, check file permissions", logfilePath));
                    MessageBox.Show(Translations.GetTranslatedString("appFailedCreateLogfile"));
                    Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
            }

            //handle any assembly resolves
            //https://stackoverflow.com/a/19806004/3128017
            AppDomain.CurrentDomain.AssemblyResolve += (sender2, bargs) =>
            {
                string   dllName      = new AssemblyName(bargs.Name).Name + ".dll";
                Assembly assem        = Assembly.GetExecutingAssembly();
                string   resourceName = assem.GetManifestResourceNames().FirstOrDefault(rn => rn.EndsWith(dllName));
                using (Stream stream = assem.GetManifestResourceStream(resourceName))
                {
                    byte[] assemblyData = new byte[stream.Length];
                    stream.Read(assemblyData, 0, assemblyData.Length);
                    Logging.Debug("An assembly was loaded via AssemblyResolve: {0}", dllName);
                    return(Assembly.Load(assemblyData));
                }
            };

            Logging.WriteHeader(Logfiles.Application);
            Logging.Info(string.Format("| Relhax Modpack version {0}", CommonUtils.GetApplicationVersion()));
            Logging.Info(string.Format("| Build version {0}, from date {1}", Settings.ApplicationVersion.ToString(), CommonUtils.GetCompileTime()));
            Logging.Info(string.Format("| Running on OS {0}", Environment.OSVersion.ToString()));

            //parse command line arguments given to the application
            CommandLineSettings.ParseCommandLine(Environment.GetCommandLineArgs());

            if ((!CommandLineSettings.ArgsOpenCustomWindow) && (!ModpackSettings.ValidFrameworkVersion))
            {
                //https://github.com/Willster419/RelhaxModpack/issues/90
                //try getting .net framework information
                //https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed
                //https://docs.microsoft.com/en-us/dotnet/api/system.environment.version?view=netcore-3.1
                //https://stackoverflow.com/questions/19096841/how-to-get-the-version-of-the-net-framework-being-targeted
                Logging.Debug(".NET Framework version information");
                int frameworkVersion = -1;
                try
                {
                    RegistryKey key = RegistryUtils.GetRegistryKeys(new RegistrySearch()
                    {
                        Root = Registry.LocalMachine, Searchpath = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
                    });
                    Logging.Debug("Registry: {0}", key.Name);
                    foreach (string subkey in key.GetValueNames())
                    {
                        object value = key.GetValue(subkey);
                        Logging.Debug("Registry: Subkey={0}, Value={1}", subkey, value.ToString());
                        if (subkey.ToLower().Equals("release"))
                        {
                            if (int.TryParse(value.ToString(), out int result))
                            {
                                frameworkVersion = result;
                            }
                            else
                            {
                                Logging.Error("Unable to parse release value: {0}", value);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logging.Exception(ex.ToString());
                }

                Logging.Info("Minimum required .NET Framework version: {0}, Installed: {1}", Settings.MinimumDotNetFrameworkVersionRequired, frameworkVersion);

                if (frameworkVersion == -1)
                {
                    Logging.Error("Failed to get .NET Framework version from the registry");
                    MessageBox.Show("failedToGetDotNetFrameworkVersion");
                }
                else if (frameworkVersion < Settings.MinimumDotNetFrameworkVersionRequired)
                {
                    Logging.Error("Invalid .NET Framework version (less then 4.8)");
                    if (MessageBox.Show("invalidDotNetFrameworkVersion", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        CommonUtils.StartProcess(Settings.DotNetFrameworkLatestDownloadURL);
                    }
                }
                else
                {
                    Logging.Info("Valid .NET Framework version");
                    ModpackSettings.ValidFrameworkVersion = true;
                }
            }

            //switch into application modes based on mode enum
            Logging.Debug("Starting application in {0} mode", CommandLineSettings.ApplicationMode.ToString());
            switch (CommandLineSettings.ApplicationMode)
            {
            case ApplicationMode.Updater:
                ModpackToolbox updater = new ModpackToolbox();

                //close application log if open
                if (Logging.IsLogOpen(Logfiles.Application))
                {
                    CloseApplicationLog(true);
                }

                //start updater logging
                if (!Logging.Init(Logfiles.Updater))
                {
                    MessageBox.Show("Failed to initialize logfile for updater");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.Updater);

                //redirect application log file to the modpack toolbox
                if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.Updater))
                {
                    Logging.Error(Logfiles.Updater, LogOptions.MethodName, "Failed to redirect messages from application to modpack toolbox");
                }

                //show window
                updater.ShowDialog();

                //stop updater logging
                CloseLog(Logfiles.Updater);
                DeleteCustomLogIfExists();
                updater = null;
                Current.Shutdown((int)ReturnCodes.Success);
                Environment.Exit((int)ReturnCodes.Success);
                return;

            case ApplicationMode.Editor:
                DatabaseEditor editor = new DatabaseEditor();

                //close application log if open
                if (Logging.IsLogOpen(Logfiles.Application))
                {
                    CloseApplicationLog(true);
                }

                //start updater logging
                if (!Logging.Init(Logfiles.Editor))
                {
                    MessageBox.Show("Failed to initialize logfile for editor");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.Editor);

                //redirect application log file to the editor
                if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.Editor))
                {
                    Logging.Error(Logfiles.Editor, LogOptions.MethodName, "Failed to redirect messages from application to editor");
                }

                //show window
                editor.ShowDialog();

                //stop updater logging
                CloseLog(Logfiles.Editor);
                DeleteCustomLogIfExists();
                editor = null;
                Current.Shutdown((int)ReturnCodes.Success);
                Environment.Exit((int)ReturnCodes.Success);
                return;

            case ApplicationMode.PatchDesigner:
                PatchDesigner patcher = new PatchDesigner();

                //close application log if open
                if (Logging.IsLogOpen(Logfiles.Application))
                {
                    CloseApplicationLog(true);
                }

                //start updater logging
                if (!Logging.Init(Logfiles.PatchDesigner))
                {
                    MessageBox.Show("Failed to initialize logfile for patcher");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.PatchDesigner);

                //redirect application log file to the patch designer
                if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.PatchDesigner))
                {
                    Logging.Error(Logfiles.PatchDesigner, LogOptions.MethodName, "Failed to redirect messages from application to patch designer");
                }

                //show window
                patcher.ShowDialog();

                //stop patch designer logging
                CloseLog(Logfiles.PatchDesigner);
                DeleteCustomLogIfExists();
                patcher = null;
                Current.Shutdown((int)ReturnCodes.Success);
                Environment.Exit((int)ReturnCodes.Success);
                return;

            case ApplicationMode.AutomationRunner:
                DatabaseAutomationRunner automationRunner = new DatabaseAutomationRunner();

                //close application log if open
                if (Logging.IsLogOpen(Logfiles.Application))
                {
                    CloseApplicationLog(true);
                }

                //start DatabaseAutomationRunner logging
                if (!Logging.Init(Logfiles.AutomationRunner))
                {
                    MessageBox.Show("Failed to initialize logfile for DatabaseAutomationRunner");
                    Current.Shutdown((int)ReturnCodes.LogfileError);
                    return;
                }
                Logging.WriteHeader(Logfiles.AutomationRunner);

                //redirect application log file to the automation runner
                if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.AutomationRunner))
                {
                    Logging.Error(Logfiles.AutomationRunner, LogOptions.MethodName, "Failed to redirect messages from application to automation runner");
                }

                //show window
                automationRunner.ShowDialog();

                //stop patch designer logging
                CloseLog(Logfiles.AutomationRunner);
                DeleteCustomLogIfExists();
                automationRunner = null;
                Current.Shutdown((int)ReturnCodes.Success);
                Environment.Exit((int)ReturnCodes.Success);
                return;

            case ApplicationMode.Patcher:
                Logging.Info("Running patch mode");

                //check that at least one patch file was specified from command line
                if (CommandLineSettings.PatchFilenames.Count == 0)
                {
                    Logging.Error("0 patch files parsed from command line!");
                    Current.Shutdown((int)ReturnCodes.PatcherNoSpecifiedFiles);
                    Environment.Exit((int)ReturnCodes.PatcherNoSpecifiedFiles);
                }
                else
                {
                    //parse patch objects from command line file list
                    List <Patch> patchList = new List <Patch>();
                    foreach (string file in CommandLineSettings.PatchFilenames)
                    {
                        if (!File.Exists(file))
                        {
                            Logging.Warning("Skipping file path {0}, not found", file);
                            continue;
                        }
                        Logging.Info("Adding patches from file {0}", file);
                        XmlUtils.AddPatchesFromFile(patchList, file);
                    }

                    //check for at least one patchfile was parsed
                    if (patchList.Count == 0)
                    {
                        Logging.Error("0 patches parsed from files!");
                        Current.Shutdown((int)ReturnCodes.PatcherNoPatchesParsed);
                        Environment.Exit((int)ReturnCodes.PatcherNoPatchesParsed);
                    }

                    //set default patch return code
                    PatchExitCode exitCode = PatchExitCode.Success;

                    //always return on worst condition
                    int i = 1;
                    foreach (Patch p in patchList)
                    {
                        Logging.Info("Running patch {0} of {1}", i++, patchList.Count);
                        PatchExitCode exitCodeTemp = PatchUtils.RunPatch(p);
                        if ((int)exitCodeTemp < (int)exitCode)
                        {
                            exitCode = exitCodeTemp;
                        }
                    }

                    Logging.Info("Patching finished, exit code {0} ({1})", (int)exitCode, exitCode.ToString());
                    CloseApplicationLog(true);
                    //add 100 to ensure it's a patch unique error code
                    Current.Shutdown(((int)exitCode) + 100);
                    Environment.Exit(((int)exitCode) + 100);
                }
                return;
            }
        }
示例#18
0
 private void CollectLogInfo_Click(object sender, System.EventArgs e)
 {
     if (TanksLocation.Equals("none"))
     {
         return;
     }
     Logging.Manager("Collecting log files...");
     CollectLogInfoResult.Text = Translations.GetTranslatedString("collectionLogInfo");
     using (ZipFile zip = new ZipFile())
     {
         string newZipFileName = "";
         try
         {
             List <string> filesToCollect = new List <string>()
             {
                 Path.Combine(AppStartupPath, "RelHaxLog.txt"),
                 Path.Combine(AppStartupPath, "RelHaxUserConfigs", "lastInstalledConfig.xml"),
                 Path.Combine(AppStartupPath, "RelHaxSettings.xml"),
                 Path.Combine(TanksLocation, "logs", "installedRelhaxFiles.log"),
                 Path.Combine(TanksLocation, "logs", "uninstall.log"),
                 Path.Combine(TanksLocation, "python.log"),
                 Path.Combine(TanksLocation, "xvm.log"),
                 Path.Combine(TanksLocation, "pmod.log")
             };
             using (AddPicturesZip apz = new AddPicturesZip()
             {
                 AppStartupPath = this.AppStartupPath
             })
             {
                 apz.ShowDialog();
                 if (!(apz.DialogResult == DialogResult.OK))
                 {
                     return;
                 }
                 foreach (object o in apz.listBox1.Items)
                 {
                     string s = (string)o;
                     filesToCollect.Add(s);
                 }
             }
             foreach (string s in filesToCollect)
             {
                 if (string.IsNullOrWhiteSpace(s))
                 {
                     continue;
                 }
                 //verify that it's not already in there but from a different folder
                 int    dupCunter     = 0;
                 string nameInZipFile = Path.GetFileName(s);
                 foreach (ZipEntry ze in zip)
                 {
                     while (ze.FileName.Equals(nameInZipFile))
                     {
                         nameInZipFile = Path.GetFileName(s) + dupCunter++;
                     }
                 }
                 if (File.Exists(s))
                 {
                     ZipEntry entry = zip.AddFile(s);
                     entry.FileName = nameInZipFile;
                     Logging.Manager("file " + s + " added to debug zip file");
                 }
                 else
                 {
                     Logging.Manager("file " + s + " skipped, does not exist");
                 }
             }
             newZipFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "RelhaxModpackLogs_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".zip");
             zip.Save(newZipFileName);
         }
         catch (Exception ex)
         {
             Utils.ExceptionLog(ex);
             CollectLogInfoResult.Text = Translations.GetTranslatedString("failedCreateZipfile");
             return;
         }
         Logging.Manager("Zip file saved to" + newZipFileName);
         CollectLogInfoResult.Text = Translations.GetTranslatedString("zipSavedTo") + newZipFileName;
     }
 }
示例#19
0
 private void StartXVMStatButton_Click(object sender, EventArgs e)
 {
     // Process.Start(string.Format(XVMURL, Translations.GetTranslatedString("xvmUrlLocalisation")));
     Utils.CallBrowser(string.Format(XVMURL, Translations.GetTranslatedString("xvmUrlLocalisation")));
     DialogResult = DialogResult.OK;
 }