diff --git a/NewHorizons/External/SerializableData/MColor.cs b/NewHorizons/External/SerializableData/MColor.cs index 0f08bd69..9c1d2fa1 100644 --- a/NewHorizons/External/SerializableData/MColor.cs +++ b/NewHorizons/External/SerializableData/MColor.cs @@ -14,6 +14,14 @@ namespace NewHorizons.External.SerializableData this.a = a; } + public MColor(Color color) + { + r = (int)(color.r * 255); + g = (int)(color.g * 255); + b = (int)(color.b * 255); + a = (int)(color.a * 255); + } + /// /// The red component of this colour from 0-255, higher values will make the colour glow if applicable. /// diff --git a/NewHorizons/INewHorizons.cs b/NewHorizons/INewHorizons.cs index d1872826..9f74f883 100644 --- a/NewHorizons/INewHorizons.cs +++ b/NewHorizons/INewHorizons.cs @@ -18,12 +18,13 @@ namespace NewHorizons /// /// Directly add ship logs from XML. Call this method right before ShipLogManager awake. /// - /// - /// - /// - /// - /// - void AddShipLogXML(IModBehaviour mod, ShipLogManager manager, XElement xml, string planetName, Dictionary entryPositions); + /// The mod this method is being called from. This is required for loading files. + /// The ship log xml contents + /// The planet that these ship logs correspond to in the map mode + /// The relative path from your mod manifest.json where the ship log images are located. The filename must be the same as the fact id. Optional. + /// A dictionary of each fact id to its 2D position in the ship log. Optional. + /// A dictionary of each curiousity ID to its colour and highlight colour in the ship log. Optional. + void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder = null, Dictionary entryPositions = null, Dictionary curiousityColours = null); /// /// Will load all configs in the regular folders (planets, systems, translations, etc) for this mod. diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index dd5a524e..f0c6221a 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -7,6 +7,7 @@ using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props.Audio; using NewHorizons.External.Modules.Props.Dialogue; +using NewHorizons.External.SerializableData; using NewHorizons.Utility; using NewHorizons.Utility.OWML; using Newtonsoft.Json; @@ -66,9 +67,17 @@ namespace NewHorizons } } - public void AddShipLogXML(IModBehaviour mod, ShipLogManager manager, XElement xml, string planetName, Dictionary entryPositions) + public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder, Dictionary entryPositions, Dictionary curiousityColours) { - var body = new NewHorizonsBody(new PlanetConfig() { name = planetName, starSystem = Main.Instance.CurrentStarSystem }, mod); + var body = new NewHorizonsBody(new PlanetConfig() + { + name = planetName, + starSystem = Main.Instance.CurrentStarSystem, + ShipLog = new ShipLogModule() + { + spriteFolder = imageFolder + } + }, mod); if (!Main.BodyDict.ContainsKey(Main.Instance.CurrentStarSystem)) { @@ -77,7 +86,8 @@ namespace NewHorizons } else { - var existingBody = Main.BodyDict[Main.Instance.CurrentStarSystem].FirstOrDefault(x => x.Config.name == planetName); + var existingBody = Main.BodyDict[Main.Instance.CurrentStarSystem] + .FirstOrDefault(x => x.Config.name == planetName && x.Mod.ModHelper.Manifest.UniqueName == mod.ModHelper.Manifest.UniqueName); if (existingBody != null) { body = existingBody; @@ -88,10 +98,19 @@ namespace NewHorizons } } - var system = new StarSystemConfig() { entryPositions = entryPositions.Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value }).ToArray() }; + var system = new StarSystemConfig() + { + entryPositions = entryPositions + .Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value }) + .ToArray(), + curiosities = curiousityColours + .Select((pair) => new CuriosityColorInfo() { id = pair.Key, color = new MColor(pair.Value.colour), highlightColor = new MColor(pair.Value.highlight) }) + .ToArray() + }; + Main.Instance.LoadStarSystemConfig(system, null, mod); - RumorModeBuilder.AddShipLogXML(manager, xml, body); + RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType(), xml, body); } public void LoadConfigs(IModBehaviour mod)