Exemple #1
0
        public static bool OnChildClick(UIBuildMenu __instance, int index)
        {
            if (!CustomKeyBindSystem.GetKeyBind("ReassignBuildBar").keyValue)
            {
                return(true);
            }
            if (buildMenu.currentCategory < 1 || buildMenu.currentCategory >= 9)
            {
                return(true);
            }

            int buildIndex = buildMenu.currentCategory * 100 + index;


            UIItemPickerExtension.Popup(pickerPos, proto =>
            {
                if (proto != null && proto.ID != 0)
                {
                    ConfigEntry <int> result = customBarBind.Bind("BuildBarBinds",
                                                                  buildIndex.ToString(),
                                                                  proto.ID,
                                                                  $"Item: {proto.Name.Translate()}");
                    result.Value = proto.ID;
                    UIBuildMenu.protos[buildMenu.currentCategory, index] = proto;
                    buildMenu.SetCurrentCategory(buildMenu.currentCategory);
                    VFAudio.Create("ui-click-0", null, Vector3.zero, true);
                }
            }, true, proto => proto.ModelIndex != 0 && proto.CanBuild);
            UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(2);
            return(false);
        }
Exemple #2
0
        public static void InitResetButton(UIBuildMenu __instance)
        {
            buildMenu = __instance;

            GameObject buttonPrefab = RebindBuildBarPlugin.resources.bundle.LoadAsset <GameObject>("Assets/RebindBuildBar/UI/buildmenu-button.prefab");
            GameObject buttonGo     = Object.Instantiate(buttonPrefab, __instance.childGroup.transform, false);

            ((RectTransform)buttonGo.transform).anchoredPosition = new Vector2(-300, 5);

            UIButton button = buttonGo.GetComponent <UIButton>();

            button.onClick += _ =>
            {
                bool   heldCtrl = CustomKeyBindSystem.GetKeyBind("ReassignBuildBar").keyValue;
                string msg      = (heldCtrl ? "ResetBuildMenuQuestion1" : "ResetBuildMenuQuestion2").Translate();

                UIMessageBox.Show("ResetBuildMenuQuestionTitle".Translate(), msg, "否".Translate(), "是".Translate(),
                                  UIMessageBox.QUESTION,
                                  null, () =>
                {
                    ResetBuildBarItems(heldCtrl);
                    buildMenu.SetCurrentCategory(buildMenu.currentCategory);
                    VFAudio.Create("ui-click-0", null, Vector3.zero, true);
                });
            };
        }
Exemple #3
0
 private static void RegisterKeyBinds()
 {
     CustomKeyBindSystem.RegisterKeyBind <PressKeyBind>(new BuiltinKey
     {
         id            = 212,
         key           = new CombineKey((int)KeyCode.BackQuote, CombineKey.ALT_COMB, ECombineKeyAction.OnceClick, false),
         conflictGroup = 2052,
         name          = "NebulaChatWindow",
         canOverride   = true
     });
     ProtoRegistry.RegisterString("KEYNebulaChatWindow", "Show or Hide Chat Window");
 }
        public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            CodeMatcher matcher = new CodeMatcher(instructions)
                                  .MatchForward(false,
                                                new CodeMatch(OpCodes.Ldc_I4_S, (sbyte)122),
                                                new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Input), nameof(Input.GetKeyDown), new [] { typeof(KeyCode) })))
                                  .RemoveInstruction()
                                  .SetInstruction(Transpilers.EmitDelegate <Func <bool> >(() =>
            {
                return(CustomKeyBindSystem.GetKeyBind("DSPTrashButton").keyValue);
            }));

            return(matcher.InstructionEnumeration());
        }
Exemple #5
0
        private void Awake()
        {
            logger = Logger;

            string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            resources = new ResourceData(MODNAME, "RebindBuildBar", pluginfolder);
            resources.LoadAssetBundle("rebindbarbundle");

            ProtoRegistry.RegisterString("ResetBuildMenuTipTitle", "Reset Build Bar item binding");
            ProtoRegistry.RegisterString("ResetBuildMenuTip",
                                         "Pressing this button will reset Build Bar items in current category to their defaults. Holding ctrl (Rebindable) resets all items in all categories.");

            ProtoRegistry.RegisterString("ResetBuildMenuQuestionTitle", "Are you sure?");
            ProtoRegistry.RegisterString("ResetBuildMenuQuestion1", "This action will reset all Build Bar items in build bar to their defaults");
            ProtoRegistry.RegisterString("ResetBuildMenuQuestion2", "This action will reset Build Bar items in current category to their defaults");

            ProtoRegistry.RegisterString("KEYReassignBuildBar", "Reassign Build Bar item");
            ProtoRegistry.RegisterString("KEYClearBuildBar", "Clear Build Bar item");

            ProtoRegistry.RegisterString("LockedTipText", "Locked");

            CustomKeyBindSystem.RegisterKeyBind <HoldKeyBind>(new BuiltinKey
            {
                id            = 150,
                key           = new CombineKey(0, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
                conflictGroup = KeyBindConflict.KEYBOARD_KEYBIND | KeyBindConflict.UI,
                name          = "ReassignBuildBar",
                canOverride   = true
            });

            CustomKeyBindSystem.RegisterKeyBind <PressKeyBind>(new BuiltinKey
            {
                id            = 151,
                key           = new CombineKey((int)KeyCode.Mouse2, 0, ECombineKeyAction.OnceClick, false),
                conflictGroup = KeyBindConflict.MOUSE_KEYBIND | KeyBindConflict.UI,
                name          = "ClearBuildBar",
                canOverride   = true
            });

            Harmony harmony = new Harmony(MODGUID);

            harmony.PatchAll(typeof(Patches));

            logger.LogInfo("Rebind Build Bar mod is loaded successfully!");
        }
        public static void OnPasteClickPrefix(UIBlueprintInspector __instance, out bool __state)
        {
            string systemCopyBuffer = GUIUtility.systemCopyBuffer;

            if (__instance.blueprint == null || string.IsNullOrEmpty(systemCopyBuffer))
            {
                __state = false;
                return;
            }

            __state   = CustomKeyBindSystem.GetKeyBind("ForceBPPlace").keyValue;
            shortDesc = __instance.blueprint.shortDesc;
            desc      = __instance.blueprint.desc;
            layout    = __instance.blueprint.layout;
            icon0     = __instance.blueprint.icon0;
            icon1     = __instance.blueprint.icon1;
            icon2     = __instance.blueprint.icon2;
            icon3     = __instance.blueprint.icon3;
            icon4     = __instance.blueprint.icon4;
        }
Exemple #7
0
        public static void Update()
        {
            if (buildMenu == null || !buildMenu.childGroup.gameObject.activeSelf)
            {
                return;
            }
            if (buildMenu.currentCategory < 1 || buildMenu.currentCategory >= 9)
            {
                return;
            }

            if (CustomKeyBindSystem.GetKeyBind("ClearBuildBar").keyValue)
            {
                for (int i = 1; i <= 10; i++)
                {
                    if (!buildMenu.childButtons[i].isPointerEnter)
                    {
                        continue;
                    }

                    int buildIndex = buildMenu.currentCategory * 100 + i;

                    ConfigEntry <int> result = customBarBind.Bind("BuildBarBinds",
                                                                  buildIndex.ToString(),
                                                                  0,
                                                                  "Cleared by player");
                    result.Value = 0;
                    UIBuildMenu.protos[buildMenu.currentCategory, i] = default;
                    buildMenu.SetCurrentCategory(buildMenu.currentCategory);
                    VFAudio.Create("ui-click-0", null, Vector3.zero, true);
                    return;
                }
            }

            if (!CustomKeyBindSystem.GetKeyBind("ReassignBuildBar").keyValue)
            {
                return;
            }

            for (int j = 1; j <= 10; j++)
            {
                if (Input.GetKeyDown(KeyCode.F1 + (j - 1)) && VFInput.inScreen && !VFInput.inputing)
                {
                    int buildIndex = buildMenu.currentCategory * 100 + j;

                    UIItemPickerExtension.Popup(pickerPos, proto =>
                    {
                        if (proto != null && proto.ID != 0)
                        {
                            ConfigEntry <int> result = customBarBind.Bind("BuildBarBinds",
                                                                          buildIndex.ToString(),
                                                                          proto.ID,
                                                                          $"Item: {proto.Name.Translate()}");
                            result.Value = proto.ID;
                            UIBuildMenu.protos[buildMenu.currentCategory, j] = proto;
                            buildMenu.SetCurrentCategory(buildMenu.currentCategory);
                            VFAudio.Create("ui-click-0", null, Vector3.zero, true);
                        }
                    }, true, proto => proto.ModelIndex != 0 && proto.CanBuild);
                    UIRoot.instance.uiGame.itemPicker.OnTypeButtonClick(2);
                    return;
                }
            }
        }
Exemple #8
0
        private void Update()
        {
            if (!GameMain.isRunning)
            {
                return;
            }
            if (GameMain.localPlanet == null)
            {
                return;
            }

            if (factoryUndo.Value)
            {
                if (CustomKeyBindSystem.GetKeyBind("FactoryUndo").keyValue)
                {
                    UndoManager.TryUndo();
                }

                if (CustomKeyBindSystem.GetKeyBind("FactoryRedo").keyValue)
                {
                    UndoManager.TryRedo();
                }
            }

            if (cameraToggleEnabled.Value && CustomKeyBindSystem.GetKeyBind("ToggleBPGodModeDesc").keyValue)
            {
                CameraFixPatch.mode = !CameraFixPatch.mode;
            }

            if (axisLockEnabled.Value && CustomKeyBindSystem.GetKeyBind("LockLongAxis").keyValue)
            {
                GridSnappingPatches.LockLongitude();
            }

            if (axisLockEnabled.Value && CustomKeyBindSystem.GetKeyBind("LockLatAxis").keyValue)
            {
                GridSnappingPatches.LockLatitude();
            }

            if (gridControlFeature.Value && CustomKeyBindSystem.GetKeyBind("SetLocalOffset").keyValue)
            {
                GridSnappingPatches.SetOffset();
            }

            if (forcePasteEnabled.Value)
            {
                BlueprintPastePatch.isEnabled = CustomKeyBindSystem.GetKeyBind("ForceBPPlace").keyValue;
            }

            if (blueprintMirroring.Value && CustomKeyBindSystem.GetKeyBind("MirrorLongAxis").keyValue)
            {
                BlueprintUtilsPatch2.mirrorLong = !BlueprintUtilsPatch2.mirrorLong;
                BlueprintUtilsPatch2.UpdateBlueprintDisplay();
            }

            if (blueprintMirroring.Value && CustomKeyBindSystem.GetKeyBind("MirrorLatAxis").keyValue)
            {
                BlueprintUtilsPatch2.mirrorLat = !BlueprintUtilsPatch2.mirrorLat;
                BlueprintUtilsPatch2.UpdateBlueprintDisplay();
            }
        }
Exemple #9
0
        private static void RegisterKeyBinds()
        {
            if (cameraToggleEnabled.Value)
            {
                CustomKeyBindSystem.RegisterKeyBind <PressKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.J, 0, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 3071,
                    name          = "ToggleBPGodModeDesc",
                    canOverride   = true
                });
            }

            if (forcePasteEnabled.Value)
            {
                CustomKeyBindSystem.RegisterKeyBind <HoldKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey(0, 1, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "ForceBPPlace",
                    canOverride   = true
                });
            }

            if (axisLockEnabled.Value)
            {
                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.G, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "LockLongAxis",
                    canOverride   = true
                });

                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.T, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "LockLatAxis",
                    canOverride   = true
                });
            }

            if (gridControlFeature.Value)
            {
                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.B, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "SetLocalOffset",
                    canOverride   = true
                });
            }

            if (blueprintMirroring.Value)
            {
                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.G, CombineKey.SHIFT_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "MirrorLongAxis",
                    canOverride   = true
                });

                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.T, CombineKey.SHIFT_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "MirrorLatAxis",
                    canOverride   = true
                });
            }

            if (factoryUndo.Value)
            {
                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.Z, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "FactoryUndo",
                    canOverride   = true
                });

                CustomKeyBindSystem.RegisterKeyBind <ReleaseKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.Z, CombineKey.SHIFT_COMB, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "FactoryRedo",
                    canOverride   = true
                });

                CustomKeyBindSystem.RegisterKeyBind <PressKeyBind>(new BuiltinKey
                {
                    key           = new CombineKey((int)KeyCode.Z, 0, ECombineKeyAction.OnceClick, false),
                    conflictGroup = 2052,
                    name          = "DSPTrashButton",
                    canOverride   = true
                });
            }
        }