ConfigurationWindow.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System.Numerics;
  2. using Dalamud.Interface.Utility;
  3. using Dalamud.Interface.Windowing;
  4. using HuntBuddy.Utils;
  5. using ImGuiNET;
  6. namespace HuntBuddy.Windows;
  7. /// <summary>
  8. /// Configuration window.
  9. /// </summary>
  10. public class ConfigurationWindow: Window {
  11. public const int BaseTooltipWidth = 450;
  12. public ConfigurationWindow() : base(
  13. $"{Plugin.Instance.Name} configuration",
  14. ImGuiWindowFlags.NoDocking,
  15. true) {
  16. this.Size = Vector2.Zero;
  17. this.SizeCondition = ImGuiCond.Always;
  18. this.RespectCloseHotkey = !Plugin.Instance.Configuration.IgnoreCloseHotkey;
  19. }
  20. public override void PreOpenCheck() {
  21. if (Plugin.Instance.Configuration.LockWindowPositions) {
  22. this.Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
  23. }
  24. else {
  25. this.Flags &= ~(ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);
  26. }
  27. }
  28. public override void Draw() {
  29. bool save = false;
  30. if (Plugin.EspConsumer?.IsAvailable == true) { // probably shouldn't name a 3pp if it's not installed
  31. save |= ImGui.Checkbox("Enable XivEsp plugin integration?", ref Plugin.Instance.Configuration.EnableXivEspIntegration);
  32. ImGui.Indent();
  33. save |= ImGui.Checkbox("Set XivEsp search when using '/phb next' command?", ref Plugin.Instance.Configuration.AutoSetEspSearchOnNextHuntCommand);
  34. ImGui.Unindent();
  35. if (ImGui.IsItemHovered()) {
  36. InterfaceUtil.DrawWrappedTooltip(ImGuiHelpers.GlobalScale * BaseTooltipWidth,
  37. "If enabled and XivEsp is available, the '/phb next' command will automatically set XivEsp's search"
  38. + "to the name of the chosen mark, EVEN IF you already have a custom search active.");
  39. }
  40. }
  41. ImGui.Spacing();
  42. if (ImGui.Checkbox("Ignore close hotkey",
  43. ref Plugin.Instance.Configuration.IgnoreCloseHotkey)) {
  44. this.RespectCloseHotkey = !Plugin.Instance.Configuration.IgnoreCloseHotkey;
  45. Plugin.Instance.MainWindow.RespectCloseHotkey = !Plugin.Instance.Configuration.IgnoreCloseHotkey;
  46. save = true;
  47. }
  48. save |= ImGui.Checkbox("Lock plugin window positions and sizes",
  49. ref Plugin.Instance.Configuration.LockWindowPositions);
  50. save |= ImGui.Checkbox("Include hunt area on map by default",
  51. ref Plugin.Instance.Configuration.IncludeAreaOnMap);
  52. if (ImGui.IsItemHovered()) {
  53. InterfaceUtil.DrawWrappedTooltip(ImGuiHelpers.GlobalScale * BaseTooltipWidth,
  54. $"{Plugin.Instance.Name} can show an approximate general area for hunt mobs around the flagged location."
  55. + "You can always hold SHIFT to toggle this when you click the button to flag a target on your map.");
  56. }
  57. save |= ImGui.Checkbox("Show hunts in local area",
  58. ref Plugin.Instance.Configuration.ShowLocalHunts);
  59. if (ImGui.IsItemHovered()) {
  60. InterfaceUtil.DrawWrappedTooltip(ImGuiHelpers.GlobalScale * BaseTooltipWidth,
  61. $"If enabled, {Plugin.Instance.Name} will display an extra window with the hunt targets in your current map zone.");
  62. }
  63. save |= ImGui.Checkbox("Show icons of hunts in local area",
  64. ref Plugin.Instance.Configuration.ShowLocalHuntIcons);
  65. if (ImGui.IsItemHovered()) {
  66. InterfaceUtil.DrawWrappedTooltip(ImGuiHelpers.GlobalScale * BaseTooltipWidth,
  67. "These icons are taken from the hunt mark bills the game displays, and so may not be the clearest images available.");
  68. }
  69. save |= ImGui.Checkbox("Hide background of local hunts window",
  70. ref Plugin.Instance.Configuration.HideLocalHuntBackground);
  71. save |= ImGui.Checkbox("Hide completed targets in local hunts window",
  72. ref Plugin.Instance.Configuration.HideCompletedHunts);
  73. save |= ImGui.Checkbox("Suppress chat warning about B-ranks not having locations",
  74. ref Plugin.Instance.Configuration.SuppressEliteMarkLocationWarning);
  75. if (ImGui.IsItemHovered()) {
  76. InterfaceUtil.DrawWrappedTooltip(ImGuiHelpers.GlobalScale * BaseTooltipWidth,
  77. $"When the '/phb next' command selects a B-rank mark, a warning is printed in your chat log that {Plugin.Instance.Name}"
  78. + " DOES NOT provide locations for B-rank hunt marks. If this warning annoys you, you can turn it off.\n"
  79. + "\n"
  80. + "Do not ask for B-rank locations to be provided.");
  81. }
  82. ImGui.Spacing();
  83. save |= ImGui.SliderFloat("Hunt icon scale", ref Plugin.Instance.Configuration.IconScale, 0.2f, 2f, "%.2f");
  84. if (ImGui.ColorEdit4("Hunt icon background colour", ref Plugin.Instance.Configuration.IconBackgroundColour)) {
  85. Plugin.Instance.Configuration.IconBackgroundColourU32 =
  86. ImGui.ColorConvertFloat4ToU32(Plugin.Instance.Configuration.IconBackgroundColour);
  87. save = true;
  88. }
  89. if (save) {
  90. Plugin.Instance.Configuration.Save();
  91. }
  92. }
  93. }