From b1320231eec372ac53a7722b6f283325263f52c9 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 21 Feb 2024 15:27:05 -0500 Subject: [PATCH 1/2] Default to auto mapmode positioning, account for scale when spacing --- NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 19 ++++++++++++------- .../External/SerializableData/MVector2.cs | 8 ++++++++ NewHorizons/manifest.json | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index d1a174b0..ff52a30b 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -45,16 +45,16 @@ namespace NewHorizons.Builder.ShipLog } } - if (flagManualPositionUsed) + if (flagAutoPositionUsed) { if (flagAutoPositionUsed && flagManualPositionUsed) - NHLogger.LogWarning("Can't mix manual and automatic layout of ship log map mode, defaulting to manual"); - return ConstructMapModeManual(bodies, transformParent, greyScaleMaterial, currentNav, layer); - } - else if (flagAutoPositionUsed) - { + NHLogger.LogWarning("Can't mix manual and automatic layout of ship log map mode, defaulting to automatic"); return ConstructMapModeAuto(bodies, transformParent, greyScaleMaterial, layer); } + else if (flagManualPositionUsed) + { + return ConstructMapModeManual(bodies, transformParent, greyScaleMaterial, currentNav, layer); + } return null; } @@ -475,7 +475,12 @@ namespace NewHorizons.Builder.ShipLog private static void MakeNode(ref MapModeObject node, GameObject parent, Material greyScaleMaterial, int layer) { - const float padding = 100f; + // Space between this node and the previous node + // Take whatever scale will prevent overlap + var lastSiblingScale = node.lastSibling?.mainBody?.Config?.ShipLog?.mapMode?.scale ?? 1f; + var scale = node.mainBody?.Config?.ShipLog?.mapMode?.scale ?? 1f; + float padding = 100f * (scale + lastSiblingScale) / 2f; + Vector2 position = Vector2.zero; if (node.lastSibling != null) { diff --git a/NewHorizons/External/SerializableData/MVector2.cs b/NewHorizons/External/SerializableData/MVector2.cs index 77c3eccc..0e4aadd6 100644 --- a/NewHorizons/External/SerializableData/MVector2.cs +++ b/NewHorizons/External/SerializableData/MVector2.cs @@ -1,6 +1,9 @@ #region +using NewHorizons.Utility.DebugTools.Menu; +using NewHorizons.Utility.OWML; using Newtonsoft.Json; +using System; using UnityEngine; #endregion @@ -26,6 +29,11 @@ namespace NewHorizons.External.SerializableData public static implicit operator Vector2(MVector2 vec) { + if (vec == null) + { + NHLogger.LogWarning($"Null MVector2 can't be turned into a non-nullable Vector2, returning Vector2.zero - {Environment.StackTrace}"); + return Vector2.zero; + } return new Vector2(vec.x, vec.y); } } diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 3359833d..ad58b177 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.18.7", + "version": "1.18.8", "owmlVersion": "2.9.8", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From d4eff832cedc9b3102788df9e084e355643384f6 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 21 Feb 2024 15:36:08 -0500 Subject: [PATCH 2/2] Gotta commit something so I take away credit haha --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index ad58b177..447d846b 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/amazingalek/owml/master/schemas/manifest_schema.json", "filename": "NewHorizons.dll", - "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", + "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "name": "New Horizons", "uniqueName": "xen.NewHorizons", "version": "1.18.8",