Use a fallback key for rich presence (#508)

This commit is contained in:
Nick 2023-01-23 08:39:57 -05:00 committed by GitHub
commit e26ead5985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -466,7 +466,7 @@ namespace NewHorizons.Handlers
}); });
} }
RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector); RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector, body.Config.Star != null, body.Config.Atmosphere != null);
Logger.LogVerbose($"Finished creating [{body.Config.name}]"); Logger.LogVerbose($"Finished creating [{body.Config.name}]");

View File

@ -9,6 +9,14 @@ namespace NewHorizons.OtherMods.OWRichPresence
public void SetTriggerActivation(bool active); public void SetTriggerActivation(bool active);
public GameObject CreateTrigger(GameObject parent, string message, string imageKey); public GameObject CreateTrigger(GameObject parent, string message, string imageKey);
public GameObject CreateTrigger(GameObject parent, Sector sector, string message, string imageKey); public GameObject CreateTrigger(GameObject parent, Sector sector, string message, string imageKey);
public GameObject CreateTrigger(GameObject parent, string message, string imageKey, string fallback);
public GameObject CreateTrigger(GameObject parent, Sector sector, string message, string imageKey, string fallback);
public void CreateTriggerVolume(OWTriggerVolume triggerVolume, string message, string imageKey);
public void CreateTriggerVolume(OWTriggerVolume triggerVolume, string message, string imageKey, string fallback);
public GameObject CreateTriggerVolume(GameObject parent, float radius, string message, string imageKey);
public GameObject CreateTriggerVolume(GameObject parent, float radius, string message, string imageKey, string fallback);
public GameObject CreateTriggerVolume(GameObject parent, Vector3 localPosition, float radius, string message, string imageKey);
public GameObject CreateTriggerVolume(GameObject parent, Vector3 localPosition, float radius, string message, string imageKey, string fallback);
public void SetCurrentRootPresence(string message, string imageKey); public void SetCurrentRootPresence(string message, string imageKey);
} }
} }

View File

@ -38,7 +38,7 @@ namespace NewHorizons.OtherMods.OWRichPresence
} }
} }
public static void SetUpPlanet(string name, GameObject go, Sector sector) public static void SetUpPlanet(string name, GameObject go, Sector sector, bool isStar = false, bool hasAtmosphere = false)
{ {
if (!Enabled) return; if (!Enabled) return;
@ -47,7 +47,11 @@ namespace NewHorizons.OtherMods.OWRichPresence
var localizedName = TranslationHandler.GetTranslation(name, TranslationHandler.TextType.UI); var localizedName = TranslationHandler.GetTranslation(name, TranslationHandler.TextType.UI);
var message = TranslationHandler.GetTranslation("RICH_PRESENCE_EXPLORING", TranslationHandler.TextType.UI).Replace("{0}", localizedName); var message = TranslationHandler.GetTranslation("RICH_PRESENCE_EXPLORING", TranslationHandler.TextType.UI).Replace("{0}", localizedName);
API.CreateTrigger(go, sector, message, name.Replace(" ", "").Replace("'", "").Replace("-", "").ToLowerInvariant()); string fallbackKey = "defaultplanet";
if (isStar) fallbackKey = "defaultstar";
else if (hasAtmosphere) fallbackKey = "defaultplanetatmosphere";
API.CreateTrigger(go, sector, message, name.Replace(" ", "").Replace("'", "").Replace("-", "").ToLowerInvariant(), fallbackKey);
} }
public static void OnStarSystemLoaded(string name) public static void OnStarSystemLoaded(string name)
@ -59,7 +63,7 @@ namespace NewHorizons.OtherMods.OWRichPresence
var localizedName = ShipLogStarChartMode.UniqueIDToName(name); var localizedName = ShipLogStarChartMode.UniqueIDToName(name);
var message = TranslationHandler.GetTranslation("RICH_PRESENCE_EXPLORING", TranslationHandler.TextType.UI).Replace("{0}", localizedName); var message = TranslationHandler.GetTranslation("RICH_PRESENCE_EXPLORING", TranslationHandler.TextType.UI).Replace("{0}", localizedName);
API.SetCurrentRootPresence(message, "sun"); API.SetCurrentRootPresence(message, "newhorizons");
} }
public static void OnChangeStarSystem(string destination) public static void OnChangeStarSystem(string destination)