Example #1
0
        /// <summary>
        /// If the <see cref="customMirrorTextBox"/> has lost focus, we set its text as the new <see cref="currentMirror"/>.
        /// </summary>
        private void CustomMirrorTextBoxLostFocus(object sender, EventArgs e)
        {
            // Check first, if the text is a valid git repo
            Regex  gitURLRegex = new Regex("https://.*\\.git");
            string mirrorText  = customMirrorTextBox.Text;

            if (!gitURLRegex.IsMatch(mirrorText))
            {
                log.Info("User used " + mirrorText + " as a custom Mirror, didn't pass git validation test.");
                MessageBox.Show(this, HelperMethods.GetText(Text.InvalidGitURL, mirrorText), Text.ErrorWindowTitle, MessageBoxType.Error);
                return;
            }

            currentMirror = mirrorText;
            CrossPlatformOperations.WriteToConfig("CustomMirrorText", currentMirror);

            log.Info("Overwriting mirror in gitconfig.");

            // Check if the gitConfig exists, if yes regex the gitURL, and replace it with the new current Mirror.
            string gitConfigPath = CrossPlatformOperations.CURRENTPATH + "/PatchData/.git/config";

            if (!File.Exists(gitConfigPath))
            {
                return;
            }
            string gitConfig = File.ReadAllText(gitConfigPath);
            Match  match     = gitURLRegex.Match(gitConfig);

            gitConfig = gitConfig.Replace(match.Value, currentMirror);
            File.WriteAllText(gitConfigPath, gitConfig);

            log.Info("Custom Mirror has been set to " + currentMirror + ".");
        }
Example #2
0
        /// <summary>Gets called when user selects a different item from <see cref="mirrorDropDown"/>.
        /// It then writes that to the config, and if <see cref="updateState"/> is not <see cref="PlayButtonState.Downloading"/>
        /// it also overwrites the upstream URL in .git/config.</summary>
        private void MirrorDropDownSelectedIndexChanged(object sender, EventArgs e)
        {
            currentMirror = mirrorList[mirrorDropDown.SelectedIndex];

            log.Info("Current mirror has been set to " + currentMirror + ".");

            CrossPlatformOperations.WriteToConfig("MirrorIndex", mirrorDropDown.SelectedIndex);

            // Don't overwrite the git config while we download!!!
            if (updateState == PlayButtonState.Downloading)
            {
                return;
            }

            log.Info("Overwriting mirror in gitconfig.");

            // Check if the gitConfig exists, if yes regex the gitURL, and replace it with the new current Mirror.
            string gitConfigPath = CrossPlatformOperations.CURRENTPATH + "/PatchData/.git/config";

            if (!File.Exists(gitConfigPath))
            {
                return;
            }
            string gitConfig   = File.ReadAllText(gitConfigPath);
            Regex  gitURLRegex = new Regex("https://.*\\.git");
            Match  match       = gitURLRegex.Match(gitConfig);

            gitConfig = gitConfig.Replace(match.Value, currentMirror);
            File.WriteAllText(gitConfigPath, gitConfig);
        }
Example #3
0
        /// <summary>
        /// Gets called when user tries to close <see cref="MainForm"/>. This does a few things:<br/>
        /// 1) Writes the Width, Height, the check if <see cref="MainForm"/> is currently maximized and the ProfileIndex to the Config<br/>
        /// 2) Checks if current <see cref="updateState"/> is <see cref="PlayButtonState.Downloading"/>. If yes, it creates a Warning to the end user.
        /// </summary>
        private void MainformClosing(object sender, CancelEventArgs e)
        {
            log.Info("Attempting to close MainForm!");

            CrossPlatformOperations.WriteToConfig("Width", ClientSize.Width);
            CrossPlatformOperations.WriteToConfig("Height", ClientSize.Height);
            CrossPlatformOperations.WriteToConfig("IsMaximized", this.WindowState == WindowState.Maximized);
            CrossPlatformOperations.WriteToConfig("ProfileIndex", profileIndex.ToString());

            switch (updateState)
            {
            // If we're currently still downloading, ask first if user really wants to close and cancel the event if necessary
            case PlayButtonState.Downloading:
            {
                var result = MessageBox.Show(this, Text.CloseOnCloningText, Text.WarningWindowTitle, MessageBoxButtons.YesNo,
                                             MessageBoxType.Warning, MessageBoxDefaultButton.No);

                if (result == DialogResult.No)
                {
                    e.Cancel = true;
                }
                else
                {
                    isGitProcessGettingCancelled = true;
                }
                // We don't need to delete any folders here, the cancelled gitClone will do that automatically for us :)
                break;
            }

            // We can't close during installing, so we cancel the event.
            case PlayButtonState.Installing:
            {
                MessageBox.Show(this, Text.CloseOnInstallingText, Text.WarningWindowTitle, MessageBoxButtons.OK, MessageBoxType.Warning);
                e.Cancel = true;
                break;
            }
            }

            // This needs to be made invisible, otherwise a tray indicator will be visible (on linux?) that clicking crashes the application
            //TODO: this sounds like an eto bug. check if this can get reproduced.
            trayIndicator.Visible = false;

            if (e.Cancel)
            {
                log.Info("Cancelled MainForm closing event during UpdateState." + updateState + ".");
            }
            else
            {
                log.Info("Successfully closed MainForm. Exiting main thread.");
            }
        }
Example #4
0
        /// <summary>Gets called when <see cref="customMirrorCheck"/> gets clicked, displays a warning <see cref="MessageBox"/>
        /// and enables <see cref="customMirrorTextBox"/> accordingly.</summary>
        private void CustomMirrorCheckChanged(object sender, EventArgs e)
        {
            log.Info("Use Custom Mirror option has been set to " + customMirrorCheck.Checked + ".");
            CrossPlatformOperations.WriteToConfig("CustomMirrorEnabled", (bool)customMirrorCheck.Checked);

            EnableMirrorControlsAccordingly();

            // Create warning dialog when enabling
            if ((bool)customMirrorCheck.Checked)
            {
                MessageBox.Show(this, Text.WarningWindowText, Text.WarningWindowTitle, MessageBoxType.Warning);
                currentMirror = customMirrorTextBox.Text;
            }
            else
            {
                // Revert mirror to selected index in mirror dropdown
                currentMirror = mirrorList[mirrorDropDown.SelectedIndex];
            }
        }
Example #5
0
 /// <summary>
 /// If <see cref="customEnvVarTextBox"/> has lost focus, we write its text to the config.
 /// </summary>
 private void CustomEnvVarTextBoxLostFocus(object sender, EventArgs e)
 {
     log.Info("Custom Environment variables have been set to \"" + customEnvVarTextBox.Text + "\".");
     CrossPlatformOperations.WriteToConfig("CustomEnvVar", customEnvVarTextBox.Text);
 }
Example #6
0
 /// <summary>
 /// Gets called when <see cref="profileDebugLogCheck"/> gets clicked, and writes it's new value to the config.
 /// </summary>
 private void ProfileDebugLogCheckedChanged(object sender, EventArgs e)
 {
     log.Info("Create Game Debug Logs option has been set to " + profileDebugLogCheck.Checked + ".");
     CrossPlatformOperations.WriteToConfig("ProfileDebugLog", profileDebugLogCheck.Checked);
 }
Example #7
0
 /// <summary>Gets called when <see cref="hqMusicAndroidCheck"/> gets clicked and writes its new value to the config.</summary>
 private void HqMusicAndroidCheckChanged(object sender, EventArgs e)
 {
     log.Info("Android HQ Music option has been changed to " + hqMusicAndroidCheck.Checked);
     CrossPlatformOperations.WriteToConfig("MusicHQAndroid", hqMusicAndroidCheck.Checked);
 }
Example #8
0
 /// <summary>Gets called when <see cref="autoUpdateLauncherCheck"/> gets clicked and writes its new value to the config.</summary>
 private void AutoUpdateLauncherCheckChanged(object sender, EventArgs e)
 {
     log.Info("Auto Update Launcher has been set to " + autoUpdateAM2RCheck.Checked + ".");
     CrossPlatformOperations.WriteToConfig("AutoUpdateLauncher", (bool)autoUpdateAM2RCheck.Checked);
 }
Example #9
0
 /// <summary>Gets called when user selects a different item from <see cref="languageDropDown"/> and writes that to the config.</summary>
 private void LanguageDropDownSelectedIndexChanged(object sender, EventArgs e)
 {
     log.Info("languageDropDown.SelectedIndex has been changed to " + languageDropDown.SelectedIndex + ".");
     CrossPlatformOperations.WriteToConfig("Language", languageDropDown.SelectedIndex == 0 ? "Default" : languageDropDown.Items[languageDropDown.SelectedIndex].Text);
 }