private static IEnumerable <CodeInstruction> Transpiler1(IEnumerable <CodeInstruction> instructions) { IEnumerable <CodeInstruction> custominstruc = new CodeMatcher(instructions) .MatchForward(false, new CodeMatch(OpCodes.Ldarg_0), new CodeMatch(OpCodes.Ldarg_0), new CodeMatch(l => l.opcode == OpCodes.Call && l.Calls(AccessTools.Method(typeof(SceneEdit), "InitMenuNative")))) .SetAndAdvance(OpCodes.Nop, null) .SetAndAdvance(OpCodes.Nop, null) .SetAndAdvance(OpCodes.Nop, null) .SetAndAdvance(OpCodes.Nop, null) .SetAndAdvance(OpCodes.Nop, null) .Insert( new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Ldarg_0), Transpilers.EmitDelegate <Action <SceneEdit> >((lthis) => { @this = lthis; Main.logger.LogDebug("Calling your modified CoRoutine"); @this.StartCoroutine(InitMenuNative()); }), new CodeInstruction(OpCodes.Pop) ) .InstructionEnumeration(); return(custominstruc); }
private static void GetInstance(ref SceneEdit __instance) { WatchOverall.Reset(); WatchOverall.Start(); @this = __instance; }
public static void ManMenuAdd(PhotoManEditManager self) { if (ManMenuAdd_run) { return; } ManMenuAdd_run = true; FieldInfo menu_file_name_list_ = typeof(PhotoManEditManager).GetField("menu_file_name_list_", BindingFlags.Static | BindingFlags.NonPublic); HashSet <string> menu_filename_list_val = (HashSet <string>)menu_file_name_list_.GetValue(null); FieldInfo man_body_menu_list_self = self.GetType().GetField("man_body_menu_list_", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo man_head_menu_list_self = self.GetType().GetField("man_head_menu_list_", BindingFlags.NonPublic | BindingFlags.Instance); HashSet <string> menu_list = new HashSet <string>(); List <SceneEdit.SMenuItem> head_list = new List <SceneEdit.SMenuItem>(); List <SceneEdit.SMenuItem> body_list = new List <SceneEdit.SMenuItem>(); MPN body = (MPN)Enum.Parse(typeof(MPN), "body"); foreach (string filename in GameUty.ModOnlysMenuFiles) { if (filename.Contains("mhead") || filename.Contains("mbody")) { menu_list.Add(filename); } } Debug.Log($"menu list pre union{ menu_list}"); if (menu_filename_list_val != null) { menu_list.UnionWith(menu_filename_list_val); } Debug.Log($"menu list post union{ menu_list}"); foreach (string filename in menu_list) { SceneEdit.SMenuItem smenuItem = new SceneEdit.SMenuItem(); if (SceneEdit.GetMenuItemSetUP(smenuItem, filename, true)) { if (smenuItem.m_mpn == body) { body_list.Add(smenuItem); } else { head_list.Add(smenuItem); } } } menu_file_name_list_.SetValue(null, menu_list); man_body_menu_list_self.SetValue(self, body_list); man_head_menu_list_self.SetValue(self, head_list); }
static private void SaveBuilding() { GameObject SceneEditor = GameObject.Find("SceneEditor"); SceneEdit edit = SceneEditor.GetComponent <SceneEdit>(); if (edit != null) { edit.SaveBuilding(); SceneEditor.transform.localPosition = new Vector3(SceneEditor.transform.localPosition.x + 1, SceneEditor.transform.localPosition.y, SceneEditor.transform.localPosition.z); } }
public void Update() { outputs.Clear(); outputs.Add(string.Format("Update")); SceneEdit sceneEdit = FindSceneEdit(); if (sceneEdit == null) { outputs.Add(string.Format("sceneEdit == null")); return; } PropSnapShot cur = CapturePropSnapShot(); if (!cur.Equals(prev)) { // マウス左ボタンがドラッグ中なら何もしない if (!Input.GetMouseButton(0)) { changeCount++; Log.WriteLine("--- : Record"); RecordHistory(); prev = PropSnapShot.Clone(cur); } } if (Input.GetKeyDown(KeyCode.Z)) { Log.WriteLine("^Z : Undo"); UndoHistory(); } if (Input.GetKeyDown(KeyCode.Y)) { Log.WriteLine("^Y : Redo"); RedoHistory(); } if (Input.GetKeyDown(KeyCode.C)) { tempShot = PropSnapShot.Clone(cur); } if (Input.GetKeyDown(KeyCode.V)) { StorePropSnapShot(tempShot); } outputs.Add(string.Format("historyCursor = {0}", history.historyCursor)); outputs.Add(string.Format("changeCount = {0}", changeCount)); }
void StorePropSnapShot(PropSnapShot s) { int maidNumber = 0; Maid maid = GameMain.Instance.CharacterMgr.GetMaid(maidNumber); if (maid == null) { return; } SceneEdit sceneEdit = FindSceneEdit(); if (sceneEdit == null) { return; } foreach (MPN mpn in Enum.GetValues(typeof(MPN))) { if (mpn == MPN.null_mpn) { continue; } try { MaidProp maidProp = s[mpn]; if (!string.IsNullOrEmpty(maidProp.strFileName)) { maid.SetProp(mpn, maidProp.strFileName, maidProp.nFileNameRID, false); } else { maid.SetProp(mpn, maidProp.value, false); } } catch (Exception) { } } foreach (KeyValuePair <MaidParts.PARTS_COLOR, MaidParts.PartsColor> kv in s.maidPartsColors) { maid.Parts.SetPartsColor(kv.Key, kv.Value); } // 値の更新 maid.AllProcProp(); sceneEdit.UpdateSliders(); }
void Update() { if (Application.loadedLevel != 5) { return; } if (editViewReset == null) { editViewReset = UnityEngine.Object.FindObjectOfType <EditViewReset>(); } if (sceneEdit == null) { sceneEdit = UnityEngine.Object.FindObjectOfType <SceneEdit>(); } if (editViewReset != null && sceneEdit != null) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); if (bLevelWasLoaded) { bLevelWasLoaded = false; LoadSettings(maid); } // UICamera.InputEnable が False になるとサムネール撮影用のために着衣状態になる TBody tbody = maid == null ? null : maid.body0; if (tbody != null && fieldInfo_TBody_m_eMaskMode != null && UICamera.InputEnable) { lastMaid = maid; bLastAutoCam = editViewReset.GetVisibleAutoCam(); bLastEyeToCam = editViewReset.GetVisibleEyeToCam(); lastBgName = GameMain.Instance.BgMgr.GetBGName(); lastClothMaskMode = (TBody.MaskMode)fieldInfo_TBody_m_eMaskMode.GetValue(tbody); lastPoseName = tbody.LastAnimeFN; lastCameraPos = mainCamera.GetPos(); lastCameraTargetPos = mainCamera.GetTargetPos(); lastCameraDistance = mainCamera.GetDistance(); lastCameraRotation = Camera.main.gameObject.transform.rotation; lastCameraFov = Camera.main.fieldOfView; } } }
private static void SetMaidPreset(Maid m_maid, string file) { if (m_maid == null) { //MyLog.LogWarning("SetMaidPreset maid null"); return; } if (m_maid.IsBusy) { if (configEntryUtill["SetMaidPreset", false]) { MyLog.LogDebug("RandPreset Maid Is Busy"); } return; } if (configEntryUtill["SetMaidPreset", false]) { MyLog.LogDebug("SetMaidPreset select :" + file); } CharacterMgr.Preset preset = GameMain.Instance.CharacterMgr.PresetLoad(file); //Main.CustomPresetDirectory = Path.GetDirectoryName(file); //UnityEngine.Debug.Log("RandPreset preset path "+ GameMain.Instance.CharacterMgr.PresetDirectory); //preset.strFileName = file; if (preset == null) { if (configEntryUtill["SetMaidPreset", false]) { MyLog.LogDebug("SetMaidPreset preset null "); } return; } GameMain.Instance.CharacterMgr.PresetSet(m_maid, preset); if (Product.isPublic) { SceneEdit.AllProcPropSeqStart(m_maid); } }
void Update() { if (Application.loadedLevel != 5) { return; } if (editViewReset == null) { editViewReset = UnityEngine.Object.FindObjectOfType<EditViewReset>(); } if (sceneEdit == null) { sceneEdit = UnityEngine.Object.FindObjectOfType<SceneEdit>(); } if (editViewReset != null && sceneEdit != null) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); if (bLevelWasLoaded) { bLevelWasLoaded = false; LoadSettings(maid); } // UICamera.InputEnable が False になるとサムネール撮影用のために着衣状態になる TBody tbody = maid == null ? null : maid.body0; if (tbody != null && fieldInfo_TBody_m_eMaskMode != null && UICamera.InputEnable) { lastMaid = maid; bLastAutoCam = editViewReset.GetVisibleAutoCam(); bLastEyeToCam = editViewReset.GetVisibleEyeToCam(); lastBgName = GameMain.Instance.BgMgr.GetBGName(); lastClothMaskMode = (TBody.MaskMode)fieldInfo_TBody_m_eMaskMode.GetValue(tbody); lastPoseName = tbody.LastAnimeFN; lastCameraPos = mainCamera.GetPos(); lastCameraTargetPos = mainCamera.GetTargetPos(); lastCameraDistance = mainCamera.GetDistance(); lastCameraRotation = Camera.main.gameObject.transform.rotation; lastCameraFov = Camera.main.fieldOfView; } } }
private static IEnumerator InitMenuNative() { while (GameMain.Instance.CharacterMgr.IsBusy()) { yield return(null); } MenuDataBase menuDataBase = GameMain.Instance.MenuDataBase; while (!menuDataBase.JobFinished()) { yield return(null); } Stopwatch watch1 = new Stopwatch(); Debug.Log("Vanilla menu file load has now begun."); watch1.Start(); AccessTools.Method(typeof(SceneEdit), "InitCategoryList").Invoke(@this, null); int fileCount = menuDataBase.GetDataSize(); List <SceneEdit.SMenuItem> menuList = new List <SceneEdit.SMenuItem>(fileCount); @this.m_menuRidDic = new Dictionary <int, SceneEdit.SMenuItem>(fileCount); Dictionary <int, List <int> > menuGroupMemberDic = new Dictionary <int, List <int> >(); float time = Time.realtimeSinceStartup; for (int i = 0; i < fileCount; i++) { menuDataBase.SetIndex(i); string fileName = menuDataBase.GetMenuFileName(); string parent_filename = menuDataBase.GetParentMenuFileName(); if (GameMain.Instance.CharacterMgr.status.IsHavePartsItem(fileName)) { SceneEdit.SMenuItem mi = new SceneEdit.SMenuItem(); mi.m_strMenuFileName = fileName; mi.m_nMenuFileRID = fileName.GetHashCode(); try { SceneEdit.ReadMenuItemDataFromNative(mi, i); } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "ReadMenuItemDataFromNative 例外/", fileName, "/", ex.Message, " StackTrace/", ex.StackTrace })); } if (!mi.m_bMan && @this.editItemTextureCache.IsRegister(mi.m_nMenuFileRID)) { AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi }); menuList.Add(mi); if ([email protected]_menuRidDic.ContainsKey(mi.m_nMenuFileRID)) { @this.m_menuRidDic.Add(mi.m_nMenuFileRID, mi); } string parentMenuName = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi }) as string; if (!string.IsNullOrEmpty(parentMenuName)) { int hashCode = parentMenuName.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode)) { menuGroupMemberDic.Add(hashCode, new List <int>()); } menuGroupMemberDic[hashCode].Add(mi.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi.m_strCateName.IndexOf("set_") != -1 && mi.m_strMenuFileName.IndexOf("_del") == -1) { mi.m_bGroupLeader = true; mi.m_listMember = new List <SceneEdit.SMenuItem>(); mi.m_listMember.Add(mi); } if (0.5f < Time.realtimeSinceStartup - time) { yield return(null); time = Time.realtimeSinceStartup; } } } } foreach (string strFileName in GameUty.ModOnlysMenuFiles) { SceneEdit.SMenuItem mi2 = new SceneEdit.SMenuItem(); if (SceneEdit.GetMenuItemSetUP(mi2, strFileName, false)) { if (!mi2.m_bMan && !(mi2.m_texIconRef == null)) { AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi2 }); menuList.Add(mi2); if ([email protected]_menuRidDic.ContainsKey(mi2.m_nMenuFileRID)) { @this.m_menuRidDic.Add(mi2.m_nMenuFileRID, mi2); } string parentMenuName2 = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi2 }) as string; if (!string.IsNullOrEmpty(parentMenuName2)) { int hashCode2 = parentMenuName2.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode2)) { menuGroupMemberDic.Add(hashCode2, new List <int>()); } menuGroupMemberDic[hashCode2].Add(mi2.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi2.m_strCateName.IndexOf("set_") != -1 && mi2.m_strMenuFileName.IndexOf("_del") == -1) { mi2.m_bGroupLeader = true; mi2.m_listMember = new List <SceneEdit.SMenuItem>(); mi2.m_listMember.Add(mi2); } if (0.5f < Time.realtimeSinceStartup - time) { yield return(null); time = Time.realtimeSinceStartup; } } } } yield return(@this.StartCoroutine(AccessTools.Method(typeof(SceneEdit), "FixedInitMenu").Invoke(@this, new object[] { menuList, @this.m_menuRidDic, menuGroupMemberDic }) as IEnumerator)); yield return(@this.StartCoroutine(AccessTools.Method(typeof(SceneEdit), "CoLoadWait").Invoke(@this, null) as IEnumerator)); watch1.Stop(); Debug.LogError($"Vanilla menu file load finished in: {watch1.Elapsed}"); yield break; }
public bool slidersAllowed = false; //Prevents SetInfo from changing the actual light states public void InitSceneInfo() //This should probably be a lot shorter. Break down into smaller/reusable bits. { slidersAllowed = false; int i = 1; //Set slider data foreach (string lightLabel in Storage.groupData.lights) { if (i <= 5) { string labelName = String.Format("SliderName{0}", i); string briSliderName = String.Format("BriSlider{0}", i); string hueSliderName = String.Format("HueSlider{0}", i); string satSliderName = String.Format("SatSlider{0}", i); System.Windows.Controls.Label nameRef = (System.Windows.Controls.Label) this.FindName(labelName); Slider sliderRef = (Slider)this.FindName(briSliderName); Slider sliderRef2 = (Slider)this.FindName(hueSliderName); Slider sliderRef3 = (Slider)this.FindName(satSliderName); LightProperty.SetLightSource(nameRef, lightLabel); LightProperty.SetLightSource(sliderRef, lightLabel); LightProperty.SetLightSource(sliderRef2, lightLabel); LightProperty.SetLightSource(sliderRef3, lightLabel); nameRef.Content = JsonParser.Read(Storage.latestData, new string[] { "lights", lightLabel, "name" }); sliderRef.Value = JsonParser.Read(Storage.latestData, new string[] { "lights", lightLabel, "state", "bri" }); sliderRef2.Value = JsonParser.Read(Storage.latestData, new string[] { "lights", lightLabel, "state", "hue" }); sliderRef3.Value = JsonParser.Read(Storage.latestData, new string[] { "lights", lightLabel, "state", "sat" }); if (JsonParser.Read(Storage.latestData, new string[] { "lights", lightLabel, "state", "on" }) == true && !Effects.effectsOn) { sliderRef.IsEnabled = true; sliderRef.Opacity = 0.85; sliderRef2.IsEnabled = true; sliderRef2.Opacity = 0.85; sliderRef3.IsEnabled = true; sliderRef3.Opacity = 0.85; } i++; } } //Set current scene this.SceneCombo.Items.Add(new ComboItem("New scene", "")); this.SceneCombo.SelectedIndex = 0; i = 1; foreach (dynamic scene in Storage.sceneData) { this.SceneCombo.Items.Add(new ComboItem(JsonParser.Read(Storage.sceneData, new string[] { scene.Key, "name" }), scene.Key)); if (SceneEdit.IsSceneMatch(scene.Key)) { this.SceneCombo.SelectedIndex = i; } i++; } //Populate group settings this.GroupCombo.Items.Clear(); this.GroupCombo.Items.Add(new ComboItem("All lights", "0")); this.GroupCombo.SelectedIndex = 0; i = 1; foreach (dynamic group in Storage.latestData.groups) { this.GroupCombo.Items.Add(new ComboItem(JsonParser.Read(Storage.latestData, new string[] { "groups", group.Key, "name" }), group.Key)); if (group.Key == Properties.Settings.Default.bridgeGroup) { this.GroupCombo.SelectedIndex = i; } i++; } //Populate light dropdowns for (int n = 1; n <= 5; n++) { string comboName = String.Format("GroupLight{0}", n); ComboBox comboRef = (ComboBox)this.FindName(comboName); if (n != 1) { comboRef.Items.Add(new ComboItem("None", "")); } foreach (dynamic light in Storage.latestData.lights) { string jsonName = JsonParser.Read(light.Value, new string[] { "name" }); string jsonModel = JsonParser.Read(light.Value, new string[] { "modelid" }); string friendlyModel = "Unknown light type"; if (jsonModel.Contains("LCT")) { friendlyModel = "hue"; } else if (jsonModel.Contains("LLC")) { friendlyModel = "LivingColors"; } else if (jsonModel.Contains("LWB")) { friendlyModel = "hue lux"; } else if (jsonModel.Contains("LWL")) { friendlyModel = "LivingWhites"; } else if (jsonModel.Contains("LST")) { friendlyModel = "LightStrips"; } string name = String.Format("{0} ({1})", jsonName, friendlyModel); comboRef.Items.Add(new ComboItem(name, light.Key)); if (Storage.groupData.lights.Length >= n) { if (Storage.groupData.lights[n - 1] == light.Key) { comboRef.SelectedIndex = comboRef.Items.Count - 1; } } } if (comboRef.SelectedIndex == -1) { comboRef.SelectedIndex = 0; } } //Populate auto-effect dropdown DefaultCombo.Items.Add(new ComboItem("None", "", 0)); DefaultCombo.SelectedIndex = 0; i = 1; DefaultCombo.Items.Add(new ComboItem("Ambient mode", "ambient", 1)); if (Properties.Settings.Default.autoEffect == 1) //There's probably a cleaner way to handle this. { if (Properties.Settings.Default.autoName == "ambient") { DefaultCombo.SelectedIndex = i; } } i++; DefaultCombo.Items.Add(new ComboItem("Daylight mode", "daylight", 1)); if (Properties.Settings.Default.autoEffect == 1) { if (Properties.Settings.Default.autoName == "daylight") { DefaultCombo.SelectedIndex = i; } } i++; foreach (dynamic scene in Storage.defaultScenes) { DefaultCombo.Items.Add(new ComboItem(JsonParser.Read(Storage.defaultScenes, new string[] { scene.Key, "name" }), scene.Key, -2)); if (Properties.Settings.Default.autoEffect == -2) { if (scene.Key == Properties.Settings.Default.autoName) { DefaultCombo.SelectedIndex = i; } } i++; } foreach (dynamic scene in Storage.sceneData) { DefaultCombo.Items.Add(new ComboItem(JsonParser.Read(Storage.sceneData, new string[] { scene.Key, "name" }), scene.Key, -1)); if (Properties.Settings.Default.autoEffect == -1) { if (scene.Key == Properties.Settings.Default.autoName) { DefaultCombo.SelectedIndex = i; } } i++; } //Populate various app setting dropdowns int sunrise = SunriseEquation.JulianToTime(SunriseEquation.sunrise); int sunset = SunriseEquation.JulianToTime(SunriseEquation.sunset); string regional = String.Format( "Regional (sunrise at {0}:{1}, sunset at {2}:{3})", (sunrise / 60).ToString("D2"), (sunrise % 60).ToString("D2"), (sunset / 60).ToString("D2"), (sunset % 60).ToString("D2")); AppCombo2.Items.Add(regional); AppCombo2.Items.Add("Equinox (sunrise at 06:00, sunset at 18:00)"); sunrise = SunriseEquation.JulianToTime(SunriseEquation.startup); sunset = SunriseEquation.JulianToTime(SunriseEquation.startup + 0.5); string startup = String.Format( "Startup (sunrise at {0}:{1}, sunset at {2}:{3})", (sunrise / 60).ToString("D2"), (sunrise % 60).ToString("D2"), (sunset / 60).ToString("D2"), (sunset % 60).ToString("D2")); AppCombo2.Items.Add(startup); AppCombo2.SelectedIndex = Albedo.Properties.Settings.Default.daylightSetting; if (Albedo.Properties.Settings.Default.ambientTransition == 80) { AppCombo1.SelectedIndex = 0; } else if (Albedo.Properties.Settings.Default.ambientTransition == 40) { AppCombo1.SelectedIndex = 1; } else if (Albedo.Properties.Settings.Default.ambientTransition == 10) { AppCombo1.SelectedIndex = 2; } slidersAllowed = true; }
static void GetInstance(ref SceneEdit __instance) { @this = __instance; }
public static IEnumerator test2() { Stopwatch test = new Stopwatch(); Debug.LogError("Coroutine was successfully engaged!"); while (GameMain.Instance.CharacterMgr.IsBusy()) { yield return(null); } MenuDataBase menuDataBase = GameMain.Instance.MenuDataBase; while (!menuDataBase.JobFinished()) { yield return(null); } test.Start(); Debug.LogError("Reaching first access method."); AccessTools.Method(typeof(SceneEdit), "InitCategoryList").Invoke(@this, null); //@this.InitCategoryList(); int fileCount = menuDataBase.GetDataSize(); ConcurrentQueue <SceneEdit.SMenuItem> menuList = new ConcurrentQueue <SceneEdit.SMenuItem>(); @this.m_menuRidDic = new Dictionary <int, SceneEdit.SMenuItem>(fileCount); var menuRidDicThreadSafe = new ConcurrentDictionary <int, SceneEdit.SMenuItem>(@this.m_menuRidDic); ConcurrentDictionary <int, ConcurrentQueue <int> > menuGroupMemberDic = new ConcurrentDictionary <int, ConcurrentQueue <int> >(); float time = Time.realtimeSinceStartup; for (int i = 0; i < fileCount; i++) { menuDataBase.SetIndex(i); string fileName = menuDataBase.GetMenuFileName(); string parent_filename = menuDataBase.GetParentMenuFileName(); if (GameMain.Instance.CharacterMgr.status.IsHavePartsItem(fileName)) { SceneEdit.SMenuItem mi = new SceneEdit.SMenuItem(); mi.m_strMenuFileName = fileName; mi.m_nMenuFileRID = fileName.GetHashCode(); try { SceneEdit.ReadMenuItemDataFromNative(mi, i); } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "ReadMenuItemDataFromNative 例外/", fileName, "/", ex.Message, " StackTrace/", ex.StackTrace })); } if (!mi.m_bMan && @this.editItemTextureCache.IsRegister(mi.m_nMenuFileRID)) { AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi }); //@this.AddMenuItemToList(mi); menuList.Enqueue(mi); if (!menuRidDicThreadSafe.ContainsKey(mi.m_nMenuFileRID)) { menuRidDicThreadSafe[mi.m_nMenuFileRID] = mi; } string parentMenuName = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi }) as string; //string parentMenuName = SceneEdit.GetParentMenuFileName(mi); if (!string.IsNullOrEmpty(parentMenuName)) { int hashCode = parentMenuName.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode)) { menuGroupMemberDic[hashCode] = new ConcurrentQueue <int>(); } menuGroupMemberDic[hashCode].Enqueue(mi.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi.m_strCateName.IndexOf("set_") != -1 && mi.m_strMenuFileName.IndexOf("_del") == -1) { mi.m_bGroupLeader = true; mi.m_listMember = new List <SceneEdit.SMenuItem>(); mi.m_listMember.Add(mi); } if (0.5f < Time.realtimeSinceStartup - time) { yield return(null); time = Time.realtimeSinceStartup; } } } } Debug.LogError($"Reaching the load ForEach at {test.Elapsed}."); //Parallel.ForEach(GameUty.ModOnlysMenuFiles, (strFileName) => Task.Factory.StartNew(new Action(() => { foreach (string strFileName in GameUty.ModOnlysMenuFiles) { Stopwatch test2 = new Stopwatch(); test2.Start(); //Debug.LogError("Invoking GetMenuItemSetUP"); SceneEdit.SMenuItem mi2 = new SceneEdit.SMenuItem(); if (Main.GetMenuItemSetUP(mi2, strFileName, out string IconTex, false)) { //Debug.LogError("Managed to setup menu item correctly. Adding to list to continue processing..."); ListOfIconLoads[mi2] = IconTex; } //Thread.Sleep(100); Debug.LogError("Finished One GetMenuItemSetUP in " + test2.Elapsed); } } //); )).Wait(); Debug.LogError($"We've finished SceneEdit.SMenuItem {test.Elapsed}"); SetupDone = true; while (IconLoadDone != true) { yield return(null); } Debug.LogError($"Now we've finished loading icons into each menu at {test.Elapsed}."); //Parallel.ForEach(ListOfContinues, (mi2) => foreach (SceneEdit.SMenuItem mi2 in ListOfContinues) { Stopwatch test2 = new Stopwatch(); if (!mi2.m_bMan && !(mi2.m_texIconRef == null)) { test2.Start(); //Debug.LogError("Invoking addmenuitemtolist"); AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi2 }); //@this.AddMenuItemToList(mi2); //Debug.LogError($"Done invoking AddMenuItemToList at: {test2.Elapsed}"); if (!menuRidDicThreadSafe.ContainsKey(mi2.m_nMenuFileRID)) { menuRidDicThreadSafe[mi2.m_nMenuFileRID] = mi2; } //Debug.LogError("Invoking GetParentMenuFileName"); string parentMenuName2 = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi2 }) as string; //string parentMenuName2 = SceneEdit.GetParentMenuFileName(mi2); //Debug.LogError($"Done Invoking GetParentMenuFileName at: {test2.Elapsed}"); if (!string.IsNullOrEmpty(parentMenuName2)) { int hashCode2 = parentMenuName2.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode2)) { menuGroupMemberDic[hashCode2] = new ConcurrentQueue <int>(); } menuGroupMemberDic[hashCode2].Enqueue(mi2.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi2.m_strCateName.IndexOf("set_") != -1 && mi2.m_strMenuFileName.IndexOf("_del") == -1) { mi2.m_bGroupLeader = true; mi2.m_listMember = new List <SceneEdit.SMenuItem>(); mi2.m_listMember.Add(mi2); } /* * if (true || 0.5f < Time.realtimeSinceStartup - time) * { * //yield return null; * Debug.LogError($"Sleeping thread, 100ms..."); * //Thread.Sleep(20); * time = Time.realtimeSinceStartup; * }*/ Debug.LogError($"Finished processing one menu file in {test2.Elapsed}"); } } //); Debug.LogError($"Finished previous foreach at {test.Elapsed}\nInvoking coroutines..."); SetupDone = true; //@this.m_menuRidDic = menuRidDicThreadSafe //.ToDictionary(t => t.Key, t => t.Value); Debug.LogError($"Converted Dictionary back..."); //yield return @this.StartCoroutine(@this.CoLoadWait()); yield return(@this.StartCoroutine(AccessTools.Method(typeof(SceneEdit), "CoLoadWait").Invoke(@this, null) as IEnumerator)); Debug.LogError($"Starting problematic coroutine."); //yield return @this.StartCoroutine(@this.FixedInitMenu(menuList, @this.m_menuRidDic, menuGroupMemberDic)); yield return(@this.StartCoroutine(AccessTools.Method(typeof(SceneEdit), "FixedInitMenu").Invoke(@this, new object[] { menuList, menuRidDicThreadSafe, menuGroupMemberDic }) as IEnumerator)); test.Stop(); Debug.LogError($"Done {test.Elapsed}"); yield break; }
void Update() { if (Application.loadedLevel != 5) { return; } if (editViewReset == null) { editViewReset = UnityEngine.Object.FindObjectOfType<EditViewReset>(); } if (sceneEdit == null) { sceneEdit = UnityEngine.Object.FindObjectOfType<SceneEdit>(); } { string gridName = "/UI Root/PresetButtonPanel/ItemPresetsViewer/Scroll View/Grid"; GameObject goGrid = GameObject.Find(gridName); if (goGrid != null) { if (poseButtonCallback == null) { poseButtonCallback = new EventDelegate.Callback(ClickPoseCallback); } foreach (Transform t in goGrid.transform) { if (!t.name.StartsWith("Pose_")) { continue; } GameObject go = t.gameObject; UIButton uiButton = go.GetComponent<UIButton>(); EventDelegate.Add(uiButton.onClick, poseButtonCallback); } } } if (editViewReset != null && sceneEdit != null) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); if (bLevelWasLoaded) { bLevelWasLoaded = false; LoadSettings(maid); } // UICamera.InputEnable が False になるとサムネール撮影用のために着衣状態になる TBody tbody = maid == null ? null : maid.body0; if (tbody != null && fieldInfo_TBody_m_eMaskMode != null && UICamera.InputEnable) { lastMaid = maid; bLastAutoCam = editViewReset.GetVisibleAutoCam(); bLastEyeToCam = editViewReset.GetVisibleEyeToCam(); lastBgName = GameMain.Instance.BgMgr.GetBGName(); lastClothMaskMode = (TBody.MaskMode)fieldInfo_TBody_m_eMaskMode.GetValue(tbody); lastCameraPos = mainCamera.GetPos(); lastCameraTargetPos = mainCamera.GetTargetPos(); lastCameraDistance = mainCamera.GetDistance(); lastCameraRotation = Camera.main.gameObject.transform.rotation; lastCameraFov = Camera.main.fieldOfView; } } }
public static void test2() { Main.logger.LogError("Coroutine was successfully engaged!"); while (GameMain.Instance.CharacterMgr.IsBusy()) { Thread.Sleep(20); //yield return null; } MenuDataBase menuDataBase = GameMain.Instance.MenuDataBase; while (!menuDataBase.JobFinished()) { Thread.Sleep(20); //yield return null; } test.Start(); Main.logger.LogError("Reaching first access method."); AccessTools.Method(typeof(SceneEdit), "InitCategoryList").Invoke(@this, null); //@this.InitCategoryList(); int fileCount = menuDataBase.GetDataSize(); List <SceneEdit.SMenuItem> menuList = new List <SceneEdit.SMenuItem>(); @this.m_menuRidDic = new Dictionary <int, SceneEdit.SMenuItem>(fileCount); Dictionary <int, List <int> > menuGroupMemberDic = new Dictionary <int, List <int> >(); float time = Time.realtimeSinceStartup; for (int i = 0; i < fileCount; i++) { menuDataBase.SetIndex(i); string fileName = menuDataBase.GetMenuFileName(); string parent_filename = menuDataBase.GetParentMenuFileName(); if (GameMain.Instance.CharacterMgr.status.IsHavePartsItem(fileName)) { SceneEdit.SMenuItem mi = new SceneEdit.SMenuItem(); mi.m_strMenuFileName = fileName; mi.m_nMenuFileRID = fileName.GetHashCode(); try { SceneEdit.ReadMenuItemDataFromNative(mi, i); } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "ReadMenuItemDataFromNative 例外/", fileName, "/", ex.Message, " StackTrace/", ex.StackTrace })); } if (!mi.m_bMan && @this.editItemTextureCache.IsRegister(mi.m_nMenuFileRID)) { AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi }); //@this.AddMenuItemToList(mi); menuList.Add(mi); if ([email protected]_menuRidDic.ContainsKey(mi.m_nMenuFileRID)) { @this.m_menuRidDic.Add(mi.m_nMenuFileRID, mi); } string parentMenuName = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi }) as string; //string parentMenuName = SceneEdit.GetParentMenuFileName(mi); if (!string.IsNullOrEmpty(parentMenuName)) { int hashCode = parentMenuName.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode)) { menuGroupMemberDic.Add(hashCode, new List <int>()); } menuGroupMemberDic[hashCode].Add(mi.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi.m_strCateName.IndexOf("set_") != -1 && mi.m_strMenuFileName.IndexOf("_del") == -1) { mi.m_bGroupLeader = true; mi.m_listMember = new List <SceneEdit.SMenuItem>(); mi.m_listMember.Add(mi); } if (0.5f < Time.realtimeSinceStartup - time) { //yield return null; time = Time.realtimeSinceStartup; } } } } //Parallel.ForEach(GameUty.ModOnlysMenuFiles, (strFileName) => foreach (string strFileName in GameUty.ModOnlysMenuFiles) { Stopwatch test2 = new Stopwatch(); test2.Start(); Main.logger.LogError("Invoking GetMenuItemSetUP"); SceneEdit.SMenuItem mi2 = new SceneEdit.SMenuItem(); if (Main.GetMenuItemSetUP(mi2, strFileName, out string IconTex, false)) { Main.logger.LogError("Managed to setup menu item correctly. Adding to list to continue processing..."); ListOfContinues[mi2] = IconTex; } //Thread.Sleep(100); Main.logger.LogError("Finished GetMenuItemSetUP: " + test2.Elapsed); } //); //@this2.StartCoroutine(SetupTexturesCoRoutine(menuList, menuGroupMemberDic)); SavedmenuList = menuList; SavedmenuGroupMemberDic = menuGroupMemberDic; Test2Done = true; }
public static IEnumerator InitialBackgroundWorker() { Debug.LogError("Coroutine was successfully engaged!"); while (GameMain.Instance.CharacterMgr.IsBusy()) { yield return(null); //Thread.Sleep(20); } MenuDataBase menuDataBase = GameMain.Instance.MenuDataBase; while (!menuDataBase.JobFinished()) { //Thread.Sleep(20); yield return(null); } test.Start(); Debug.LogError("Reaching first access method."); AccessTools.Method(typeof(SceneEdit), "InitCategoryList").Invoke(@this, null); //@this.InitCategoryList(); int fileCount = menuDataBase.GetDataSize(); var menuList = new HashSet <SceneEdit.SMenuItem>(); @this.m_menuRidDic = new Dictionary <int, SceneEdit.SMenuItem>(fileCount); var menuRidDicThreadSafe = @this.m_menuRidDic; var menuGroupMemberDic = new Dictionary <int, HashSet <int> >(); float time = Time.realtimeSinceStartup; for (int i = 0; i < fileCount; i++) { menuDataBase.SetIndex(i); string fileName = menuDataBase.GetMenuFileName(); string parent_filename = menuDataBase.GetParentMenuFileName(); if (GameMain.Instance.CharacterMgr.status.IsHavePartsItem(fileName)) { SceneEdit.SMenuItem mi = new SceneEdit.SMenuItem(); mi.m_strMenuFileName = fileName; mi.m_nMenuFileRID = fileName.GetHashCode(); try { SceneEdit.ReadMenuItemDataFromNative(mi, i); } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "ReadMenuItemDataFromNative 例外/", fileName, "/", ex.Message, " StackTrace/", ex.StackTrace })); } if (!mi.m_bMan && @this.editItemTextureCache.IsRegister(mi.m_nMenuFileRID)) { AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi }); //@this.AddMenuItemToList(mi); menuList.Add(mi); menuRidDicThreadSafe[mi.m_nMenuFileRID] = mi; string parentMenuName = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi }) as string; //string parentMenuName = SceneEdit.GetParentMenuFileName(mi); if (!string.IsNullOrEmpty(parentMenuName)) { int hashCode = parentMenuName.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode)) { menuGroupMemberDic[hashCode] = new HashSet <int>(); } menuGroupMemberDic[hashCode].Add(mi.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi.m_strCateName.IndexOf("set_") != -1 && mi.m_strMenuFileName.IndexOf("_del") == -1) { mi.m_bGroupLeader = true; mi.m_listMember = new List <SceneEdit.SMenuItem>(); mi.m_listMember.Add(mi); } if (0.5f < Time.realtimeSinceStartup - time) { //Thread.Sleep(20); yield return(null); time = Time.realtimeSinceStartup; } } } } Debug.LogError($"Reaching the load ForEach at {test.Elapsed}."); Stopwatch test2 = new Stopwatch(); foreach (string strFileName in GameUty.ModOnlysMenuFiles) { test2.Reset(); test2.Start(); SceneEdit.SMenuItem mi2 = new SceneEdit.SMenuItem(); if (Main.GetMenuItemSetUP(mi2, strFileName, out string iconTex, false)) { ListOfIconLoads[mi2] = iconTex; } Debug.LogError("Finished One GetMenuItemSetUP in " + test2.Elapsed); } Debug.LogError($"We've finished SceneEdit.SMenuItem {test.Elapsed}"); /* * SetupDone = true; * * while (IconLoadDone == false) * { * yield return null; * }*/ //foreach (KeyValuePair<SceneEdit.SMenuItem, string> keyPair in ListOfIconLoads) while (ListOfIconLoads.Count > 0) { var keyPair = ListOfIconLoads.FirstOrDefault(); if (keyPair.Key == null || keyPair.Value == null) { ListOfIconLoads.Remove(keyPair.Key); continue; } //Debug.LogError("Icon Coroutine is loading an icon..."); try { keyPair.Key.m_texIcon = ImportCM.CreateTexture(keyPair.Value); } catch { //ListOfIconLoads.Remove(keyPair.Key); continue; } if (!(keyPair.Key.m_texIconRef == null)) { ListOfContinues.Add(keyPair.Key); } ListOfIconLoads.Remove(keyPair.Key); } Debug.LogError($"Now we've finished loading icons into each menu at {test.Elapsed}."); //Parallel.ForEach(ListOfContinues, (mi2) => //foreach (SceneEdit.SMenuItem mi2 in ListOfContinues) while (ListOfContinues.Count > 0) { var mi2 = ListOfContinues.FirstOrDefault(); if (mi2 == null) { continue; } test2.Reset(); if (!mi2.m_bMan) { test2.Start(); //Debug.LogError("Invoking addmenuitemtolist"); AccessTools.Method(typeof(SceneEdit), "AddMenuItemToList").Invoke(@this, new object[] { mi2 }); //@this.AddMenuItemToList(mi2); //Debug.LogError($"Done invoking AddMenuItemToList at: {test2.Elapsed}"); menuRidDicThreadSafe[mi2.m_nMenuFileRID] = mi2; //Debug.LogError("Invoking GetParentMenuFileName"); string parentMenuName2 = AccessTools.Method(typeof(SceneEdit), "GetParentMenuFileName").Invoke(@this, new object[] { mi2 }) as string; //string parentMenuName2 = SceneEdit.GetParentMenuFileName(mi2); //Debug.LogError($"Done Invoking GetParentMenuFileName at: {test2.Elapsed}"); if (!string.IsNullOrEmpty(parentMenuName2)) { int hashCode2 = parentMenuName2.GetHashCode(); if (!menuGroupMemberDic.ContainsKey(hashCode2)) { menuGroupMemberDic[hashCode2] = new HashSet <int>(); } menuGroupMemberDic[hashCode2].Add(mi2.m_strMenuFileName.ToLower().GetHashCode()); } else if (mi2.m_strCateName.IndexOf("set_") != -1 && mi2.m_strMenuFileName.IndexOf("_del") == -1) { mi2.m_bGroupLeader = true; mi2.m_listMember = new List <SceneEdit.SMenuItem>(); mi2.m_listMember.Add(mi2); } if (0.5f < Time.realtimeSinceStartup - time) { yield return(null); Debug.LogError($"Sleeping thread, 100ms..."); time = Time.realtimeSinceStartup; } Debug.LogError($"Finished processing one menu file in {test2.Elapsed}"); } ListOfContinues.Remove(mi2); } //); Debug.LogError($"Finished previous foreach at {test.Elapsed}\nInvoking coroutines..."); @this.m_menuRidDic = menuRidDicThreadSafe; //var localmenuRidDic = @this.m_menuRidDic; //var tempMenuList = menuList.ToList(); var tempGroupMemberDic = menuGroupMemberDic.ToDictionary(t => t.Key, t => t.Value.ToList()); Debug.LogError($"Converted Dictionary back..."); //yield return @this.StartCoroutine(@this.CoLoadWait()); yield return(@this.StartCoroutine(AccessTools.Method(typeof(SceneEdit), "CoLoadWait").Invoke(@this, null) as IEnumerator)); Debug.LogError($"Starting problematic coroutine."); //yield return @this.StartCoroutine(@this.FixedInitMenu(menuList, @this.m_menuRidDic, menuGroupMemberDic)); yield return(@this.StartCoroutine(AccessTools.Method(typeof(SceneEdit), "FixedInitMenu").Invoke(@this, new object[] { menuList.ToList(), @this.m_menuRidDic, tempGroupMemberDic }) as IEnumerator)); test.Stop(); Debug.LogError($"Done, loaded {ListOfContinues.Count} menus in {test.Elapsed}"); ListOfContinues.Clear(); test.Reset(); yield break; } /*
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, bool f_bMan, out string IconTex) { var fetchedField = AccessTools.DeclaredField(typeof(SceneEdit), "m_byItemFileBuffer"); var fetchedVal = fetchedField.GetValue(@this) as byte[]; IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { using (AFileBase afileBase = GameUty.FileOpen(f_strMenuFileName, null)) { NDebug.Assert(afileBase.IsValid(), "メニューファイルが存在しません。 :" + f_strMenuFileName); if (fetchedVal == null) { fetchedVal = new byte[System.Math.Max(500000, afileBase.GetSize())]; } else if (fetchedVal.Length < afileBase.GetSize()) { fetchedVal = new byte[afileBase.GetSize()]; } afileBase.Read(ref fetchedVal, afileBase.GetSize()); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } BinaryReader binaryReader = new BinaryReader(new MemoryStream(fetchedVal), Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); int num = binaryReader.ReadInt32(); string path = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); string text3 = binaryReader.ReadString(); string text4 = binaryReader.ReadString(); long num2 = (long)binaryReader.ReadInt32(); int num3 = 0; string text5 = null; string text6 = string.Empty; string text7 = string.Empty; try { for (; ;) { int num4 = (int)binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); } catch { Main.logger.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Main.logger.LogError("err SaveItem \"" + text11); } if (text11 == null) { Main.logger.LogError("err SaveItem null=\"" + text11); } if (text11 != string.Empty) { } } else if (!(stringCom == "catno")) { if (stringCom == "additem") { num3++; } else if (stringCom == "unsetitem") { mi.m_boDelOnly = true; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; } } } } } } } } catch (Exception ex2) { Main.logger.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Main.logger.LogError("Error:"); } } binaryReader.Close(); return(true); }
void Update() { if (Application.loadedLevel != 5) { return; } if (editViewReset == null) { editViewReset = UnityEngine.Object.FindObjectOfType <EditViewReset>(); } if (sceneEdit == null) { sceneEdit = UnityEngine.Object.FindObjectOfType <SceneEdit>(); } { string gridName = "/UI Root/PresetButtonPanel/ItemPresetsViewer/Scroll View/Grid"; GameObject goGrid = GameObject.Find(gridName); if (goGrid != null) { if (poseButtonCallback == null) { poseButtonCallback = new EventDelegate.Callback(ClickPoseCallback); } foreach (Transform t in goGrid.transform) { if (!t.name.StartsWith("Pose_")) { continue; } GameObject go = t.gameObject; UIButton uiButton = go.GetComponent <UIButton>(); EventDelegate.Add(uiButton.onClick, poseButtonCallback); } } } if (editViewReset != null && sceneEdit != null) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); if (bLevelWasLoaded) { bLevelWasLoaded = false; LoadSettings(maid); } // UICamera.InputEnable が False になるとサムネール撮影用のために着衣状態になる TBody tbody = maid == null ? null : maid.body0; if (tbody != null && fieldInfo_TBody_m_eMaskMode != null && UICamera.InputEnable) { lastMaid = maid; bLastAutoCam = editViewReset.GetVisibleAutoCam(); bLastEyeToCam = editViewReset.GetVisibleEyeToCam(); lastBgName = GameMain.Instance.BgMgr.GetBGName(); lastClothMaskMode = (TBody.MaskMode)fieldInfo_TBody_m_eMaskMode.GetValue(tbody); lastCameraPos = mainCamera.GetPos(); lastCameraTargetPos = mainCamera.GetTargetPos(); lastCameraDistance = mainCamera.GetDistance(); lastCameraRotation = Camera.main.gameObject.transform.rotation; lastCameraFov = Camera.main.fieldOfView; } } }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, out string IconTex) { IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } if (MenuCache.ContainsKey(f_strMenuFileName)) { try { MenuStub tempStub = MenuCache[f_strMenuFileName]; if (tempStub.DateModified == File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName])) { if (tempStub.Name != null) { mi.m_strMenuName = tempStub.Name; } if (tempStub.Description != null) { mi.m_strInfo = tempStub.Description; } if (tempStub.Category != null) { mi.m_strCateName = tempStub.Category; mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), tempStub.Category); } else { mi.m_mpn = MPN.null_mpn; } if (tempStub.ColorSetMPN != null) { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), tempStub.ColorSetMPN); } if (tempStub.ColorSetMenu != null) { mi.m_strMenuNameInColorSet = tempStub.ColorSetMenu; } if (tempStub.MultiColorID == null) { mi.m_pcMultiColorID = MaidParts.PARTS_COLOR.NONE; } else if (tempStub.MultiColorID != null) { mi.m_pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), tempStub.MultiColorID); } mi.m_boDelOnly = tempStub.DelMenu; mi.m_fPriority = tempStub.Priority; mi.m_bMan = tempStub.ManMenu; IconTex = tempStub.Icon; return(true); } else { Main.logger.LogWarning($"A cache entry was found outdated. This should be automatically fixed and the cache reloaded."); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { $"Encountered an issue while trying to load menu {f_strMenuFileName} from cache. This should be automatically fixed and the cache reloaded.", "\n\n", ex.Message, "\n", ex.StackTrace })); } } try { if (FilesToRead[f_strMenuFileName] == null) { FilesToRead[f_strMenuFileName] = new MemoryStream(File.ReadAllBytes(FilesDictionary[f_strMenuFileName])); } } catch (Exception ex) { Main.logger.LogError(string.Concat(new string[] { "The following menu file could not be read! (メニューファイルがが読み込めませんでした。): ", f_strMenuFileName, "\n\n", ex.Message, "\n", ex.StackTrace })); return(false); } string text6 = string.Empty; string text7 = string.Empty; string path = ""; MenuStub cacheEntry = new MenuStub(); try { cacheEntry.DateModified = File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName]); BinaryReader binaryReader = new BinaryReader(FilesToRead[f_strMenuFileName], Encoding.UTF8); string text = binaryReader.ReadString(); if (text != "CM3D2_MENU") { Main.logger.LogError("ProcScriptBin (例外 : ヘッダーファイルが不正です。) The header indicates a file type that is not a menu file!" + text + " @ " + f_strMenuFileName); return(false); } binaryReader.ReadInt32(); path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadInt32(); string text5 = null; while (true) { int num4 = binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { if (stringList.Length > 1) { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; cacheEntry.Name = mi.m_strMenuName; } else { Main.logger.LogWarning("Menu file has no name and an empty description will be used instead." + " @ " + f_strMenuFileName); mi.m_strMenuName = ""; cacheEntry.Name = mi.m_strMenuName; } } else if (stringCom == "setumei") { if (stringList.Length > 1) { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); cacheEntry.Description = mi.m_strInfo; } else { Main.logger.LogWarning("Menu file has no description (setumei) and an empty description will be used instead." + " @ " + f_strMenuFileName); mi.m_strInfo = ""; cacheEntry.Description = mi.m_strInfo; } } else if (stringCom == "category") { if (stringList.Length > 1) { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; cacheEntry.Category = mi.m_strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); cacheEntry.Category = mi.m_mpn.ToString(); } catch { Main.logger.LogWarning("There is no category called (カテゴリがありません。): " + mi.m_strCateName + " @ " + f_strMenuFileName); return(false); } } else { Main.logger.LogWarning("The following menu file has a category parent with no category: " + f_strMenuFileName); return(false); } } else if (stringCom == "color_set") { if (stringList.Length > 1) { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); cacheEntry.ColorSetMPN = mi.m_eColorSetMPN.ToString(); } catch { Main.logger.LogWarning("There is no category called(カテゴリがありません。): " + mi.m_strCateName + " @ " + f_strMenuFileName); return(false); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); cacheEntry.ColorSetMenu = mi.m_strMenuNameInColorSet; } } else { Main.logger.LogWarning("A color_set entry exists but is otherwise empty" + " @ " + f_strMenuFileName); } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { Main.logger.LogError("無限色IDがありません。(The following free color ID does not exist: )" + text10 + " @ " + f_strMenuFileName); return(false); } mi.m_pcMultiColorID = pcMultiColorID; cacheEntry.MultiColorID = mi.m_pcMultiColorID.ToString(); } } else if (stringCom == "icon" || stringCom == "icons") { if (stringList.Length > 1) { text5 = stringList[1]; } else { Main.logger.LogError("The following menu file has an icon entry but no field set: " + f_strMenuFileName); return(false); } } else if (stringCom == "saveitem") { if (stringList.Length > 1) { string text11 = stringList[1]; if (String.IsNullOrEmpty(text11)) { Main.logger.LogWarning("SaveItem is either null or empty." + " @ " + f_strMenuFileName); } } else { Main.logger.LogWarning("A saveitem entry exists with nothing set in the field @ " + f_strMenuFileName); } } else if (stringCom == "unsetitem") { mi.m_boDelOnly = true; cacheEntry.DelMenu = mi.m_boDelOnly; } else if (stringCom == "priority") { if (stringList.Length > 1) { mi.m_fPriority = float.Parse(stringList[1]); cacheEntry.Priority = mi.m_fPriority; } else { Main.logger.LogError("The following menu file has a priority entry but no field set. A default value of 10000 will be used: " + f_strMenuFileName); mi.m_fPriority = 10000f; cacheEntry.Priority = mi.m_fPriority; } } else if (stringCom == "メニューフォルダ") { if (stringList.Length > 1) { if (stringList[1].ToLower() == "man") { mi.m_bMan = true; cacheEntry.ManMenu = mi.m_bMan; } } else { Main.logger.LogError("A a menu with a menu folder setting (メニューフォルダ) has an entry but no field set: " + f_strMenuFileName); return(false); } } } } if (!String.IsNullOrEmpty(text5)) { try { IconTex = text5; cacheEntry.Icon = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Main.logger.LogError("Error setting some icon tex from a normal mod." + " @ " + f_strMenuFileName); return(false); } } binaryReader.Close(); } catch (Exception ex2) { Main.logger.LogError(string.Concat(new string[] { "Exception when reading: ", f_strMenuFileName, "\nThe line currently being processed, likely the issue (現在処理中だった行): ", text6, "\nPrevious line (以前の行): ", text7, "\n\n", ex2.Message, "\n", ex2.StackTrace })); return(false); } MenuCache[f_strMenuFileName] = cacheEntry; return(true); }
public static bool InitMenuItemScript(SceneEdit.SMenuItem mi, string f_strMenuFileName, out string IconTex) { IconTex = null; if (f_strMenuFileName.IndexOf("mod_") == 0) { string modPathFileName = Menu.GetModPathFileName(f_strMenuFileName); return(!string.IsNullOrEmpty(modPathFileName) && SceneEdit.InitModMenuItemScript(mi, modPathFileName)); } try { if (MenuCache.ContainsKey(f_strMenuFileName)) { MenuStub tempStub = MenuCache[f_strMenuFileName]; if (tempStub.DateModified == File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName])) { if (tempStub.Name != null) { mi.m_strMenuName = tempStub.Name; } if (tempStub.Description != null) { mi.m_strInfo = tempStub.Description; } if (tempStub.Category != null) { mi.m_strCateName = tempStub.Category; mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), tempStub.Category); } else { mi.m_mpn = MPN.null_mpn; } if (tempStub.ColorSetMPN != null) { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), tempStub.ColorSetMPN); } if (tempStub.ColorSetMenu != null) { mi.m_strMenuNameInColorSet = tempStub.ColorSetMenu; } if (tempStub.MultiColorID == "null") { mi.m_pcMultiColorID = MaidParts.PARTS_COLOR.NONE; } else if (tempStub.MultiColorID != null) { mi.m_pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), tempStub.MultiColorID); } mi.m_boDelOnly = tempStub.DelMenu; mi.m_fPriority = tempStub.Priority; mi.m_bMan = tempStub.ManMenu; IconTex = tempStub.Icon; return(true); } else { Debug.Log($"A cache entry was found outdated. This should be automatically fixed and the cache reloaded."); } } if (FilesToRead[f_strMenuFileName] == null) { FilesToRead[f_strMenuFileName] = new MemoryStream(File.ReadAllBytes(FilesDictionary[f_strMenuFileName])); } } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "メニューファイルがが読み込めませんでした。 : ", f_strMenuFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } string text6 = string.Empty; string text7 = string.Empty; string path = ""; MenuStub cacheEntry = new MenuStub(); try { cacheEntry.DateModified = File.GetLastWriteTimeUtc(FilesDictionary[f_strMenuFileName]); BinaryReader binaryReader = new BinaryReader(FilesToRead[f_strMenuFileName], Encoding.UTF8); string text = binaryReader.ReadString(); NDebug.Assert(text == "CM3D2_MENU", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text); binaryReader.ReadInt32(); path = binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadInt32(); string text5 = null; while (true) { int num4 = binaryReader.ReadByte(); text7 = text6; text6 = string.Empty; if (num4 == 0) { break; } for (int i = 0; i < num4; i++) { text6 = text6 + "\"" + binaryReader.ReadString() + "\" "; } if (!(text6 == string.Empty)) { string stringCom = UTY.GetStringCom(text6); string[] stringList = UTY.GetStringList(text6); if (stringCom == "name") { string text8 = stringList[1]; string text9 = string.Empty; string arg = string.Empty; int j = 0; while (j < text8.Length && text8[j] != '\u3000' && text8[j] != ' ') { text9 += text8[j]; j++; } while (j < text8.Length) { arg += text8[j]; j++; } mi.m_strMenuName = text9; cacheEntry.Name = mi.m_strMenuName; } else if (stringCom == "setumei") { mi.m_strInfo = stringList[1]; mi.m_strInfo = mi.m_strInfo.Replace("《改行》", "\n"); cacheEntry.Description = mi.m_strInfo; } else if (stringCom == "category") { string strCateName = stringList[1].ToLower(); mi.m_strCateName = strCateName; cacheEntry.Category = mi.m_strCateName; try { mi.m_mpn = (MPN)Enum.Parse(typeof(MPN), mi.m_strCateName); cacheEntry.Category = mi.m_mpn.ToString(); } catch { Debug.LogWarning("カテゴリがありません。" + mi.m_strCateName); mi.m_mpn = MPN.null_mpn; } } else if (stringCom == "color_set") { try { mi.m_eColorSetMPN = (MPN)Enum.Parse(typeof(MPN), stringList[1].ToLower()); cacheEntry.ColorSetMPN = mi.m_eColorSetMPN.ToString(); } catch { Debug.LogWarning("カテゴリがありません。" + mi.m_strCateName); } if (stringList.Length >= 3) { mi.m_strMenuNameInColorSet = stringList[2].ToLower(); cacheEntry.ColorSetMenu = mi.m_strMenuNameInColorSet; } } else if (stringCom == "tex" || stringCom == "テクスチャ変更") { MaidParts.PARTS_COLOR pcMultiColorID = MaidParts.PARTS_COLOR.NONE; cacheEntry.MultiColorID = "null"; if (stringList.Length == 6) { string text10 = stringList[5]; try { pcMultiColorID = (MaidParts.PARTS_COLOR)Enum.Parse(typeof(MaidParts.PARTS_COLOR), text10.ToUpper()); } catch { NDebug.Assert("無限色IDがありません。" + text10, false); } mi.m_pcMultiColorID = pcMultiColorID; cacheEntry.MultiColorID = mi.m_pcMultiColorID.ToString(); } } else if (stringCom == "icon" || stringCom == "icons") { text5 = stringList[1]; } else if (!(stringCom == "iconl")) { if (!(stringCom == "setstr")) { if (!(stringCom == "アイテムパラメータ")) { if (stringCom == "saveitem") { string text11 = stringList[1]; if (text11 == string.Empty) { Debug.LogError("err SaveItem \"" + text11); } if (text11 == null) { Debug.LogError("err SaveItem null=\"" + text11); } } else if (!(stringCom == "catno")) { if (stringCom == "unsetitem") { mi.m_boDelOnly = true; cacheEntry.DelMenu = mi.m_boDelOnly; } else if (stringCom == "priority") { mi.m_fPriority = float.Parse(stringList[1]); cacheEntry.Priority = mi.m_fPriority; } else if (stringCom == "メニューフォルダ" && stringList[1].ToLower() == "man") { mi.m_bMan = true; cacheEntry.ManMenu = mi.m_bMan; } } } } } } } if (text5 != null && text5 != string.Empty) { try { IconTex = text5; cacheEntry.Icon = text5; //mi.m_texIcon = ImportCM.CreateTexture(text5); } catch (Exception) { Debug.LogError("Error:"); } } binaryReader.Close(); } catch (Exception ex2) { Debug.LogError(string.Concat(new string[] { "Exception ", Path.GetFileName(path), " 現在処理中だった行 = ", text6, " 以前の行 = ", text7, " ", ex2.Message, "StackTrace:\n", ex2.StackTrace })); throw ex2; } MenuCache[f_strMenuFileName] = cacheEntry; return(true); }