## Bug fixes
- Default to automatic map mode positioning when mixing manual and
automatic (would just break before)
- Account for map mode image scale when automatically positioning
This commit is contained in:
xen-42 2024-02-21 16:01:54 -05:00 committed by GitHub
commit 3e1de0b511
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 9 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

@ -1,10 +1,10 @@
{ {
"$schema": "https://raw.githubusercontent.com/amazingalek/owml/master/schemas/manifest_schema.json", "$schema": "https://raw.githubusercontent.com/amazingalek/owml/master/schemas/manifest_schema.json",
"filename": "NewHorizons.dll", "filename": "NewHorizons.dll",
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends",
"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" ],