Beispiel #1
0
        private void Render(Timer timer)
        {
            m_Console.Canvas.Clear();

            m_Console.Canvas.DrawLine(new Pixel('O', EColor.White, EColor.Black), m_Console.Canvas.Width / 2, 0, m_Input.Mouse.X, m_Input.Mouse.Y);
            m_Console.Canvas.DrawEllipse(new Pixel('o', EColor.White, EColor.Black), m_Input.Mouse.X, m_Input.Mouse.Y, 8, 4);
            m_Console.Canvas.Plot(new Pixel('@', EColor.DarkBlue, EColor.DarkGray), m_Input.Mouse.X, m_Input.Mouse.Y);

            double averageFPS = Math.Round(timer.AverageFPS);
            double fps        = Math.Round(timer.FPS);

            m_Console.Canvas.SetColor(EColor.White, EColor.Black);
            m_Console.Canvas.DrawText("FPS: " + fps + ", Average FPS: " + averageFPS + ", Mouse(" + m_Input.Mouse.X + ", " + m_Input.Mouse.Y + ", " + m_Input.Mouse.Scroll + ")", 0, 0);

            int offy = 1;

            if (m_Input.Keyboard.AnyKeyPressed)
            {
                EButtonState[] states = m_Input.Keyboard.GetKeys();
                for (int x = 0; x < states.Length; ++x)
                {
                    EButtonState state = states[x];
                    if (state != EButtonState.Released)
                    {
                        string name;
                        if (x >= 8)
                        {
                            name = ((ConsoleKey)x).ToString();
                        }
                        else
                        {
                            name = ((EInputModifier)x).ToString();
                        }
                        m_Console.Canvas.DrawText(string.Format("{0} [{1}]", name, state), 0, offy);
                        ++offy;
                    }
                }
            }

            if (m_Input.Mouse.AnyKeyPressed)
            {
                EButtonState[] states = m_Input.Mouse.GetKeys();
                for (int x = 0; x < states.Length; ++x)
                {
                    EButtonState state = states[x];
                    if (state != EButtonState.Released)
                    {
                        m_Console.Canvas.DrawText(string.Format("{0} [{1}]", ((EMouseButton)x).ToString(), state), 0, offy);
                        ++offy;
                    }
                }
            }

            m_Console.Render();
        }
Beispiel #2
0
 public static EButtonState GetNextState(this EButtonState current, bool isPressed)
 {
     if (isPressed)
     {
         if (current == EButtonState.Released)
         {
             return(EButtonState.JustPressed);
         }
         return(EButtonState.Pressed);
     }
     else if (current == EButtonState.Pressed)
     {
         return(EButtonState.JustReleased);
     }
     return(EButtonState.Released);
 }
Beispiel #3
0
 public static string GetRussianString(this EButtonState state)
 {
     if (state == EButtonState.Open)
     {
         return("Загрузить EXE");
     }
     else if (state == EButtonState.Start)
     {
         return("Старт");
     }
     else if (state == EButtonState.Stop)
     {
         return("Стоп");
     }
     else
     {
         return("<Ошибка>");
     }
 }
Beispiel #4
0
        public bool GetButton(IVRInputDevice device, List <EButtonType> buttonTypes, EButtonState state)
        {
            foreach (var eButtonType in buttonTypes)
            {
                switch (eButtonType)
                {
                case EButtonType.MiddleMouse:
                case EButtonType.LeftMouse:
                case EButtonType.RightMouse:
                    var mouseNumber = GetMouseNumber(eButtonType);
                    if (UnityEngine.Input.GetMouseButtonDown(mouseNumber) && state == EButtonState.Down)
                    {
                        return(true);
                    }
                    if (UnityEngine.Input.GetMouseButton(mouseNumber) && state == EButtonState.Pressed)
                    {
                        return(true);
                    }
                    if (UnityEngine.Input.GetMouseButtonUp(mouseNumber) && state == EButtonState.Up)
                    {
                        return(true);
                    }
                    break;

                default:
                    if (state == EButtonState.Down && device.GetButtonDown(ToVRButton(eButtonType)))
                    {
                        return(true);
                    }
                    if (state == EButtonState.Pressed && device.GetButton(ToVRButton(eButtonType)))
                    {
                        return(true);
                    }
                    if (state == EButtonState.Up && device.GetButtonUp(ToVRButton(eButtonType)))
                    {
                        return(true);
                    }
                    break;
                }
            }

            return(false);
        }
Beispiel #5
0
        protected virtual void OnUpdateState()
        {
            m_IsActive      = false;
            m_AnyKeyPressed = false;

            int length = m_KeyStates.Length;

            for (int codeValue = 0; codeValue < length; ++codeValue)
            {
                if (m_ValidKeys == null || m_ValidKeys[codeValue])
                {
                    bool         isPressed = IsPressed(codeValue);
                    EButtonState oldState  = m_KeyStates[codeValue];
                    EButtonState newState  = oldState.GetNextState(isPressed);
                    m_KeyStates[codeValue] = newState;

                    m_IsActive = m_IsActive || isPressed;
                }
            }
            m_AnyKeyPressed = m_IsActive;
        }
Beispiel #6
0
 public void Clear()
 {
     State = EButtonState.Up;
 }
Beispiel #7
0
 public ButtonState(EButton id)
 {
     _id   = id;
     State = EButtonState.Up;
 }
Beispiel #8
0
 public static bool IsUp(this EButtonState state)
 {
     return(state == EButtonState.Released || state == EButtonState.JustReleased);
 }
Beispiel #9
0
 public static bool IsDown(this EButtonState state)
 {
     return(state == EButtonState.Pressed || state == EButtonState.JustPressed);
 }