コード例 #1
0
ファイル: MainForm.cs プロジェクト: haolink/GG2PlayerScale
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            FrmCurrentHeight frm = this._frmCurrentHeight;

            this._frmCurrentHeight = null;

            frm.MustNotClose = false;
            frm.Close();
            frm = null;

            this._threadEnd = true;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: haolink/GG2PlayerScale
        public MainForm(VRMode vrMode = VRMode.Any)
        {
            InitializeComponent();

            this._jsonIni      = new JSONINIFile();
            this._playerHeight = DEFAULT_HEIGHT;

            this._paused      = false;
            this._scalePaused = false;

            this.cbTargetTimeUnit.SelectedIndex = 0;

            string pHeight = this._jsonIni.Read("Height", null, "invalid");
            float  pHeightF;

            if (float.TryParse(pHeight, out pHeightF) && pHeightF > 100 && pHeightF < 250)
            {
                this._playerHeight = pHeightF;
            }

            MainForm.WriteTextboxThreadSafe(txtPlayerHeight, this._playerHeight.ToString(CultureInfo.InvariantCulture));
            this._jsonIni.Write("Height", this._playerHeight.ToString(CultureInfo.InvariantCulture));

            this._subtitleOffset = (float)(this._jsonIni.ReadFloat("SubtitleOffset", null, 30.0));
            if (this._subtitleOffset < -20 || this._subtitleOffset > 100)
            {
                this._subtitleOffset = 30.0f;
            }
            //this.txtSubtitleOffset.Text = this._subtitleOffset.ToString(CultureInfo.InvariantCulture);

            this.txtTargetScale.Text            = this._jsonIni.ReadFloat("ProcessSpeed", null, 0.5).ToString(CultureInfo.InvariantCulture);
            this.txtTargetTimeValue.Text        = this._jsonIni.ReadFloat("ProcessTime", null, 30).ToString(CultureInfo.InvariantCulture);
            this.cbTargetTimeUnit.SelectedIndex = this._jsonIni.ReadInt("ProcessTimeUnit", null, 0);
            this.chkEnableEndScale.Checked      = this._jsonIni.ReadBool("ProcessHasEndScale", null, false);
            this.txtEndScale.Text = this._jsonIni.ReadFloat("ProcessEndScale", null, 0.1).ToString(CultureInfo.InvariantCulture);

            this.chkResetScaleGradually.Checked = this._jsonIni.ReadBool("ResetGradually", null, true);
            this.chkResetWorldScale.Checked     = this._jsonIni.ReadBool("ResetWorldScale", null, true);

            this.chkEnableEndScale_CheckedChanged(null, new EventArgs());

            this.chkResetScaleGradually.CheckedChanged += SaveCheckImmediate;
            this.chkResetWorldScale.CheckedChanged     += SaveCheckImmediate;

            this._oculusWrapper = null;

            if (vrMode != VRMode.OpenVR)
            {
                try
                {
                    _oculusWrapper    = new OculusTouchWrapper();
                    this._vrAvailable = true;
                }
                catch (Exception ex)
                {
                    _oculusWrapper    = null;
                    this._vrAvailable = false;
                }
            }

            if (vrMode != VRMode.Oculus)
            {
                if (this._oculusWrapper == null)
                {
                    try
                    {
                        this._openVRWrapper = new OpenVRWrapper();
                        this._vrAvailable   = true;
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show("Err 3: " + ex.Message);
                        this._openVRWrapper = null;
                        this._vrAvailable   = false;
                    }
                }
            }

            if (this._vrAvailable)
            {
                if (this._openVRWrapper != null)
                {
                    this._vrWrapper = this._openVRWrapper;
                }
                else if (this._oculusWrapper != null)
                {
                    this._vrWrapper = this._oculusWrapper;
                }
            }

            if (this._oculusWrapper != null)
            {
                this.gbScaleReset.Text += " (Hold B or Y to activate)";
            }
            else if (this._openVRWrapper != null)
            {
                this.gbScaleReset.Text += " (Hold both grips at the same time to activate)";
            }

            this.chkResetWorldScale.Enabled     = this._vrAvailable;
            this.chkResetScaleGradually.Enabled = this._vrAvailable;

            this._frmCurrentHeight = new FrmCurrentHeight();


            this._scaleCalculator            = new ScaleOverTimeCalculator(this._frmCurrentHeight.lblMultiplicationTime);
            this._scaleCalculator.Completed += ScaleProgessCompleted;

            this._scaleResetManager = new ScaleOverTimeCalculator(null);

            _threadEnd        = false;
            _hasBeenCapturing = false;
            _playerScale      = 1.0f;
            _memEditor        = new MemEditor64("GalGun2-Win64-Shipping.exe");

            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

            try
            {
                this._patchManager = new AssemblyPatchManager();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }
        }