Beispiel #1
0
 public static void Postfix(ref float __result, GameInput.Button button)
 {
     if (!InputPatch.controlsEnabled)
     {
         __result = 0;
     }
 }
Beispiel #2
0
 public static void Postfix(ref bool __result, GameInput.Button button)
 {
     if (!InputPatch.controlsEnabled)
     {
         __result = true;
     }
 }
Beispiel #3
0
 public static void Postfix(ref GameInput.InputState __result, GameInput.Button button)
 {
     if (!InputPatch.controlsEnabled)
     {
         __result = new GameInput.InputState
         {
             flags    = GameInput.InputStateFlags.Up,
             timeDown = 0f
         };
     }
 }
        public static void ApplyAdditiveRotation(ref float additiveRotation, out float rotationFactor)
        {
            // Get the rotation factor from user options based on whether the fine snapping key is held or not
            rotationFactor = Config.FineRotation.Enabled ? Config.FineRotationRounding : Config.RotationRounding;

            // If the user is rotating, apply the additive rotation
            if (GameInput.GetButtonHeld(Builder.buttonRotateCW)) // Clockwise
            {
                if (LastButton != Builder.buttonRotateCW)
                {   // Clear previous rotation held time
                    LastButton         = Builder.buttonRotateCW;
                    LastButtonHeldTime = -1f;
                }

                float buttonHeldTime = FloorToNearest(GameInput.GetButtonHeldTime(Builder.buttonRotateCW), 0.15f);
                if (buttonHeldTime > LastButtonHeldTime)
                {                                        // Store rotation held time
                    LastButtonHeldTime = buttonHeldTime;
                    additiveRotation  -= rotationFactor; // Decrement rotation
                }
            }
            else if (GameInput.GetButtonHeld(Builder.buttonRotateCCW)) // Counter-clockwise
            {
                if (LastButton != Builder.buttonRotateCCW)
                {   // Clear previous rotation held time
                    LastButton         = Builder.buttonRotateCCW;
                    LastButtonHeldTime = -1f;
                }

                float buttonHeldTime = FloorToNearest(GameInput.GetButtonHeldTime(Builder.buttonRotateCCW), 0.15f);
                if (buttonHeldTime > LastButtonHeldTime)
                {                                        // Store rotation held time
                    LastButtonHeldTime = buttonHeldTime;
                    additiveRotation  += rotationFactor; // Increment rotation
                }
            }
            else if (GameInput.GetButtonUp(Builder.buttonRotateCW) || GameInput.GetButtonUp(Builder.buttonRotateCCW))
            {   // User is not rotating, clear rotation held time
                LastButtonHeldTime = -1f;
            }

            // Round to the nearest rotation factor for rotation snapping
            additiveRotation = RoundToNearest(additiveRotation, rotationFactor) % 360;
        }
Beispiel #5
0
        private static void Postfix(Exosuit __instance)
        {
            bool   hasPropCannon   = Exosuit_rightArm.GetValue(__instance) is ExosuitPropulsionArm || Exosuit_leftArm.GetValue(__instance) is ExosuitPropulsionArm;
            var    toggleLights    = __instance.GetComponent <ToggleLights>();
            string lightsString    = LanguageCache.GetButtonFormat((!toggleLights.lightsActive) ? "Lights On (<color=#ADF8FFFF>{0}</color>)" : "Lights Off (<color=#ADF8FFFF>{0}</color>)", lightsBinding);
            string exitString      = string.Join("\n", ((string)Exosuit_uiStringPrimary.GetValue(__instance)).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Take(1).ToArray());
            var    primaryString   = string.Join("\n", ((string)Exosuit_uiStringPrimary.GetValue(__instance)).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray()) + System.Environment.NewLine + lightsString;
            var    secondaryString = string.Empty;

            if (hasPropCannon)
            {
                lightsBinding   = GameInput.Button.Deconstruct;
                secondaryString = exitString;
            }
            else
            {
                lightsBinding = GameInput.Button.AltTool;
                primaryString = primaryString + System.Environment.NewLine + exitString;
            }
            HandReticle.main.SetUseTextRaw(primaryString, secondaryString);
        }
Beispiel #6
0
 private static void Postfix(uGUI_TabbedControlsPanel __instance, int tabIndex, string label, GameInput.Device device, GameInput.Button button)
 {
     if (button == GameInput.Button.Slot5 && device == GameInput.GetPrimaryDevice())
     {
         var qsc = __instance.gameObject.GetComponent <uGUI_QuickSlots_ConfigTab>();
         if (qsc != null)
         {
             qsc.SetControls();
         }
     }
 }
Beispiel #7
0
        static bool uGUI_BuilderMenu_OnButtonDown_Prefix(uGUI_BuilderMenu __instance, GameInput.Button button)
        {
            int dir = button switch
            {
                GameInput.Button.UIPrevTab => - 1,
                GameInput.Button.UINextTab => + 1,
                _ => 0
            };

            if (dir == 0)
            {
                return(true);
            }

            int nextTab = __instance.TabOpen;
            var list    = Main.config.lockedTabs.get(GameUtils.getHeldToolType());

            do
            {
                nextTab = (__instance.TabCount + nextTab + dir) % __instance.TabCount;
            }while (list.Contains(nextTab));

            __instance.SetCurrentTab(nextTab);
            return(false);
        }
    }
        public void TryBind(string input, bool cancel = false)
        {
            var assignedValue = Config.Instance.Slots[index.ToString()][(int)bindingSet];

            if (cancel && !string.IsNullOrEmpty(assignedValue))
            {
                string arg  = $"<color=#ADF8FFFF>{uGUI.GetDisplayTextForBinding(GameInput.GetInputName(input))}</color>";
                string text = string.Format(Language.main.Get("UnbindFormat"), arg, string.Format("<color=#ADF8FFFF>{0}</color>", Config.Instance.SlotLabels[index]));
                uGUI_QuickSlots_ConfigTab.optionsPanel.dialog.Show(text, delegate(int option)
                {
                    if (option == 1)
                    {
                        SetToConfig(null);
                    }
                }, Language.main.Get("No"), Language.main.Get("Yes"));
                return;
            }

            var listPool = Pool <ListPool <KeyValuePair <GameInput.Button, GameInput.BindingSet> > > .Get();

            var list = listPool.list;

            GameInput.Button sbnInput = GameInput.Button.None;
            Enum.TryParse <GameInput.Button>(input, true, out sbnInput);
            BindConflicts.GetConflicts(device, input, sbnInput, list);
            var    slotsConflicts = new Dictionary <int, string[]>();
            var    stringBuilder  = new StringBuilder();
            string value          = Language.main.Get("InputSeparator");

            for (int i = 0; i < list.Count; i++)
            {
                if (i > 0)
                {
                    stringBuilder.Append(value);
                }
                stringBuilder.AppendFormat("<color=#ADF8FFFF>{0}</color>", Language.main.Get("Option" + list[i].Key));
            }

            foreach (var slot in Config.Instance.Slots.Where(x => x.Key != index.ToString()).ToList())
            {
                var slIndex = 0;
                foreach (var slValue in slot.Value)
                {
                    if (slValue == input)
                    {
                        stringBuilder.Append(value);
                        stringBuilder.AppendFormat("<color=#ADF8FFFF>{0}</color>", Config.Instance.SlotLabels[int.Parse(slot.Key)]);
                        slotsConflicts.Add(int.Parse(slot.Key), slot.Value);
                    }
                    slIndex++;
                }
            }

            if (slotsConflicts.Count + list.Count > 0)
            {
                string arg2   = $"<color=#ADF8FFFF>{uGUI.GetDisplayTextForBinding(GameInput.GetInputName(input))}</color>";
                string format = Language.main.GetFormat("BindConflictFormat", arg2, stringBuilder, string.Format("<color=#ADF8FFFF>{0}</color>", Config.Instance.SlotLabels[index]));
                uGUI_QuickSlots_ConfigTab.optionsPanel.dialog.Show(format, delegate(int option)
                {
                    if (option == 1)
                    {
                        foreach (var sc in slotsConflicts)
                        {
                            if (sc.Value[0] == input)
                            {
                                Config.Instance.SlotBindings[sc.Key].primaryBinding.SetToConfig(string.Empty);
                            }
                            if (sc.Value[1] == input)
                            {
                                Config.Instance.SlotBindings[sc.Key].secondaryBinding.SetToConfig(string.Empty);
                            }
                        }
                        SetToConfig(input);
                    }
                }, Language.main.Get("No"), Language.main.Get("Yes"));
            }
            else
            {
                SetToConfig(input);
            }
        }
Beispiel #9
0
        private void SetInteractText(string text1, bool translate1, string text2 = "", bool translate2 = false, GameInput.Button hand = GameInput.Button.None)
        {
            HandReticle.main.SetText(HandReticle.TextType.Hand, text1, translate1);
            if (!String.IsNullOrEmpty(text2))
            {
                HandReticle.main.SetText(HandReticle.TextType.HandSubscript, text2, translate2);
            }
#endif
        }