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 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); }); }; }
public static void _OnOpen(UIFunctionPanel __instance) { if (!blueprintPanelInit) { UIBuildMenu menu = __instance.buildMenu; Transform mainTrs = menu.gameObject.transform.Find("main-group"); if (mainTrs == null) { return; } GameObject buttonPrefab = MultiBuildUI.bundle.LoadAsset <GameObject>("assets/blueprints/ui/button.prefab"); GameObject button = Object.Instantiate(buttonPrefab, Vector3.zero, Quaternion.identity, mainTrs); button.transform.localPosition = new Vector3(260, 0, 0); menu.categoryButtons[10].transform.localPosition += new Vector3(52, 0, 0); menu.mainCanvas.transform.localPosition += new Vector3(-26, 0, 0); Button blueprintButton = button.GetComponent <Button>(); GameObject prefab = MultiBuildUI.bundle.LoadAsset <GameObject>("assets/blueprints/ui/blueprint-group.prefab"); GameObject group = Object.Instantiate(prefab, menu.transform, false); blueprintGroup = group.GetComponent <UIBlueprintGroup>(); blueprintGroup.Init(menu, button.GetComponent <UIButton>()); blueprintGroup._Close(); blueprintGroup.InfoText.GetComponent <RectTransform>().offsetMin = new Vector2(3f, -66f); blueprintGroup.InfoText.resizeTextForBestFit = true; blueprintGroup.InfoText.resizeTextMinSize = 10; blueprintGroup.InfoText.resizeTextMaxSize = 14; blueprintGroup.infoTitle.text = "Stored blueprint"; blueprintGroup.InfoText.text = "None"; blueprintButton.onClick.AddListener(() => { if (blueprintGroup.isOpen) { menu.SetCurrentCategory(0); } else { blueprintGroup._Open(); } }); blueprintPanelInit = true; } }
public void _Open() { isOpen = true; menu.SetCurrentCategory(12); menu.childGroup.gameObject.SetActive(true); foreach (UIButton child in menu.childButtons) { if (child == null) { continue; } child.gameObject.SetActive(false); } button.highlighted = true; mainGroup.interactable = true; mainGroup.blocksRaycasts = true; }