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");
        }
Example #2
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 static AndOrFlag GetAndOrID(string s)
 {
     foreach (AndOrFlag f in Enum.GetValues(typeof(AndOrFlag)))
     {
         if (GetAndOrString(f).ToLower().Equals(s.ToLower()))
         {
             return(f);
         }
     }
     Logging.Manager("Get invalid AndOrString. Reporting default AND flag");
     return(AndOrFlag.AND);
 }
Example #4
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));
 }
Example #6
0
 //use the ints to set a new start location
 private void FirstLoadHelper_Load(object sender, EventArgs e)
 {
     //log info
     Logging.Manager("FirstLoadHelper: startup location is x: " + x + ", y: " + y);
     this.Location = new Point(x, y);
     //setting UI color
     Settings.SetUIColorsWinForms(this);
     //font scaling
     this.AutoScaleMode = Settings.AppScalingMode;
     helperText.Font    = Settings.AppFont;
     this.Font          = Settings.AppFont;
     if (Settings.AppScalingMode == System.Windows.Forms.AutoScaleMode.Dpi)
     {
         this.Scale(new SizeF(Settings.ScaleSize, Settings.ScaleSize));
     }
 }
Example #7
0
 private void LegacyHotfixTimer_Tick(object sender, EventArgs e)
 {
     if (Settings.SView == SelectionView.Legacy)
     {
         if (Program.Version == Program.ProgramVersion.Alpha)
         {
             Logging.Manager(string.Format("DEBUG: from Preview timer: Legacy view, p.ContainsFocus={0}", this.ContainsFocus));
         }
         if (!this.ContainsFocus)
         {
             if (Program.Version == Program.ProgramVersion.Alpha)
             {
                 Logging.Manager(string.Format("DEBUG: from Preview timer: Legacy view, forcing focus conatin"));
             }
             this.Focus();
         }
     }
     LegacyHotfixTimer.Stop();
 }
Example #8
0
 private void SelectButton_Click(object sender, EventArgs e)
 {
     SelectedDocument = this.GetSelectedXMLDoc();
     if (SelectedDocument.Equals("-1"))
     {
         //error
         Logging.Manager("ERROR: Failed to parse XML File");
         SelectedXML = SelectedDocument;
     }
     else if (SelectedDocument.Equals("localFile"))
     {
         //local file dialog box
         SelectedXML       = SelectedDocument;
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         SelectedXML       = string.Format("{0},{1}", Settings.ModInfoDatFile, SelectedDocument);
         this.DialogResult = DialogResult.OK;
     }
     this.Close();
 }
Example #9
0
        //sets the window title to reflect the new picture, and
        //begine the async process of loading the new picture
        public void DisplayMedia(Media m)
        {
            if (PreviewPicture != null)
            {
                PreviewPicture.Image = null;
            }
            if (Medias.Count == 0)
            {
                return;
            }
            if (m.URL.Equals(""))
            {
                return;
            }
            if (Controls.Contains(PreviewPicture))
            {
                Controls.Remove(PreviewPicture);
                PreviewPicture.Dispose();
                PreviewPicture = null;
            }
            if (Controls.Contains(Browser))
            {
                Controls.Remove(Browser);
                Browser.Dispose();
                Browser = null;
            }
            if (Controls.Contains(player))
            {
                Controls.Remove(player);
                player.Dispose();
                player = null;
            }
            if (Controls.Contains(ErrorLabel))
            {
                Controls.Remove(ErrorLabel);
                ErrorLabel.Dispose();
                ErrorLabel = null;
            }
            //calculate the new component size
            //width is from the top left of previous to the top right of next
            //height is PreviewComponentLocation (12) Y to location of top left of preview - 6
            int picturewidth  = (NextPicButton.Location.X + NextPicButton.Size.Width) - PreviousPicButton.Location.X;
            int pictureHeight = PreviousPicButton.Location.Y - 6 - PreviewComponentLocation.Y;

            PreviewComponentSize = new Size(picturewidth, pictureHeight);
            switch (m.MediaType)
            {
            case MediaType.Picture:
                PreviewPicture = new PictureBox()
                {
                    Size      = PreviewComponentSize,
                    BackColor = PreviewComponentBackColor,
                    Location  = PreviewComponentLocation,
                    SizeMode  = PictureBoxSizeMode.Zoom,
                    Anchor    = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                };
                PreviewPicture.Click += PreviewPicture_Click;
                Controls.Add(PreviewPicture);
                PreviewPicture.Image = Settings.GetLoadingImage();
                PreviewPicture.LoadAsync(m.URL);
                Text = DBO.NameFormatted + " - " + CurrentlySelected;
                Logging.Manager("Preview: started loading of picture '" + DBO.NameFormatted + "' at URL '" + m.URL + "'");
                break;

            case MediaType.Webpage:
                //NOTE: needs to be fixed
                Browser = new WebBrowser()
                {
                    Size     = PreviewComponentSize,
                    Location = PreviewComponentLocation,
                    ScriptErrorsSuppressed = true,
                    Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                };
                Controls.Add(Browser);
                Browser.Navigate(m.URL);
                Text = DBO.NameFormatted + " - " + CurrentlySelected;
                Logging.Manager("Preview: started loading of webpage '" + DBO.NameFormatted + "' at URL '" + m.URL + "'");
                break;

            case MediaType.MediaFile:
                try
                {
                    player = new RelhaxMediaPlayer()
                    {
                        Size     = PreviewComponentSize,
                        Location = PreviewComponentLocation,
                        //BackColor = PreviewComponentBackColor,
                        MediaURL = m.URL,
                        Anchor   = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                    };
                    Controls.Add(player);
                    Text = DBO.NameFormatted + " - " + CurrentlySelected;
                    Logging.Manager("Preview: started loading of direct media '" + DBO.NameFormatted + "' at URL '" + m.URL + "'");
                }
                catch (Exception e)
                {
                    Utils.ExceptionLog(e);
                    ErrorLabel = new Label()
                    {
                        Text     = "ERROR",
                        AutoSize = false,
                        Size     = PreviewComponentSize
                    };
                    Controls.Add(ErrorLabel);
                    Text = DBO.NameFormatted + " - " + CurrentlySelected;
                }
                break;

            case MediaType.HTML:
                Browser = new WebBrowser()
                {
                    Size     = PreviewComponentSize,
                    Location = PreviewComponentLocation,
                    ScriptErrorsSuppressed = true,
                    Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left)
                };
                Controls.Add(Browser);
                Browser.DocumentText = m.URL;
                Text = DBO.NameFormatted + " - " + CurrentlySelected;
                Logging.Manager("Preview: started loading of HTML '" + DBO.NameFormatted + "' at HTML '" + m.URL + "'");
                break;

            default:
                Logging.Manager("WARNING: Unknown mediaType: " + m.MediaType);
                break;
            }
        }
Example #10
0
 private void CRCCHECK2_FormClosing(object sender, FormClosingEventArgs e)
 {
     Logging.Manager("|------------------------------------------------------------------------------------------------|");
 }
Example #11
0
        //saves settings to xml file
        public static void SaveSettings()
        {
            Logging.Manager("Saving application settings");
            if (File.Exists(SettingsXmlFile)) File.Delete(SettingsXmlFile);
            XmlDocument doc = new XmlDocument();
            XmlElement settingsHolder = doc.CreateElement("settings");
            doc.AppendChild(settingsHolder);
            XmlElement xcomicSans = doc.CreateElement("comicSans");
            xcomicSans.InnerText = "" + ComicSans;
            settingsHolder.AppendChild(xcomicSans);
            XmlElement xfontSizeForum = doc.CreateElement("FontSizeForum");
            xfontSizeForum.InnerText = "" + (int)FontSizeforum;
            settingsHolder.AppendChild(xfontSizeForum);
            XmlElement xbackupModFolder = doc.CreateElement("backupModFolder");
            xbackupModFolder.InnerText = "" + BackupModFolder;
            settingsHolder.AppendChild(xbackupModFolder);
            XmlElement xcleanInstallation = doc.CreateElement("cleanInstallation");
            xcleanInstallation.InnerText = "" + CleanInstallation;
            settingsHolder.AppendChild(xcleanInstallation);
            XmlElement xsaveLastConfig = doc.CreateElement("saveLastConfig");
            xsaveLastConfig.InnerText = "" + SaveLastConfig;
            settingsHolder.AppendChild(xsaveLastConfig);
            XmlElement xsaveUserData = doc.CreateElement("saveUserData");
            xsaveUserData.InnerText = "" + SaveUserData;
            settingsHolder.AppendChild(xsaveUserData);
            XmlElement xclearCache = doc.CreateElement("clearCache");
            xclearCache.InnerText = "" + ClearCache;
            settingsHolder.AppendChild(xclearCache);
            XmlElement xdarkUI = doc.CreateElement("darkUI");
            xdarkUI.InnerText = "" + DarkUI;
            settingsHolder.AppendChild(xdarkUI);
            //modselectionlistUI options
            XmlElement xEnableBordersDefaultView = doc.CreateElement("EnableBordersDefaultView");
            xEnableBordersDefaultView.InnerText = "" + EnableBordersDefaultView;
            settingsHolder.AppendChild(xEnableBordersDefaultView);
            XmlElement xEnableBordersDefaultV2View = doc.CreateElement("EnableBordersDefaultV2View");
            xEnableBordersDefaultV2View.InnerText = "" + EnableBordersDefaultV2View;
            settingsHolder.AppendChild(xEnableBordersDefaultV2View);
            XmlElement xEnableBordersLegacyView = doc.CreateElement("EnableBordersLegacyView");
            xEnableBordersLegacyView.InnerText = "" + EnableBordersLegacyView;
            settingsHolder.AppendChild(xEnableBordersLegacyView);
            XmlElement xEnableChildColorChangeDefaultView = doc.CreateElement("EnableChildColorChangeDefaultView");
            xEnableChildColorChangeDefaultView.InnerText = "" + EnableColorChangeDefaultView;
            settingsHolder.AppendChild(xEnableChildColorChangeDefaultView);
            XmlElement xEnableChildColorChangeDefaultV2View = doc.CreateElement("EnableChildColorChangeDefaultV2View");
            xEnableChildColorChangeDefaultV2View.InnerText = "" + EnableColorChangeDefaultV2View;
            settingsHolder.AppendChild(xEnableChildColorChangeDefaultV2View);
            XmlElement xEnableChildColorChangeLegacyView = doc.CreateElement("EnableChildColorChangeLegacyView");
            xEnableChildColorChangeLegacyView.InnerText = "" + EnableColorChangeLegacyView;
            settingsHolder.AppendChild(xEnableChildColorChangeLegacyView);
            //installer settings
            XmlElement xdeleteLogs = doc.CreateElement("deleteLogs");
            xdeleteLogs.InnerText = "" + DeleteLogs;
            settingsHolder.AppendChild(xdeleteLogs);
            XmlElement xNotifyIfSameDatabase = doc.CreateElement("NotifyIfSameDatabase");
            xNotifyIfSameDatabase.InnerText = "" + NotifyIfSameDatabase;
            settingsHolder.AppendChild(xNotifyIfSameDatabase);
            XmlElement xShowInstallCompleteWindow = doc.CreateElement("ShowInstallCompleteWindow");
            xShowInstallCompleteWindow.InnerText = "" + ShowInstallCompleteWindow;
            settingsHolder.AppendChild(xShowInstallCompleteWindow);
            XmlElement xExportMode = doc.CreateElement("ExportMode");
            xExportMode.InnerText = "" + ExportMode;
            settingsHolder.AppendChild(xExportMode);
            XmlElement xlanguage = doc.CreateElement("language");
            xlanguage.InnerText = "" + (int)Translations.language;
            settingsHolder.AppendChild(xlanguage);
            XmlElement xSelectionView = doc.CreateElement("SelectionView");
            xSelectionView.InnerText = "" + (int)SView;
            settingsHolder.AppendChild(xSelectionView);
            XmlElement xloadingGif = doc.CreateElement("loadingGif");
            xloadingGif.InnerText = "" + (int)GIF;
            settingsHolder.AppendChild(xloadingGif);
            XmlElement xUninstallMode = doc.CreateElement("UninstallMode");
            xUninstallMode.InnerText = "" + (int)UninstallMode;
            settingsHolder.AppendChild(xUninstallMode);
            XmlElement xforceManuel = doc.CreateElement("forceManuel");
            xforceManuel.InnerText = "" + ForceManuel;
            settingsHolder.AppendChild(xforceManuel);
            XmlElement xmodSelectionHeight = doc.CreateElement("modSelectionHeight");
            xmodSelectionHeight.InnerText = "" + ModSelectionHeight;
            settingsHolder.AppendChild(xmodSelectionHeight);
            XmlElement xmodSelectionWidth = doc.CreateElement("modSelectionWidth");
            xmodSelectionWidth.InnerText = "" + ModSelectionWidth;
            settingsHolder.AppendChild(xmodSelectionWidth);
            XmlElement xModSelectionFullscreen = doc.CreateElement("ModSelectionFullscreen");
            xModSelectionFullscreen.InnerText = "" + ModSelectionFullscreen;
            settingsHolder.AppendChild(xModSelectionFullscreen);
            XmlElement xCreateShortcuts = doc.CreateElement("CreateShortcuts");
            xCreateShortcuts.InnerText = "" + CreateShortcuts;
            settingsHolder.AppendChild(xCreateShortcuts);
            XmlElement xSuperExtraction = doc.CreateElement("SuperExtraction");
            xSuperExtraction.InnerText = "" + SuperExtraction;
            settingsHolder.AppendChild(xSuperExtraction);
            XmlElement xInstantExtraction = doc.CreateElement("InstantExtraction");
            xInstantExtraction.InnerText = "" + InstantExtraction;
            settingsHolder.AppendChild(xInstantExtraction);
            XmlElement xpreviewX = doc.CreateElement("previewX");
            if (PreviewX < 0) { PreviewX = 0; };
            xpreviewX.InnerText = "" + PreviewX;
            settingsHolder.AppendChild(xpreviewX);
            XmlElement xpreviewY = doc.CreateElement("previewY");
            if (PreviewY < 0) { PreviewY = 0; };
            xpreviewY.InnerText = "" + PreviewY;
            settingsHolder.AppendChild(xpreviewY);
            XmlElement customModInfoPath = doc.CreateElement("customModInfoPath");
            if (!CustomModInfoPath.Equals("")) { customModInfoPath.InnerText = CustomModInfoPath; }
            settingsHolder.AppendChild(customModInfoPath);
            XmlElement priorityBrowser = doc.CreateElement("priorityBrowser");
            if (!PriorityBrowser.Equals("")) { priorityBrowser.InnerText = PriorityBrowser; }
            settingsHolder.AppendChild(priorityBrowser);
            XmlElement xPreviewFullscreen = doc.CreateElement("PreviewFullscreen");
            xPreviewFullscreen.InnerText = "" + PreviewFullscreen;
            settingsHolder.AppendChild(xPreviewFullscreen);
            XmlElement xPreviewWidth = doc.CreateElement("PreviewWidth");
            xPreviewWidth.InnerText = "" + PreviewWidth;
            settingsHolder.AppendChild(xPreviewWidth);
            XmlElement xPreviewHeight = doc.CreateElement("PreviewHeight");
            xPreviewHeight.InnerText = "" + PreviewHeight;
            settingsHolder.AppendChild(xPreviewHeight);
            XmlElement xUseAlternateUpdateMethod = doc.CreateElement("UseAlternateUpdateMethod");
            xUseAlternateUpdateMethod.InnerText = "" + UseAlternateUpdateMethod;
            settingsHolder.AppendChild(xUseAlternateUpdateMethod);
            XmlElement xBetaApplication = doc.CreateElement("BetaApplication");
            xBetaApplication.InnerText = "" + BetaApplication;
            settingsHolder.AppendChild(xBetaApplication);
            XmlElement xBetaDatabase = doc.CreateElement("BetaDatabase");
            xBetaDatabase.InnerText = "" + BetaDatabase;
            settingsHolder.AppendChild(xBetaDatabase);

            doc.Save(SettingsXmlFile);
            Logging.Manager("Settings saved successfully");
        }
Example #12
0
 //loads settings from xml file
 public static void LoadSettings()
 {
     //Settings declared here are set for what their default values should be, then later modified in the settings xml file
     //i.e. when new features are added
     FirstLoad = false;
     Logging.Manager("Loading application settings");
     if (!File.Exists(SettingsXmlFile))
     {
         Logging.Manager("WARNING:Settings xml not found, defaults used");
         //also specify that this is the first load
         FirstLoad = true;
         Logging.Manager("Language: " + CultureInfo.CurrentCulture.DisplayName);
         string lang = CultureInfo.InstalledUICulture.Name.Split('-')[0].ToLower();
         switch (lang)
         {
             case "de":
                 Translations.language = Translations.Languages.German;
                 break;
             case "pl":
                 Translations.language = Translations.Languages.Polish;
                 break;
             case "fr":
                 Translations.language = Translations.Languages.French;
                 break;
             default:
                 Translations.language = Translations.Languages.English;
                 break;
         }
     }
     else
     {
         Logging.Manager("Loading xml file");
         XmlDocument doc = new XmlDocument();
         doc.Load(SettingsXmlFile);
         XmlNodeList settingsList = doc.ChildNodes[0].ChildNodes;
         foreach (XmlNode n in settingsList)
         {
             switch (n.Name)
             {
                 case "comicSans":
                     ComicSans = bool.Parse(n.InnerText);
                     break;
                 case "backupModFolder":
                     BackupModFolder = bool.Parse(n.InnerText);
                     break;
                 case "cleanInstallation":
                     CleanInstallation = bool.Parse(n.InnerText);
                     break;
                 case "loadingGif":
                     GIF = (LoadingGifs)int.Parse(n.InnerText);
                     break;
                 case "forceManuel":
                     ForceManuel = bool.Parse(n.InnerText);
                     break;
                 case "modSelectionHeight":
                     ModSelectionHeight = int.Parse(n.InnerText);
                     break;
                 case "modSelectionWidth":
                     ModSelectionWidth = int.Parse(n.InnerText);
                     break;
                 case "saveLastConfig":
                     SaveLastConfig = bool.Parse(n.InnerText);
                     break;
                 case "saveUserData":
                     SaveUserData = bool.Parse(n.InnerText);
                     break;
                 case "clearCache":
                     ClearCache = bool.Parse(n.InnerText);
                     break;
                 case "darkUI":
                     DarkUI = bool.Parse(n.InnerText);
                     break;
                 case "EnableBordersDefaultView":
                     EnableBordersDefaultView = bool.Parse(n.InnerText);
                     break;
                 case "EnableBordersLegacyView":
                     EnableBordersLegacyView = bool.Parse(n.InnerText);
                     break;
                 case "EnableBordersDefaultV2View":
                     EnableBordersDefaultV2View = bool.Parse(n.InnerText);
                     break;
                 case "EnableChildColorChangeDefaultView":
                     EnableColorChangeDefaultView = bool.Parse(n.InnerText);
                     break;
                 case "EnableChildColorChangeLegacyView":
                     EnableColorChangeLegacyView = bool.Parse(n.InnerText);
                     break;
                 case "EnableChildColorChangeDefaultV2View":
                     EnableColorChangeDefaultV2View = bool.Parse(n.InnerText);
                     break;
                 case "deleteLogs":
                     DeleteLogs = bool.Parse(n.InnerText);
                     break;
                 case "language":
                     Translations.language = (Translations.Languages)int.Parse(n.InnerText);
                     break;
                 case "ModSelectionFullscreen":
                     ModSelectionFullscreen = bool.Parse(n.InnerText);
                     break;
                 case "NotifyIfSameDatabase":
                     NotifyIfSameDatabase = bool.Parse(n.InnerText);
                     break;
                 case "ShowInstallCompleteWindow":
                     ShowInstallCompleteWindow = bool.Parse(n.InnerText);
                     break;
                 case "previewX":
                     PreviewX = int.Parse(n.InnerText);
                     break;
                 case "previewY":
                     PreviewY = int.Parse(n.InnerText);
                     break;
                 case "customModInfoPath":
                     CustomModInfoPath = n.InnerText;
                     break; 
                 case "SelectionView":
                     SView = (SelectionView)int.Parse(n.InnerText);
                     break;
                 case "FontSizeForum":
                     FontSizeforum = (FontSize)int.Parse(n.InnerText);
                     break;
                 case "CreateShortcuts":
                     CreateShortcuts = bool.Parse(n.InnerText);
                     break;
                 case "InstantExtraction":
                     InstantExtraction = bool.Parse(n.InnerText);
                     break;
                 case "UninstallMode":
                     UninstallMode = (UninstallModes)int.Parse(n.InnerText);
                     break;
                 case "SuperExtraction":
                     SuperExtraction = bool.Parse(n.InnerText);
                     break;
                 case "PreviewFullscreen":
                     PreviewFullscreen = bool.Parse(n.InnerText);
                     break;
                 case "PreviewWidth":
                     PreviewWidth = int.Parse(n.InnerText);
                     break;
                 case "PreviewHeight":
                     PreviewHeight = int.Parse(n.InnerText);
                     break;
                 case "ExportMode":
                     ExportMode = bool.Parse(n.InnerText);
                     break;
                 case "UseAlternateUpdateMethod":
                     UseAlternateUpdateMethod = bool.Parse(n.InnerText);
                     break;
                 case "BetaApplication":
                     if(!Program.betaAppSetFromCommandLine)
                         BetaApplication = bool.Parse(n.InnerText);
                     break;
                 case "BetaDatabase":
                     if(!Program.betaDBSetFromCommandLine)
                         BetaDatabase = bool.Parse(n.InnerText);
                     break;
                 case "priorityBrowser":
                     PriorityBrowser = n.InnerText;
                     break;
             }
         }
     }
     ApplyInternalProperties();
     Logging.Manager("Settings loaded successfully");
 }
Example #13
0
 private void DatabaseListGenerater_FormClosing(object sender, FormClosingEventArgs e)
 {
     Logging.Manager("|------------------------------------------------------------------------------------------------|");
 }
 private void PatchTester_FormClosing(object sender, FormClosingEventArgs e)
 {
     Logging.Manager("|------------------------------------------------------------------------------------------------|");
 }
Example #15
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logging.Manager("|------------------------------------------------------------------------------------------------|");
            Logging.Manager("Main Entry point launched");

            //loading embeded dlls from the application
            //https://www.codeproject.com/articles/528178/load-dll-from-embedded-resource
            string defaultResourcePath = "RelhaxModpack.Resources.";
            Dictionary <string, Compressed> librariesMultiPlatform = new Dictionary <string, Compressed>()
            {
                { "DotNetZip.dll", Compressed.No },
                { "Newtonsoft.Json.dll", Compressed.No },
                { "NAudio.dll", Compressed.No },
                { "nvtt32.zip", Compressed.Yes },
                { "nvtt64.zip", Compressed.Yes },
                { "FreeImage32.zip", Compressed.Yes },
                { "FreeImage64.zip", Compressed.Yes }
            };

            //load multiplatform
            foreach (var s in librariesMultiPlatform)
            {
                string resourcePath = defaultResourcePath + s.Key;
                try
                {
                    EmbeddedAssembly.Load(resourcePath, s.Key);
                    Logging.Manager("loading managed library: " + s.Key);
                    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                    continue;
                }
                catch
                {
                    // if EmbeddedAssembly.Load failes, it should be an unmanaged dll
                    try
                    {
                        EmbeddedUnmanagedDll.ExtractEmbeddedDlls(resourcePath, s.Key, s.Value == Compressed.Yes, out string filename);
                        Logging.Manager(string.Format("extracted unmanaged library: {0}{1}", s.Key, s.Value == Compressed.Yes ? " (" + filename + ")" : ""));
                        continue;
                    }
                    catch (Exception ex)
                    {
                        MainWindow.errorCounter++;
                        Logging.Manager(string.Format("failed to handle library: {0} ({1})", s.Key, ex.Message));
                    }
                }
            }

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            // delete RelicCopyUpdate.bat at start (it is only needed at updates, so kill it)
            try
            {
                string updateBatPath = Path.Combine(Application.StartupPath, "RelicCopyUpdate.bat");
                if (System.IO.File.Exists(updateBatPath))
                {
                    System.IO.File.Delete(updateBatPath);
                }
            }
            catch (Exception ex)
            {
                Utils.ExceptionLog("Main", "delete RelicCopyUpdate.bat", ex);
            }
            //get the command line args for testing of auto install
            string[] commandArgs = Environment.GetCommandLineArgs();
            //log command line
            Logging.Manager("command line: " + string.Join(" ", commandArgs));
            for (int i = 0; i < commandArgs.Count(); i++)
            {
                //check what type of arg each one is
                if (Regex.IsMatch(commandArgs[i], @"restart-wait$"))
                {
                    Logging.Manager("/restart-wait detected, sleep 1000ms");
                    System.Threading.Thread.Sleep(1000);
                }
                else if (Regex.IsMatch(commandArgs[i], @"test$"))
                {
                    Logging.Manager("/test detected, loading in test mode");
                    testMode = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"skip-update$"))
                {
                    Logging.Manager("/skip-update detected, skipping update of application");
                    skipUpdate = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"patchday$"))
                {
                    Logging.Manager("/patchday detected, welcome database manager");
                    patchDayTest = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"beta-database$"))
                {
                    Logging.Manager("/beta-database detected, welcome beta tester");
                    Settings.BetaDatabase    = true;
                    betaDBSetFromCommandLine = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"beta-application"))
                {
                    Logging.Manager("/beta-application detected, welcome beta tester");
                    Settings.BetaApplication  = true;
                    betaAppSetFromCommandLine = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"silent-start"))
                {
                    Logging.Manager("/silent-start detected, loading in silent mode");
                    silentStart = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"auto-install$"))
                {
                    Logging.Manager("/auto-install detected");
                    autoInstall = true;
                    //parse the config file and advance the counter
                    configName = commandArgs[++i];
                }
                else if (Regex.IsMatch(commandArgs[i], @"updateKeyFile$"))
                {
                    Logging.Manager("/updateKeyFile detected");
                    updateFileKey = true;
                    updateKeyFile = commandArgs[++i];
                }
                else if (Regex.IsMatch(commandArgs[i], @"editorAutoLoad$"))
                {
                    editorAutoLoad     = true;
                    editorDatabaseFile = commandArgs[++i];
                    Logging.Manager("/editorAutoLoad detected, attempting to auto load database from " + editorDatabaseFile);
                }
                else if (Regex.IsMatch(commandArgs[i], @"forceVisible$"))
                {
                    Logging.Manager("/forceVisible detected, loading all invisible mods in selection list");
                    forceVisible = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"forceEnabled$"))
                {
                    Logging.Manager("/forceEnabled detected, loading all visible mods as enabled");
                    forceEnabled = true;
                }
                else if (Regex.IsMatch(commandArgs[i], @"patchcheck$"))
                {
                    Logging.Manager("/patchcheck detected, loading in patch design mode");
                    Application.Run(new PatchTester());
                    return;
                }
                else if (Regex.IsMatch(commandArgs[i], @"databaseupdate$"))
                {
                    Logging.Manager("/databaseupdate detected, loading in database update mode");
                    if (skipUpdate)
                    {
                        Logging.Manager("if calling databaseupdate, /skip-update will be ignored");
                        skipUpdate = false;
                    }
                    Application.Run(new DatabaseUpdater());
                    return;
                }
                else if (Regex.IsMatch(commandArgs[i], @"databaseedit$"))
                {
                    Logging.Manager("/databaseedit detected, loading in database edit mode");
                    if (skipUpdate)
                    {
                        Logging.Manager("if calling databaseedit, /skip-update will be ignored");
                        skipUpdate = false;
                    }
                    Application.Run(new DatabaseEditor());
                    return;
                }
            }
            //load the translations
            Logging.Manager("Loading translation hashes");
            try
            {
                Translations.LoadHashes();
            }
            catch (Exception ex)
            {
                MainWindow.errorCounter++;
                Logging.Manager(string.Format("failed to load hash tables: {0}", ex.Message));
            }

            //start the background taskbar form
            Logging.Manager("Loading main window");
            MainWindow mw = new MainWindow();

            if (silentStart)
            {
                mw.WindowState = FormWindowState.Minimized;
            }
            Application.Run(mw);
        }
Example #16
0
        /// <summary>
        /// Extract DLLs from resources to temporary folder
        /// </summary>
        /// <param name="dllName">name of DLL file to create (including dll suffix)</param>
        /// <param name="resourceBytes">The resource name (fully qualified)</param>
        public static void ExtractEmbeddedDlls(string embeddedResource, string dllName, bool compressed, out string containedDllName)
        {
            containedDllName = dllName;

            Assembly assem = Assembly.GetExecutingAssembly();

            string[]     names = assem.GetManifestResourceNames();
            AssemblyName an    = assem.GetName();

            // The temporary folder holds one or more of the temporary DLLs
            // It is made "unique" to avoid different versions of the DLL or architectures.
            // tempFolder = String.Format("{0}.{1}.{2}", an.Name, an.ProcessorArchitecture, an.Version);
            tempFolder = Settings.RelHaxLibrariesFolder;

            if (!Directory.Exists(tempFolder))
            {
                Directory.CreateDirectory(tempFolder);
            }

            // Add the temporary dirName to the PATH environment variable (at the head!)
            string path = Environment.GetEnvironmentVariable("PATH");

            string[] pathPieces = path.Split(';');
            bool     found      = false;

            foreach (string pathPiece in pathPieces)
            {
                if (pathPiece == tempFolder)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                Environment.SetEnvironmentVariable("PATH", tempFolder + ";" + path);
            }

            string   tempFile = "";
            Assembly curAsm   = Assembly.GetExecutingAssembly();

            byte[] resourceBytes = null;

            using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
            {
                using (Stream stm = curAsm.GetManifestResourceStream(embeddedResource))
                {
                    // Either the file is not existed or it is not mark as embedded resource
                    if (stm == null)
                    {
                        throw new Exception(embeddedResource + " is not found in Embedded Resources.");
                    }

                    // Get byte[] from the file from embedded resource
                    resourceBytes = new byte[(int)stm.Length];
                    stm.Read(resourceBytes, 0, (int)stm.Length);
                }

                // Get the hash value from embedded DLL/assembly
                string fileHash = BitConverter.ToString(sha1.ComputeHash(resourceBytes)).Replace("-", string.Empty);

                // Define the temporary storage location of the DLL/assembly
                tempFile = Path.Combine(tempFolder, dllName);

                // Determines whether the DLL/assembly is existed or not
                if (File.Exists(tempFile))
                {
                    // Get the hash value of the existed file
                    byte[] bb        = File.ReadAllBytes(tempFile);
                    string fileHash2 = BitConverter.ToString(sha1.ComputeHash(bb)).Replace("-", string.Empty);

                    // Compare the existed DLL/assembly with the Embedded DLL/assembly
                    if (fileHash == fileHash2)
                    {
                        // Same file
                        return;
                    }
                }
            }

            if (compressed)
            {
                try
                {
                    Utils.GetByteArryFromZip(ref resourceBytes, out dllName);
                    containedDllName = dllName;
                }
                catch (Exception ex)
                {
                    Logging.Manager(string.Format("Exception at UnZip: {0} ({1})", dllName, ex.Message));
                    return;
                }
            }

            // See if the file exists, avoid rewriting it if not necessary
            string dllPath = Path.Combine(tempFolder, dllName);
            bool   rewrite = true;

            if (File.Exists(dllPath))
            {
                byte[] existing = File.ReadAllBytes(dllPath);
                if (resourceBytes.SequenceEqual(existing))
                {
                    rewrite = false;
                }
            }
            if (rewrite)
            {
                File.WriteAllBytes(dllPath, resourceBytes);
            }
            return;
        }
 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;
     }
 }