private void GUIAssignKey(string buttonDesc, TimeControlKeyBinding kb)
        {
            const string logBlockName = nameof(KeyBindingsEditorIMGUI) + "." + nameof(KeyBindingsEditorIMGUI.GUIAssignKey);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                // Left Mouse Button, Assign Key
                if (Event.current.button == 0 && !currentlyAssigningKey)
                {
                    currentlyAssigningKey = true;
                    KeyboardInputManager.Instance.GetPressedKeyCombination((lkc) =>
                    {
                        const string logBlockName2 = nameof(KeyBindingsEditorIMGUI) + "." + nameof(KeyBindingsEditorIMGUI.GUIAssignKey) + " - " + nameof(KeyboardInputManager.Instance.GetPressedKeyCombination) + " Callback";
                        using (EntryExitLogger.EntryExitLog(logBlockName2, EntryExitLoggerOptions.All))
                        {
                            currentlyAssigningKey = false;
                            kb.KeyCombination     = new List <KeyCode>(lkc);
                            refreshKBCache        = true;
                            Log.Info("Key Combination " + kb.KeyCombinationDescription + " assigned to button " + buttonDesc, logBlockName2);

                            TimeControlEvents.OnTimeControlKeyBindingsChanged?.Fire(kb);
                        }
                    });
                }
                // Right Mouse Button, Clear Assigned Key
                else if (Event.current.button == 1 && !currentlyAssigningKey)
                {
                    kb.KeyCombination = new List <KeyCode>();
                    TimeControlEvents.OnTimeControlKeyBindingsChanged?.Fire(kb);
                }
            }
        }
示例#2
0
        public void DeleteKeyBinding(TimeControlKeyBinding kb)
        {
            if (activeKeyBinds.Contains(kb))
            {
                activeKeyBinds.Remove(kb);

                if (GlobalSettings.IsReady)
                {
                    GlobalSettings.Instance.SetActiveKeyBinds(activeKeyBinds);
                }
            }
        }
示例#3
0
        public void AddKeyBinding(TimeControlKeyBinding kb)
        {
            if (!activeKeyBinds.Contains(kb))
            {
                var l = activeKeyBinds.FindAll(tckb => tckb.TimeControlKeyActionName == kb.TimeControlKeyActionName && tckb.ID == kb.ID);
                if (l != null && l.Count > 0)
                {
                    kb.ID = l.Select(x => x.ID).Max() + 1;
                }
                activeKeyBinds.Add(kb);

                if (GlobalSettings.IsReady)
                {
                    GlobalSettings.Instance.SetActiveKeyBinds(activeKeyBinds);
                }
            }
        }
示例#4
0
        public KeyBindingsAddIMGUI(TimeControlKeyBinding kb)
        {
            this.kb = kb;

            if (kb is TimeControlKeyBindingValue tckbv)
            {
                usePercentage = (tckbv is SlowMoSetRate || tckbv is SlowMoSlowDown || tckbv is SlowMoSpeedUp);

                if (!usePercentage)
                {
                    sValue = sCurrentValue = tckbv.V.MemoizedToString();
                }
                else
                {
                    sValue = sCurrentValue = Mathf.RoundToInt(tckbv.V * 100.0f).MemoizedToString();
                }

                parseValue();
            }
        }