示例#1
0
文件: DevUtils.cs 项目: THDigi/Helmet
        public static double GetValueScroll(string id, double initial, double step, MyKeys modifier = MyKeys.None, int roundDigits = 10, int notifyTime = 16)
        {
            if(!values.ContainsKey(id))
                values.Add(id, initial);

            var val = values[id];

            if(modifier != MyKeys.None && !MyAPIGateway.Input.IsKeyPress(modifier))
                return val;

            var scroll = MyAPIGateway.Input.DeltaMouseScrollWheelValue();

            if(scroll != 0)
            {
                val += (scroll > 0 ? step : -step);

                if(roundDigits > -1)
                    val = Math.Round(val, roundDigits);

                values[id] = val;
            }

            MyAPIGateway.Utilities.ShowNotification(id + "=" + val.ToString("#,###,###,##0.##########"), notifyTime);
            return val;
        }
 public MyGuiControlTextboxKeyToString(MyKeys key, string character, string characterWhenShift)
 {
     Key                = key;
     Character          = character;
     CharacterWhenShift = characterWhenShift;
     LastKeyPressTime   = MyGuiManager.FAREST_TIME_IN_PAST;
 }
示例#3
0
    IEnumerator Wait()
    {
        yield return(0);

        //初始化最高分数属性的关键字
        MyKeys.Top_Score_Key = MyKeys.MissionName.ToString();
        //为最高分赋值,属性内会自己判断分数是否更新
        MyKeys.Top_Score = MyKeys.Game_Score;
        //检测是否为导航关卡
        if (GuidanceBase.GuidanceMark == 0)
        {
            GuidanceBase.GuidanceMark = 1;
        }

        //通过关卡加一点体力
        TimeManager.ResetTime();
        //增加金币
        MyKeys.Gold_Value += MyKeys.Game_Score;
        //开始播放动效
        int stars = StartEffect();

        //增加钻石
        AddDiamond(stars);
        //保存过关最大星数
        MyKeys.PassStarsMax = stars;
        //保存此关卡通过状态
        MyKeys.PassMission = MyKeys.GetNameToInt(MyKeys.MissionName.ToString());
        //初始化属性
        Cut_Number = 0;
        //显示分数
        Score();
        UMManager.FinishMission(MyKeys.MissionName.ToString());
    }
        public ThrottledKeyStatus GetKeyStatus(MyKeys key)
        {
            if (!MyInput.Static.IsKeyPress(key))
                return ThrottledKeyStatus.UNPRESSED;

            var controller = GetKeyController(key);

            // If we find no controller, we cannot time so we assume the key is ready.
            if (controller == null)
                return ThrottledKeyStatus.PRESSED_AND_READY;

            // If the key was pressed during this update cycle, the key is deemed as instantly
            // ready, but it will be a longer delay before the next repeat is allowed.
            var wasPressedNow = MyInput.Static.IsNewKeyPressed(key);
            if (wasPressedNow)
            {
                controller.RequiredDelay = MyGuiConstants.TEXTBOX_INITIAL_THROTTLE_DELAY;
                controller.LastKeyPressTime = MyGuiManager.TotalTimeInMilliseconds;
                return ThrottledKeyStatus.PRESSED_AND_READY;
            }

            // If this is a continuous key press, we want to make sure we wait a minimum amount of time before allowing a repeat
            // of the action this key enables.
            if ((MyGuiManager.TotalTimeInMilliseconds - controller.LastKeyPressTime) > controller.RequiredDelay)
            {
                // Reset the required delay to the default for the next repeat.
                controller.RequiredDelay = MyGuiConstants.TEXTBOX_REPEAT_THROTTLE_DELAY;
                controller.LastKeyPressTime = MyGuiManager.TotalTimeInMilliseconds;
                return ThrottledKeyStatus.PRESSED_AND_READY;
            }

            // The key was pressed, but we're still waiting for the required delay.
            return ThrottledKeyStatus.PRESSED_AND_WAITING;
        }
示例#5
0
 public static void AppendName(ref StringBuilder output, MyKeys key)
 {
     EnsureExists(ref output);
     if (key != MyKeys.None)
     {
         output.Append(MyInput.Static.GetKeyName(key));
     }
 }
    private void OnEnemyDefeatedCheck(IGameEvent obj)
    {
        StandardSendGameEvent ssge = (StandardSendGameEvent)obj;

        if (MyKeys.VerificaEnemyShift((string)ssge.MyObject[0]))
        {
            Destroy((GameObject)ssge.MyObject[1]);
        }
    }
    private void OnIdDestroyCheck(IGameEvent e)
    {
        StandardSendGameEvent ssge = (StandardSendGameEvent)e;

        if (MyKeys.VerificaAutoShift((KeyShift)ssge.MyObject[0]))
        {
            Destroy((GameObject)ssge.MyObject[1]);
        }
    }
        private MyKeyThrottleState GetKeyController(MyKeys key)
        {
            MyKeyThrottleState controller;
            if (m_keyTimeControllers.TryGetValue(key, out controller))
                return controller;

            controller = new MyKeyThrottleState();
            m_keyTimeControllers[key] = controller;
            return controller;
        }
示例#9
0
        private void OnEquipAllKeySubmit(MyKeys key, bool shift, bool ctrl, bool alt)
        {
            if (!menuEnabled)
            {
                return;
            }

            EquipAllKey     = key;
            equipInput.Text = "Equip All Key - " + ToolSwitcherSession.GetKeyName(key);
            Save();
        }
示例#10
0
        private void OnDowngradeKeySubmit(MyKeys key, bool shift, bool ctrl, bool alt)
        {
            if (!menuEnabled)
            {
                return;
            }

            DowngradeKey        = key;
            downgradeInput.Text = "Downgrade Key - " + ToolSwitcherSession.GetKeyName(key);
            Save();
        }
示例#11
0
        public void SetControl(MyGuiInputDeviceEnum device, MyKeys key)
        {
            Debug.Assert(device == MyGuiInputDeviceEnum.Keyboard ||
                         device == MyGuiInputDeviceEnum.KeyboardSecond);

            if (device == MyGuiInputDeviceEnum.Keyboard)
                m_keyboardKey = key;
            else if (device == MyGuiInputDeviceEnum.KeyboardSecond)
                m_KeyboardKey2 = key;
            else
                MyLog.Default.WriteLine("ERROR: Setting non-keyboard device to keyboard control.");
        }
示例#12
0
 public MyControl(MyStringId controlId,
     MyStringId name,
     MyGuiControlTypeEnum controlType,
     MyMouseButtonsEnum? defaultControlMouse,
     MyKeys? defaultControlKey,
     MyStringId? helpText = null,
     MyKeys? defaultControlKey2 = null,
     MyStringId? description = null)
 {
     m_controlId = controlId;
     m_name = name;
     m_controlType = controlType;
     m_mouseButton = defaultControlMouse ?? MyMouseButtonsEnum.None;
     m_keyboardKey = defaultControlKey ?? MyKeys.None;
     m_KeyboardKey2 = defaultControlKey2 ?? MyKeys.None;
     m_data.Description = description;
 }
        /// <summary>
        /// Determines if the given key was pressed during this update cycle, but it also
        /// makes sure a minimum amount of time has passed before allowing a press.
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool IsNewPressAndThrottled(MyKeys key)
        {
            if (!MyInput.Static.IsNewKeyPressed(key))
                return false;

            var controller = GetKeyController(key);

            // If we find no controller, we cannot time so we assume the key is ready.
            if (controller == null)
                return true;

            // Make sure we wait a minimum amount of time before allowing a repeat of the action this key enables. This
            // version of the check overrides the currently configured required delay for the key on purpose.
            if ((MyGuiManager.TotalTimeInMilliseconds - controller.LastKeyPressTime) > MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)
            {
                // Reset the required delay to the default for the next repeat.
                controller.LastKeyPressTime = MyGuiManager.TotalTimeInMilliseconds;
                return true;
            }

            // The key was pressed but was choked by the minimum time requirement.
            return false;
        }
        //  Return true if new key pressed right now. Don't care if it was pressed in previous update too.
        public bool IsKeyPress(MyKeys key)
        {
#if UNSHARPER
            Debug.Assert(false, "Not keyboard support!");
#endif
            return false;
        }
 public string GetKeyName(MyKeys key)
 {
     return m_nameLookup.GetKeyName(key);
 }
 //  Return true if key was pressed in previous update and now it is not.
 bool ModAPI.IMyInput.IsNewKeyReleased(MyKeys key) { return IsNewKeyReleased(key); }
 //  Return true if new key pressed right now. Don't care if it was pressed in previous update too.
 bool ModAPI.IMyInput.IsKeyPress(MyKeys key) { return IsKeyPress(key); }
 //  Return true if key is used by some user control
 ModAPI.IMyControl ModAPI.IMyInput.GetControl(MyKeys key) { return GetControl(key); }
 //  Return true if key is valid for user controls
 bool ModAPI.IMyInput.IsKeyValid(MyKeys key) { return IsKeyValid(key); }
示例#20
0
 bool IMyInput.IsKeyDigit(MyKeys key) { return false; }
        //  Return true if key was pressed in previous update and now it is not.
        public bool IsNewKeyReleased(MyKeys key)
        {
#if UNSHARPER
            Debug.Assert(false, "Not keyboard support!");
#endif
            return false;
        }
示例#22
0
 bool IMyInput.IsKeyValid(MyKeys key) { return false; }
示例#23
0
 string IMyInput.GetKeyName(MyKeys key) { return ""; }
示例#24
0
 MyControl IMyInput.GetControl(MyKeys key) { return null; }
示例#25
0
 bool IMyInput.IsNewKeyPressed(MyKeys key) { return false; }
示例#26
0
 bool IMyInput.IsKeyPress(MyKeys key) { return false; }
示例#27
0
 public void SetKey(MyKeys key, bool value)
 {
     m_buffer.SetBit((byte)key, value);
 }
示例#28
0
 bool IMyInput.IsNewKeyReleased(MyKeys key) { return false; }
示例#29
0
 public bool IsKeyDown(MyKeys key)
 {
     return m_buffer.GetBit((byte)key);
 }
 bool ModAPI.IMyInput.IsKeyDigit(MyKeys key) { return IsKeyDigit(key); }
示例#31
0
 public bool IsKeyUp(MyKeys key)
 {
     return !IsKeyDown(key);
 }
 string ModAPI.IMyInput.GetKeyName(MyKeys key) { return GetKeyName(key); }
 public bool IsSkipCharacter(MyKeys character)
 {
     if (SkipCombinations != null)
         foreach (var skipCombination in SkipCombinations)
         {
             if (skipCombination.Alt == MyInput.Static.IsAnyAltKeyPressed() &&
                 skipCombination.Ctrl == MyInput.Static.IsAnyCtrlKeyPressed() &&
                 skipCombination.Shift == MyInput.Static.IsAnyShiftKeyPressed() &&
                 (skipCombination.Keys == null ||
                 skipCombination.Keys.Contains((MyKeys)character)))
             {
                 return true;
             }
         }
     return false;
 }
 //  Return true if new key was pressed, that means this key was pressed now. During previous Update it wasn't pressed at all.
 bool ModAPI.IMyInput.IsNewKeyPressed(MyKeys key) { return IsNewKeyPressed(key); }
 public bool IsKeyDigit(MyKeys key)
 {
     Debug.Assert(false, "Not keyboard support!");
     return false;
     
 }
            private void OverwriteAssignment(MyControl controlAlreadySet, MyKeys key)
            {
                Debug.Assert(controlAlreadySet != null);
                Debug.Assert(m_deviceType == MyGuiInputDeviceEnum.Keyboard ||
                             m_deviceType == MyGuiInputDeviceEnum.KeyboardSecond);
                Debug.Assert(controlAlreadySet.GetKeyboardControl() == key ||
                             controlAlreadySet.GetSecondKeyboardControl() == key);

                if (controlAlreadySet.GetKeyboardControl() == key)
                    controlAlreadySet.SetControl(MyGuiInputDeviceEnum.Keyboard, MyKeys.None);
                else
                    controlAlreadySet.SetControl(MyGuiInputDeviceEnum.KeyboardSecond, MyKeys.None);

                m_controlBeingSet.SetControl(m_deviceType, key);
            }
 //  Return true if key is used by some user control
 public MyControl GetControl(MyKeys key)
 {
     foreach (var item in m_gameControlsList.Values)
     {
         if (item.GetKeyboardControl() == key ||
             item.GetSecondKeyboardControl() == key) return item;
     }
     return null;
 }