mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
I've gone past the point of insanity
Starting out is a pain. So far I'm just sketching out what I will be implementing. How I will implement the merging of title screens is what is making me go insane.
This commit is contained in:
parent
0c2709bff6
commit
5fc78411ac
11
NewHorizons/Assets/title-screen.json
Normal file
11
NewHorizons/Assets/title-screen.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"disableNHPlanets": false,
|
||||||
|
"mergeWithOtherTitles": true,
|
||||||
|
// FOR TESTING!!!!
|
||||||
|
// Remove once actually loading a json file is implemented
|
||||||
|
"menuTextTint": {
|
||||||
|
"r": 128,
|
||||||
|
"g": 128,
|
||||||
|
"b": 255
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,8 @@
|
|||||||
|
using NewHorizons.External.Modules;
|
||||||
|
using NewHorizons.External.Modules.Props;
|
||||||
using NewHorizons.External.SerializableData;
|
using NewHorizons.External.SerializableData;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NewHorizons.External.Configs
|
namespace NewHorizons.External.Configs
|
||||||
{
|
{
|
||||||
@ -15,5 +13,73 @@ namespace NewHorizons.External.Configs
|
|||||||
/// Colour of the text on the main menu
|
/// Colour of the text on the main menu
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MColor menuTextTint;
|
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>
|
||||||
|
/// Relative path to music to replace the title screen music with.
|
||||||
|
/// </summary>
|
||||||
|
public string music;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the speed the main menu planet and the skybox rotates.
|
||||||
|
/// </summary>
|
||||||
|
public float rotationSpeed;
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
/// Extra data that may be used by extension mods
|
||||||
|
/// </summary>
|
||||||
|
public object extras;
|
||||||
|
|
||||||
|
public bool KnowsFact() => string.IsNullOrEmpty(factRequiredForTitle) || ShipLogHandler.KnowsFact(factRequiredForTitle);
|
||||||
|
|
||||||
|
public bool HasCondition() => string.IsNullOrEmpty(conditionRequiredForTitle) || PlayerData.GetPersistentCondition(conditionRequiredForTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
using NewHorizons.Builder.Body;
|
using NewHorizons.Builder.Body;
|
||||||
|
using NewHorizons.Builder.StarSystem;
|
||||||
using NewHorizons.External;
|
using NewHorizons.External;
|
||||||
using NewHorizons.External.Configs;
|
using NewHorizons.External.Configs;
|
||||||
using NewHorizons.External.Modules;
|
using NewHorizons.External.Modules;
|
||||||
|
using NewHorizons.External.Modules.Props;
|
||||||
using NewHorizons.Handlers.TitleScreen;
|
using NewHorizons.Handlers.TitleScreen;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
|
using OWML.Common;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -28,12 +31,82 @@ namespace NewHorizons.Handlers
|
|||||||
subtitleContainer.AddComponent<SubtitlesHandler>();
|
subtitleContainer.AddComponent<SubtitlesHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetUp(TitleScreenConfig config)
|
public static void SetUp(IModBehaviour mod, TitleScreenConfig config)
|
||||||
{
|
{
|
||||||
if (config.menuTextTint != null)
|
if (config.menuTextTint != null)
|
||||||
{
|
{
|
||||||
TitleScreenColourHandler.SetColour(config.menuTextTint.ToColor());
|
TitleScreenColourHandler.SetColour(config.menuTextTint.ToColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.Skybox?.destroyStarField ?? false)
|
||||||
|
{
|
||||||
|
Object.Destroy(SearchUtilities.Find("Skybox/Starfield"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.Skybox?.rightPath != null ||
|
||||||
|
config.Skybox?.leftPath != null ||
|
||||||
|
config.Skybox?.topPath != null ||
|
||||||
|
config.Skybox?.bottomPath != null ||
|
||||||
|
config.Skybox?.frontPath != null ||
|
||||||
|
config.Skybox?.bottomPath != null)
|
||||||
|
{
|
||||||
|
SkyboxBuilder.Make(config.Skybox, mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(config.music))
|
||||||
|
{
|
||||||
|
//TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.MenuPlanet != null)
|
||||||
|
{
|
||||||
|
if (config.MenuPlanet.destroyMenuPlanet)
|
||||||
|
{
|
||||||
|
//TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.MenuPlanet.removeChildren != null)
|
||||||
|
{
|
||||||
|
//TODO: Implement
|
||||||
|
//RemoveChildren(null, config.MenuPlanet.removeChildren);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.MenuPlanet.details != null)
|
||||||
|
{
|
||||||
|
foreach (var simplifiedDetail in config.MenuPlanet.details)
|
||||||
|
{
|
||||||
|
var detail = new DetailInfo(simplifiedDetail);
|
||||||
|
//TODO: Implement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RemoveChildren(GameObject go, string[] paths)
|
||||||
|
{
|
||||||
|
var goPath = go.transform.GetPath();
|
||||||
|
var transforms = go.GetComponentsInChildren<Transform>(true);
|
||||||
|
foreach (var childPath in paths)
|
||||||
|
{
|
||||||
|
// Multiple children can have the same path so we delete all that match
|
||||||
|
var path = $"{goPath}/{childPath}";
|
||||||
|
|
||||||
|
var flag = true;
|
||||||
|
foreach (var childObj in transforms.Where(x => x.GetPath() == path))
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
// idk why we wait here but we do
|
||||||
|
Delay.FireInNUpdates(() =>
|
||||||
|
{
|
||||||
|
if (childObj != null && childObj.gameObject != null)
|
||||||
|
{
|
||||||
|
childObj.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag) NHLogger.LogWarning($"Couldn't find \"{childPath}\".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DisplayBodyOnTitleScreen(List<NewHorizonsBody> bodies)
|
public static void DisplayBodyOnTitleScreen(List<NewHorizonsBody> bodies)
|
||||||
|
|||||||
@ -96,6 +96,16 @@ namespace NewHorizons
|
|||||||
///</summary>
|
///</summary>
|
||||||
T QuerySystem<T>(string path);
|
T QuerySystem<T>(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uses JSONPath to query a title screen config
|
||||||
|
/// </summary>
|
||||||
|
object QueryTitleScreen(Type outType, IModBehaviour mod, string path);
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Uses JSONPath to query a title screen config
|
||||||
|
/// </summary>
|
||||||
|
T QueryTitleScreen<T>(IModBehaviour mod, string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register your own builder that will act on the given GameObject by reading the json string of its "extras" module
|
/// Register your own builder that will act on the given GameObject by reading the json string of its "extras" module
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -222,5 +232,8 @@ namespace NewHorizons
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
void SetNextSpawnID(string id);
|
void SetNextSpawnID(string id);
|
||||||
|
|
||||||
|
|
||||||
|
void RegisterTitleScreenHandler(Action<GameObject> builder, bool deleteNHPlanets = true, bool shareTitleScreen = false, string conditionRequired = null, string factRequired = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,7 @@ namespace NewHorizons
|
|||||||
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new();
|
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new();
|
||||||
public static List<IModBehaviour> MountedAddons = new();
|
public static List<IModBehaviour> MountedAddons = new();
|
||||||
public static Dictionary<IModBehaviour, AddonConfig> AddonConfigs = new();
|
public static Dictionary<IModBehaviour, AddonConfig> AddonConfigs = new();
|
||||||
|
public static Dictionary<IModBehaviour, TitleScreenConfig> TitleScreenConfigs = new();
|
||||||
|
|
||||||
public static float SecondsElapsedInLoop = -1;
|
public static float SecondsElapsedInLoop = -1;
|
||||||
|
|
||||||
@ -269,6 +270,7 @@ namespace NewHorizons
|
|||||||
OnChangeStarSystem.AddListener(RichPresenceHandler.OnChangeStarSystem);
|
OnChangeStarSystem.AddListener(RichPresenceHandler.OnChangeStarSystem);
|
||||||
|
|
||||||
LoadAddonManifest("Assets/addon-manifest.json", this);
|
LoadAddonManifest("Assets/addon-manifest.json", this);
|
||||||
|
LoadTitleScreenConfig("Assets/title-screen.json", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetupPauseMenu(IPauseMenuManager pauseMenu)
|
public override void SetupPauseMenu(IPauseMenuManager pauseMenu)
|
||||||
@ -431,9 +433,9 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
TitleSceneHandler.InitSubtitles();
|
TitleSceneHandler.InitSubtitles();
|
||||||
|
|
||||||
// FOR TESTING!!!!
|
// TODO: Select one title screen and if it has shareTitleScreen set to true do all the other ones that have it true too.
|
||||||
// Remove once actually loading a json file is implemented
|
var (mod, config) = Main.TitleScreenConfigs.FirstOrDefault(kvp => kvp.Value.KnowsFact() && kvp.Value.HasCondition());
|
||||||
TitleSceneHandler.SetUp(new TitleScreenConfig() { menuTextTint = new External.SerializableData.MColor(128, 128, 255) });
|
TitleSceneHandler.SetUp(mod, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOTU fixes
|
// EOTU fixes
|
||||||
@ -792,6 +794,10 @@ namespace NewHorizons
|
|||||||
{
|
{
|
||||||
LoadAddonManifest("addon-manifest.json", mod);
|
LoadAddonManifest("addon-manifest.json", mod);
|
||||||
}
|
}
|
||||||
|
if (File.Exists(Path.Combine(folder, "title-screen.json")))
|
||||||
|
{
|
||||||
|
LoadTitleScreenConfig("title-screen.json", mod);
|
||||||
|
}
|
||||||
if (Directory.Exists(Path.Combine(folder, "translations")))
|
if (Directory.Exists(Path.Combine(folder, "translations")))
|
||||||
{
|
{
|
||||||
LoadTranslations(folder, mod);
|
LoadTranslations(folder, mod);
|
||||||
@ -840,6 +846,21 @@ namespace NewHorizons
|
|||||||
AddonConfigs[mod] = addonConfig;
|
AddonConfigs[mod] = addonConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadTitleScreenConfig(string file, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
NHLogger.LogVerbose($"Loading title screen config for {mod.ModHelper.Manifest.Name}");
|
||||||
|
|
||||||
|
var titleScreenConfig = mod.ModHelper.Storage.Load<TitleScreenConfig>(file, false);
|
||||||
|
|
||||||
|
if (titleScreenConfig == null)
|
||||||
|
{
|
||||||
|
NHLogger.LogError($"Title screen config for {mod.ModHelper.Manifest.Name} could not load, check your JSON");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TitleScreenConfigs[mod] = titleScreenConfig;
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadTranslations(string folder, IModBehaviour mod)
|
private void LoadTranslations(string folder, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
var foundFile = false;
|
var foundFile = false;
|
||||||
|
|||||||
@ -178,6 +178,24 @@ namespace NewHorizons
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object QueryTitleScreen(Type outType, IModBehaviour mod, string jsonPath)
|
||||||
|
{
|
||||||
|
var titleScreenConfig = Main.TitleScreenConfigs[mod];
|
||||||
|
return titleScreenConfig == null
|
||||||
|
? null
|
||||||
|
: QueryJson(outType, Path.Combine(mod.ModHelper.Manifest.ModFolderPath, "title-screen.json"), jsonPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T QueryTitleScreen<T>(IModBehaviour mod, string jsonPath)
|
||||||
|
{
|
||||||
|
var data = QueryTitleScreen(typeof(T), mod, jsonPath);
|
||||||
|
if (data is T result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
public GameObject SpawnObject(IModBehaviour mod, GameObject planet, Sector sector, string propToCopyPath, Vector3 position, Vector3 eulerAngles,
|
public GameObject SpawnObject(IModBehaviour mod, GameObject planet, Sector sector, string propToCopyPath, Vector3 position, Vector3 eulerAngles,
|
||||||
float scale, bool alignRadial)
|
float scale, bool alignRadial)
|
||||||
{
|
{
|
||||||
@ -344,5 +362,11 @@ namespace NewHorizons
|
|||||||
public void AddSubtitle(IModBehaviour mod, string filePath) => SubtitlesHandler.RegisterAdditionalSubtitle(mod, filePath);
|
public void AddSubtitle(IModBehaviour mod, string filePath) => SubtitlesHandler.RegisterAdditionalSubtitle(mod, filePath);
|
||||||
|
|
||||||
public void SetNextSpawnID(string id) => PlayerSpawnHandler.TargetSpawnID = id;
|
public void SetNextSpawnID(string id) => PlayerSpawnHandler.TargetSpawnID = id;
|
||||||
|
|
||||||
|
// TODO: Implement
|
||||||
|
public void RegisterTitleScreenHandler(Action<GameObject> builder, bool deleteNHPlanets = true, bool shareTitleScreen = false, string conditionRequired = null, string factRequired = null)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public static class SchemaExporter
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_title is "Star System Schema" or "Celestial Body Schema")
|
if (_title is "Star System Schema" or "Celestial Body Schema" or "Title Screen Schema")
|
||||||
{
|
{
|
||||||
schema.Properties["extras"] = new JsonSchemaProperty {
|
schema.Properties["extras"] = new JsonSchemaProperty {
|
||||||
Type = JsonObjectType.Object,
|
Type = JsonObjectType.Object,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user