Beispiel #1
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);
                });
            };
        }
Beispiel #2
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);
        }
        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());
        }
        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;
        }
Beispiel #5
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;
                }
            }
        }
Beispiel #6
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();
            }
        }