1
- using BepInEx ;
1
+ using System ;
2
+ using BepInEx ;
2
3
using BepInEx . Configuration ;
3
4
using BepInEx . Logging ;
4
5
using ChaCustom ;
9
10
using KKAPI . Maker ;
10
11
using KKAPI . Studio ;
11
12
using System . Linq ;
13
+ using Screencap ;
12
14
using UnityEngine ;
13
15
using UnityEngine . Rendering ;
14
16
using UnityEngine . SceneManagement ;
@@ -18,6 +20,7 @@ namespace IllusionFixes
18
20
{
19
21
[ BepInPlugin ( PluginGUID , PluginName , Constants . PluginsVersion ) ]
20
22
[ BepInDependency ( KoikatuAPI . GUID , KoikatuAPI . VersionConst ) ]
23
+ [ BepInDependency ( ScreenshotManager . GUID , ScreenshotManager . Version ) ]
21
24
public class EyebrowFix : BaseUnityPlugin
22
25
{
23
26
public const string PluginGUID = "KK_Fix_Eyebrow" ;
@@ -26,10 +29,10 @@ public class EyebrowFix : BaseUnityPlugin
26
29
27
30
public static RenderTexture rt ;
28
31
public static Material mat ;
29
-
32
+ private static bool captureActive ;
30
33
public static ConfigEntry < bool > ConfigEnabled { get ; private set ; }
31
34
32
- internal void Awake ( )
35
+ private void Awake ( )
33
36
{
34
37
ConfigEnabled = Config . Bind ( "" , "Enabled" , false , "Whether the plugin is enabled. Restart the game after changing this setting.\n \n Warning: This plugin is still experiemental and not recommended for general use." ) ;
35
38
if ( ! ConfigEnabled . Value )
@@ -44,6 +47,9 @@ internal void Awake()
44
47
SceneManager . sceneLoaded += InitStudioUI ;
45
48
46
49
Camera . onPreCull += OnPreCull ;
50
+
51
+ ScreenshotManager . OnPreCapture += ( ) => captureActive = true ;
52
+ ScreenshotManager . OnPostCapture += ( ) => captureActive = false ;
47
53
}
48
54
49
55
private void InitStudioUI ( Scene scene , LoadSceneMode loadSceneMode )
@@ -72,35 +78,35 @@ private void InitStudioUI(Scene scene, LoadSceneMode loadSceneMode)
72
78
//pre render
73
79
private void Update ( )
74
80
{
75
- if ( rt != null )
76
- {
77
- RenderTexture . ReleaseTemporary ( rt ) ;
78
- rt = null ;
79
- }
80
-
81
81
int rx ;
82
82
int ry ;
83
-
84
- if ( Screencap . ScreenshotManager . KeyCaptureAlpha . Value . IsDown ( ) )
83
+ if ( captureActive )
85
84
{
86
- rx = Screencap . ScreenshotManager . ResolutionX . Value * Screencap . ScreenshotManager . DownscalingRate . Value ;
87
- ry = Screencap . ScreenshotManager . ResolutionY . Value * Screencap . ScreenshotManager . DownscalingRate . Value ;
85
+ rx = ScreenshotManager . ResolutionX . Value * ScreenshotManager . DownscalingRate . Value ;
86
+ ry = ScreenshotManager . ResolutionY . Value * ScreenshotManager . DownscalingRate . Value ;
88
87
}
89
88
else
90
89
{
91
90
rx = Screen . width ;
92
91
ry = Screen . height ;
93
92
}
94
93
95
- rt = RenderTexture . GetTemporary ( rx , ry , 0 , RenderTextureFormat . ARGBHalf ) ;
94
+ if ( rt == null || rt . width != rx || rt . height != ry )
95
+ {
96
+ if ( rt != null ) RenderTexture . ReleaseTemporary ( rt ) ;
97
+ rt = RenderTexture . GetTemporary ( rx , ry , 0 , RenderTextureFormat . ARGBHalf ) ;
98
+ }
96
99
}
97
100
98
101
/// <summary>
99
102
/// Clear RenderTexture before rendering
100
103
/// </summary>
101
- static internal void OnPreCull ( Camera cam )
104
+ internal static void OnPreCull ( Camera cam )
102
105
{
103
- if ( rt == null || ( LayerName . CharaMask & cam . cullingMask ) == 0 )
106
+ if ( ( LayerName . CharaMask & cam . cullingMask ) == 0 )
107
+ return ;
108
+
109
+ if ( rt == null )
104
110
return ;
105
111
106
112
var rta = RenderTexture . active ;
@@ -176,10 +182,12 @@ public static void SetEyebrows(ChaControl chaControl, byte value)
176
182
return ;
177
183
178
184
if ( value == 0 ) //From config
185
+ {
179
186
if ( Manager . Config . EtcData . ForegroundEyebrow )
180
187
EnableEyebrows ( chaControl ) ;
181
188
else
182
189
DisableEyebrows ( chaControl ) ;
190
+ }
183
191
else if ( value == 1 ) //Behind hair
184
192
DisableEyebrows ( chaControl ) ;
185
193
else if ( value == 2 ) //In front of hair
@@ -208,10 +216,12 @@ public static void SetEyeliners(ChaControl chaControl, byte value)
208
216
return ;
209
217
210
218
if ( value == 0 ) //From config
219
+ {
211
220
if ( Manager . Config . EtcData . ForegroundEyes )
212
221
EnableEyeliners ( chaControl ) ;
213
222
else
214
223
DisableEyeliners ( chaControl ) ;
224
+ }
215
225
else if ( value == 1 ) //Behind hair
216
226
DisableEyeliners ( chaControl ) ;
217
227
else if ( value == 2 ) //In front of hair
0 commit comments