Sfoglia il codice sorgente

Merge pull request #18 from PrincessRTFM/master

More QoL fixes
SheepGoMeh 3 anni fa
parent
commit
60ff8b582f
3 ha cambiato i file con 52 aggiunte e 27 eliminazioni
  1. 23 22
      HuntBuddy/Interface.cs
  2. 28 4
      HuntBuddy/Ipc/TeleportConsumer.cs
  3. 1 1
      HuntBuddy/Plugin.cs

+ 23 - 22
HuntBuddy/Interface.cs

@@ -155,7 +155,7 @@ namespace HuntBuddy
 
 							ImGui.SameLine();
 
-							if (Plugin.TeleportConsumer?.Subscribed == true)
+							if (Plugin.TeleportConsumer?.IsAvailable == true)
 							{
 								if (Interface.IconButton(FontAwesomeIcon.StreetView, $"t##{mobHuntEntry.MobHuntId}"))
 								{
@@ -278,38 +278,39 @@ namespace HuntBuddy
 
 					ImGui.SameLine();
 
-					if (Interface.IconButton(FontAwesomeIcon.Compass, $"openRadius##{mobHuntEntry.MobHuntId}"))
-					{
-						Location.CreateMapMarker(
-							mobHuntEntry.TerritoryType,
-							mobHuntEntry.MapId,
-							mobHuntEntry.MobHuntId,
-							mobHuntEntry.Name,
-							Location.OpenType.ShowOpen);
-					}
-
-					if (ImGui.IsItemHovered())
-					{
-						ImGui.BeginTooltip();
-						ImGui.Text("Show hunt area on the map");
-						ImGui.EndTooltip();
-					}
-
-					ImGui.SameLine();
-
 					if (Interface.IconButton(FontAwesomeIcon.MapMarkedAlt, $"open##{mobHuntEntry.MobHuntId}"))
 					{
+						var includeArea = this.plugin.Configuration.IncludeAreaOnMap;
+						if (ImGui.IsKeyDown(ImGuiKey.ModShift))
+						{
+							includeArea = !includeArea;
+						}
 						Location.CreateMapMarker(
 							mobHuntEntry.TerritoryType,
 							mobHuntEntry.MapId,
 							mobHuntEntry.MobHuntId,
-							mobHuntEntry.Name);
+							mobHuntEntry.Name,
+							includeArea ? Location.OpenType.ShowOpen : Location.OpenType.MarkerOpen);
 					}
 
 					if (ImGui.IsItemHovered())
 					{
+						var color = ImGui.IsKeyDown(ImGuiKey.ModShift) ? new Vector4(0f, 0.7f, 0f, 1f) : new Vector4(0.7f, 0.7f, 0.7f, 1f);
 						ImGui.BeginTooltip();
-						ImGui.Text("Show hunt location on the map");
+						if (this.plugin.Configuration.IncludeAreaOnMap)
+						{
+							ImGui.Text("Show hunt area on the map");
+							ImGui.TextColored(
+								color,
+								"Hold [SHIFT] to show the location only");
+						}
+						else
+						{
+							ImGui.Text("Show hunt location on the map");
+							ImGui.TextColored(
+								color,
+								"Hold [SHIFT] to include the area");
+						}
 						ImGui.EndTooltip();
 					}
 

+ 28 - 4
HuntBuddy/Ipc/TeleportConsumer.cs

@@ -6,8 +6,34 @@ namespace HuntBuddy.Ipc
 {
 	public class TeleportConsumer
 	{
-		public bool Subscribed { get; private set; }
+		private bool isAvailable;
+		private long timeSinceLastCheck;
 
+		public bool IsAvailable
+		{
+			get
+			{
+				if (this.timeSinceLastCheck + 5000 > Environment.TickCount64)
+				{
+					return this.isAvailable;
+				}
+
+				try
+				{
+					this.consumerMessageSetting.InvokeFunc();
+					this.isAvailable = true;
+					this.timeSinceLastCheck = Environment.TickCount64;
+				}
+				catch
+				{
+					this.isAvailable = false;
+				}
+
+				return this.isAvailable;
+			}
+		}
+
+		private ICallGateSubscriber<bool> consumerMessageSetting = null!;
 		private ICallGateSubscriber<uint, byte, bool> consumerTeleport = null!;
 
 		private void Subscribe()
@@ -15,12 +41,10 @@ namespace HuntBuddy.Ipc
 			try
 			{
 				this.consumerTeleport = Plugin.PluginInterface.GetIpcSubscriber<uint, byte, bool>("Teleport");
-
-				this.Subscribed = true;
+				this.consumerMessageSetting = Plugin.PluginInterface.GetIpcSubscriber<bool>("Teleport.ChatMessage");
 			}
 			catch (Exception ex)
 			{
-				this.Subscribed = false;
 				PluginLog.LogDebug($"Failed to subscribe to Teleporter\nReason: {ex}");
 			}
 		}

+ 1 - 1
HuntBuddy/Plugin.cs

@@ -202,7 +202,7 @@ namespace HuntBuddy
 						}
 						if (chosen != null)
 						{
-							PluginLog.Information($"Selected next hunt target: {chosen.Name}");
+							Chat.Print($"Hunting {chosen.Name} in {chosen.TerritoryName}");
 							Location.CreateMapMarker(
 								chosen.TerritoryType,
 								chosen.MapId,