private void MakerAPI_RegisterCustomSubCategories(object sender, RegisterSubCategoriesEvent e) { #if AI || HS2 var window = MakerAPI.AddAccessoryWindowControl(new MakerButton("Material Editor", null, this)); window.GroupingID = "Buttons"; window.OnClick.AddListener(UpdateUIAccessory); e.AddControl(new MakerButton("Material Editor (Body)", MakerConstants.Body.All, this)).OnClick.AddListener(() => UpdateUICharacter("body")); e.AddControl(new MakerButton("Material Editor (Head)", MakerConstants.Body.All, this)).OnClick.AddListener(() => UpdateUICharacter("head")); e.AddControl(new MakerButton("Material Editor (All)", MakerConstants.Body.All, this)).OnClick.AddListener(() => UpdateUICharacter()); MakerCategory hairCategory = new MakerCategory(MakerConstants.Hair.CategoryName, "ME", 0, "Material Editor"); e.AddControl(new MakerButton("Material Editor (Back)", hairCategory, this)).OnClick.AddListener(() => UpdateUIHair(0)); e.AddControl(new MakerButton("Material Editor (Front)", hairCategory, this)).OnClick.AddListener(() => UpdateUIHair(1)); e.AddControl(new MakerButton("Material Editor (Side)", hairCategory, this)).OnClick.AddListener(() => UpdateUIHair(2)); e.AddControl(new MakerButton("Material Editor (Extension)", hairCategory, this)).OnClick.AddListener(() => UpdateUIHair(3)); e.AddSubCategory(hairCategory); MakerCategory clothesCategory = new MakerCategory(MakerConstants.Clothes.CategoryName, "ME", 0, "Material Editor"); e.AddControl(new MakerButton("Material Editor (Top)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(0)); e.AddControl(new MakerButton("Material Editor (Bottom)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(1)); e.AddControl(new MakerButton("Material Editor (Bra)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(2)); e.AddControl(new MakerButton("Material Editor (Underwear)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(3)); e.AddControl(new MakerButton("Material Editor (Gloves)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(4)); e.AddControl(new MakerButton("Material Editor (Pantyhose)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(5)); e.AddControl(new MakerButton("Material Editor (Socks)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(6)); e.AddControl(new MakerButton("Material Editor (Shoes)", clothesCategory, this)).OnClick.AddListener(() => UpdateUIClothes(7)); e.AddSubCategory(clothesCategory); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Mouth, this)).OnClick.AddListener(() => UpdateUICharacter("tang,tooth")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eyes, this)).OnClick.AddListener(() => UpdateUICharacter("eyebase,eyeshadow")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.HL, this)).OnClick.AddListener(() => UpdateUICharacter("eyebase,eyeshadow")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eyelashes, this)).OnClick.AddListener(() => UpdateUICharacter("eyelashes")); #endif }
private void MakerAPI_MakerBaseLoaded(object s, RegisterCustomControlsEvent e) { InitUI(); #if AI var ButtonAllLocation = MakerConstants.Body.All; #else var ButtonAllLocation = MakerConstants.Face.All; #endif MakerAPI.AddAccessoryWindowControl(new MakerButton("Open Material Editor", null, this)).OnClick.AddListener(delegate { PopulateListAccessory(); }); e.AddControl(new MakerButton("Open Material Editor (Body)", ButtonAllLocation, this)).OnClick.AddListener(delegate { PopulateListBody(); }); e.AddControl(new MakerButton("Open Material Editor (Face)", ButtonAllLocation, this)).OnClick.AddListener(delegate { PopulateListFace(); }); e.AddControl(new MakerButton("Open Material Editor (All)", ButtonAllLocation, this)).OnClick.AddListener(delegate { PopulateListCharacter(); }); #if !AI e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Top, this)).OnClick.AddListener(delegate { PopulateListClothes(0); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Bottom, this)).OnClick.AddListener(delegate { PopulateListClothes(1); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Bra, this)).OnClick.AddListener(delegate { PopulateListClothes(2); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Shorts, this)).OnClick.AddListener(delegate { PopulateListClothes(3); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Gloves, this)).OnClick.AddListener(delegate { PopulateListClothes(4); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Panst, this)).OnClick.AddListener(delegate { PopulateListClothes(5); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Socks, this)).OnClick.AddListener(delegate { PopulateListClothes(6); }); #if KK e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.InnerShoes, this)).OnClick.AddListener(delegate { PopulateListClothes(7); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.OuterShoes, this)).OnClick.AddListener(delegate { PopulateListClothes(8); }); #else e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Shoes, this)).OnClick.AddListener(delegate { PopulateListClothes(7); }); #endif e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Back, this)).OnClick.AddListener(delegate { PopulateListHair(0); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Front, this)).OnClick.AddListener(delegate { PopulateListHair(1); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Side, this)).OnClick.AddListener(delegate { PopulateListHair(2); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Extension, this)).OnClick.AddListener(delegate { PopulateListHair(3); }); #endif }
// Do Work on Entering/Leaving Maker public void SetupMakerControls(object sender, RegisterCustomControlsEvent eventData) { CharacterAccessoryControlWrapper = MakerAPI.AddEditableAccessoryWindowControl <MakerToggle, bool>(new MakerToggle(new MakerCategory("Accessory", ""), "Character Accessory", this)); AutoMatchHairColorWrapper = MakerAPI.AddEditableAccessoryWindowControl <MakerToggle, bool>(new MakerToggle(new MakerCategory("Accessory", ""), "Match Hair Color on Coord Load", this)); MakerAPI.AddAccessoryWindowControl(new MakerButton("Visibility Rules", null, this)).OnClick.AddListener(VisibilityRulesListener); AccessoriesApi.SelectedMakerAccSlotChanged += UpdateUI; AccessoriesApi.SelectedMakerAccSlotChanged += RefreshAdvancedParents; MakerAPI.ReloadCustomInterface += ReloadCustomInterface; MakerAPI.AddAccessoryWindowControl(new MakerButton("Show", null, this)).OnClick.AddListener(ShowAccessory); MakerAPI.AddAccessoryWindowControl(new MakerButton("Hide", null, this)).OnClick.AddListener(HideAccessory); advancedParentLabel = new MakerText("Adv Parent: None", null, this); MakerAPI.AddAccessoryWindowControl(advancedParentLabel); MakerAPI.AddAccessoryWindowControl(new MakerButton("Advanced Parent", null, this)).OnClick.AddListener(AdvancedParent); if (ShowSlotSettingResyncButton.Value) { MakerAPI.AddAccessoryWindowControl(new MakerButton("Clear and Resync Slot", null, this)).OnClick.AddListener(ClearAndResyncSlot); } CoordinateRulesToggle = MakerAPI.AddSidebarControl(new SidebarToggle("Coordinate Visibility Rules", false, this)); CoordinateRulesToggle.ValueChanged.Subscribe(b => { ShowCoordinateRulesGUI(b); }); MakerControlsRegistered = true; }
private void MakerAPI_MakerBaseLoaded(object s, RegisterCustomControlsEvent e) { InitUI(); #if KK || EC MakerAPI.AddAccessoryWindowControl(new MakerButton("Open Material Editor", null, this)).OnClick.AddListener(delegate { PopulateListAccessory(); }); e.AddControl(new MakerButton("Open Material Editor (Body)", MakerConstants.Face.All, this)).OnClick.AddListener(delegate { PopulateListCharacter("body"); }); e.AddControl(new MakerButton("Open Material Editor (Face)", MakerConstants.Face.All, this)).OnClick.AddListener(delegate { PopulateListCharacter("face"); }); e.AddControl(new MakerButton("Open Material Editor (All)", MakerConstants.Face.All, this)).OnClick.AddListener(delegate { PopulateListCharacter(); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Top, this)).OnClick.AddListener(delegate { PopulateListClothes(0); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Bottom, this)).OnClick.AddListener(delegate { PopulateListClothes(1); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Bra, this)).OnClick.AddListener(delegate { PopulateListClothes(2); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Shorts, this)).OnClick.AddListener(delegate { PopulateListClothes(3); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Gloves, this)).OnClick.AddListener(delegate { PopulateListClothes(4); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Panst, this)).OnClick.AddListener(delegate { PopulateListClothes(5); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Socks, this)).OnClick.AddListener(delegate { PopulateListClothes(6); }); #if KK e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.InnerShoes, this)).OnClick.AddListener(delegate { PopulateListClothes(7); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.OuterShoes, this)).OnClick.AddListener(delegate { PopulateListClothes(8); }); #else e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Clothes.Shoes, this)).OnClick.AddListener(delegate { PopulateListClothes(7); }); #endif e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Back, this)).OnClick.AddListener(delegate { PopulateListHair(0); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Front, this)).OnClick.AddListener(delegate { PopulateListHair(1); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Side, this)).OnClick.AddListener(delegate { PopulateListHair(2); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Hair.Extension, this)).OnClick.AddListener(delegate { PopulateListHair(3); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Face.Eyebrow, this)).OnClick.AddListener(delegate { PopulateListCharacter("mayuge"); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Face.Eye, this)).OnClick.AddListener(delegate { PopulateListCharacter("eyeline,hitomi"); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Face.Nose, this)).OnClick.AddListener(delegate { PopulateListCharacter("nose"); }); e.AddControl(new MakerButton("Open Material Editor", MakerConstants.Face.Mouth, this)).OnClick.AddListener(delegate { PopulateListCharacter("tang,tooth,canine"); }); #endif }
internal static void RegisterControls() { _cfgCharaMakerPreview.SettingChanged += (sender, args) => { if (JetPack.CharaMaker.Loaded) { if (_sidebarTogglePreview.Value != _cfgCharaMakerPreview.Value) { _sidebarTogglePreview.Value = _cfgCharaMakerPreview.Value; } if (_sidebarTogglePreview.Value) { _pluginCtrl.RefreshPreview("ToggleForcePreview"); } /* * else * { * _pluginCtrl.SetAccessoryStateCategory(0, _imgTglCol01.isOn); * _pluginCtrl.SetAccessoryStateCategory(1, _imgTglCol02.isOn); * } */ } }; AccessoriesApi.AccessoryTransferred += (_sender, _args) => _pluginCtrl.AccessoryTransferredHandler(_args.SourceSlotIndex, _args.DestinationSlotIndex); AccessoriesApi.AccessoriesCopied += (_sender, _args) => _pluginCtrl.AccessoriesCopiedHandler((int)_args.CopySource, (int)_args.CopyDestination, _args.CopiedSlotIndexes.ToList()); MakerAPI.RegisterCustomSubCategories += (_sender, _args) => { _makerLoadToggle = _args.AddLoadToggle(new MakerLoadToggle("AccStateSync")); _makerCoordinateLoadToggle = _args.AddCoordinateLoadToggle(new MakerCoordinateLoadToggle("AccStateSync")); _charaConfigWindow = _instance.gameObject.AddComponent <AccStateSyncUI>(); _sidebarTogglePreview = _args.AddSidebarControl(new SidebarToggle("A.S.S. Preview", _cfgCharaMakerPreview.Value, _instance)); _sidebarTogglePreview.ValueChanged.Subscribe(_value => { if (_cfgCharaMakerPreview.Value != _value) { _cfgCharaMakerPreview.Value = _value; } }); _accWinCtrlEnable = MakerAPI.AddAccessoryWindowControl(new MakerButton("AccStateSync", null, _instance)); _accWinCtrlEnable.OnClick.AddListener(() => _charaConfigWindow.enabled = true); }; MakerAPI.MakerFinishedLoading += (_sender, _args) => { PatchMakerToggles(); if (MoreAccessories._installed) { _accMenuTree = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/04_AccessoryTop/Slots/Viewport/Content").transform; } else { _accMenuTree = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/04_AccessoryTop").transform; } MoreAccessories.HarmonyPatch(); }; MakerAPI.MakerExiting += (_sender, _args) => { Destroy(_charaConfigWindow); MoreAccessories.HarmonyUnpatch(); _sidebarTogglePreview = null; _makerLoadToggle = null; _makerCoordinateLoadToggle = null; _accWinCtrlEnable = null; _imgTglCol01 = null; _imgTglCol02 = null; }; JetPack.CharaMaker.OnCvsNavMenuClick += (_sender, _args) => { if (_args.TopIndex == 4) { if (_args.SideToggle?.GetComponentInChildren <CvsAccessory>(true) == null) { _chaCtrl.StartCoroutine(_pluginCtrl.AccSlotChangedHandlerCoroutine()); _charaConfigWindow._onAccTab = false; _pluginCtrl._curPartsInfo = null; _pluginCtrl._cachedSlotPropertyList.Clear(); return; } int _slotIndex = (int)_args.SideToggle.GetComponentInChildren <CvsAccessory>(true)?.slotNo; _chaCtrl.StartCoroutine(_pluginCtrl.AccSlotChangedHandlerCoroutine()); _charaConfigWindow._onAccTab = true; } else { _chaCtrl.StartCoroutine(_pluginCtrl.AccSlotChangedHandlerCoroutine()); _charaConfigWindow._onAccTab = false; } }; JetPack.CharaMaker.OnAccessoryTypeChanged += (_sender, _args) => { _pluginCtrl.AccessoryTypeChanged(_args); }; }
private void MakerAPI_MakerBaseLoaded(object s, RegisterCustomControlsEvent e) { InitUI(); #if KK || EC var window = MakerAPI.AddAccessoryWindowControl(new MakerButton("Material Editor", null, this)); window.GroupingID = "Buttons"; window.OnClick.AddListener(UpdateUIAccessory); e.AddControl(new MakerButton("Material Editor", MakerConstants.Body.All, this)).OnClick.AddListener(() => UpdateUICharacter("body")); e.AddControl(new MakerButton("Material Editor (Body)", MakerConstants.Face.All, this)).OnClick.AddListener(() => UpdateUICharacter("body")); e.AddControl(new MakerButton("Material Editor (Face)", MakerConstants.Face.All, this)).OnClick.AddListener(() => UpdateUICharacter("face")); e.AddControl(new MakerButton("Material Editor (All)", MakerConstants.Face.All, this)).OnClick.AddListener(() => UpdateUICharacter()); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Top, this)).OnClick.AddListener(() => UpdateUIClothes(0)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Bottom, this)).OnClick.AddListener(() => UpdateUIClothes(1)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Bra, this)).OnClick.AddListener(() => UpdateUIClothes(2)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Shorts, this)).OnClick.AddListener(() => UpdateUIClothes(3)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Gloves, this)).OnClick.AddListener(() => UpdateUIClothes(4)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Panst, this)).OnClick.AddListener(() => UpdateUIClothes(5)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Socks, this)).OnClick.AddListener(() => UpdateUIClothes(6)); #if KK e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.InnerShoes, this)).OnClick.AddListener(() => UpdateUIClothes(7)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.OuterShoes, this)).OnClick.AddListener(() => UpdateUIClothes(8)); #else e.AddControl(new MakerButton("Material Editor", MakerConstants.Clothes.Shoes, this)).OnClick.AddListener(() => UpdateUIClothes(7)); #endif e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Back, this)).OnClick.AddListener(() => UpdateUIHair(0)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Front, this)).OnClick.AddListener(() => UpdateUIHair(1)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Side, this)).OnClick.AddListener(() => UpdateUIHair(2)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Extension, this)).OnClick.AddListener(() => UpdateUIHair(3)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eyebrow, this)).OnClick.AddListener(() => UpdateUICharacter("mayuge")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eye, this)).OnClick.AddListener(() => UpdateUICharacter("eyeline,hitomi")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Nose, this)).OnClick.AddListener(() => UpdateUICharacter("nose")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Mouth, this)).OnClick.AddListener(() => UpdateUICharacter("tang,tooth,canine")); #endif #if PH MakerAPI.AddAccessoryWindowControl(new MakerButton("Material Editor", null, this)).OnClick.AddListener(UpdateUIAccessory); e.AddControl(new MakerButton("Material Editor (Body)", MakerConstants.Body.General, this)).OnClick.AddListener(() => UpdateUICharacter("body")); e.AddControl(new MakerButton("Material Editor (All)", MakerConstants.Body.General, this)).OnClick.AddListener(() => UpdateUICharacter()); e.AddControl(new MakerButton("Material Editor", MakerConstants.Body.Nail, this)).OnClick.AddListener(() => UpdateUICharacter("nail")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Body.Lower, this)).OnClick.AddListener(() => UpdateUICharacter("mnpk")); e.AddControl(new MakerButton("Material Editor (Face)", MakerConstants.Face.General, this)).OnClick.AddListener(() => UpdateUICharacter("head,face")); e.AddControl(new MakerButton("Material Editor (All)", MakerConstants.Face.General, this)).OnClick.AddListener(() => UpdateUICharacter()); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eye, this)).OnClick.AddListener(() => UpdateUICharacter("eye")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eyebrow, this)).OnClick.AddListener(() => UpdateUICharacter("mayuge")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Eyelash, this)).OnClick.AddListener(() => UpdateUICharacter("matuge")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Face.Mouth, this)).OnClick.AddListener(() => UpdateUICharacter("ha,sita")); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Tops, this)).OnClick.AddListener(() => UpdateUIClothes(0)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Bottoms, this)).OnClick.AddListener(() => UpdateUIClothes(1)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Bra, this)).OnClick.AddListener(() => UpdateUIClothes(2)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Shorts, this)).OnClick.AddListener(() => UpdateUIClothes(3)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.SwimWear, this)).OnClick.AddListener(() => UpdateUIClothes(4)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.SwimTops, this)).OnClick.AddListener(() => UpdateUIClothes(5)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.SwimWear, this)).OnClick.AddListener(() => UpdateUIClothes(6)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Glove, this)).OnClick.AddListener(() => UpdateUIClothes(7)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Panst, this)).OnClick.AddListener(() => UpdateUIClothes(8)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Socks, this)).OnClick.AddListener(() => UpdateUIClothes(9)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Wear.Shoes, this)).OnClick.AddListener(() => UpdateUIClothes(10)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Back, this)).OnClick.AddListener(() => UpdateUIHair(0)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Front, this)).OnClick.AddListener(() => UpdateUIHair(1)); e.AddControl(new MakerButton("Material Editor", MakerConstants.Hair.Side, this)).OnClick.AddListener(() => UpdateUIHair(2)); #endif currentHairIndex = 0; currentClothesIndex = 0; }
public static void InitUI() { DynamicBoneEditorButton = MakerAPI.AddAccessoryWindowControl(new MakerButton("Dynamic Bone Editor", null, PluginInstance)); #if !PH DynamicBoneEditorButton.GroupingID = "Buttons"; #endif DynamicBoneEditorButton.OnClick.AddListener(() => ShowUI(0)); var windowBackground = new Texture2D(1, 1, TextureFormat.ARGB32, false); windowBackground.SetPixel(0, 0, new Color(0f, 0f, 0f, 0f)); windowBackground.Apply(); WindowBackground = windowBackground; Padding = new RectOffset(3, 2, 0, 1); EditorWindow = UIUtility.CreateNewUISystem("DynamicBoneEditorCanvas"); EditorWindow.GetComponent <CanvasScaler>().referenceResolution = new Vector2(1920f / UIScale, 1080f / UIScale); Visible = false; EditorWindow.sortingOrder = 1000; EditorMainPanel = UIUtility.CreatePanel("Panel", EditorWindow.transform); EditorMainPanel.color = Color.white; EditorMainPanel.transform.SetRect(0.05f, 0.05f, UIWidth * UIScale, UIHeight * UIScale); UIUtility.AddOutlineToObject(EditorMainPanel.transform, Color.black); DragPanel = UIUtility.CreatePanel("Draggable", EditorMainPanel.transform); DragPanel.transform.SetRect(0f, 1f, 1f, 1f, 0f, -HeaderSize); DragPanel.color = Color.gray; UIUtility.MakeObjectDraggable(DragPanel.rectTransform, EditorMainPanel.rectTransform); var nametext = UIUtility.CreateText("Nametext", DragPanel.transform, "Dynamic Bone Editor"); nametext.transform.SetRect(); nametext.alignment = TextAnchor.MiddleCenter; var close = UIUtility.CreateButton("CloseButton", DragPanel.transform, ""); close.transform.SetRect(1f, 0f, 1f, 1f, -20f, 1f, -1f, -1f); close.onClick.AddListener(() => Visible = false); //X button var x1 = UIUtility.CreatePanel("x1", close.transform); x1.transform.SetRect(0f, 0f, 1f, 1f, 8f, 0f, -8f); x1.rectTransform.eulerAngles = new Vector3(0f, 0f, 45f); x1.color = Color.black; var x2 = UIUtility.CreatePanel("x2", close.transform); x2.transform.SetRect(0f, 0f, 1f, 1f, 8f, 0f, -8f); x2.rectTransform.eulerAngles = new Vector3(0f, 0f, -45f); x2.color = Color.black; EditorScrollableUI = UIUtility.CreateScrollView("DynamicBoneEditorWindow", EditorMainPanel.transform); EditorScrollableUI.transform.SetRect(0f, 0f, 1f, 1f, MarginSize, MarginSize, -MarginSize, -HeaderSize - MarginSize / 2f); EditorScrollableUI.gameObject.AddComponent <Mask>(); EditorScrollableUI.content.gameObject.AddComponent <VerticalLayoutGroup>(); EditorScrollableUI.content.gameObject.AddComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; EditorScrollableUI.verticalScrollbar.GetComponent <RectTransform>().offsetMin = new Vector2(ScrollOffsetX, 0f); EditorScrollableUI.viewport.offsetMax = new Vector2(ScrollOffsetX, 0f); EditorScrollableUI.movementType = ScrollRect.MovementType.Clamped; EditorScrollableUI.verticalScrollbar.GetComponent <Image>().color = new Color(1, 1, 1, 0.6f); { var contentList = UIUtility.CreatePanel("ListEntry", EditorScrollableUI.content.transform); contentList.gameObject.AddComponent <LayoutElement>().preferredHeight = PanelHeight; contentList.gameObject.AddComponent <Mask>(); contentList.color = RowColor; var itemPanel = UIUtility.CreatePanel("DynamicBonePanel", contentList.transform); itemPanel.gameObject.AddComponent <CanvasGroup>(); itemPanel.gameObject.AddComponent <HorizontalLayoutGroup>().padding = Padding; itemPanel.color = ItemColor; var label = UIUtility.CreateText("DynamicBoneLabel", itemPanel.transform, "Dynamic Bone"); label.alignment = TextAnchor.MiddleLeft; label.color = Color.black; var labelLE = label.gameObject.AddComponent <LayoutElement>(); labelLE.preferredWidth = LabelWidth; labelLE.flexibleWidth = LabelWidth; DynamicBoneDropdown = UIUtility.CreateDropdown("DynamicBoneDropdown", itemPanel.transform); DynamicBoneDropdown.transform.SetRect(0f, 0f, 0f, 1f, 0f, 0f, 100f); DynamicBoneDropdown.captionText.transform.SetRect(0f, 0f, 1f, 1f, 5f, 2f, -15f, -2f); DynamicBoneDropdown.captionText.alignment = TextAnchor.MiddleLeft; var dropdownEnabledLE = DynamicBoneDropdown.gameObject.AddComponent <LayoutElement>(); dropdownEnabledLE.preferredWidth = DropdownWidth; dropdownEnabledLE.flexibleWidth = 0; } FreezeAxis.CreateUI(EditorScrollableUI.content.transform); Weight.CreateUI(EditorScrollableUI.content.transform); Damping.CreateUI(EditorScrollableUI.content.transform); Elasticity.CreateUI(EditorScrollableUI.content.transform); Stiffness.CreateUI(EditorScrollableUI.content.transform); Inertia.CreateUI(EditorScrollableUI.content.transform); Radius.CreateUI(EditorScrollableUI.content.transform); }
private void MakerAPI_MakerBaseLoaded(object s, RegisterCustomControlsEvent e) { var controller = GetController(MakerAPI.GetCharacterControl()); ColorMatchToggle = new AccessoryControlWrapper <MakerToggle, bool>(MakerAPI.AddAccessoryWindowControl(new MakerToggle(null, "Match Color With Hair", ColorMatchDefault, this))); HairGlossToggle = new AccessoryControlWrapper <MakerToggle, bool>(MakerAPI.AddAccessoryWindowControl(new MakerToggle(null, "Use Hair Gloss", ColorMatchDefault, this))); OutlineColorPicker = new AccessoryControlWrapper <MakerColor, Color>(MakerAPI.AddAccessoryWindowControl(new MakerColor("Outline Color", false, null, OutlineColorDefault, this))); AccessoryColorPicker = new AccessoryControlWrapper <MakerColor, Color>(MakerAPI.AddAccessoryWindowControl(new MakerColor("Accessory Color", false, null, OutlineColorDefault, this))); HairLengthSlider = new AccessoryControlWrapper <MakerSlider, float>(MakerAPI.AddAccessoryWindowControl(new MakerSlider(null, "Length", 0, 1, HairLengthDefault, this))); //Color Match ColorMatchToggle.Control.Visible.OnNext(false); ColorMatchToggle.ValueChanged += ColorMatchToggle_ValueChanged; void ColorMatchToggle_ValueChanged(object sender, AccessoryWindowControlValueChangedEventArgs <bool> eventArgs) { controller.SetColorMatch(eventArgs.NewValue, eventArgs.SlotIndex); OutlineColorPicker.Control.Visible.OnNext(!eventArgs.NewValue); if (eventArgs.NewValue) { HideAccColors(); } else { ShowAccColors(true); } controller.UpdateAccessory(eventArgs.SlotIndex); } //Hair Gloss HairGlossToggle.Control.Visible.OnNext(false); HairGlossToggle.ValueChanged += HairGlossToggle_ValueChanged; void HairGlossToggle_ValueChanged(object sender, AccessoryWindowControlValueChangedEventArgs <bool> eventArgs) { controller.SetHairGloss(eventArgs.NewValue, eventArgs.SlotIndex); controller.UpdateAccessory(eventArgs.SlotIndex); } //Outline Color OutlineColorPicker.Control.ColorBoxWidth = 230; OutlineColorPicker.Control.Visible.OnNext(false); OutlineColorPicker.ValueChanged += OutlineColorPicker_ValueChanged; void OutlineColorPicker_ValueChanged(object sender, AccessoryWindowControlValueChangedEventArgs <Color> eventArgs) { controller.SetOutlineColor(eventArgs.NewValue, eventArgs.SlotIndex); controller.UpdateAccessory(eventArgs.SlotIndex); } //AccessoryColor AccessoryColorPicker.Control.ColorBoxWidth = 230; AccessoryColorPicker.Control.Visible.OnNext(false); AccessoryColorPicker.ValueChanged += AccessoryColorPicker_ValueChanged; void AccessoryColorPicker_ValueChanged(object sender, AccessoryWindowControlValueChangedEventArgs <Color> eventArgs) { controller.SetAccessoryColor(eventArgs.NewValue, eventArgs.SlotIndex); controller.UpdateAccessory(eventArgs.SlotIndex); } //HairLength HairLengthSlider.Control.Visible.OnNext(false); HairLengthSlider.ValueChanged += HairLengthSlider_ValueChanged; void HairLengthSlider_ValueChanged(object sender, AccessoryWindowControlValueChangedEventArgs <float> eventArgs) { controller.SetHairLength(eventArgs.NewValue, eventArgs.SlotIndex); controller.UpdateAccessory(eventArgs.SlotIndex); } }
private void Start() { CharacterApi.RegisterExtraBehaviour <MaterialRouterController>(GUID); HooksInstance = Harmony.CreateAndPatchAll(typeof(Hooks)); BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.materialeditor", out PluginInfo PluginInfo); Type MaterialEditorCharaController = PluginInfo.Instance.GetType().Assembly.GetType("KK_Plugins.MaterialEditor.MaterialEditorCharaController"); HooksInstance.Patch(MaterialEditorCharaController.GetMethod("OnReload", AccessTools.all, null, new[] { typeof(GameMode), typeof(bool) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialEditorCharaController_OnReload_Prefix))); HooksInstance.Patch(MaterialEditorCharaController.GetMethod("OnCoordinateBeingLoaded", AccessTools.all, null, new[] { typeof(ChaFileCoordinate), typeof(bool) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialEditorCharaController_OnCoordinateBeingLoaded_Prefix))); HooksInstance.Patch(MaterialEditorCharaController.GetMethod("CorrectTongue", AccessTools.all, null, new Type[0], null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialEditorCharaController_CorrectTongue_Prefix))); Type MaterialEditorMaterialAPI = PluginInfo.Instance.GetType().Assembly.GetType("MaterialEditorAPI.MaterialAPI"); if (MaterialEditorMaterialAPI.GetMethods().Single(x => x.Name == "SetTexture").GetParameters().ElementAtOrDefault(3)?.ParameterType == typeof(Texture)) { HooksInstance.Patch(MaterialEditorMaterialAPI.GetMethod("SetTexture", AccessTools.all, null, new[] { typeof(GameObject), typeof(string), typeof(string), typeof(Texture) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialAPI_SetTexture_Prefix))); } else { HooksInstance.Patch(MaterialEditorMaterialAPI.GetMethod("SetTexture", AccessTools.all, null, new[] { typeof(GameObject), typeof(string), typeof(string), typeof(Texture2D) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialAPI_SetTexture_Prefix))); } MakerAPI.MakerBaseLoaded += (object sender, RegisterCustomControlsEvent ev) => { HooksMakerInstance = Harmony.CreateAndPatchAll(typeof(HooksMaker)); }; MakerAPI.MakerFinishedLoading += (object sender, EventArgs ev) => { btmGetTemplate.Visible.OnNext(false); btmImportSetting.Visible.OnNext(false); btmRemoveSetting.Visible.OnNext(false); }; AccessoriesApi.SelectedMakerAccSlotChanged += (object sender, AccessorySlotEventArgs ev) => { InitCurrentSlot(); }; MakerAPI.MakerExiting += (object sender, EventArgs ev) => { HooksMakerInstance.UnpatchAll(HooksMakerInstance.Id); HooksMakerInstance = null; }; AccessoriesApi.AccessoryTransferred += (object sender, AccessoryTransferEventArgs ev) => { MaterialRouterController pluginCtrl = GetController(MakerAPI.GetCharacterControl()); pluginCtrl.AccessoryTransferEvent(ev); }; AccessoriesApi.AccessoriesCopied += (object sender, AccessoryCopyEventArgs ev) => { MaterialRouterController pluginCtrl = GetController(MakerAPI.GetCharacterControl()); pluginCtrl.AccessoryCopyEvent(ev); }; MakerAPI.RegisterCustomSubCategories += (object sender, RegisterSubCategoriesEvent ev) => { ChaControl chaCtrl = MakerAPI.GetCharacterControl(); MaterialRouterController pluginCtrl = GetController(chaCtrl); MakerCategory category = new MakerCategory("05_ParameterTop", "tglMaterialRouter", MakerConstants.Parameter.Attribute.Position + 1, "Router"); ev.AddSubCategory(category); ev.AddControl(new MakerText("BodyTrigger", category, this)); ev.AddControl(new MakerButton("Export", category, this)).OnClick.AddListener(delegate { pluginCtrl.ExportBodyTrigger(); }); ev.AddControl(new MakerButton("Import", category, this)).OnClick.AddListener(delegate { pluginCtrl.ImportBodyTrigger(); }); ev.AddControl(new MakerButton("Reset", category, this)).OnClick.AddListener(delegate { pluginCtrl.ResetBodyTrigger(); }); ev.AddControl(new MakerSeparator(category, this)); ev.AddControl(new MakerText("OutfitTriggers", category, this)); ev.AddControl(new MakerButton("Export", category, this)).OnClick.AddListener(delegate { pluginCtrl.ExportOutfitTrigger(); }); ev.AddControl(new MakerButton("Import", category, this)).OnClick.AddListener(delegate { pluginCtrl.ImportOutfitTrigger(); }); ev.AddControl(new MakerButton("Reset", category, this)).OnClick.AddListener(delegate { pluginCtrl.ResetOutfitTrigger(); }); ev.AddControl(new MakerSeparator(category, this)); ev.AddControl(new MakerText("Config", category, this)); tglSkipCloned = ev.AddControl(new MakerToggle(category, "Get Template Skip Cloned", CfgSkipCloned.Value, this)); tglSkipCloned.ValueChanged.Subscribe(value => CfgSkipCloned.Value = value); ev.AddControl(new MakerSeparator(category, this)); ev.AddControl(new MakerText("Tools", category, this)); ev.AddControl(new MakerButton("Reload", category, Instance)).OnClick.AddListener(delegate { string CardPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Paths.ExecutablePath) + "_MaterialRouter.png"); chaCtrl.chaFile.SaveCharaFile(CardPath, byte.MaxValue, false); chaCtrl.chaFile.LoadFileLimited(CardPath); if (chaCtrl.chaFile.GetLastErrorCode() != 0) { throw new Exception("LoadFileLimited failed"); } chaCtrl.ChangeCoordinateType(true); chaCtrl.Reload(); CustomBase.Instance.updateCustomUI = true; }); ev.AddControl(new MakerButton("Info", category, Instance)).OnClick.AddListener(delegate { Logger.LogInfo($"[BodyTrigger][{pluginCtrl?.BodyTrigger?.Count}]"); for (int i = 0; i < chaCtrl.chaFile.coordinate.Length; i++) { Logger.LogInfo($"[OutfitTriggers][{i}][{pluginCtrl?.OutfitTriggers?[i].Count}]"); } }); ev.AddControl(new MakerButton("Head Get Template", MakerConstants.Face.All, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHead, true)); ev.AddControl(new MakerButton("Body Get Template", MakerConstants.Face.All, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objBody, true)); const string labelConsolePrint = "Console Output"; const string labelGenerateSetting = "Generate Setting"; const string labelRemoveSetting = "Remove Setting"; ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Top, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[0])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Bottom, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[1])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Bra, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[2])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Shorts, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[3])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Gloves, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[4])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Panst, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[5])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Socks, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[6])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.InnerShoes, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[7])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.OuterShoes, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[8])); btmGetTemplate = MakerAPI.AddAccessoryWindowControl(new MakerButton(labelConsolePrint, null, this)); btmGetTemplate.OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.GetAccessoryObject(AccessoriesApi.SelectedMakerAccSlot))); btmImportSetting = MakerAPI.AddAccessoryWindowControl(new MakerButton(labelGenerateSetting, null, this)); btmImportSetting.OnClick.AddListener(() => pluginCtrl.ImportFromRendererInfo(AccessoriesApi.SelectedMakerAccSlot)); btmRemoveSetting = MakerAPI.AddAccessoryWindowControl(new MakerButton(labelRemoveSetting, null, this)); btmRemoveSetting.OnClick.AddListener(() => pluginCtrl.RemoveAccSlotInfo(AccessoriesApi.SelectedMakerAccSlot)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Back, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[0], true)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Front, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[1], true)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Side, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[2], true)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Extension, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[3], true)); }; }