internal void Backup() { Reset(); CharacterAccessoryController _controller = CharacterAccessory.GetController(_chaCtrl); int _coordinateIndex = _chaCtrl.fileStatus.coordinateType; List <int> _slots = _controller.PartsInfo.Keys.ToList(); foreach (string _key in _containerKeys) { int n = Traverse.Create(_extdataLink[_key]).Property("Count").GetValue <int>(); DebugMsg(LogLevel.Warning, $"[MaterialEditor][Backup][{_chaCtrl.GetFullname()}][_extdataLink[{_key}] count: {n}]"); for (int i = 0; i < n; i++) { object x = _extdataLink[_key].RefElementAt(i).JsonClone(); // should I null cheack this? //if (Traverse.Create(x).Field("ObjectType").GetValue<int>() != (int) ObjectType.Accessory) continue; if (Traverse.Create(x).Field("ObjectType").Method("ToString").GetValue <string>() != "Accessory") { continue; } if (Traverse.Create(x).Field("CoordinateIndex").GetValue <int>() != _coordinateIndex) { continue; } if (_slots.IndexOf(Traverse.Create(x).Field("Slot").GetValue <int>()) < 0) { continue; } Traverse.Create(x).Field("CoordinateIndex").SetValue(-1); Traverse.Create(_charaAccData[_key]).Method("Add", new object[] { x }).GetValue(); } DebugMsg(LogLevel.Warning, $"[MaterialEditor][Backup][{_chaCtrl.GetFullname()}][_charaAccData[{_key}] count: {Traverse.Create(_charaAccData[_key]).Property("Count").GetValue<int>()}]"); //string json = JSONSerializer.Serialize(_charaAccData[_key].GetType(), _charaAccData[_key], true); //DebugMsg(LogLevel.Warning, $"{_charaAccData[_key].GetType()}\n" + json); } object TextureDictionary = Traverse.Create(_pluginCtrl).Field("TextureDictionary").GetValue(); foreach (object x in _charaAccData["MaterialTexturePropertyList"] as IList) { int?TexID = Traverse.Create(x).Field("TexID").GetValue <int?>(); if (TexID != null) { if (_texData.ContainsKey((int)TexID)) { continue; } object _tex = TextureDictionary.RefTryGetValue(TexID); if (_tex != null) { _texData[(int)TexID] = Traverse.Create(_tex).Property("Data").GetValue <byte[]>(); DebugMsg(LogLevel.Warning, $"[TexID: {TexID}][Length: {_texData[(int) TexID].Length}]"); } } } }
internal void Backup() { if (!_installed) { return; } Reset(); RefreshCache(); object TriggerPropertyList = Traverse.Create(_pluginCtrl).Field("_cachedCoordinatePropertyList").GetValue(); object TriggerGroupList = Traverse.Create(_pluginCtrl).Field("_cachedCoordinateGroupList").GetValue(); if (TriggerPropertyList == null) { return; } CharacterAccessoryController _controller = CharacterAccessory.GetController(_chaCtrl); HashSet <int> _slots = new HashSet <int>(_controller.PartsInfo?.Keys); for (int i = 0; i < (TriggerPropertyList as IList).Count; i++) { object x = TriggerPropertyList.RefElementAt(i).JsonClone(); if (!_slots.Contains(Traverse.Create(x).Property("Slot").GetValue <int>())) { continue; } Traverse.Create(x).Property("Coordinate").SetValue(-1); (_charaAccData["TriggerPropertyList"] as IList).Add(x); } for (int i = 0; i < (TriggerGroupList as IList).Count; i++) { object x = TriggerGroupList.RefElementAt(i).JsonClone(); Traverse.Create(x).Property("Coordinate").SetValue(-1); (_charaAccData["TriggerGroupList"] as IList).Add(x); int _kind = Traverse.Create(x).Property("Kind").GetValue <int>(); string _guid = Traverse.Create(x).Property("GUID").GetValue <string>(); _guidMapping[_guid] = _kind; } }
internal void Backup() { if (!_installed) { return; } _charaAccData.Clear(); CharacterAccessoryController _controller = CharacterAccessory.GetController(_chaCtrl); int _coordinateIndex = _chaCtrl.fileStatus.coordinateType; List <int> _slots = _controller.PartsInfo?.Keys?.ToList(); object _extdataLink = GetExtDataLink(_coordinateIndex); if (_extdataLink == null) { return; } int n = (_extdataLink as IList).Count; for (int i = 0; i < n; i++) { object _rule = _extdataLink.RefElementAt(i); string _path = Traverse.Create(_rule).Property("GameObjectPath").GetValue <string>(); if (!_path.Contains($"/ca_slot")) { continue; } //DebugMsg(LogLevel.Warning, $"[MaterialRouter][Backup][{_chaCtrl.GetFullname()}][{_path}]"); foreach (int _slotIndex in _slots) { if (!_path.Contains($"/ca_slot{_slotIndex:00}/")) { continue; } DebugMsg(LogLevel.Warning, $"[MaterialRouter][Backup][{_slotIndex}]"); _charaAccData.Add(_rule.JsonClone()); } } //DebugMsg(LogLevel.Warning, $"[MaterialRouter][Backup][{_chaCtrl.GetFullname()}][{_charaAccData.Count}]"); }
internal void Backup() { if (!_installed) { return; } _charaAccData.Clear(); object _extdataLink = GetExtDataLink(); if (_extdataLink == null) { return; } int _coordinateIndex = _chaCtrl.fileStatus.coordinateType; CharacterAccessoryController _controller = CharacterAccessory.GetController(_chaCtrl); List <int> _slots = _controller.PartsInfo?.Keys?.ToList(); int n = (_extdataLink as IList).Count; for (int i = 0; i < n; i++) { object x = _extdataLink.RefElementAt(i).JsonClone(); // should I null cheack this? if (Traverse.Create(x).Field("CoordinateIndex").GetValue <int>() != _coordinateIndex) { continue; } if (_slots.IndexOf(Traverse.Create(x).Field("Slot").GetValue <int>()) < 0) { continue; } Traverse.Create(x).Field("CoordinateIndex").SetValue(-1); Traverse.Create(_charaAccData).Method("Add", new object[] { x }).GetValue(); #if DEBUG DebugMsg(LogLevel.Warning, $"[DynamicBoneEditor][Backup][Slot: {_chaCtrl.GetFullname()}][{Traverse.Create(x).Field("Slot").GetValue<int>()}]"); #endif } DebugMsg(LogLevel.Warning, $"[DynamicBoneEditor][Backup][Count: {_chaCtrl.GetFullname()}][{_charaAccData.Count}]"); }
private void Awake() { Logger = base.Logger; Instance = this; CfgMakerMasterSwitch = Config.Bind("Maker", "Master Switch", true, new ConfigDescription("A quick switch on the sidebar that templary disable the function", null, new ConfigurationManagerAttributes { IsAdvanced = true })); CfgStudioFallbackReload = Config.Bind("Studio", "Fallback Reload Mode", false, new ConfigDescription("Enable this if some plugins are having visual problem", null, new ConfigurationManagerAttributes { IsAdvanced = true })); CfgDebugMode = Config.Bind("Debug", "Debug Mode", false, new ConfigDescription("Showing debug messages in LogWarning level", null, new ConfigurationManagerAttributes { IsAdvanced = true })); CfgMAHookUpdateStudioUI = Config.Bind("Hook", "MoreAccessories UpdateStudioUI", true, new ConfigDescription("Performance tweak, disable it if having issue on studio chara state panel update", null, new ConfigurationManagerAttributes { IsAdvanced = true })); if (Application.dataPath.EndsWith("CharaStudio_Data")) { CharaStudio.Running = true; } }