Beispiel #1
0
        //request a new job
        public void JobNew()
        {
            AutoSteerSettingsOutToPort();
            isJobStarted = true;
            startCounter = 0;

            btnManualOffOn.Enabled = true;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            btnSectionOffAutoOn.Enabled = true;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            btnABLine.Enabled    = true;
            btnABCurve.Enabled   = true;
            btnContour.Enabled   = true;
            btnAutoSteer.Enabled = true;
            ABLine.abHeading     = 0.00;

            btnRightYouTurn.Enabled = false;
            btnLeftYouTurn.Enabled  = false;
            btnFlag.Enabled         = true;

            LineUpManualBtns();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsCloseField;
        }
Beispiel #2
0
        //close the current job
        public void JobClose()
        {
            //turn manual button off
            manualBtnState       = btnStates.Off;
            btnManualOffOn.Image = Properties.Resources.ManualOff;

            //job is closed
            isJobStarted = false;

            //clear out the contour Lists
            ct.ResetContour();

            //clear the flags
            flagPts.Clear();
            btnFlag.Enabled = false;

            //reset the buttons
            btnABLine.Enabled    = false;
            btnContour.Enabled   = false;
            btnAutoSteer.Enabled = false;
            isAutoSteerBtnOn     = false;

            ct.isContourBtnOn = false;
            ct.isContourOn    = false;
            ct.ptList.Clear();


            cboxLastPass.Checked       = false;
            cboxLaserModeOnOff.Checked = false;


            //change images to reflect on off
            btnABLine.Image    = Properties.Resources.ABLineOff;
            btnContour.Image   = Properties.Resources.ContourOff;
            btnAutoSteer.Image = Properties.Resources.AutoSteerOff;

            //fix ManualOffOnAuto buttons
            btnManualOffOn.Enabled = false;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            //reset all the ABLine stuff
            ABLine.ResetABLine();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsStartNewField;

            //reset all Port Module values
            mc.ResetAllModuleCommValues();

            //by Pat
            ct.eleViewList.Clear();
            ct.mapList.Clear();
            ct.boundaryList.Clear();
            ct.usedPtList.Clear();
            pn.eastingOffset  = 0;
            pn.northingOffset = 0;
            pn.altitudeOffset = 0;
        }
Beispiel #3
0
        //close the current job
        public void JobClose()
        {
            //turn manual button off
            manualBtnState       = btnStates.Off;
            btnManualOffOn.Image = Properties.Resources.ManualOff;

            //job is closed
            isJobStarted = false;

            //clear out the contour Lists
            ct.ResetContour();

            //clear the flags
            flagPts.Clear();
            btnFlag.Enabled = false;

            //reset the buttons
            btnABLine.Enabled    = false;
            btnContour.Enabled   = false;
            btnAutoSteer.Enabled = false;
            isAutoSteerBtnOn     = false;

            ct.isContourBtnOn = false;
            ct.isContourOn    = false;
            ct.ptList.Clear();
            ct.drawList.Clear();
            lblCut.Text          = "*";
            lblFill.Text         = "*";
            lblCutFillRatio.Text = "*";
            lblDrawSlope.Text    = "*";

            cboxLastPass.Checked     = false;
            cboxRecLastOnOff.Checked = false;

            //change images to reflect on off
            btnABLine.Image    = Properties.Resources.ABLineOff;
            btnContour.Image   = Properties.Resources.ContourOff;
            btnAutoSteer.Image = Properties.Resources.AutoSteerOff;

            //fix ManualOffOnAuto buttons
            btnManualOffOn.Enabled = false;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            //reset all the ABLine stuff
            ABLine.ResetABLine();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsStartNewField;

            //reset all Port Module values
            mc.ResetAllModuleCommValues();
        }
Beispiel #4
0
        //request a new job
        public void JobNew()
        {
            //isGPSPositionInitialized = false;
            //offset = 0;
            AutoSteerSettingsOutToPort();
            isJobStarted = true;
            startCounter = 0;

            btnManualOffOn.Enabled = true;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            btnSectionOffAutoOn.Enabled = true;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            btnSection1Man.BackColor  = Color.Red;
            btnSection2Man.BackColor  = Color.Red;
            btnSection3Man.BackColor  = Color.Red;
            btnSection4Man.BackColor  = Color.Red;
            btnSection5Man.BackColor  = Color.Red;
            btnSection6Man.BackColor  = Color.Red;
            btnSection7Man.BackColor  = Color.Red;
            btnSection8Man.BackColor  = Color.Red;
            btnSection9Man.BackColor  = Color.Red;
            btnSection10Man.BackColor = Color.Red;
            btnSection11Man.BackColor = Color.Red;
            btnSection12Man.BackColor = Color.Red;

            btnABLine.Enabled    = true;
            btnContour.Enabled   = true;
            btnAutoSteer.Enabled = true;
            btnCurve.Enabled     = true;
            ABLine.abHeading     = 0.00;

            btnRightYouTurn.Enabled = false;
            btnLeftYouTurn.Enabled  = false;
            btnFlag.Enabled         = true;

            if (recPath.isRecordOn)
            {
                recPath.isRecordOn          = false;
                btnRecPathPauseRecord.Image = Properties.Resources.BoundaryRecord;
            }

            LineUpManualBtns();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsCloseField;
        }
Beispiel #5
0
        //request a new job
        public void JobNew()
        {
            AutoSteerSettingsOutToPort();
            isJobStarted = true;
            startCounter = 0;

            btnManualOffOn.Enabled = true;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            btnSectionOffAutoOn.Enabled = true;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            LineUpManualBtns();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsCloseField;
        }
Beispiel #6
0
        //close the current job
        public void JobClose()
        {
            //rate control buttons
            if (rcd.isRateControlOn)
            {
                btnDualRate.PerformClick();
            }

            rcd.ShutdownRateControl();  //double dam sure its off

            btnRateRightDn.Visible = false;
            btnRateRightUp.Visible = false;
            btnRateLeftDn.Visible  = false;
            btnRateLeftUp.Visible  = false;
            btnSelectRate1.Visible = false;
            btnSelectRate2.Visible = false;

            lblFlowRateRight.Visible          = false;
            lblRateAppliedActualRight.Visible = false;
            lblRateSetpointRight.Visible      = false;
            lblFlowRight.Visible = false;

            lblFlowRateLeft.Visible          = false;
            lblRateAppliedActualLeft.Visible = false;
            lblRateSetpointLeft.Visible      = false;
            lblFlowLeft.Visible = false;

            btnDualRate.Image = Properties.Resources.RateControlOff;
            btnDualRate.Text  = "Off";
            lblRateAppliedActualRight.Text = "-";
            lblRateAppliedActualLeft.Text  = "-";
            lblFlowRateLeft.Text           = "-";
            lblFlowRateRight.Text          = "-";

            //turn auto button off
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //turn section buttons all OFF and zero square meters
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                section[j].isAllowedOn = false;
                section[j].manBtnState = manBtn.On;
            }

            //turn manual button off
            manualBtnState       = btnStates.Off;
            btnManualOffOn.Image = Properties.Resources.ManualOff;

            //Update the button colors and text
            ManualAllBtnsUpdate();

            //enable disable manual buttons
            LineUpManualBtns();

            btnSection1Man.Enabled  = false;
            btnSection2Man.Enabled  = false;
            btnSection3Man.Enabled  = false;
            btnSection4Man.Enabled  = false;
            btnSection5Man.Enabled  = false;
            btnSection6Man.Enabled  = false;
            btnSection7Man.Enabled  = false;
            btnSection8Man.Enabled  = false;
            btnSection9Man.Enabled  = false;
            btnSection10Man.Enabled = false;
            btnSection11Man.Enabled = false;
            btnSection12Man.Enabled = false;

            btnSection1Man.BackColor  = Color.Silver;
            btnSection2Man.BackColor  = Color.Silver;
            btnSection3Man.BackColor  = Color.Silver;
            btnSection4Man.BackColor  = Color.Silver;
            btnSection5Man.BackColor  = Color.Silver;
            btnSection6Man.BackColor  = Color.Silver;
            btnSection7Man.BackColor  = Color.Silver;
            btnSection8Man.BackColor  = Color.Silver;
            btnSection9Man.BackColor  = Color.Silver;
            btnSection10Man.BackColor = Color.Silver;
            btnSection11Man.BackColor = Color.Silver;
            btnSection12Man.BackColor = Color.Silver;

            //job is closed
            isJobStarted = false;

            //clear the section lists
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                //clean out the lists
                section[j].patchList?.Clear();
                section[j].triangleList?.Clear();
            }

            //clear out the contour Lists
            ct.ResetContour();

            //clear the flags
            flagPts.Clear();
            btnFlag.Enabled = false;

            //reset the buttons
            btnABLine.Enabled          = false;
            btnContour.Enabled         = false;
            btnContourPriority.Enabled = false;
            btnAutoSteer.Enabled       = false;
            isAutoSteerBtnOn           = false;

            btnCurve.Enabled = false;
            curve.isCurveSet = false;

            ct.isContourBtnOn = false;
            ct.isContourOn    = false;

            //curve line
            btnCurve.Image = Properties.Resources.CurveOff;
            curve.ResetCurveLine();
            curve.isCurveBtnOn = false;
            btnCurve.Enabled   = false;

            //change images to reflect on off
            btnABLine.Image = Properties.Resources.ABLineOff;

            DisableYouTurnButtons();

            btnContour.Image   = Properties.Resources.ContourOff;
            btnAutoSteer.Image = Properties.Resources.AutoSteerOff;

            //fix ManualOffOnAuto buttons
            btnManualOffOn.Enabled = false;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            //fix auto button
            btnSectionOffAutoOn.Enabled = false;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //reset all the ABLine stuff
            ABLine.ResetABLine();

            //reset acre and distance counters
            totalSquareMeters = 0;

            //reset boundaries
            for (int i = 0; i < MAXBOUNDARIES; i++)
            {
                bndArr[i].ResetBoundary();
            }

            //reset headland
            for (int i = 0; i < FormGPS.MAXHEADS; i++)
            {
                hlArr[i].ResetHeadland();
            }

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsStartNewField;

            //turn off top level buttons
            btnRightYouTurn.Enabled = false;
            btnLeftYouTurn.Enabled  = false;

            //auto YouTurn shutdown
            yt.isYouTurnBtnOn = false;
            yt.ResetYouTurn();
            youTurnProgressBar = 0;

            //turn off youturn...
            btnEnableAutoYouTurn.Enabled = false;
            yt.isYouTurnBtnOn            = false;
            btnEnableAutoYouTurn.Image   = Properties.Resources.YouTurnNo;

            ////turn off path record
            recPath.recList.Clear();
            if (recPath.isRecordOn)
            {
                recPath.isRecordOn          = false;
                btnRecPathPauseRecord.Image = Properties.Resources.BoundaryRecord;
            }

            //reset all Port Module values
            mc.ResetAllModuleCommValues();

            //reset all Dew loop stuff
            yt.dew2Index = 0;
            yt.isDew2Set = false;
            yt.isDew4Set = false;
            yt.dew4Index = 0;
            yt.ResetYouTurn();
        }
Beispiel #7
0
        //close the current job
        public void JobClose()
        {
            //rate control buttons
            if (rc.isRateControlOn)
            {
                btnRate.PerformClick();
            }

            rc.ShutdownRateControl();  //double dam sure its off

            //turn auto button off
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //turn section buttons all OFF and zero square meters
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                section[j].isAllowedOn = false;
                section[j].manBtnState = manBtn.On;
            }

            //turn manual button off
            manualBtnState       = btnStates.Off;
            btnManualOffOn.Image = Properties.Resources.ManualOff;

            //Update the button colors and text
            ManualAllBtnsUpdate();

            //enable disable manual buttons
            LineUpManualBtns();

            btnSection1Man.Enabled = false;
            btnSection2Man.Enabled = false;
            btnSection3Man.Enabled = false;
            btnSection4Man.Enabled = false;
            btnSection5Man.Enabled = false;
            btnSection6Man.Enabled = false;
            btnSection7Man.Enabled = false;
            btnSection8Man.Enabled = false;

            //job is closed
            isJobStarted = false;

            //clear the section lists
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                //clean out the lists
                section[j].patchList?.Clear();
                section[j].triangleList?.Clear();
            }

            //clear out the contour Lists
            ct.ResetContour();

            //clear the flags
            flagPts.Clear();
            btnFlag.Enabled = false;

            //reset the buttons
            btnABLine.Enabled    = false;
            btnABCurve.Enabled   = true;
            btnContour.Enabled   = false;
            btnAutoSteer.Enabled = false;
            isAutoSteerBtnOn     = false;

            ct.isContourBtnOn = false;
            ct.isContourOn    = false;

            //change images to reflect on off
            btnABLine.Image         = Properties.Resources.ABLineOff;
            btnRightYouTurn.Visible = false;
            btnLeftYouTurn.Visible  = false;
            btnContour.Image        = Properties.Resources.ContourOff;
            btnAutoSteer.Image      = Properties.Resources.AutoSteerOff;

            //fix ManualOffOnAuto buttons
            btnManualOffOn.Enabled = false;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            //fix auto button
            btnSectionOffAutoOn.Enabled = false;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //reset all the ABLine stuff
            ABLine.ResetABLine();

            //reset acre and distance counters
            totalSquareMeters = 0;

            //reset boundary
            boundz.ResetBoundary();

            //reset headland
            hl.ResetHeadland();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsStartNewField;

            //turn off top level buttons
            btnRightYouTurn.Enabled = false;
            btnLeftYouTurn.Enabled  = false;

            //auto YouTurn shutdown
            yt.isYouTurnBtnOn = false;
            yt.ResetYouTurnAndSequenceEvents();
            youTurnProgressBar = 0;

            //turn off youturn...
            btnEnableAutoYouTurn.Enabled = false;
            yt.isYouTurnBtnOn            = false;
            btnEnableAutoYouTurn.Image   = Properties.Resources.YouTurnNo;

            //reset all Port Module values
            mc.ResetAllModuleCommValues();
        }
Beispiel #8
0
        //close the current job
        public void JobClose()
        {
            //rate control buttons
            //turn auto button off
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //turn section buttons all OFF and zero square meters
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                section[j].isAllowedOn = false;
                section[j].manBtnState = manBtn.On;
            }

            //turn manual button off
            manualBtnState       = btnStates.Off;
            btnManualOffOn.Image = Properties.Resources.ManualOff;

            //Update the button colors and text
            ManualAllBtnsUpdate();

            //enable disable manual buttons
            LineUpManualBtns();

            btnSection1Man.Enabled = false;
            btnSection2Man.Enabled = false;
            btnSection3Man.Enabled = false;
            btnSection4Man.Enabled = false;
            btnSection5Man.Enabled = false;
            btnSection6Man.Enabled = false;
            btnSection7Man.Enabled = false;
            btnSection8Man.Enabled = false;

            //job is closed
            isJobStarted = false;

            //clear the section lists
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                //clean out the lists
                section[j].patchList?.Clear();
                section[j].triangleList?.Clear();
            }

            //fix ManualOffOnAuto buttons
            btnManualOffOn.Enabled = false;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            //fix auto button
            btnSectionOffAutoOn.Enabled = false;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //reset acre and distance counters
            totalSquareMeters = 0;

            //reset boundary
            boundz.ResetBoundary();

            //update the menu
            fieldToolStripMenuItem.Text = gStr.gsStartNewField;

            //clear out the rec path list
            recPath.recList.Clear();

            //reset all Port Module values
            mc.ResetAllModuleCommValues();
        }
Beispiel #9
0
        //close the current job
        public void JobClose()
        {
            //turn auto button off
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //turn section buttons all OFF and zero square meters
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                section[j].isAllowedOn = false;
                section[j].manBtnState = manBtn.On;
            }

            //turn manual button off
            manualBtnState       = btnStates.Off;
            btnManualOffOn.Image = Properties.Resources.ManualOff;

            //Update the button colors and text
            ManualAllBtnsUpdate();

            //enable disable manual buttons
            LineUpManualBtns();

            btnSection1Man.Enabled = false;
            btnSection2Man.Enabled = false;
            btnSection3Man.Enabled = false;
            btnSection4Man.Enabled = false;
            btnSection5Man.Enabled = false;
            btnSection6Man.Enabled = false;
            btnSection7Man.Enabled = false;
            btnSection8Man.Enabled = false;

            //job is closed
            isJobStarted = false;

            //clear the section lists
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                //clean out the lists
                section[j].patchList.Clear();
                section[j].triangleList?.Clear();
            }

            //clear out the contour Lists
            ct.ResetContour();

            //clear the flags
            flagPts.Clear();
            btnFlag.Enabled = false;

            //reset the buttons
            btnABLine.Enabled    = false;
            btnContour.Enabled   = false;
            btnAutoSteer.Enabled = false;
            btnSnap.Enabled      = false;

            btnAutoYouTurn.Enabled  = false;
            btnRightYouTurn.Enabled = false;
            btnLeftYouTurn.Enabled  = false;

            ct.isContourBtnOn = false;
            ct.isContourOn    = false;

            //change images to reflect on off
            btnABLine.Image         = Properties.Resources.ABLineOff;
            btnRightYouTurn.Visible = false;
            btnLeftYouTurn.Visible  = false;
            btnContour.Image        = Properties.Resources.ContourOff;
            btnAutoSteer.Image      = Properties.Resources.AutoSteerOff;

            //fix ManualOffOnAuto buttons
            btnManualOffOn.Enabled = false;
            manualBtnState         = btnStates.Off;
            btnManualOffOn.Image   = Properties.Resources.ManualOff;

            //fix auto button
            btnSectionOffAutoOn.Enabled = false;
            autoBtnState = btnStates.Off;
            btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

            //reset all the ABLine stuff
            ABLine.ResetABLine();

            //reset acre and distance counters
            totalSquareMeters = 0;

            //reset boundary
            boundary.ResetBoundary();

            //update the menu
            fieldToolStripMenuItem.Text = "Start Field";

            //rate control buttons
            btnRate1Select.Visible = false;
            btnRate2Select.Visible = false;
            btnRate.Image          = Properties.Resources.RateControlOff;
            rc.ShutdownRateControl();

            //auto YouTurn shutdown
            yt.isAutoYouTurnEnabled = false;
            yt.CancelYouTurn();
            autoTurnInProgressBar = 0;
            btnAutoYouTurn.Text   = "Off";

            //reset all Port Module values
            mc.ResetAllModuleCommValues();
        }
Beispiel #10
0
        public Button(btnTypes type, Game1 game, int x, int y)
        {
            switch (type)
            {
            case btnTypes.Exit:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnExit");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2((x / 4) * 3, y - 50);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;

            case btnTypes.Highscores:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnHighscores");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2((x / 4) * 2, y - 50);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;

            case btnTypes.Play:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnPlay");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2((x / 4), y - 50);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;

            case btnTypes.Pause:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnPause");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2(Global.vpwidth - this.tButton.Width / 2, this.tButton.Height);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = false;
                break;

            case btnTypes.Idioma:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnES");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2(Global.vpwidth - this.tButton.Width / 2, Global.vpheight);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;

            case btnTypes.Inst:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnInst");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;

            case btnTypes.Sounds:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnSoundsPlay");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2(Global.vpwidth - this.tButton.Width / 2 - Global.botones[3].tButton.Width - 5, this.tButton.Height + 5);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;

            case btnTypes.Music:
                this.type     = type;
                this.tButton  = game.Content.Load <Texture2D>("Imagenes/btnMusicPlay");
                this.scale    = 1.0f;
                this.state    = btnStates.None;
                this.position = new Vector2(Global.vpwidth - (this.tButton.Width * 1.5f) - Global.botones[3].tButton.Width - 15, this.tButton.Height + 5);
                this.origin   = new Vector2(this.tButton.Width / 2, this.tButton.Height);
                this.present  = true;
                break;
            }
        }
Beispiel #11
0
        public void Update(MouseState ms, Game1 game, SpriteBatch sb, GraphicsDevice gd)
        {
            Rectangle btnRec = new Rectangle((int)this.position.X - ((int)this.tButton.Width / 2),
                                             (int)this.position.Y - (int)this.tButton.Height,
                                             (int)this.tButton.Width,
                                             (int)this.tButton.Height);
            Rectangle msRec = new Rectangle(ms.X, ms.Y, 1, 1);

            if (btnRec.Intersects(msRec))
            {
                if (ms.LeftButton == ButtonState.Pressed)
                {
                    if (!Global.soundmute)
                    {
                        Global.SEInstances[8].Play();
                    }
                    else
                    {
                        Global.SEInstances[8].Stop();
                    }
                    this.state = btnStates.Pressed;
                    switch (this.type) //Ejecuta el codigo adecaudo del boton que se apreto
                    {
                    case btnTypes.Play:
                        Global.ClearForPlay(sb, game, gd, true);
                        Global.gameState          = Global.GameState.Jugando;
                        Global.botones[0].present = false;     //Salir
                        Global.botones[1].present = false;     //Highscores
                        Global.botones[2].present = false;     //Jugar
                        Global.botones[3].present = true;      //Pausa
                        Global.botones[4].present = false;     //Idioma
                        Global.botones[5].present = false;     //Instrucciones
                        Global.flyers.Clear();
                        break;

                    case btnTypes.Exit:
                        Global.botones[0].present = false;     //Salir
                        Global.botones[1].present = false;     //Highscores
                        Global.botones[2].present = false;     //Jugar
                        Global.botones[3].present = false;     //Pausa
                        Global.botones[4].present = false;     //Idioma
                        Global.botones[5].present = false;     //Instrucciones
                        game.Exit();
                        break;

                    case btnTypes.Highscores:
                        Global.botones[0].present = true;     //Salir
                        Global.botones[1].present = false;    //Highscores
                        Global.botones[2].present = true;     //Jugar
                        Global.botones[3].present = false;    //Pausa
                        Global.botones[4].present = false;    //Idioma
                        Global.botones[5].present = true;     //Instrucciones
                        Global.gameState          = Global.GameState.Highscores;
                        //CONECTAR DB
                        OleDbConnection  cn;
                        OleDbDataAdapter DA;
                        DataSet          DS;
                        OleDbCommand     cmd;
                        cn = new OleDbConnection();
                        cn.ConnectionString = "Provider = 'Microsoft.ACE.OLEDB.12.0';Data Source = 'Highscores.accdb'";
                        cn.Open();
                        //GUARDAR 3 mayores en array de strings
                        cmd = new OleDbCommand("SELECT TOP 3 * FROM Highscores ORDER by Puntajes DESC", cn);
                        DA  = new OleDbDataAdapter(cmd);
                        DS  = new DataSet();
                        DA.Fill(DS, "Highscores");
                        int i = 0;
                        foreach (DataRow row in DS.Tables["Highscores"].Rows)
                        {
                            try
                            {
                                // Posible MEGA ERROR
                                // Original: Global.hs[i] = row[0].ToString(); (este era en ves del row [2])
                                Global.hs[i] = row[2].ToString();
                                i++;
                                Global.hs[i] = row[1].ToString();
                                i++;
                            }
                            catch (IndexOutOfRangeException nre)
                            {
                                Console.WriteLine("Error IndexOutOfRangeException... Microsoft must (but won't) fix this");
                            }
                        }
                        //DESCONECTAR DB
                        cn.Close();
                        break;

                    case btnTypes.Pause:
                        Global.botones[0].present = false;              //Salir
                        Global.botones[1].present = false;              //Highscores
                        Global.botones[2].present = false;              //Jugar
                        Global.botones[3].present = true;               //Pausa
                        Global.botones[4].present = false;              //Idioma
                        Global.botones[5].present = false;              //Instrucciones
                        if (Global.gameState == Global.GameState.Pausa) //Se mueve para que no sea apretado multiples veces
                        {
                            Global.botones[3].position = new Vector2(Global.vpwidth - this.tButton.Width / 2, this.tButton.Height);
                            Global.gameState           = Global.GameState.Jugando;
                        }
                        else
                        {
                            Global.botones[3].position = new Vector2(Global.vpwidth / 2, Global.vpheight / 2);
                            Global.gameState           = Global.GameState.Pausa;
                        }
                        break;

                    case btnTypes.Idioma:
                        if (Global.idioma)
                        {
                            this.position             = new Vector2(Global.vpwidth - this.tButton.Width / 2, Global.vpheight);
                            Global.botones[4].tButton = game.Content.Load <Texture2D>("Imagenes/btnEN");
                            Global.idioma             = false;
                            Global.reload             = true;
                        }
                        else
                        {
                            this.position             = new Vector2(Global.vpwidth - (this.tButton.Width / 2) * 3, Global.vpheight);
                            Global.botones[4].tButton = game.Content.Load <Texture2D>("Imagenes/btnES");
                            Global.idioma             = true;
                            Global.reload             = true;
                        }
                        break;

                    case btnTypes.Inst:
                        Global.ClearForPlay(sb, game, gd, false);
                        Game1.finished            = false;
                        Game1.tutorialStage       = 0;
                        Global.botones[0].present = true;     //Salir
                        Global.botones[1].present = true;     //Highscores
                        Global.botones[2].present = true;     //Jugar
                        Global.botones[3].present = false;    //Pausa
                        Global.botones[4].present = true;     //Idioma
                        Global.botones[5].present = false;    //Instrucciones
                        Global.gameState          = Global.GameState.Instrucciones;
                        Global.flyers.Clear();
                        break;

                    case btnTypes.Music:
                        if (Global.musicmute)
                        {
                            Global.musicmute = false;
                            this.tButton     = game.Content.Load <Texture2D>("Imagenes/btnMusicPlay");
                        }
                        else
                        {
                            Global.musicmute = true;
                            this.tButton     = game.Content.Load <Texture2D>("Imagenes/btnMusicMute");
                        }
                        break;

                    case btnTypes.Sounds:
                        if (!Global.soundmute)
                        {
                            Global.soundmute = false;
                            this.tButton     = game.Content.Load <Texture2D>("Imagenes/btnSoundsPlay");
                        }
                        else
                        {
                            Global.soundmute = true;
                            this.tButton     = game.Content.Load <Texture2D>("Imagenes/btnSoundsMute");
                        }
                        break;
                    }
                }
                else
                {
                    this.state = btnStates.Hover;
                }
            }
            else
            {
                this.state = btnStates.None;
            }
            switch (this.state)
            {
            case btnStates.None:
                this.scale = 1.0f;
                break;

            case btnStates.Hover:
                this.scale = 1.10f;
                break;

            case btnStates.Pressed:
                this.scale = 0.90f;
                break;
            }
        }