diff --git a/BeatSaberCinema/Environment/EnvironmentController.cs b/BeatSaberCinema/Environment/EnvironmentController.cs index feb61ab..7bd55cb 100644 --- a/BeatSaberCinema/Environment/EnvironmentController.cs +++ b/BeatSaberCinema/Environment/EnvironmentController.cs @@ -563,15 +563,6 @@ private static void DefaultSceneModifications(VideoConfig? videoConfig) { hud.transform.localScale = invertedScale; } - - //Use different defaults for this environment - var placement = new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) - { - Position = videoConfig?.screenPosition ?? new Vector3(0f, 6.2f, 52.7f), Rotation = videoConfig?.screenRotation ?? Vector3.zero, - Height = videoConfig?.screenHeight ?? 16f, - Curvature = videoConfig?.screenCurvature ?? 0f - }; - PlaybackController.Instance.VideoPlayer.SetPlacement(placement); break; } case "KaleidoscopeEnvironment": @@ -593,14 +584,6 @@ private static void DefaultSceneModifications(VideoConfig? videoConfig) var localPos = glowLine.transform.localPosition; glowLine.transform.localPosition = new Vector3(localPos.x, localPos.y - coneOffset, localPos.z); } - - var placement = new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) - { - Position = videoConfig?.screenPosition ?? new Vector3(0f, 1f, 35f), Rotation = videoConfig?.screenRotation ?? Vector3.zero, - Height = videoConfig?.screenHeight ?? 12f, - Curvature = videoConfig?.screenCurvature - }; - PlaybackController.Instance.VideoPlayer.SetPlacement(placement); break; } case "GlassDesertEnvironment": @@ -629,14 +612,6 @@ private static void DefaultSceneModifications(VideoConfig? videoConfig) { light.SetActive(false); } - - var placement = new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) - { - Position = videoConfig?.screenPosition ?? new Vector3(0f, 6.3f, 37f), Rotation = videoConfig?.screenRotation ?? Vector3.zero, - Height = videoConfig?.screenHeight ?? 12.5f, - Curvature = videoConfig?.screenCurvature - }; - PlaybackController.Instance.VideoPlayer.SetPlacement(placement); break; } case "CrabRaveEnvironment": @@ -819,15 +794,6 @@ private static void DefaultSceneModifications(VideoConfig? videoConfig) laser11.transform.position = new Vector3(-12.4f, 10f, 9.3f); laser11.transform.eulerAngles = new Vector3(0f, 0, 30); } - - var placement = new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) - { - Position = videoConfig?.screenPosition ?? new Vector3(0f, 5.46f, 40f), Rotation = videoConfig?.screenRotation ?? new Vector3(-5f, 0f, 0f), - Height = videoConfig?.screenHeight ?? 13f, - Curvature = videoConfig?.screenCurvature - }; - PlaybackController.Instance.VideoPlayer.SetPlacement(placement); - break; } case "SkrillexEnvironment": @@ -843,25 +809,6 @@ private static void DefaultSceneModifications(VideoConfig? videoConfig) { skrillexLogoBottom.transform.position = new Vector3(-0.23f, -15.5f, 60f); } - - var placement = new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) - { - Position = videoConfig?.screenPosition ?? new Vector3(0f, 1.5f, 30f), Rotation = videoConfig?.screenRotation ?? new Vector3(0f, 0f, 0f), - Height = videoConfig?.screenHeight ?? 12f, - Curvature = videoConfig?.screenCurvature - }; - PlaybackController.Instance.VideoPlayer.SetPlacement(placement); - break; - } - case "WeaveEnvironment": - { - var placement = new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) - { - Position = videoConfig?.screenPosition ?? new Vector3(0f, 1.5f, 21f), Rotation = videoConfig?.screenRotation ?? new Vector3(0f, 0f, 0f), - Height = videoConfig?.screenHeight ?? 4.3f, - Curvature = videoConfig?.screenCurvature - }; - PlaybackController.Instance.VideoPlayer.SetPlacement(placement); break; } } @@ -1014,7 +961,8 @@ private static void PrepareClonedScreens(VideoConfig videoConfig) } PlaybackController.Instance.VideoPlayer.SetPlacement( - new Placement(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio())); + Placement.CreatePlacementForConfig(videoConfig, PlaybackController.Scene.SoloGameplay, PlaybackController.Instance.VideoPlayer.GetVideoAspectRatio()) + ); PlaybackController.Instance.VideoPlayer.screenController.SetShaderParameters(videoConfig); } diff --git a/BeatSaberCinema/Screen/Placement.cs b/BeatSaberCinema/Screen/Placement.cs index 80285db..4600d6b 100644 --- a/BeatSaberCinema/Screen/Placement.cs +++ b/BeatSaberCinema/Screen/Placement.cs @@ -12,13 +12,13 @@ public class Placement public bool? CurveYAxis; public int? Subsurfaces; - public static Placement SoloGameplayPlacement => new Placement( + private static Placement SoloGameplayPlacement => new Placement( new Vector3(0, 12.4f, 67.8f), new Vector3(-8, 0, 0), 25f ); - public static Placement MultiplayerPlacement => new Placement( + private static Placement MultiplayerPlacement => new Placement( new Vector3(0, 5f, 67f), new Vector3(-5, 0, 0), 17f @@ -36,35 +36,62 @@ public class Placement 12f ); - public Placement(Vector3 position, Vector3 rotation, float height, float? width = null) + private Placement(Vector3 position, Vector3 rotation, float height, float? width = null, float? curvature = null) { Position = position; Rotation = rotation; Height = height; Width = width ?? (height * (16f / 9f)); + Curvature = curvature; } - public Placement(VideoConfig? config, PlaybackController.Scene scene, float aspectRatio) + public static Placement CreatePlacementForConfig(VideoConfig? config, PlaybackController.Scene scene, float aspectRatio) { var defaultPlacement = GetDefaultPlacementForScene(scene); - Position = config?.screenPosition ?? defaultPlacement.Position; - Rotation = config?.screenRotation ?? defaultPlacement.Rotation; - Height = config?.screenHeight ?? defaultPlacement.Height; - Width = Height * aspectRatio; - Curvature = config?.screenCurvature; - Subsurfaces = config?.screenSubsurfaces; - CurveYAxis = config?.curveYAxis; + if (scene == PlaybackController.Scene.MultiplayerGameplay || config == null) + { + return defaultPlacement; + } + + var placement = new Placement( + config.screenPosition ?? defaultPlacement.Position, + config.screenRotation ?? defaultPlacement.Rotation, + config.screenHeight ?? defaultPlacement.Height + ); + + placement.Width = placement.Height * aspectRatio; + placement.Curvature = config?.screenCurvature; + placement.Subsurfaces = config?.screenSubsurfaces; + placement.CurveYAxis = config?.curveYAxis; + + return placement; } public static Placement GetDefaultPlacementForScene(PlaybackController.Scene scene) { return scene switch { - PlaybackController.Scene.SoloGameplay => SoloGameplayPlacement, + PlaybackController.Scene.SoloGameplay => (GetDefaultEnvironmentPlacement() ?? SoloGameplayPlacement), PlaybackController.Scene.MultiplayerGameplay => MultiplayerPlacement, PlaybackController.Scene.Menu => MenuPlacement, _ => SoloGameplayPlacement }; } + + private static Placement? GetDefaultEnvironmentPlacement() + { + return Util.GetEnvironmentName() switch + { + "LinkinParkEnvironment" => new Placement(new Vector3(0f, 6.2f, 52.7f), Vector3.zero, 16f, null, 0f), + "BTSEnvironment" => new Placement(new Vector3(0, 12.4f, 80f), new Vector3(-8, 0, 0), 25f), + "KaleidoscopeEnvironment" => new Placement(new Vector3(0f, 1f, 35f), Vector3.zero, 12f), + "InterscopeEnvironment" => new Placement(new Vector3(0f, 6.3f, 37f), Vector3.zero, 12.5f), + "CrabRaveEnvironment" => new Placement(new Vector3(0f, 5.46f, 40f), new Vector3(-5f, 0f, 0f), 13f), + "MonstercatEnvironment" => new Placement(new Vector3(0f, 5.46f, 40f), new Vector3(-5f, 0f, 0f), 13f), + "SkrillexEnvironment" => new Placement(new Vector3(0f, 1.5f, 30f), Vector3.zero, 12f), + "WeaveEnvironment" => new Placement(new Vector3(0f, 1.5f, 21f), Vector3.zero, 4.3f, null, 0f), + _ => null + }; + } } } \ No newline at end of file diff --git a/BeatSaberCinema/Screen/PlaybackController.cs b/BeatSaberCinema/Screen/PlaybackController.cs index 0ba19f2..3c8367c 100644 --- a/BeatSaberCinema/Screen/PlaybackController.cs +++ b/BeatSaberCinema/Screen/PlaybackController.cs @@ -407,7 +407,7 @@ private void OnConfigChanged(VideoConfig? config) } else { - VideoPlayer.SetPlacement(new Placement(config, _activeScene, VideoPlayer.GetVideoAspectRatio())); + VideoPlayer.SetPlacement(Placement.CreatePlacementForConfig(config, _activeScene, VideoPlayer.GetVideoAspectRatio())); } if (previousVideoPath != config.VideoPath) @@ -575,7 +575,7 @@ private void GameSceneLoaded() VideoLoader.SaveVideoConfig(VideoConfig); } - VideoPlayer.SetPlacement(Util.IsMultiplayer() ? Placement.MultiplayerPlacement : new Placement(VideoConfig, _activeScene, VideoPlayer.GetVideoAspectRatio())); + VideoPlayer.SetPlacement(Placement.CreatePlacementForConfig(VideoConfig, _activeScene, VideoPlayer.GetVideoAspectRatio())); //Fixes rough pop-in at the start of the song when transparency is disabled if (VideoConfig.TransparencyEnabled)