Fix some slide bugs (#756)

<!-- A new module or something else important -->
## Major features
-

<!-- A new parameter added to a module, or API feature -->
## Minor features
-

<!-- Some improvement that requires no action on the part of add-on
creators i.e., improved star graphics -->
## Improvements
-

<!-- Be sure to reference the existing issue if it exists -->
## Bug fixes
- [ ] make async slide loading actually async. maybe try to find a way
to unload them too, idk
- [ ] maybe fix #755 
- [x] fix #754
- [x] fix #746
This commit is contained in:
xen-42 2023-12-17 00:43:25 -05:00 committed by GitHub
commit ddcd1cdf4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 71 deletions

View File

@ -110,6 +110,7 @@ namespace NewHorizons.Builder.Props
// Now we replace the slides // Now we replace the slides
int slidesCount = info.slides.Length; int slidesCount = info.slides.Length;
var slideCollection = new SlideCollection(slidesCount); var slideCollection = new SlideCollection(slidesCount);
slideCollection.streamingAssetIdentifier = string.Empty; // NREs if null
// The base game ones only have 15 slides max // The base game ones only have 15 slides max
var textures = new Texture2D[slidesCount >= 15 ? 15 : slidesCount]; var textures = new Texture2D[slidesCount >= 15 ? 15 : slidesCount];
@ -177,6 +178,7 @@ namespace NewHorizons.Builder.Props
// Now we replace the slides // Now we replace the slides
int slidesCount = info.slides.Length; int slidesCount = info.slides.Length;
var slideCollection = new SlideCollection(slidesCount); var slideCollection = new SlideCollection(slidesCount);
slideCollection.streamingAssetIdentifier = string.Empty; // NREs if null
var imageLoader = AddAsyncLoader(projectorObj, mod, info.slides, ref slideCollection); var imageLoader = AddAsyncLoader(projectorObj, mod, info.slides, ref slideCollection);
imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = ImageUtilities.Invert(tex); }); imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = ImageUtilities.Invert(tex); });
@ -215,6 +217,7 @@ namespace NewHorizons.Builder.Props
var slides = info.slides; var slides = info.slides;
var slidesCount = slides.Length; var slidesCount = slides.Length;
var slideCollection = new SlideCollection(slidesCount); // TODO: uh I think that info.slides[i].playTimeDuration is not being read here... note to self for when I implement support for that: 0.7 is what to default to if playTimeDuration turns out to be 0 var slideCollection = new SlideCollection(slidesCount); // TODO: uh I think that info.slides[i].playTimeDuration is not being read here... note to self for when I implement support for that: 0.7 is what to default to if playTimeDuration turns out to be 0
slideCollection.streamingAssetIdentifier = string.Empty; // NREs if null
var imageLoader = AddAsyncLoader(g, mod, info.slides, ref slideCollection); var imageLoader = AddAsyncLoader(g, mod, info.slides, ref slideCollection);
imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = tex; }); imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = tex; });
@ -262,6 +265,7 @@ namespace NewHorizons.Builder.Props
var slides = info.slides; var slides = info.slides;
var slidesCount = slides.Length; var slidesCount = slides.Length;
var slideCollection = new SlideCollection(slidesCount); var slideCollection = new SlideCollection(slidesCount);
slideCollection.streamingAssetIdentifier = string.Empty; // NREs if null
var imageLoader = AddAsyncLoader(standingTorch, mod, slides, ref slideCollection); var imageLoader = AddAsyncLoader(standingTorch, mod, slides, ref slideCollection);
@ -331,7 +335,7 @@ namespace NewHorizons.Builder.Props
private static void AddModules(SlideInfo slideInfo, ref Slide slide, IModBehaviour mod) private static void AddModules(SlideInfo slideInfo, ref Slide slide, IModBehaviour mod)
{ {
var modules = new List<SlideFunctionModule>(); var modules = new List<SlideFunctionModule>();
if (!String.IsNullOrEmpty(slideInfo.beatAudio)) if (!string.IsNullOrEmpty(slideInfo.beatAudio))
{ {
var audioBeat = new SlideBeatAudioModule var audioBeat = new SlideBeatAudioModule
{ {
@ -340,7 +344,7 @@ namespace NewHorizons.Builder.Props
}; };
modules.Add(audioBeat); modules.Add(audioBeat);
} }
if (!String.IsNullOrEmpty(slideInfo.backdropAudio)) if (!string.IsNullOrEmpty(slideInfo.backdropAudio))
{ {
var audioBackdrop = new SlideBackdropAudioModule var audioBackdrop = new SlideBackdropAudioModule
{ {
@ -349,13 +353,13 @@ namespace NewHorizons.Builder.Props
}; };
modules.Add(audioBackdrop); modules.Add(audioBackdrop);
} }
if (slideInfo.ambientLightIntensity > 0) if (slideInfo.ambientLightIntensity != 0)
{ {
var ambientLight = new SlideAmbientLightModule var ambientLight = new SlideAmbientLightModule
{ {
_intensity = slideInfo.ambientLightIntensity, _intensity = slideInfo.ambientLightIntensity,
_range = slideInfo.ambientLightRange, _range = slideInfo.ambientLightRange,
_color = slideInfo.ambientLightColor.ToColor(), _color = slideInfo.ambientLightColor?.ToColor() ?? Color.white,
_spotIntensityMod = slideInfo.spotIntensityMod _spotIntensityMod = slideInfo.spotIntensityMod
}; };
modules.Add(ambientLight); modules.Add(ambientLight);
@ -376,7 +380,7 @@ namespace NewHorizons.Builder.Props
}; };
modules.Add(blackFrame); modules.Add(blackFrame);
} }
if (!String.IsNullOrEmpty(slideInfo.reveal)) if (!string.IsNullOrEmpty(slideInfo.reveal))
{ {
var shipLogEntry = new SlideShipLogEntryModule var shipLogEntry = new SlideShipLogEntryModule
{ {

View File

@ -1,5 +1,6 @@
using NewHorizons.External.SerializableData; using NewHorizons.External.SerializableData;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Props.EchoesOfTheEye namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
{ {
@ -7,80 +8,81 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
public class SlideInfo public class SlideInfo
{ {
/// <summary> /// <summary>
/// Ambient light colour when viewing this slide. /// The path to the image file for this slide.
/// </summary> /// </summary>
public MColor ambientLightColor; public string imagePath;
// SlideAmbientLightModule // SlideAmbientLightModule
/// <summary> /// <summary>
/// Ambient light intensity when viewing this slide. /// Ambient light intensity when viewing this slide.
/// Set this to add ambient light module. Base game default is 1.
/// </summary> /// </summary>
public float ambientLightIntensity; public float ambientLightIntensity;
/// <summary> /// <summary>
/// Ambient light range when viewing this slide. /// Ambient light range when viewing this slide.
/// </summary> /// </summary>
public float ambientLightRange; [DefaultValue(20f)] public float ambientLightRange = 20f;
/// <summary>
/// Ambient light colour when viewing this slide. Defaults to white.
/// </summary>
public MColor ambientLightColor;
/// <summary>
/// Spotlight intensity modifier when viewing this slide.
/// </summary>
[DefaultValue(0f)] public float spotIntensityMod = 0f;
// SlideBackdropAudioModule // SlideBackdropAudioModule
/// <summary> /// <summary>
/// The name of the AudioClip that will continuously play while watching these slides /// The name of the AudioClip that will continuously loop while watching these slides.
/// Set this to include backdrop audio module. Base game default is Reel_1_Backdrop_A.
/// </summary> /// </summary>
public string backdropAudio; public string backdropAudio;
/// <summary> /// <summary>
/// The time to fade into the backdrop audio /// The time to fade into the backdrop audio.
/// </summary> /// </summary>
public float backdropFadeTime; [DefaultValue(2f)] public float backdropFadeTime = 2f;
// SlideBeatAudioModule // SlideBeatAudioModule
/// <summary> /// <summary>
/// The name of the AudioClip for a one-shot sound when opening the slide. /// The name of the AudioClip for a one-shot sound when opening the slide.
/// Set this to include beat audio module. Base game default is Reel_1_Beat_A.
/// </summary> /// </summary>
public string beatAudio; public string beatAudio;
/// <summary> /// <summary>
/// The time delay until the one-shot audio /// The time delay until the one-shot audio.
/// </summary> /// </summary>
public float beatDelay; [DefaultValue(0f)] public float beatDelay = 0f;
// SlideBlackFrameModule // SlideBlackFrameModule
/// <summary> /// <summary>
/// Before viewing this slide, there will be a black frame for this many seconds. /// Before viewing this slide, there will be a black frame for this many seconds.
/// Set this to include black frame module. Base game default is 0.
/// </summary> /// </summary>
public float blackFrameDuration; public float blackFrameDuration;
/// <summary>
/// The path to the image file for this slide.
/// </summary>
public string imagePath;
// SlidePlayTimeModule // SlidePlayTimeModule
/// <summary> /// <summary>
/// Play-time duration for auto-projector slides. /// Play-time duration for auto-projector slides.
/// Set this to include play time module. Base game default is 0.
/// </summary> /// </summary>
public float playTimeDuration; public float playTimeDuration;
// SlideShipLogEntryModule // SlideShipLogEntryModule
/// <summary> /// <summary>
/// Ship log fact revealed when viewing this slide /// Ship log fact revealed when viewing this slide.
/// Set this to include ship log entry module. Base game default is "".
/// </summary> /// </summary>
public string reveal; public string reveal;
/// <summary>
/// Spotlight intensity modifier when viewing this slide.
/// </summary>
public float spotIntensityMod;
} }
} }

View File

@ -2086,60 +2086,64 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"ambientLightColor": { "imagePath": {
"description": "Ambient light colour when viewing this slide.", "type": "string",
"$ref": "#/definitions/MColor" "description": "The path to the image file for this slide."
}, },
"ambientLightIntensity": { "ambientLightIntensity": {
"type": "number", "type": "number",
"description": "Ambient light intensity when viewing this slide.", "description": "Ambient light intensity when viewing this slide.\nSet this to add ambient light module. Base game default is 1.",
"format": "float" "format": "float"
}, },
"ambientLightRange": { "ambientLightRange": {
"type": "number", "type": "number",
"description": "Ambient light range when viewing this slide.", "description": "Ambient light range when viewing this slide.",
"format": "float" "format": "float",
"default": 20.0
}, },
"backdropAudio": { "ambientLightColor": {
"type": "string", "description": "Ambient light colour when viewing this slide. Defaults to white.",
"description": "The name of the AudioClip that will continuously play while watching these slides" "$ref": "#/definitions/MColor"
},
"backdropFadeTime": {
"type": "number",
"description": "The time to fade into the backdrop audio",
"format": "float"
},
"beatAudio": {
"type": "string",
"description": "The name of the AudioClip for a one-shot sound when opening the slide."
},
"beatDelay": {
"type": "number",
"description": "The time delay until the one-shot audio",
"format": "float"
},
"blackFrameDuration": {
"type": "number",
"description": "Before viewing this slide, there will be a black frame for this many seconds.",
"format": "float"
},
"imagePath": {
"type": "string",
"description": "The path to the image file for this slide."
},
"playTimeDuration": {
"type": "number",
"description": "Play-time duration for auto-projector slides.",
"format": "float"
},
"reveal": {
"type": "string",
"description": "Ship log fact revealed when viewing this slide"
}, },
"spotIntensityMod": { "spotIntensityMod": {
"type": "number", "type": "number",
"description": "Spotlight intensity modifier when viewing this slide.", "description": "Spotlight intensity modifier when viewing this slide.",
"format": "float",
"default": 0.0
},
"backdropAudio": {
"type": "string",
"description": "The name of the AudioClip that will continuously loop while watching these slides.\nSet this to include backdrop audio module. Base game default is Reel_1_Backdrop_A."
},
"backdropFadeTime": {
"type": "number",
"description": "The time to fade into the backdrop audio.",
"format": "float",
"default": 2.0
},
"beatAudio": {
"type": "string",
"description": "The name of the AudioClip for a one-shot sound when opening the slide.\nSet this to include beat audio module. Base game default is Reel_1_Beat_A."
},
"beatDelay": {
"type": "number",
"description": "The time delay until the one-shot audio.",
"format": "float",
"default": 0.0
},
"blackFrameDuration": {
"type": "number",
"description": "Before viewing this slide, there will be a black frame for this many seconds.\nSet this to include black frame module. Base game default is 0.",
"format": "float" "format": "float"
},
"playTimeDuration": {
"type": "number",
"description": "Play-time duration for auto-projector slides.\nSet this to include play time module. Base game default is 0.",
"format": "float"
},
"reveal": {
"type": "string",
"description": "Ship log fact revealed when viewing this slide.\nSet this to include ship log entry module. Base game default is \"\"."
} }
} }
}, },