Hn mapmode and subtitle borked (#816)

## Bug fixes
- Fix ship log map mode auto/manual placement
- Fix subtitle becoming invisible when image width is smaller than EOTE
subtitle
This commit is contained in:
xen-42 2024-03-21 23:10:37 -04:00 committed by GitHub
commit bb662a610a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 9 deletions

View File

@ -30,7 +30,7 @@ namespace NewHorizons.Builder.ShipLog
{ {
if (body.Config.ShipLog == null) continue; if (body.Config.ShipLog == null) continue;
if (body.Config.ShipLog?.mapMode?.manualPosition == null) if (body.Config.ShipLog.mapMode?.manualPosition == null)
{ {
flagAutoPositionUsed = true; flagAutoPositionUsed = true;
} }
@ -45,6 +45,12 @@ namespace NewHorizons.Builder.ShipLog
} }
} }
// If they're both false, just default to auto (this means that no planets even have ship log info)
if (!flagManualPositionUsed && !flagAutoPositionUsed)
{
flagAutoPositionUsed = true;
}
var isBaseSolarSystem = systemName == "SolarSystem"; var isBaseSolarSystem = systemName == "SolarSystem";
// Default to MANUAL in Base Solar System (we can't automatically fix them so it might just break, but AUTO breaks even more!) // Default to MANUAL in Base Solar System (we can't automatically fix them so it might just break, but AUTO breaks even more!)

View File

@ -213,7 +213,6 @@ namespace NewHorizons.External.Configs
// Always have to have a base module // Always have to have a base module
if (Base == null) Base = new BaseModule(); if (Base == null) Base = new BaseModule();
if (Orbit == null) Orbit = new OrbitModule(); if (Orbit == null) Orbit = new OrbitModule();
if (ShipLog == null) ShipLog = new ShipLogModule();
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule(); if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
} }

View File

@ -11,8 +11,8 @@ namespace NewHorizons.Handlers
{ {
class SubtitlesHandler : MonoBehaviour class SubtitlesHandler : MonoBehaviour
{ {
public static int SUBTITLE_HEIGHT = 97; public static float SUBTITLE_HEIGHT = 97;
public static int SUBTITLE_WIDTH = 669; // nice public static float SUBTITLE_WIDTH = 669; // nice
public float fadeSpeed = 0.005f; public float fadeSpeed = 0.005f;
public float fade = 1; public float fade = 1;
@ -67,7 +67,7 @@ namespace NewHorizons.Handlers
CheckForEOTE(); CheckForEOTE();
// We add our subtitles as a child object so that their sizing doesnt shift the layout of the main menu // We add our subtitles as a child object so that their sizing doesnt shift the layout of the main menu
_subtitleDisplay = new GameObject().AddComponent<Image>(); _subtitleDisplay = new GameObject("SubtitleDisplay").AddComponent<Image>();
_subtitleDisplay.transform.parent = transform; _subtitleDisplay.transform.parent = transform;
_subtitleDisplay.transform.localPosition = new Vector3(0, 0, 0); _subtitleDisplay.transform.localPosition = new Vector3(0, 0, 0);
_subtitleDisplay.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); _subtitleDisplay.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
@ -173,9 +173,12 @@ namespace NewHorizons.Handlers
{ {
subtitleIndex = (subtitleIndex + 1) % possibleSubtitles.Count; subtitleIndex = (subtitleIndex + 1) % possibleSubtitles.Count;
_subtitleDisplay.sprite = possibleSubtitles[subtitleIndex]; var subtitle = possibleSubtitles[subtitleIndex];
var ratio = SUBTITLE_WIDTH / _subtitleDisplay.sprite.texture.width; _subtitleDisplay.sprite = subtitle;
_subtitleDisplay.rectTransform.sizeDelta = new Vector2(_subtitleDisplay.sprite.texture.width, _subtitleDisplay.sprite.texture.height) * ratio; var width = subtitle.texture.width;
var height = subtitle.texture.height;
var ratio = SUBTITLE_WIDTH / width; // one of these needs to be a float so that compiler doesn't think "oh 2 integers! let's round to nearest whole"
_subtitleDisplay.rectTransform.sizeDelta = new Vector2(width, height) * ratio;
} }
} }
} }