Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ME] Refresh edits after importing an overlay using the overlay plugin #304

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/MaterialEditor.Core/Core.MaterialEditor.CharaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,11 @@ private void LoadCoordinateExtSaveData(ChaFileCoordinate coordinate)
}

public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
{
return LoadData(clothes, accessories, hair, true);
}

public IEnumerator LoadData(bool clothes, bool accessories, bool hair, bool body)
{
yield return null;
#if !EC
Expand All @@ -809,9 +814,10 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
while (ChaControl == null || ChaControl.GetHead() == null)
yield return null;

CorrectTongue();
if (body)
CorrectTongue();
#if KK || KKS
if (KKAPI.Studio.StudioAPI.InsideStudio)
if (KKAPI.Studio.StudioAPI.InsideStudio && body)
CorrectFace();
#endif

Expand All @@ -823,6 +829,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if (property.ObjectType == ObjectType.Accessory && !accessories) continue;
if (property.ObjectType == ObjectType.Hair && !hair) continue;
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

CopyMaterial(FindGameObject(property.ObjectType, property.Slot), property.MaterialName, property.MaterialCopyName);
}
Expand All @@ -836,6 +843,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if (property.ObjectType == ObjectType.Accessory && !accessories) continue;
if (property.ObjectType == ObjectType.Hair && !hair) continue;
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

MaterialAPI.SetName(FindGameObject(property.ObjectType, property.Slot), property.Renderer, property.MaterialName, property.Value);
}
Expand All @@ -847,6 +855,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if (property.ObjectType == ObjectType.Accessory && !accessories) continue;
if (property.ObjectType == ObjectType.Hair && !hair) continue;
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

#if KK || EC || KKS
if (property.ObjectType == ObjectType.Character && MaterialEditorPlugin.EyeMaterials.Contains(property.MaterialName))
Expand All @@ -867,6 +876,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if (property.ObjectType == ObjectType.Accessory && !accessories) continue;
if (property.ObjectType == ObjectType.Hair && !hair) continue;
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

MaterialAPI.SetRendererProperty(FindGameObject(property.ObjectType, property.Slot), property.RendererName, property.Property, property.Value);
}
Expand All @@ -879,6 +889,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
var go = FindGameObject(property.ObjectType, property.Slot);
if (Instance.CheckBlacklist(property.MaterialName, property.Property)) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

SetFloat(go, property.MaterialName, property.Property, float.Parse(property.Value));
}
Expand All @@ -891,6 +902,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
var go = FindGameObject(property.ObjectType, property.Slot);
if (Instance.CheckBlacklist(property.MaterialName, property.Property)) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

SetKeyword(go, property.MaterialName, property.Property, property.Value);
}
Expand All @@ -903,6 +915,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
var go = FindGameObject(property.ObjectType, property.Slot);
if (Instance.CheckBlacklist(property.MaterialName, property.Property)) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

SetColor(go, property.MaterialName, property.Property, property.Value);
}
Expand All @@ -913,6 +926,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if (property.ObjectType == ObjectType.Accessory && !accessories) continue;
if (property.ObjectType == ObjectType.Hair && !hair) continue;
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;
var go = FindGameObject(property.ObjectType, property.Slot);
if (Instance.CheckBlacklist(property.MaterialName, property.Property)) continue;

Expand All @@ -927,6 +941,7 @@ public IEnumerator LoadData(bool clothes, bool accessories, bool hair)
if (property.ObjectType == ObjectType.Accessory && !accessories) continue;
if (property.ObjectType == ObjectType.Hair && !hair) continue;
if ((property.ObjectType == ObjectType.Clothing || property.ObjectType == ObjectType.Accessory) && property.CoordinateIndex != CurrentCoordinateIndex) continue;
if (property.ObjectType == ObjectType.Character && !body) continue;

MaterialAPI.SetProjectorProperty(FindGameObject(property.ObjectType, property.Slot), property.ProjectorName, property.Property, float.Parse(property.Value));
}
Expand Down Expand Up @@ -1329,6 +1344,7 @@ internal void ChangeCustomClothesEvent(int slot)
if (CustomClothesOverride) return;
if (new System.Diagnostics.StackTrace().ToString().Contains("KoiClothesOverlayController"))
{
StartCoroutine(LoadData(true, false, false, false));
RefreshingTextures = true;
return;
}
Expand Down