Skip to content

Commit

Permalink
Added actual eye overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Feb 18, 2019
1 parent 97637a6 commit 165e7ea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
18 changes: 16 additions & 2 deletions KoiSkinOverlay/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void Init()
{
HarmonyInstance.Create(nameof(Hooks)).PatchAll(typeof(Hooks));
}

/// <summary>
/// Skin underlay logic
/// </summary>
Expand Down Expand Up @@ -81,7 +81,7 @@ public static IEnumerable<CodeInstruction> tpl_CustomTextureCreate_RebuildTextur

return instructions;
}

/// <summary>
/// Skin overlay
/// </summary>
Expand All @@ -103,6 +103,20 @@ public static void post_CustomTextureCreate_RebuildTextureAndSetMaterial(CustomT
}
}

/// <summary>
/// Eye overlay
/// </summary>
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomTextureCreate), nameof(CustomTextureCreate.RebuildTextureAndSetMaterial))]
public static void EyeChangeSettingEyePostfix(CustomTextureCreate __instance, Texture __result)
{
var overlay = __instance.trfParent?.GetComponent<KoiSkinOverlayController>();
if (overlay == null) return;

if (__instance == overlay.ChaControl.ctCreateEyeL || __instance == overlay.ChaControl.ctCreateEyeR)
overlay.ApplyOverlayToRT((RenderTexture)__result, TexType.EyeOver);
}

/// <summary>
/// Eye underlay
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions KoiSkinOverlay/KoiSkinOverlayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public static void UpdateTexture(ChaControl cc, TexType type)
cc.CreateFaceTexture();
break;
case TexType.EyeUnder:
case TexType.EyeOver:
cc.ChangeSettingEye(true, false, false);
break;
default:
Expand Down
8 changes: 6 additions & 2 deletions KoiSkinOverlay/KoiSkinOverlayGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ private void SetupEyeInterface(RegisterSubCategoriesEvent e, KoiSkinOverlayMgr o

e.AddControl(new MakerSeparator(eyeCategory, owner));

SetupTexControls(e, eyeCategory, owner, TexType.EyeUnder, "Eye underlay texture (Under reflections)");
SetupTexControls(e, eyeCategory, owner, TexType.EyeOver, "Iris overlay texture (On top of original iris)");

e.AddControl(new MakerSeparator(eyeCategory, owner));

SetupTexControls(e, eyeCategory, owner, TexType.EyeUnder, "Iris underlay texture (Before coloring and effects)");
}

private static void AddConfigSettings(RegisterSubCategoriesEvent e, KoiSkinOverlayMgr owner, MakerCategory makerCategory)
Expand Down Expand Up @@ -321,7 +325,7 @@ private void OnChaFileLoaded()

private void UpdateInterface(KoiSkinOverlayController ctrl)
{
foreach (var texType in new[] { TexType.BodyOver, TexType.BodyUnder, TexType.FaceOver, TexType.FaceUnder })
foreach (TexType texType in Enum.GetValues(typeof(TexType)))
{
var tex = ctrl.Overlays.FirstOrDefault(x => x.Key == texType).Value;
_textureChanged.OnNext(new KeyValuePair<TexType, Texture2D>(texType, tex));
Expand Down
1 change: 1 addition & 0 deletions KoiSkinOverlay/KoiSkinOverlayMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ internal static RenderTexture GetOverlayRT(TexType overlayType)
case TexType.FaceOver:
return _rtFace;
case TexType.EyeUnder:
case TexType.EyeOver:
return _rtEye;
default:
return null;
Expand Down
3 changes: 2 additions & 1 deletion KoiSkinOverlay/TexType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum TexType
FaceOver,
BodyUnder,
FaceUnder,
EyeUnder
EyeUnder,
EyeOver
}
}

0 comments on commit 165e7ea

Please sign in to comment.