Default to auto mapmode positioning, account for scale when spacing

This commit is contained in:
Nick 2024-02-21 15:27:05 -05:00
parent 6f1bdb44f3
commit b1320231ee
3 changed files with 21 additions and 8 deletions

View File

@ -45,16 +45,16 @@ namespace NewHorizons.Builder.ShipLog
} }
} }
if (flagManualPositionUsed) if (flagAutoPositionUsed)
{ {
if (flagAutoPositionUsed && flagManualPositionUsed) if (flagAutoPositionUsed && flagManualPositionUsed)
NHLogger.LogWarning("Can't mix manual and automatic layout of ship log map mode, defaulting to manual"); NHLogger.LogWarning("Can't mix manual and automatic layout of ship log map mode, defaulting to automatic");
return ConstructMapModeManual(bodies, transformParent, greyScaleMaterial, currentNav, layer);
}
else if (flagAutoPositionUsed)
{
return ConstructMapModeAuto(bodies, transformParent, greyScaleMaterial, layer); return ConstructMapModeAuto(bodies, transformParent, greyScaleMaterial, layer);
} }
else if (flagManualPositionUsed)
{
return ConstructMapModeManual(bodies, transformParent, greyScaleMaterial, currentNav, layer);
}
return null; return null;
} }
@ -475,7 +475,12 @@ namespace NewHorizons.Builder.ShipLog
private static void MakeNode(ref MapModeObject node, GameObject parent, Material greyScaleMaterial, int layer) 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; Vector2 position = Vector2.zero;
if (node.lastSibling != null) if (node.lastSibling != null)
{ {

View File

@ -1,6 +1,9 @@
#region #region
using NewHorizons.Utility.DebugTools.Menu;
using NewHorizons.Utility.OWML;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using UnityEngine; using UnityEngine;
#endregion #endregion
@ -26,6 +29,11 @@ namespace NewHorizons.External.SerializableData
public static implicit operator Vector2(MVector2 vec) 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); return new Vector2(vec.x, vec.y);
} }
} }

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.18.7", "version": "1.18.8",
"owmlVersion": "2.9.8", "owmlVersion": "2.9.8",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],