Fix opacity on star icon, fix generated map mode icon states

This commit is contained in:
Nick 2024-03-25 13:08:42 -04:00
parent 0e10d31995
commit 53d3f70a22
3 changed files with 31 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -148,6 +148,7 @@ namespace NewHorizons.Builder.ShipLog
astroObject._imageObj = CreateImage(gameObject, image, body.Config.name + " Revealed", layer);
astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.name + " Outline", layer);
if (ShipLogHandler.BodyHasEntries(body))
{
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
@ -162,6 +163,12 @@ namespace NewHorizons.Builder.ShipLog
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
astroObject._unviewedObj.transform.localPosition = new Vector3(imageRect.width / 2 + unviewedIconOffset, imageRect.height / 2 + unviewedIconOffset, 0);
// Set all icons inactive, they will be conditionally activated when the map mode is opened for the first time
astroObject._unviewedObj.SetActive(false);
astroObject._imageObj.SetActive(false);
astroObject._outlineObj.SetActive(false);
return astroObject;
}
#endregion

View File

@ -25,9 +25,32 @@ namespace NewHorizons.Patches.ShipLogPatches
}
}
[HarmonyPrefix]
[HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))]
public static bool ShipLogAstroObject_UpdateState_Pre(ShipLogAstroObject __instance)
{
// Custom astro objects might have no entries, in this case they will be permanently hidden
// Just treat it as if it were revealed
if (__instance._entries.Count == 0)
{
__instance._state = ShipLogEntry.State.Explored;
__instance._imageObj.SetActive(true);
__instance._outlineObj?.SetActive(false);
if (__instance._image != null)
{
__instance.SetMaterialGreyscale(false);
__instance._image.color = Color.white;
}
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))]
public static void ShipLogAstroObject_UpdateState(ShipLogAstroObject __instance)
public static void ShipLogAstroObject_UpdateState_Post(ShipLogAstroObject __instance)
{
Transform detailsParent = __instance.transform.Find("Details");
if (detailsParent != null)