SHA256
Compare commits
3
Commits
01f1d4be9d
...
fd54371de2
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
fd54371de2
|
||
|
|
ea9db52c86
|
||
|
|
0e691550e7
|
No files matched your search
@@ -82,6 +82,9 @@
|
|||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath>$(ADOFAI_PATH)\A Dance of Fire and Ice_Data\Managed\Newtonsoft.Json.dll</HintPath>
|
<HintPath>$(ADOFAI_PATH)\A Dance of Fire and Ice_Data\Managed\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UniTask">
|
||||||
|
<HintPath>$(ADOFAI_PATH)\A Dance of Fire and Ice_Data\Managed\UniTask.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+10
-7
@@ -1,5 +1,5 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ namespace ADOFAIRenderer.Core;
|
|||||||
internal class PostRenderHook : MonoBehaviour
|
internal class PostRenderHook : MonoBehaviour
|
||||||
{
|
{
|
||||||
private FieldInfo? _camQuadMeshField;
|
private FieldInfo? _camQuadMeshField;
|
||||||
|
private MeshRenderer? _camQuadMeshRenderer;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@@ -20,15 +21,17 @@ internal class PostRenderHook : MonoBehaviour
|
|||||||
if (RenderManager.Instance)
|
if (RenderManager.Instance)
|
||||||
RenderManager.Instance.OnLastUpdate();
|
RenderManager.Instance.OnLastUpdate();
|
||||||
|
|
||||||
StartCoroutine(PostFrameCoroutine());
|
PostFrameAsync().Forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator PostFrameCoroutine()
|
private async UniTaskVoid PostFrameAsync()
|
||||||
{
|
{
|
||||||
yield return new WaitForEndOfFrame();
|
await UniTask.WaitForEndOfFrame(this, destroyCancellationToken);
|
||||||
|
|
||||||
var val = (MeshRenderer)_camQuadMeshField!.GetValue(scrCamera.instance);
|
if (!_camQuadMeshRenderer && scrCamera.instance)
|
||||||
if (RenderManager.Instance)
|
_camQuadMeshRenderer = _camQuadMeshField?.GetValue(scrCamera.instance) as MeshRenderer;
|
||||||
RenderManager.Instance.OnPostFrame(val.sharedMaterial.mainTexture as RenderTexture);
|
|
||||||
|
if (RenderManager.Instance && _camQuadMeshRenderer)
|
||||||
|
RenderManager.Instance.OnPostFrame(_camQuadMeshRenderer.sharedMaterial.mainTexture as RenderTexture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,6 @@ public static class EndscreenLanternsPatch
|
|||||||
for (var i = 0; i < lampSequencesArray.Length; i++)
|
for (var i = 0; i < lampSequencesArray.Length; i++)
|
||||||
{
|
{
|
||||||
var item = lampSequencesArray.GetValue(i);
|
var item = lampSequencesArray.GetValue(i);
|
||||||
if (item == null) continue;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var killMethod = item.GetType().GetMethod("Kill", new[] { typeof(bool) });
|
var killMethod = item.GetType().GetMethod("Kill", new[] { typeof(bool) });
|
||||||
|
|||||||
@@ -78,10 +78,8 @@ public static class scnGamePatch
|
|||||||
{
|
{
|
||||||
// Remove FFmpeg player if it was attached previously
|
// Remove FFmpeg player if it was attached previously
|
||||||
var oldPlayer = __instance.videoBG.gameObject.GetComponent<FFmpegVideoBGPlayer>();
|
var oldPlayer = __instance.videoBG.gameObject.GetComponent<FFmpegVideoBGPlayer>();
|
||||||
if (oldPlayer != null)
|
if (oldPlayer) Object.Destroy(oldPlayer);
|
||||||
{
|
|
||||||
Object.Destroy(oldPlayer);
|
|
||||||
}
|
|
||||||
// Re-enable native player component
|
// Re-enable native player component
|
||||||
__instance.videoBG.enabled = true;
|
__instance.videoBG.enabled = true;
|
||||||
return true; // Execute original
|
return true; // Execute original
|
||||||
@@ -125,8 +123,7 @@ public static class scnGamePatch
|
|||||||
__instance.videoBG.enabled = false;
|
__instance.videoBG.enabled = false;
|
||||||
|
|
||||||
// Add or retrieve our custom FFmpeg video background player
|
// Add or retrieve our custom FFmpeg video background player
|
||||||
var player = __instance.videoBG.gameObject.GetComponent<FFmpegVideoBGPlayer>();
|
if (!__instance.videoBG.gameObject.TryGetComponent<FFmpegVideoBGPlayer>(out var player))
|
||||||
if (player == null)
|
|
||||||
{
|
{
|
||||||
player = __instance.videoBG.gameObject.AddComponent<FFmpegVideoBGPlayer>();
|
player = __instance.videoBG.gameObject.AddComponent<FFmpegVideoBGPlayer>();
|
||||||
}
|
}
|
||||||
@@ -134,7 +131,7 @@ public static class scnGamePatch
|
|||||||
var isLooping = __instance.levelData.miscSettings.GetBool("loopVideo");
|
var isLooping = __instance.levelData.miscSettings.GetBool("loopVideo");
|
||||||
|
|
||||||
// Initialize player. If targetTexture is null (CameraFarPlane mode), it will build a quad in front of targetCamera.
|
// Initialize player. If targetTexture is null (CameraFarPlane mode), it will build a quad in front of targetCamera.
|
||||||
player.Init(videoPath, __instance.videoBG.targetTexture, isLooping, targetCamera, __instance.videoBG.gameObject);
|
player.Init(videoPath, __instance.videoBG?.targetTexture, isLooping, targetCamera, __instance.videoBG.gameObject);
|
||||||
|
|
||||||
return false; // Skip original UpdateVideo
|
return false; // Skip original UpdateVideo
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-41
@@ -85,46 +85,6 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TMP_FontAsset GetNanumSquareNeoBdFontAsset()
|
|
||||||
{
|
|
||||||
TMP_FontAsset? font = null;
|
|
||||||
if (ModAssets.FontBundle)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
font = ModAssets.FontBundle.LoadAsset<TMP_FontAsset>("NanumSquareNeoOTF-Bd SDF");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Loading failed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback processing
|
|
||||||
if (font == null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
font = RDString.fontData.fontTMP;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (font == null)
|
|
||||||
{
|
|
||||||
// ReSharper disable once Unity.UnknownResource
|
|
||||||
font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (font) return font;
|
|
||||||
var fonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
|
|
||||||
if (fonts.Length > 0) font = fonts[0];
|
|
||||||
|
|
||||||
return font!;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
// Set UI layer (5)
|
// Set UI layer (5)
|
||||||
@@ -159,7 +119,7 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
|||||||
bgRect.offsetMin = Vector2.zero;
|
bgRect.offsetMin = Vector2.zero;
|
||||||
bgRect.offsetMax = Vector2.zero;
|
bgRect.offsetMax = Vector2.zero;
|
||||||
|
|
||||||
var font = GetNanumSquareNeoBdFontAsset();
|
var font = ModAssets.NanumSquareNeoNormal;
|
||||||
|
|
||||||
// 2. Create modal container
|
// 2. Create modal container
|
||||||
var modalContainerObj = new GameObject("ModalContainer");
|
var modalContainerObj = new GameObject("ModalContainer");
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ internal class RendererUIManager : MonoBehaviour
|
|||||||
ObjectBG = new Color(0f, 0f, 0f, 1f),
|
ObjectBG = new Color(0f, 0f, 0f, 1f),
|
||||||
ObjectButton = new Color(0f, 0f, 0f, 1f),
|
ObjectButton = new Color(0f, 0f, 0f, 1f),
|
||||||
ObjectActive = new Color(1.000f, 0.294f, 0.079f, 1f),
|
ObjectActive = new Color(1.000f, 0.294f, 0.079f, 1f),
|
||||||
ObjectActiveBright = new Color(0.812f, 0.827f, 1.000f, 1f),
|
ObjectActiveBright = new Color(1.000f, 0.294f, 0.079f, 1f),
|
||||||
ControlOutlineIdle = new Color(1f, 1f, 1f, 0.4f),
|
ControlOutlineIdle = new Color(1f, 1f, 1f, 0.4f),
|
||||||
ButtonHover = new Color(0.133f, 0.133f, 0.133f, 1.0f),
|
ButtonHover = new Color(0.133f, 0.133f, 0.133f, 1.0f),
|
||||||
ControlOutlineHover = new Color(1f, 1f, 1f, 0.4f),
|
ControlOutlineHover = new Color(1f, 1f, 1f, 0.4f),
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ internal static class RenderConfigWindow
|
|||||||
{
|
{
|
||||||
Id = "RendererMod_RenderConfig",
|
Id = "RendererMod_RenderConfig",
|
||||||
Title = LocalizationManager.Get("ui.render_config.window_title"),
|
Title = LocalizationManager.Get("ui.render_config.window_title"),
|
||||||
Size = new Vector2(580f, 480f),
|
Size = new Vector2(900, 600), TopBarHeight = 40,
|
||||||
Draggable = true,
|
Draggable = true, Resizable = true,
|
||||||
Resizable = true,
|
|
||||||
ShowCloseButton = true
|
ShowCloseButton = true
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ internal static class RenderConfigWindow
|
|||||||
defaultValue: 60, min: 0.01, max: 3000, value: 60,
|
defaultValue: 60, min: 0.01, max: 3000, value: 60,
|
||||||
format: "F3", clampMode: ClampMode.All,
|
format: "F3", clampMode: ClampMode.All,
|
||||||
|
|
||||||
sliderFilter: value => renderFpsSnap.OrderBy(n => Math.Abs(n - value)).First(),
|
sliderFilter: value => Snap(renderFpsSnap, value),
|
||||||
inputFilter: null, onComplete: null, onChanged: val => { config.RenderFPS = val; },
|
inputFilter: null, onComplete: null, onChanged: val => { config.RenderFPS = val; },
|
||||||
text: LocalizationManager.Get("ui.render_config.render_fps"),
|
text: LocalizationManager.Get("ui.render_config.render_fps"),
|
||||||
id: "slider_render_fps", showFill: true
|
id: "slider_render_fps", showFill: true
|
||||||
@@ -137,7 +136,7 @@ internal static class RenderConfigWindow
|
|||||||
defaultValue: 60, min: 0.01, max: 600, value: 60,
|
defaultValue: 60, min: 0.01, max: 600, value: 60,
|
||||||
format: "F3", clampMode: ClampMode.All,
|
format: "F3", clampMode: ClampMode.All,
|
||||||
|
|
||||||
sliderFilter: value => videoFpsSnap.OrderBy(n => Math.Abs(n - value)).First(),
|
sliderFilter: value => Snap(videoFpsSnap, value),
|
||||||
inputFilter: null, onComplete: null, onChanged: val => { config.VideoFPS = val; },
|
inputFilter: null, onComplete: null, onChanged: val => { config.VideoFPS = val; },
|
||||||
text: LocalizationManager.Get("ui.render_config.video_fps"),
|
text: LocalizationManager.Get("ui.render_config.video_fps"),
|
||||||
id: "slider_video_fps", showFill: true
|
id: "slider_video_fps", showFill: true
|
||||||
@@ -148,7 +147,7 @@ internal static class RenderConfigWindow
|
|||||||
defaultValue: 2560, min: 0, max: 15360, value: 2560,
|
defaultValue: 2560, min: 0, max: 15360, value: 2560,
|
||||||
format: "F0", clampMode: ClampMode.All,
|
format: "F0", clampMode: ClampMode.All,
|
||||||
|
|
||||||
sliderFilter: value => renderWidthSnap.OrderBy(n => Math.Abs(n - value)).First(), inputFilter: value => Math.Max(value, 2),
|
sliderFilter: value => Snap(renderWidthSnap, value), inputFilter: value => Math.Max(value, 2),
|
||||||
onComplete: null, onChanged: val => { config.RenderWidth = (int)Math.Round(val); },
|
onComplete: null, onChanged: val => { config.RenderWidth = (int)Math.Round(val); },
|
||||||
text: LocalizationManager.Get("ui.render_config.render_width"),
|
text: LocalizationManager.Get("ui.render_config.render_width"),
|
||||||
id: "slider_render_width", showFill: true
|
id: "slider_render_width", showFill: true
|
||||||
@@ -159,7 +158,7 @@ internal static class RenderConfigWindow
|
|||||||
defaultValue: 1440, min: 0, max: 8640, value: 1440,
|
defaultValue: 1440, min: 0, max: 8640, value: 1440,
|
||||||
format: "F0", clampMode: ClampMode.All,
|
format: "F0", clampMode: ClampMode.All,
|
||||||
|
|
||||||
sliderFilter: value => renderHeightSnap.OrderBy(n => Math.Abs(n - value)).First(), inputFilter: value => Math.Max(value, 2),
|
sliderFilter: value => Snap(renderHeightSnap, value), inputFilter: value => Math.Max(value, 2),
|
||||||
onComplete: null, onChanged: val => { config.RenderWidth = (int)Math.Round(val); },
|
onComplete: null, onChanged: val => { config.RenderWidth = (int)Math.Round(val); },
|
||||||
text: LocalizationManager.Get("ui.render_config.render_height"),
|
text: LocalizationManager.Get("ui.render_config.render_height"),
|
||||||
id: "slider_render_height", showFill: true
|
id: "slider_render_height", showFill: true
|
||||||
@@ -293,7 +292,7 @@ internal static class RenderConfigWindow
|
|||||||
defaultValue: 256, min: 64, max: 384, value: 256,
|
defaultValue: 256, min: 64, max: 384, value: 256,
|
||||||
format: "F0", clampMode: ClampMode.All,
|
format: "F0", clampMode: ClampMode.All,
|
||||||
|
|
||||||
sliderFilter: value => audioBitrateSnap.OrderBy(n => Math.Abs(n - value)).First(),
|
sliderFilter: value => Snap(audioBitrateSnap, value),
|
||||||
inputFilter: null, onComplete: null, onChanged: val => { config.AudioConfig.AudioBitrate = (int)Math.Round(val) * 1000; },
|
inputFilter: null, onComplete: null, onChanged: val => { config.AudioConfig.AudioBitrate = (int)Math.Round(val) * 1000; },
|
||||||
text: LocalizationManager.Get("ui.render_config.audio_bitrate"),
|
text: LocalizationManager.Get("ui.render_config.audio_bitrate"),
|
||||||
id: "slider_audio_bitrate", showFill: true
|
id: "slider_audio_bitrate", showFill: true
|
||||||
@@ -465,6 +464,9 @@ internal static class RenderConfigWindow
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
double Snap(double[] array, double value) =>
|
||||||
|
array.OrderBy(n => Math.Abs(n - value)).First();
|
||||||
|
|
||||||
void UpdateVideoCodec(Codec codec)
|
void UpdateVideoCodec(Codec codec)
|
||||||
{
|
{
|
||||||
_sampleRateDropdown?.SetValues(CodecUtil.AvailableSampleRate[CodecUtil.AudioCodecMatch[codec]]);
|
_sampleRateDropdown?.SetValues(CodecUtil.AvailableSampleRate[CodecUtil.AudioCodecMatch[codec]]);
|
||||||
|
|||||||
Reference in new issue
Block a user