Prechádzať zdrojové kódy

Only show teleport option when successfully subscribed to Teleporter plugin

Dragon 4 rokov pred
rodič
commit
22be39db11
2 zmenil súbory, kde vykonal 26 pridanie a 5 odobranie
  1. 22 5
      Interface.cs
  2. 4 0
      Ipc/TeleportConsumer.cs

+ 22 - 5
Interface.cs

@@ -83,15 +83,32 @@ namespace HuntBuddy
 									mobHuntEntry.MobHuntId);
 							}
 
-							ImGui.SameLine();
-
-							if (Interface.IconButton(FontAwesomeIcon.StreetView, $"t##{mobHuntEntry.MobHuntId}"))
+							if (ImGui.IsItemHovered())
 							{
-								Location.TeleportToNearestAetheryte(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
-									mobHuntEntry.MobHuntId);
+								ImGui.BeginTooltip();
+								ImGui.Text("Show hunt location on the map");
+								ImGui.EndTooltip();
 							}
 
 							ImGui.SameLine();
+
+							if (Plugin.TeleportConsumer?.Subscribed == true)
+							{
+								if (Interface.IconButton(FontAwesomeIcon.StreetView, $"t##{mobHuntEntry.MobHuntId}"))
+								{
+									Location.TeleportToNearestAetheryte(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
+										mobHuntEntry.MobHuntId);
+								}
+
+								if (ImGui.IsItemHovered())
+								{
+									ImGui.BeginTooltip();
+									ImGui.Text("Teleport to nearest aetheryte");
+									ImGui.EndTooltip();
+								}
+
+								ImGui.SameLine();
+							}
 						}
 
 						var currentKills = this._plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];

+ 4 - 0
Ipc/TeleportConsumer.cs

@@ -6,6 +6,7 @@ namespace HuntBuddy.Ipc
 {
 	public class TeleportConsumer
 	{
+		public bool Subscribed { get; private set; }
 		private ICallGateSubscriber<uint, byte, bool> _consumerTeleport = null!;
 
 		private void Subscribe()
@@ -13,9 +14,12 @@ namespace HuntBuddy.Ipc
 			try
 			{
 				this._consumerTeleport = Plugin.PluginInterface.GetIpcSubscriber<uint, byte, bool>("Teleport");
+
+				this.Subscribed = true;
 			}
 			catch (Exception ex)
 			{
+				this.Subscribed = false;
 				PluginLog.LogDebug($"Failed to subscribe to Teleporter\nReason: {ex}");
 			}
 		}