Example #1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     try
     {
         if (!emuInit)
         {
             emuInit = Dolphin.Init();
         }
         if (emuInit && !gameInit)
         {
             gameInit = Dolphin.GameInit();
         }
         if (emuInit && gameInit && !formInit)
         {
             Dolphin.InitMP();
             Dolphin.InitTracker(this);
             formInit = true;
             bW.RunWorkerAsync();
             this.timer1.Stop();
         }
     }
     catch
     {
         emuInit  = false;
         gameInit = false;
         formInit = false;
         FormUtils.Close();
     }
 }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadSettings();
            try
            {
                this.comboBox1.SelectedIndex = 0;
                this.comboBox1.Update();
                this.comboBox2.SelectedIndex = 0;
                this.comboBox2.Update();
                this.comboBox3.SelectedIndex = 0;
                this.comboBox3.Update();
                GCSettings.LatencyMode = GCLatencyMode.LowLatency;
                var Worker = new BackgroundWorker();
                Worker.DoWork += (s, ev) =>
                {
                    emuInit = Dolphin.Init();
                    if (emuInit)
                    {
                        gameInit = Dolphin.GameInit();
                        if (gameInit)
                        {
                            detectVersion = Dolphin.InitMP();
                        }
                    }

                    while (!this.Exiting)
                    {
                        try
                        {
                            if (emuInit && gameInit && detectVersion)
                            {
                                if (Dolphin.GameCode == "")
                                {
                                    throw new Exception();
                                }

                                if (Dolphin.MetroidPrime.Health == 0)
                                {
                                    Thread.Sleep(1);
                                    continue;
                                }
                                this.label5.SetTextSafely(Dolphin.MetroidPrime.IGTAsStr);
                                if (WasInSaveStation != Dolphin.MetroidPrime.IsInSaveStationRoom && Dolphin.MetroidPrime.IsInSaveStationRoom)
                                {
                                    Dolphin.MetroidPrime.Health = Dolphin.MetroidPrime.MaxHealth;
                                }
                                WasInSaveStation = Dolphin.MetroidPrime.IsInSaveStationRoom;
                                this.label1.SetTextSafely("Missiles : " + Dolphin.MetroidPrime.Missiles + " / " + Dolphin.MetroidPrime.MaxMissiles);
                                this.label2.SetTextSafely("Morph Ball Bombs : " + Dolphin.MetroidPrime.MorphBallBombs + " / " + Dolphin.MetroidPrime.MaxMorphBallBombs);
                                this.label3.SetTextSafely("Power Bombs : " + Dolphin.MetroidPrime.PowerBombs + " / " + Dolphin.MetroidPrime.MaxPowerBombs);
                                this.label4.SetTextSafely("HP : " + Dolphin.MetroidPrime.Health + " / " + Dolphin.MetroidPrime.MaxHealth + (Dolphin.MetroidPrime.Health < 30 ? " /!\\" : ""));
                                if (!EditingInventory)
                                {
                                    this.morphBallChkBox.SetChecked(Dolphin.MetroidPrime.HaveMorphBall);
                                    this.scanVisorChkBox.SetChecked(Dolphin.MetroidPrime.HaveScanVisor);
                                    this.thermalVisorChkBox.SetChecked(Dolphin.MetroidPrime.HaveThermalVisor);
                                    this.xrayVisorChkBox.SetChecked(Dolphin.MetroidPrime.HaveXRayVisor);
                                    this.morphBallBombsChkBox.SetChecked(Dolphin.MetroidPrime.HaveMorphBallBombs);
                                    this.missileLauncherChkBox.SetChecked(Dolphin.MetroidPrime.MaxMissiles > 0);
                                    this.superMissileChkBox.SetChecked(Dolphin.MetroidPrime.HaveSuperMissile);
                                    this.plasmaBeamChkBox.SetChecked(Dolphin.MetroidPrime.HavePlasmaBeam);
                                    this.iceBeamChkBox.SetChecked(Dolphin.MetroidPrime.HaveIceBeam);
                                    this.waveBeamChkBox.SetChecked(Dolphin.MetroidPrime.HaveWaveBeam);
                                    this.chargeBeamChkBox.SetChecked(Dolphin.MetroidPrime.HaveChargeBeam);
                                    this.grappleBeamChkBox.SetChecked(Dolphin.MetroidPrime.HaveGrappleBeam);
                                    this.spiderBallChkBox.SetChecked(Dolphin.MetroidPrime.HaveSpiderBall);
                                    this.boostBallChkBox.SetChecked(Dolphin.MetroidPrime.HaveBoostBall);
                                    this.powerBombsChkBox.SetChecked(Dolphin.MetroidPrime.MaxPowerBombs > 0);
                                    this.variaSuitChkBox.SetChecked(Dolphin.MetroidPrime.HaveVariaSuit);
                                    this.gravitySuitChkBox.SetChecked(Dolphin.MetroidPrime.HaveGravitySuit);
                                    this.phazonSuitChkBox.SetChecked(Dolphin.MetroidPrime.HavePhazonSuit);
                                    this.wavebusterChkBox.SetChecked(Dolphin.MetroidPrime.HaveWavebuster);
                                    this.iceSpreaderChkBox.SetChecked(Dolphin.MetroidPrime.HaveIceSpreader);
                                    this.flamethrowerChkBox.SetChecked(Dolphin.MetroidPrime.HaveFlamethrower);
                                    this.spaceJumpBootsChkBox.SetChecked(Dolphin.MetroidPrime.HaveSpaceJumpBoots);
                                }
                                for (int i = 0; i < 12; i++)
                                {
                                    ((Label)this.groupBox3.Controls["lblArtifact_" + (i + 1)]).SetTextSafely(this.groupBox3.Controls["lblArtifact_" + (i + 1)].Text.Split(':')[0] + ": " + (Dolphin.MetroidPrime.Artifacts(i) ? OBTAINED : UNOBTAINED));
                                }
                                HandleRefillMissiles(comboBox1.GetSelectedIndex());
                                if (comboBox2.GetText() == "Instant Refill")
                                {
                                    Dolphin.MetroidPrime.MorphBallBombs = Dolphin.MetroidPrime.MaxMorphBallBombs;
                                }
                                HandleRefillPowerBombs(comboBox3.GetSelectedIndex());
                            }
                            else
                            {
                                if (!this.Exiting)
                                {
                                    new Thread(() => MessageBox.Show("Either Dolphin or the game is not running!\r\nExiting...")).Start();
                                    SafeClose();
                                    this.Exiting = true;
                                }
                            }
                        }
                        catch
                        {
                            if (!this.Exiting)
                            {
                                new Thread(() => MessageBox.Show("Either Dolphin or the game is not running!\r\nExiting...")).Start();
                                SafeClose();
                                this.Exiting = true;
                            }
                        }
                        Thread.Sleep(100);
                    }
                };
                Worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }