private static void TranslateDisplayList(CharaList charaList) { // ReSharper disable once RedundantAssignment - used in DEBUG var start = Time.realtimeSinceStartup; try { if (charaList == null || TranslationHelper.Instance == null || !TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } var cfiList = Traverse.Create(charaList)?.Field <CharaFileSort>("charaFileSort")?.Value?.cfiList; if (cfiList == null || cfiList.Count == 0) { return; } var sex = Traverse.Create(charaList)?.Field <int>("sex")?.Value ?? -1; if (sex == -1) { return; } var scope = new NameScope((CharacterSex)sex); var jobs = 0; void Finished() { // ReSharper disable once AccessToModifiedClosure jobs--; if (jobs < 1) { Logger.DebugLogDebug( $"TranslateDisplayList: All jobs done: {Time.realtimeSinceStartup - start:000.0000000000} seconds"); } } foreach (var entry in cfiList) { jobs++; TranslationHelper.Instance.StartCoroutine( TranslateDisplayListEntryCoroutine(entry, scope, Finished)); } if (jobs > 0) { Logger.DebugLogDebug( $"TranslateDisplayList: All jobs started: {Time.realtimeSinceStartup - start:000.0000000000} seconds"); } } finally { Logger.DebugLogDebug($"TranslateDisplayList: {Time.realtimeSinceStartup - start:000.0000000000}"); } }
internal static void InitCharaListPrefix(CharaList __instance, bool _force) { if (!_charaListEntries.ContainsKey(__instance.name)) { _charaListEntries[__instance.name] = new CharaListEntry(__instance); } _refilterOnly = _force && _charaListEntries[__instance.name].RefilterInProgress; }
internal static void InitCharaListPostfix(CharaList __instance) { if (_charaListEntries.TryGetValue(__instance.name, out var entry)) { entry.RefilterInProgress = false; } _refilterOnly = false; }
private static void TranslateDisplayList(CharaList charaList) { if (charaList == null || TranslationHelper.Instance == null || !TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } var cfiList = Traverse.Create(charaList)?.Field <CharaFileSort>("charaFileSort")?.Value?.cfiList; if (cfiList == null) { return; } var sex = Traverse.Create(charaList)?.Field <int>("sex")?.Value ?? -1; if (sex == -1) { return; } void HandleResult(CharaFileInfo charaFileInfo, ITranslationResult result) { if (!result.Succeeded) { return; } charaFileInfo.name = charaFileInfo.node.text = result.TranslatedText; } var scope = new NameScope((CharacterSex)sex); foreach (var entry in cfiList) { var origName = entry.name; if (TryApplyAlternateTranslation(entry, origName)) { TreeNodeLimiter.EndImmediately(); return; } void Handler(ITranslationResult result) { HandleResult(entry, result); if (TryApplyAlternateTranslation(entry, origName)) { TreeNodeLimiter.EndImmediately(); } TreeNodeLimiter.EndImmediately(); } TranslationHelper.Instance.StartCoroutine(TreeNodeLimiter.Start().AppendCo( TranslationHelper.CardNameManager.TranslateCardName(origName, scope, CardNameTranslationManager.CanForceSplitNameString(origName), Handler))); } }
public static bool ChangeChara(CharaList __instance) { (from v in Singleton <GuideObjectManager> .Instance.selectObjectKey select Studio.Studio.GetCtrlInfo(v) as OCIChar into v where v != null select v).ToList().ForEach((OCIChar ocichar) => { ocichar.charInfo.fileParam.sex = (byte)(int)__instance.GetField("sex"); ocichar.ChangeChara((__instance.GetField("charaFileSort") as CharaFileSort).selectPath); }); return(false); }
private static void SetKeepCoorButtonInteractable(CharaList __instance) { if (null != __instance) { int i = (string.Equals(__instance.name, "00_Female") ? 1 : 0); if (null != btn[i] && null != btn[i].GetComponent <Button>() && null != __instance.GetField("buttonChange")) { btn[i].GetComponent <Button>().interactable = ((Button)__instance.GetField("buttonChange")).interactable; } } }
public static void InitCharaListPostfix(CharaList __instance) { bool flag = string.Equals(__instance.name, "00_Female") == (SampleChara.chaFile.parameter.sex == 1); if (Extension.Extension.TryGetPluginInstance("com.jim60105.kk.studioallgirlsplugin")) { flag = true; } if (flag && null == UnityEngine.GameObject.Find($"StudioScene/Canvas Main Menu/01_Add/{__instance.name}/redBagBtn")) { KK_FBIOpenUp.nowGameMode = KK_FBIOpenUp.GameMode.Studio; UnityStuff.DrawRedBagBtn(KK_FBIOpenUp.GameMode.Studio, __instance); } }
internal static void StudioInitCharaListPostfix(CharaList __instance) { try { CharaListsInProgress.Remove(__instance); if (CharaListsInProgress.Count == 0) { DisableCharaListHandler(); } } catch (Exception err) { Logger.LogException(err, __instance, nameof(StudioInitCharaListPostfix)); } }
public static bool ChangeChara(CharaList __instance) { (from v in Singleton <GuideObjectManager> .Instance.selectObjectKey select Studio.Studio.GetCtrlInfo(v) as OCIChar into v where v != null select v).ToList().ForEach((OCIChar ocichar) => { int sex = (int)__instance.GetField("sex"); ocichar.charInfo.fileParam.sex = (byte)sex; ocichar.optionItemCtrl.oiCharInfo.SetProperty <OICharInfo>("sex", sex); ShapeBodyInfoFemale sib = ocichar.charInfo.sibBody as ShapeBodyInfoFemale; sib.correctHeadSize = sex == 0 ? 0.91f : 1f; sib.correctNeckSize = sex == 0 ? 0.91f : 1f; ocichar.ChangeChara((__instance.GetField("charaFileSort") as CharaFileSort).selectPath); }); return(false); }
CharFileInfoCustomFemale GetCharCustom() { CharFileInfoCustomFemale charCustomFile = null; CharaList operatingList = listFemales.gameObject.activeInHierarchy ? listFemales.gameObject.GetComponent <CharaList>() : null; if (operatingList != null) { CharaFileSort charaFiles = (CharaFileSort)operatingList.GetType() .GetField("charaFileSort", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(operatingList); if (System.IO.File.Exists(charaFiles.selectPath) && charaFiles.selectPath != null) { CharFemaleFile charPNG = new CharFemaleFile(); charPNG.Load(charaFiles.selectPath, true, true); charCustomFile = charPNG.femaleCustomInfo; } return(charCustomFile); } return(charCustomFile); }
internal static void CharaList_InitCharaList_Postfix(CharaList __instance, ref object __state) { try { TranslateDisplayList(__instance); var _ = __state; } catch (Exception err) { Logger.LogException(err, __instance, nameof(CharaList_InitCharaList_Postfix)); } /* * Logger.LogDebug("Enable XUA"); * (__state as AutoTranslationPlugin)?.EnableAutoTranslator(); * __state = null; */ }
void Delete() { CharaList operatingList = mainCanvas.Find("01_Add/00_Female").gameObject.activeInHierarchy ? listFemale : mainCanvas.Find("01_Add/01_Male").gameObject.activeInHierarchy ? listMale : null; if (operatingList != null) { CharaFileSort charaFiles = (CharaFileSort)operatingList.GetType() .GetField("charaFileSort", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(operatingList); if (System.IO.File.Exists(charaFiles.selectPath) && charaFiles.selectPath != null) { var sortType = charaFiles.sortKind; mainCanvas.gameObject.SetActive(false); System.IO.File.Delete(charaFiles.selectPath); operatingList.InitCharaList(true); operatingList.OnSort(sortType); mainCanvas.gameObject.SetActive(true); } } }
public static void InitCharaListPostfix(CharaList __instance) { //繪製UI GameObject original = GameObject.Find("StudioScene/Canvas Main Menu/01_Add/" + __instance.name + "/Button Change"); int i = (string.Equals(__instance.name, "00_Female") ? 1 : 0); if (null != btn[i]) { return; } btn[i] = UnityEngine.Object.Instantiate(original, original.transform.parent); btn[i].name = "Button Keep Coordinate Change" + i; btn[i].transform.position += new Vector3(0, -25, 0); btn[i].transform.SetRect(new Vector2(0, 1), new Vector2(0, 1), new Vector2(180, -401), new Vector2(390, -380)); //依照語言選擇圖片 switch (Application.systemLanguage) { case SystemLanguage.Chinese: case SystemLanguage.ChineseTraditional: case SystemLanguage.ChineseSimplified: btn[i].GetComponent <Image>().sprite = ImageHelper.LoadNewSprite("StudioCharaOnlyLoadBody.Resources.buttonChange.png", 183, 20); break; case SystemLanguage.Japanese: btn[i].GetComponent <Image>().sprite = ImageHelper.LoadNewSprite("StudioCharaOnlyLoadBody.Resources.buttonChange_JP.png", 183, 20); break; default: btn[i].GetComponent <Image>().sprite = ImageHelper.LoadNewSprite("StudioCharaOnlyLoadBody.Resources.buttonChange_EN.png", 183, 20); break; } //Button Onclick btn[i].GetComponent <Button>().onClick.RemoveAllListeners(); btn[i].GetComponent <Button>().onClick.SetPersistentListenerState(0, UnityEngine.Events.UnityEventCallState.Off); btn[i].GetComponent <Button>().onClick.AddListener(() => Model.OnButtonClick(__instance, i)); //同步按鈕狀態 SetKeepCoorButtonInteractable(__instance); }
internal static void StudioInitCharaListPrefix(CharaList __instance) { try { if (!TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } if (CharaListsInProgress.Contains(__instance)) { return; } CharaListsInProgress.Add(__instance); EnableCharaListHandler(); } catch (Exception err) { Logger.LogException(err, __instance, nameof(StudioInitCharaListPrefix)); } }
void Start() { mainCanvas = studio.gameObject.transform.Find("Canvas Main Menu"); listFemale = mainCanvas.Find("01_Add/00_Female").gameObject.GetComponent <CharaList>(); listMale = mainCanvas.Find("01_Add/01_Male").gameObject.GetComponent <CharaList>(); }
public CharaListEntry(CharaList charaList) { _charaList = charaList; }
/// <summary> /// 建立紅色書包圖標 /// </summary> /// <param name="gameMode">遊戲模式</param> /// <param name="param">我知道這不安全,但這很方便σ`∀´)σ</param> internal static void DrawRedBagBtn(KK_FBIOpenUp.GameMode gameMode, object param = null) { GameObject original, parent; Vector2 offsetMin, offsetMax; KK_FBIOpenUp.nowGameMode = gameMode; switch (KK_FBIOpenUp.nowGameMode) { case KK_FBIOpenUp.GameMode.Studio: CharaList charaList = param as CharaList; original = GameObject.Find($"StudioScene/Canvas Main Menu/01_Add/{charaList.name}/Button Change"); parent = original.transform.parent.gameObject; offsetMin = new Vector2(-120, -270); offsetMax = new Vector2(-40, -190); break; case KK_FBIOpenUp.GameMode.Maker: original = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/01_BodyTop/tglShape/ShapeTop/Scroll View/Viewport/Content/grpBtn/btnS"); parent = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsCoordinateType").gameObject; offsetMin = new Vector2(849.64f, -69f); offsetMax = new Vector2(914.64f, -4f); break; case KK_FBIOpenUp.GameMode.MainGame: original = GameObject.Find("ActionScene/UI/ActionMenuCanvas/ModeAnimation/Status"); parent = original.transform.parent.gameObject; offsetMin = new Vector2(0, -80); offsetMax = new Vector2(80, 0); break; case KK_FBIOpenUp.GameMode.FreeH: original = GameObject.Find("Canvas/SubMenu/DressCategory/ClothChange"); int i = (int)param; if (i == 1) { parent = GameObject.Find("Canvas/SubMenu/DressCategory"); } else { parent = GameObject.Find("Canvas/SubMenu/SecondDressCategory"); } offsetMin = new Vector2(5, -198); offsetMax = new Vector2(107, -96); break; default: return; } GameObject redBagBtn = UnityEngine.Object.Instantiate(original, parent.transform); redBagBtn.name = "redBagBtn"; redBagBtn.transform.SetRect(new Vector2(0, 1), new Vector2(0, 1), offsetMin, offsetMax); redBagBtn.GetComponent <Button>().spriteState = new SpriteState(); redBagBtn.GetComponent <Image>().sprite = Extension.Extension.LoadNewSprite("KK_FBIOpenUp.Resources.redBag.png", 100, 100); redBagBtn.GetComponent <Button>().onClick.RemoveAllListeners(); for (int i = 0; i < redBagBtn.GetComponent <Button>().onClick.GetPersistentEventCount(); i++) { redBagBtn.GetComponent <Button>().onClick.SetPersistentListenerState(i, UnityEngine.Events.UnityEventCallState.Off); } if (redBagBtn.transform.Find("textBtn")?.gameObject is GameObject go) { GameObject.Destroy(go); } redBagBtn.GetComponent <Button>().interactable = true; //因為要handle長按,監聽PointerDown、PointerUp Event //在Update()裡面有對Timer累加 redBagBtn.AddComponent <EventTrigger>(); EventTrigger trigger = redBagBtn.gameObject.GetComponent <EventTrigger>(); EventTrigger.Entry pointerDown = new EventTrigger.Entry { eventID = EventTriggerType.PointerDown, callback = new EventTrigger.TriggerEvent() }; pointerDown.callback.AddListener((baseEventData) => { btnClickTimer = 0; downState = true; }); trigger.triggers.Add(pointerDown); EventTrigger.Entry pointerUp = new EventTrigger.Entry { eventID = EventTriggerType.PointerUp, callback = new EventTrigger.TriggerEvent() }; pointerUp.callback.AddListener((baseEventData) => { downState = false; float clickDeltaTime = btnClickTimer; btnClickTimer = 0; if (step != 0) { return; } switch (KK_FBIOpenUp.nowGameMode) { case KK_FBIOpenUp.GameMode.FreeH: //不分長短按 KK_FBIOpenUp.SetEnabled(); if (KK_FBIOpenUp._isenabled) { step = 10; } else { if (KK_FBIOpenUp.Effect_on_ABMX.Value) { step = 2; } else { step = 20; } } ChangeWithoutShiftPicture = true; StepLightAndPlay(); //開ABMX時不變更狀態 if (KK_FBIOpenUp.Effect_on_ABMX.Value) { KK_FBIOpenUp.SetEnabled(); } ChangeRedBagBtn(redBagBtn); break; case KK_FBIOpenUp.GameMode.Maker: KK_FBIOpenUp.SetEnabled(); if (KK_FBIOpenUp._isenabled) { DrawSlidePic(10); } else { if (KK_FBIOpenUp.Effect_on_ABMX.Value) { DrawSlidePic(2); } else { DrawSlidePic(20); } } //Maker開ABMX時、啟用長按時不變更狀態 if (KK_FBIOpenUp.Effect_on_ABMX.Value || (clickDeltaTime >= 1f && KK_FBIOpenUp._isenabled)) { KK_FBIOpenUp.SetEnabled(); } ChangeRedBagBtn(redBagBtn); break; case KK_FBIOpenUp.GameMode.MainGame: //主遊戲不分長短按 KK_FBIOpenUp.SetEnabled(); if (KK_FBIOpenUp._isenabled) { DrawSlidePic(10); } else { if (KK_FBIOpenUp.Effect_on_ABMX.Value) { DrawSlidePic(2); } else { DrawSlidePic(20); } } if (KK_FBIOpenUp.Effect_on_ABMX.Value) { KK_FBIOpenUp.SetEnabled(); } ChangeRedBagBtn(redBagBtn); break; case KK_FBIOpenUp.GameMode.Studio: //Studio長按時調整狀態而不變人 KK_FBIOpenUp.SetEnabled(); if (clickDeltaTime <= 1f) { if (KK_FBIOpenUp._isenabled) { DrawSlidePic(10); } else { if (KK_FBIOpenUp.Effect_on_ABMX.Value) { DrawSlidePic(2); } else { DrawSlidePic(20); } } ChangeRedBagBtn(redBagBtn); } else { if (KK_FBIOpenUp._isenabled) { DrawSlidePic(1); } else { DrawSlidePic(2); } ChangeRedBagBtn(redBagBtn); } break; } }); trigger.triggers.Add(pointerUp); ChangeRedBagBtn(redBagBtn); }
public static bool ChangeCharaMale(CharaList __instance) => ChangeChara(__instance);
public static void OnSort(CharaList __instance) { SetKeepCoorButtonInteractable(__instance); }
internal static void InitMaleListPostfix(CharaList __instance) { InitListPostfix(__instance.name); }
internal static void CharaList_InitCharaList_Postfix(CharaList __instance) { TranslateDisplayList(__instance); }
//按鈕邏輯 internal static void OnButtonClick(CharaList __instance, int sex) { CharaFileSort charaFileSort = __instance.GetField("charaFileSort") as CharaFileSort; ChaFileControl chaFileControl = new ChaFileControl(); string fullPath = chaFileControl.ConvertCharaFilePath(charaFileSort.selectPath, (byte)sex, false); chaFileControl = null; OCIChar[] array = (from v in Singleton <GuideObjectManager> .Instance.selectObjectKey select Studio.Studio.GetCtrlInfo(v) as OCIChar into v where v != null select v).ToArray(); foreach (OCIChar ocichar in array) { ChaControl chaCtrl = ocichar.charInfo; foreach (OCIChar.BoneInfo boneInfo in (from v in ocichar.listBones where v.boneGroup == OIBoneInfo.BoneGroup.Hair select v).ToList <OCIChar.BoneInfo>()) { Singleton <GuideObjectManager> .Instance.Delete(boneInfo.guideObject, true); } ocichar.listBones = (from v in ocichar.listBones where v.boneGroup != OIBoneInfo.BoneGroup.Hair select v).ToList <OCIChar.BoneInfo>(); int[] array2 = (from b in ocichar.oiCharInfo.bones where b.Value.@group == OIBoneInfo.BoneGroup.Hair select b.Key).ToArray <int>(); for (int j = 0; j < array2.Length; j++) { ocichar.oiCharInfo.bones.Remove(array2[j]); } ocichar.hairDynamic = null; ocichar.skirtDynamic = null; string oldName = ocichar.charInfo.chaFile.parameter.fullname; //用這種方式初始化不會觸發其他鉤子 ChaControl tmpCtrl = new ChaControl(); tmpCtrl.SetProperty("chaFile", new ChaFileControl()); if (null != MoreAccessories) { CopyAllMoreAccessoriesData(ocichar.charInfo, tmpCtrl); } //Main Load Control if (chaCtrl.chaFile.LoadFileLimited(fullPath, (byte)sex, true, true, true, true, false) || !LoadExtendedData(ocichar, charaFileSort.selectPath, (byte)sex) || !UpdateTreeNodeObjectName(ocichar)) { Logger.LogError("Load Body FAILED"); } else { if (null != MoreAccessories) { CopyAllMoreAccessoriesData(tmpCtrl, ocichar.charInfo); } } GameObject.Destroy(tmpCtrl); ocichar.charInfo.AssignCoordinate((ChaFileDefine.CoordinateType)ocichar.charInfo.fileStatus.coordinateType); chaCtrl.Reload(false, false, false, false); AddObjectAssist.InitHairBone(ocichar, Singleton <Info> .Instance.dicBoneInfo); ocichar.hairDynamic = AddObjectFemale.GetHairDynamic(ocichar.charInfo.objHair); ocichar.skirtDynamic = AddObjectFemale.GetSkirtDynamic(ocichar.charInfo.objClothes); ocichar.InitFK(null); foreach (var tmp in FKCtrl.parts.Select((OIBoneInfo.BoneGroup p, int i2) => new { p, i2 })) { ocichar.ActiveFK(tmp.p, ocichar.oiCharInfo.activeFK[tmp.i2], ocichar.oiCharInfo.activeFK[tmp.i2]); } ocichar.ActiveKinematicMode(OICharInfo.KinematicMode.FK, ocichar.oiCharInfo.enableFK, true); ocichar.UpdateFKColor(new OIBoneInfo.BoneGroup[] { OIBoneInfo.BoneGroup.Hair }); ocichar.ChangeEyesOpen(ocichar.charFileStatus.eyesOpenMax); ocichar.ChangeBlink(ocichar.charFileStatus.eyesBlink); ocichar.ChangeMouthOpen(ocichar.oiCharInfo.mouthOpen); Logger.LogInfo($"Load Body: {oldName} -> {ocichar.charInfo.chaFile.parameter.fullname}"); } }
internal static bool InitMaleListPrefix(CharaList __instance) { return(InitListPrefix(__instance.name)); }
void PickUp() { mainCanvas = Studio.Studio.Instance.gameObject.transform.Find("Canvas Main Menu"); listFemale = mainCanvas.Find("01_Add/00_Female").gameObject.GetComponent <CharaList>(); listMale = mainCanvas.Find("01_Add/01_Male").gameObject.GetComponent <CharaList>(); }