Ejemplo n.º 1
0
        /*-----------------------------------------------------------------------------
        | Processes key releases for free-look style movement.
        |  -----------------------------------------------------------------------------*/

        public virtual void injectKeyUp(SIS.KeyEventArgs evt)
        {
            if (this.mStyle == CameraStyle.FreeLook)
            {
                if (evt.Key == SIS.KeyCode.Key_W || evt.Key == SIS.KeyCode.Key_UP)
                {
                    this.mGoingForward = false;
                }
                else if (evt.Key == SIS.KeyCode.Key_S || evt.Key == SIS.KeyCode.Key_DOWN)
                {
                    this.mGoingBack = false;
                }
                else if (evt.Key == SIS.KeyCode.Key_A || evt.Key == SIS.KeyCode.Key_LEFT)
                {
                    this.mGoingLeft = false;
                }
                else if (evt.Key == SIS.KeyCode.Key_D || evt.Key == SIS.KeyCode.Key_RIGHT)
                {
                    this.mGoingRight = false;
                }
                else if (evt.Key == SIS.KeyCode.Key_PGUP)
                {
                    this.mGoingUp = false;
                }
                else if (evt.Key == SIS.KeyCode.Key_PGDOWN)
                {
                    this.mGoingDown = false;
                }
            }
        }
Ejemplo n.º 2
0
 public virtual bool KeyReleased(SIS.KeyEventArgs evt)
 {
     if (CurrentSample != null && !this.IsSamplePaused)
     {
         return(CurrentSample.KeyReleased(evt));
     }
     return(true);
 }
Ejemplo n.º 3
0
        public override bool KeyPressed(SIS.KeyEventArgs evt)
        {
            switch (evt.Key)
            {
            case SIS.KeyCode.Key_S:
                // CTRL-S to save
                if (Keyboard.IsKeyDown(SIS.KeyCode.Key_LCONTROL) || Keyboard.IsKeyDown(SIS.KeyCode.Key_RCONTROL))
                {
                    SaveTerrains(true);
                }
                else
                {
                    return(base.KeyPressed(evt));
                }
                break;

            case SIS.KeyCode.Key_F10:
                //dump
                var tkey = 0;
                foreach (var ts in this.terrainGroup.TerrainSlots)
                {
                    if (ts.Instance != null && ts.Instance.IsLoaded)
                    {
                        ts.Instance.DumpTextures("terrain_" + tkey, ".png");
                    }

                    tkey++;
                }
                break;

            default:
                return(base.KeyPressed(evt));
            }

            return(true);
        }
Ejemplo n.º 4
0
 public virtual bool KeyReleased(SIS.KeyEventArgs evt)
 {
     return(true);
 }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="evt"></param>
        /// <returns></returns>
        public override bool KeyPressed(SIS.KeyEventArgs evt)
        {
            if (this.TrayManager.IsDialogVisible)
            {
                return(true);
            }

            switch (evt.Key)
            {
            case SIS.KeyCode.Key_ESCAPE:
                if (this.TitleLabel.TrayLocation != TrayLocation.None)
                {
                    if (CurrentSample != null)
                    {
                        if (IsSamplePaused)
                        {
                            this.TrayManager.HideAll();
                            UnpauseCurrentSample();
                        }
                        else
                        {
                            PauseCurrentSample();
                            this.TrayManager.ShowAll();
                        }
                    }
                }
                else
                {
                    OnButtonHit(this, (Button)this.TrayManager.GetWidget("Back"));
                }
                break;

            case SIS.KeyCode.Key_UP:
            case SIS.KeyCode.Key_DOWN:
            {
                //if ( evt.Key == SIS.KeyCode.Key_DOWN && TitleLabel.TrayLocation != TrayLocation.None )
                //{
                //    break;
                //}

                int newIndex = this.SampleMenu.SelectionIndex + (evt.Key == SIS.KeyCode.Key_UP ? -1 : 1);
                this.SampleMenu.SelectItem(Utility.Clamp <int>(newIndex, this.SampleMenu.ItemsCount - 1, 0));
            }
            break;

            case SIS.KeyCode.Key_RETURN:
                if (!(this.LoadedSamples.Count == 0) && (IsSamplePaused || CurrentSample == null))
                {
                    var newSample = (Sample)this.Thumbs[this.SampleMenu.SelectionIndex].UserData;
                    RunSample(newSample == CurrentSample ? null : newSample);
                }
                break;

            case SIS.KeyCode.Key_F9:     // toggle full screen
                Configuration.ConfigOption option = Root.RenderSystem.ConfigOptions["Video Mode"];
                string[] vals = option.Value.Split('x');
                int      w    = int.Parse(vals[0]);
#if !(XBOX || XBOX360)
                int h = int.Parse(vals[1].Remove(vals[1].IndexOf('@')));
#else
                int h = int.Parse(vals[1].Remove(vals[1].IndexOf('@'), 1));
#endif
                //RenderWindow.IsFullScreen = ...;
                break;

            case SIS.KeyCode.Key_R:
                if (CurrentSample != null)
                {
                    switch (RenderWindow.GetViewport(0).Camera.PolygonMode)
                    {
                    case PolygonMode.Points:
                        RenderWindow.GetViewport(0).Camera.PolygonMode = PolygonMode.Solid;
                        break;

                    case PolygonMode.Solid:
                        RenderWindow.GetViewport(0).Camera.PolygonMode = PolygonMode.Wireframe;
                        break;

                    case PolygonMode.Wireframe:
                        RenderWindow.GetViewport(0).Camera.PolygonMode = PolygonMode.Points;
                        break;
                    }
                }
                break;
            }
            try
            {
                return(base.KeyPressed(evt));
            }
            catch (Exception ex)
            {
                RunSample(null);
                string msg = ex.Message + "\nSource: " + ex.InnerException;
                LogManager.Instance.Write("[Samples] Error! " + msg);
                this.TrayManager.ShowOkDialog("Error!", msg);
            }
            return(true);
        }
Ejemplo n.º 6
0
        public override bool KeyReleased(SIS.KeyEventArgs evt)
        {
            this.CameraManager.injectKeyUp(evt);

            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="evt"></param>
        /// <returns></returns>
        public override bool KeyPressed(SIS.KeyEventArgs evt)
        {
            if (evt.Key == SIS.KeyCode.Key_H || evt.Key == SIS.KeyCode.Key_F1)               // toggle visibility of help dialog
            {
                if (!this.TrayManager.IsDialogVisible && Metadata["Help"] != "")
                {
                    this.TrayManager.ShowOkDialog("Help", Metadata["Help"]);
                }
                else
                {
                    this.TrayManager.CloseDialog();
                }
            }

            if (this.TrayManager.IsDialogVisible)
            {
                return(true);                // don't process any more keys if dialog is up
            }

            if (evt.Key == SIS.KeyCode.Key_F)               // toggle visibility of advanced frame stats
            {
                this.TrayManager.ToggleAdvancedFrameStats();
            }
            else if (evt.Key == SIS.KeyCode.Key_G)               // toggle visibility of even rarer debugging details
            {
                if (this.DetailsPanel.TrayLocation == TrayLocation.None)
                {
                    this.TrayManager.MoveWidgetToTray(this.DetailsPanel, TrayLocation.TopRight, 0);
                    this.DetailsPanel.Show();
                }
                else
                {
                    this.TrayManager.RemoveWidgetFromTray(this.DetailsPanel);
                    this.DetailsPanel.Hide();
                }
            }
            else if (evt.Key == SIS.KeyCode.Key_T)               // cycle polygon rendering mode
            {
                String           newVal;
                TextureFiltering tfo;
                int aniso;

                switch (this.DetailsPanel.GetParamValue(9)[0])
                {
                case 'B':
                    newVal = "Trilinear";
                    tfo    = TextureFiltering.Trilinear;
                    aniso  = 1;
                    break;

                case 'T':
                    newVal = "Anisotropic";
                    tfo    = TextureFiltering.Anisotropic;
                    aniso  = 8;
                    break;

                case 'A':
                    newVal = "None";
                    tfo    = TextureFiltering.None;
                    aniso  = 1;
                    break;

                default:
                    newVal = "Bilinear";
                    tfo    = TextureFiltering.Bilinear;
                    aniso  = 1;
                    break;
                }

                MaterialManager.Instance.SetDefaultTextureFiltering(tfo);
                MaterialManager.Instance.DefaultAnisotropy = aniso;
                this.DetailsPanel.SetParamValue(9, newVal);
            }
            else if (evt.Key == SIS.KeyCode.Key_R)               // cycle polygon rendering mode
            {
                String      newVal;
                PolygonMode pm;

                switch (this.Camera.PolygonMode)
                {
                case PolygonMode.Solid:
                    newVal = "Wireframe";
                    pm     = PolygonMode.Wireframe;
                    break;

                case PolygonMode.Wireframe:
                    newVal = "Points";
                    pm     = PolygonMode.Points;
                    break;

                default:
                    newVal = "Solid";
                    pm     = PolygonMode.Solid;
                    break;
                }

                this.Camera.PolygonMode = pm;
                this.DetailsPanel.SetParamValue(10, newVal);
            }
            else if (evt.Key == SIS.KeyCode.Key_F5)               // refresh all textures
            {
                TextureManager.Instance.ReloadAll();
            }
            else if (evt.Key == SIS.KeyCode.Key_F9)               // take a screenshot
            {
                Window.WriteContentsToTimestampedFile("screenshot", ".png");
            }

            this.CameraManager.injectKeyDown(evt);

            return(true);
        }