| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Threading.Tasks;
- using Dalamud.Interface;
- using Dalamud.Interface.Utility;
- using Dalamud.Interface.Windowing;
- using FFXIVClientStructs.FFXIV.Client.Game.UI;
- using HuntBuddy.Utils;
- using ImGuiNET;
- namespace HuntBuddy.Windows;
- /// <summary>
- /// Main plugin window.
- /// </summary>
- public class MainWindow: Window {
- public MainWindow() : base(
- $"{Plugin.Instance.Name}",
- ImGuiWindowFlags.NoDocking,
- true) {
- this.Size = new Vector2(400 * ImGui.GetIO().FontGlobalScale, 500);
- this.SizeCondition = ImGuiCond.FirstUseEver;
- this.RespectCloseHotkey = !Plugin.Instance.Configuration.IgnoreCloseHotkey;
- }
- public override void PreOpenCheck() {
- if (Plugin.Instance.Configuration.LockWindowPositions) {
- this.Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
- }
- else {
- this.Flags &= ~(ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);
- }
- }
- public override unsafe void Draw() {
- if (!Plugin.Instance.MobHuntEntriesReady) {
- ImGui.Text("Reloading data ...");
- return;
- }
- ImGui.BeginGroup();
- ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.8f, 0.2f, 0.2f, 1));
- InterfaceUtil.DrawCenteredText("B-RANK AND ARR HUNT MARK");
- InterfaceUtil.DrawCenteredText("LOCATIONS ARE NOT SUPPORTED");
- ImGui.PopStyleColor();
- ImGui.EndGroup();
- if (ImGui.IsItemHovered()) {
- InterfaceUtil.DrawWrappedTooltip(ImGuiHelpers.GlobalScale * 400,
- "B-rank marks have a varying number of potential spawn locations, and will only ever exist in one of them at a time."
- + $" {Plugin.Instance.Name} has no way to know which location a given mob is in, and as such cannot direct you to it."
- + " You can look up spawn maps online to find the possible spots for your target.\n"
- + "\n"
- + "Several ARR hunt marks are FATE mobs, which means they aren't always available."
- + $" Since {Plugin.Instance.Name} has no way to know if the FATE is up or not, ARR marks are not part of the plugin.");
- }
- if (InterfaceUtil.IconButton(FontAwesomeIcon.Redo, "Reload")) {
- Plugin.Instance.MobHuntEntriesReady = false;
- Task.Run(Plugin.Instance.ReloadData);
- return;
- }
- if (ImGui.IsItemHovered()) {
- ImGui.BeginTooltip();
- ImGui.Text("Click this button to reload daily hunt data");
- ImGui.EndTooltip();
- }
- ImGui.SameLine();
- if (InterfaceUtil.IconButton(FontAwesomeIcon.Cog, "Config")) {
- Plugin.Instance.OpenConfigUi();
- }
- IEnumerable<KeyValuePair<string, Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>>> expansionEntriesWithTreeNodes = Plugin.Instance
- .MobHuntEntries
- .Where(expansionEntry => ImGui.TreeNode(expansionEntry.Key));
- foreach (KeyValuePair<string, Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>> expansionEntry in expansionEntriesWithTreeNodes) {
- IEnumerable<KeyValuePair<KeyValuePair<uint, string>, List<MobHuntEntry>>> mobEntriesWithTreeNodes = expansionEntry.Value
- .Where(entry => {
- bool treeOpen = ImGui.TreeNodeEx(entry.Key.Value, ImGuiTreeNodeFlags.AllowItemOverlap);
- ImGui.SameLine();
- int killedCount = entry.Value.Count(x => MobHunt.Instance()->GetKillCount(x.BillNumber, x.MobIndex) == x.NeededKills);
- if (killedCount != entry.Value.Count) {
- ImGui.Text($"({killedCount}/{entry.Value.Count})");
- }
- else {
- ImGui.TextColored(
- new Vector4(0f, 1f, 0f, 1f),
- $"({killedCount}/{entry.Value.Count})");
- }
- return treeOpen;
- });
- foreach (KeyValuePair<KeyValuePair<uint, string>, List<MobHuntEntry>> entry in mobEntriesWithTreeNodes) {
- foreach (MobHuntEntry? mobHuntEntry in entry.Value) {
- if (Location.Database.ContainsKey(mobHuntEntry.MobHuntId)) {
- if (InterfaceUtil.IconButton(FontAwesomeIcon.MapMarkerAlt, $"pin##{mobHuntEntry.MobHuntId}")) {
- Location.CreateMapMarker(
- mobHuntEntry.TerritoryType,
- mobHuntEntry.MapId,
- mobHuntEntry.MobHuntId,
- mobHuntEntry.Name,
- Location.OpenType.None);
- }
- if (ImGui.IsItemHovered()) {
- ImGui.BeginTooltip();
- ImGui.Text("Place marker on the map");
- ImGui.EndTooltip();
- }
- ImGui.SameLine();
- if (InterfaceUtil.IconButton(FontAwesomeIcon.MapMarkedAlt, $"open##{mobHuntEntry.MobHuntId}")) {
- bool includeArea = Plugin.Instance.Configuration.IncludeAreaOnMap;
- if (ImGui.IsKeyDown(ImGuiKey.ModShift)) {
- includeArea = !includeArea;
- }
- Location.CreateMapMarker(
- mobHuntEntry.TerritoryType,
- mobHuntEntry.MapId,
- mobHuntEntry.MobHuntId,
- mobHuntEntry.Name,
- includeArea ? Location.OpenType.ShowOpen : Location.OpenType.MarkerOpen);
- }
- if (ImGui.IsItemHovered()) {
- Vector4 color = ImGui.IsKeyDown(ImGuiKey.ModShift)
- ? new Vector4(0f, 0.7f, 0f, 1f)
- : new Vector4(0.7f, 0.7f, 0.7f, 1f);
- ImGui.BeginTooltip();
- if (Plugin.Instance.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();
- }
- ImGui.SameLine();
- if (Plugin.TeleportConsumer?.IsAvailable == true) {
- if (InterfaceUtil.IconButton(FontAwesomeIcon.StreetView, $"teleport##{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();
- }
- if (Plugin.Instance.Configuration.EnableXivEspIntegration && Plugin.EspConsumer?.IsAvailable == true) {
- if (InterfaceUtil.IconButton(FontAwesomeIcon.Search, $"esp##{mobHuntEntry.MobHuntId}")) {
- Plugin.EspConsumer.SearchFor(mobHuntEntry.Name!);
- }
- if (ImGui.IsItemHovered()) {
- ImGui.BeginTooltip();
- ImGui.Text("Set XivEsp search to this target");
- ImGui.EndTooltip();
- }
- ImGui.SameLine();
- }
- }
- int currentKills = MobHunt.Instance()->GetKillCount(mobHuntEntry.BillNumber, mobHuntEntry.MobIndex);
- ImGui.Text(mobHuntEntry.Name);
- if (ImGui.IsItemHovered()) {
- ImGui.PushStyleColor(ImGuiCol.PopupBg, Vector4.Zero);
- ImGui.BeginTooltip();
- InterfaceUtil.DrawHuntIcon(mobHuntEntry);
- ImGui.PopStyleColor();
- ImGui.EndTooltip();
- }
- ImGui.SameLine();
- if (currentKills != mobHuntEntry.NeededKills) {
- ImGui.Text($"({currentKills}/{mobHuntEntry.NeededKills})");
- }
- else {
- ImGui.TextColored(
- new Vector4(0f, 1f, 0f, 1f),
- $"({currentKills}/{mobHuntEntry.NeededKills})");
- }
- }
- ImGui.TreePop();
- }
- ImGui.TreePop();
- }
- }
- }
|