Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title Screen config #1028

Draft
wants to merge 29 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3ea4a3a
Make a config
xen-42 Jan 15, 2025
2e78a3c
Updated Schemas
Bwc9876 Jan 15, 2025
165be74
Finished tinting the menu
xen-42 Jan 15, 2025
01397d4
Merge branch 'title-screen-config' of https://github.com/Outer-Wilds-…
xen-42 Jan 15, 2025
e92a7ab
Make config in code for testing
xen-42 Jan 15, 2025
e494a82
Updated Schemas
Bwc9876 Jan 15, 2025
d17221d
Rename config to title screen config
MegaPiggy Jan 25, 2025
02c771d
Add schema
MegaPiggy Jan 25, 2025
8e5d736
Move skybox module to separate file
MegaPiggy Jan 25, 2025
0c2709b
Add simplified detail info to use later
MegaPiggy Jan 25, 2025
5fc7841
I've gone past the point of insanity
MegaPiggy Jan 25, 2025
dafcb06
Updated Schemas
Bwc9876 Jan 25, 2025
310301c
grah
MegaPiggy Jan 25, 2025
3ae1e25
Remove testing json
MegaPiggy Jan 25, 2025
0e1f63b
always set alpha to 1
MegaPiggy Jan 25, 2025
2af8686
parent campfire and ambient light to planet root
MegaPiggy Jan 25, 2025
a8f48fc
implement music
MegaPiggy Jan 25, 2025
b61ea5a
grah 2
MegaPiggy Jan 25, 2025
c726b08
do ambience too because might as well
MegaPiggy Jan 25, 2025
9e97e59
Updated Schemas
Bwc9876 Jan 25, 2025
dd917ad
gabagool
MegaPiggy Jan 25, 2025
20d6502
Updated Schemas
Bwc9876 Jan 25, 2025
79ffb99
use the pivot instead
MegaPiggy Jan 25, 2025
1380bbb
bleh
MegaPiggy Jan 25, 2025
37bd326
Updated Schemas
Bwc9876 Jan 25, 2025
5d37898
null check
MegaPiggy Jan 26, 2025
e5b964d
shenanigans
MegaPiggy Jan 26, 2025
64b0816
I don't understand why visual studio keeps adding in unused namespaces
MegaPiggy Jan 26, 2025
fcd4ab4
Null check for profile
MegaPiggy Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions NewHorizons/Builder/Props/ProjectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P
}

slideCollectionContainer.slideCollection = slideCollection;
slideCollectionContainer._playWithShipLogFacts = Array.Empty<string>();

StreamingHandler.SetUpStreaming(projectorObj, sector);

Expand Down
6 changes: 3 additions & 3 deletions NewHorizons/Builder/StarSystem/SkyboxBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OWML;
Expand All @@ -13,13 +13,13 @@ public static class SkyboxBuilder
{
private static readonly Shader _unlitShader = Shader.Find("Unlit/Texture");

public static void Make(StarSystemConfig.SkyboxModule module, IModBehaviour mod)
public static void Make(SkyboxModule module, IModBehaviour mod)
{
NHLogger.Log("Building Skybox");
BuildSkySphere(module, mod);
}

public static GameObject BuildSkySphere(StarSystemConfig.SkyboxModule module, IModBehaviour mod)
public static GameObject BuildSkySphere(SkyboxModule module, IModBehaviour mod)
{
var skybox = SearchUtilities.Find("Skybox");

Expand Down
9 changes: 6 additions & 3 deletions NewHorizons/Components/EOTE/NHSlideCollectionContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ public static bool SlideCollectionContainer_Initialize(SlideCollectionContainer
__instance._changeSlidesAllowed = true;
__instance._initialized = true;
__instance._slideCollection.isVision = __instance._owningItem == null;
foreach (var factID in __instance._playWithShipLogFacts)
if (__instance._playWithShipLogFacts != null)
{
var fact = Locator.GetShipLogManager().GetFact(factID);
fact?.RegisterSlideCollection(__instance._slideCollection);
foreach (var factID in __instance._playWithShipLogFacts)
{
var fact = Locator.GetShipLogManager().GetFact(factID);
fact?.RegisterSlideCollection(__instance._slideCollection);
}
}
return false;
}
Expand Down
45 changes: 0 additions & 45 deletions NewHorizons/External/Configs/StarSystemConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,51 +175,6 @@ public class NomaiCoordinates
public int[] z;
}

[JsonObject]
public class SkyboxModule
{

/// <summary>
/// Whether to destroy the star field around the player
/// </summary>
public bool destroyStarField;

/// <summary>
/// Whether to use a cube for the skybox instead of a smooth sphere
/// </summary>
public bool useCube;

/// <summary>
/// Relative filepath to the texture to use for the skybox's positive X direction
/// </summary>
public string rightPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's negative X direction
/// </summary>
public string leftPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's positive Y direction
/// </summary>
public string topPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's negative Y direction
/// </summary>
public string bottomPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's positive Z direction
/// </summary>
public string frontPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's negative Z direction
/// </summary>
public string backPath;
}

[JsonObject]
public class GlobalMusicModule
{
Expand Down
95 changes: 95 additions & 0 deletions NewHorizons/External/Configs/TitleScreenConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.SerializableData;
using NewHorizons.Handlers;
using Newtonsoft.Json;

namespace NewHorizons.External.Configs
{
[JsonObject]
public class TitleScreenConfig
{
/// <summary>
/// Colour of the text on the main menu
/// </summary>
public MColor menuTextTint;

/// <summary>
/// Ship log fact required for this title screen to appear.
/// </summary>
public string factRequiredForTitle;

/// <summary>
/// Persistent condition required for this title screen to appear.
/// </summary>
public string conditionRequiredForTitle;

/// <summary>
/// If set to true, NH generated planets will not show on the title screen. If false, this title screen has the same chance as other NH planet title screens to show.
/// </summary>
public bool disableNHPlanets = true;

/// <summary>
/// If set to true, this custom title screen will merge with all other custom title screens with shareTitleScreen set to true. If false, NH will randomly select between this and other valid title screens that are loaded.
/// </summary>
public bool shareTitleScreen = true;

/// <summary>
/// Customize the skybox for this title screen
/// </summary>
public SkyboxModule Skybox;

/// <summary>
/// The music audio that will play on the title screen. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string music;

/// <summary>
/// The ambience audio that will play on the title screen. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string ambience;

/// <summary>
/// Changes the speed the skybox rotates (and by extension the main menu planet). This is in degrees per second.
/// </summary>
public float rotationSpeed = 1;

/// <summary>
/// Edit properties of the main menu planet
/// </summary>
public MenuPlanetModule MenuPlanet;

[JsonObject]
public class MenuPlanetModule
{
/// <summary>
/// Disables the renderers of the main menu planet and all objects on it (this is to improve compatibility with other mods that don't use the NH title screen json).
/// </summary>
public bool destroyMenuPlanet = false;

/// <summary>
/// Disables the renderers of objects at the provided paths
/// </summary>
public string[] removeChildren;

/// <summary>
/// A list of DetailInfos to populate the main menu planet with.
/// </summary>
public SimplifiedDetailInfo[] details;

/// <summary>
/// Changes the speed the main menu planet. This is in degrees per second.
/// </summary>
public float rotationSpeed = 2;
}

/// <summary>
/// Extra data that may be used by extension mods
/// </summary>
public object extras;

public bool KnowsFact() => string.IsNullOrEmpty(factRequiredForTitle) || StandaloneProfileManager.SharedInstance.currentProfile != null && ShipLogHandler.KnowsFact(factRequiredForTitle);

public bool HasCondition() => string.IsNullOrEmpty(conditionRequiredForTitle) || StandaloneProfileManager.SharedInstance.currentProfile != null && PlayerData.GetPersistentCondition(conditionRequiredForTitle);
}
}
22 changes: 19 additions & 3 deletions NewHorizons/External/Modules/Props/DetailInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
namespace NewHorizons.External.Modules.Props
{
[JsonObject]
public class DetailInfo : GeneralPropInfo
public class SimplifiedDetailInfo : GeneralPropInfo
{
public DetailInfo() { }
public SimplifiedDetailInfo() { }

public DetailInfo(GeneralPointPropInfo info)
public SimplifiedDetailInfo(GeneralPointPropInfo info)
{
JsonConvert.PopulateObject(JsonConvert.SerializeObject(info), this);
}
Expand Down Expand Up @@ -47,6 +47,22 @@ public DetailInfo(GeneralPointPropInfo info)
/// Scale each axis of the prop. Overrides `scale`.
/// </summary>
public MVector3 stretch;
}

[JsonObject]
public class DetailInfo : SimplifiedDetailInfo
{
public DetailInfo() { }

public DetailInfo(GeneralPointPropInfo info)
{
JsonConvert.PopulateObject(JsonConvert.SerializeObject(info), this);
}

public DetailInfo(SimplifiedDetailInfo info)
{
JsonConvert.PopulateObject(JsonConvert.SerializeObject(info), this);
}

[Obsolete("Use QuantumDetailInfo")]
public string quantumGroupID;
Expand Down
48 changes: 48 additions & 0 deletions NewHorizons/External/Modules/SkyboxModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Newtonsoft.Json;

namespace NewHorizons.External.Modules
{
[JsonObject]
public class SkyboxModule
{
/// <summary>
/// Whether to destroy the star field around the player
/// </summary>
public bool destroyStarField;

/// <summary>
/// Whether to use a cube for the skybox instead of a smooth sphere
/// </summary>
public bool useCube;

/// <summary>
/// Relative filepath to the texture to use for the skybox's positive X direction
/// </summary>
public string rightPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's negative X direction
/// </summary>
public string leftPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's positive Y direction
/// </summary>
public string topPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's negative Y direction
/// </summary>
public string bottomPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's positive Z direction
/// </summary>
public string frontPath;

/// <summary>
/// Relative filepath to the texture to use for the skybox's negative Z direction
/// </summary>
public string backPath;
}
}
12 changes: 10 additions & 2 deletions NewHorizons/Handlers/AudioTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,28 @@ public static class AudioTypeHandler
{
private static Dictionary<string, AudioType> _customAudioTypes;
private static List<AudioLibrary.AudioEntry> _audioEntries;
private static bool _postInitialized = false;

public static void Init()
{
_customAudioTypes = new Dictionary<string, AudioType>();
_audioEntries = new List<AudioLibrary.AudioEntry>();
_postInitialized = false;

Delay.RunWhen(
() => Locator.GetAudioManager()?._libraryAsset != null,
Delay.RunWhen(() => Locator.GetAudioManager()?._libraryAsset != null && Locator.GetAudioManager()?._audioLibraryDict != null,
PostInit
);
}

private static void PostInit()
{
NHLogger.LogVerbose($"Adding all custom AudioTypes to the library");
_postInitialized = true;
ModifyAudioLibrary();
}

private static void ModifyAudioLibrary()
{
var library = Locator.GetAudioManager()._libraryAsset;
var audioEntries = library.audioEntries; // store previous array
library.audioEntries = library.audioEntries.Concat(_audioEntries).ToArray(); // concat custom entries
Expand Down Expand Up @@ -88,6 +94,8 @@ public static AudioType AddCustomAudioType(string id, AudioClip[] audioClips)
_audioEntries.Add(new AudioLibrary.AudioEntry(audioType, audioClips));
_customAudioTypes.Add(id, audioType);

if (_postInitialized) ModifyAudioLibrary();

return audioType;
}
}
Expand Down
Loading
Loading