v1.0.0.18: Minimap automations (Desynth, Extract, Repair, Equip, Coffers); player movement cancels automation; >> button with tooltip
Made-with: Cursor
This commit is contained in:
@@ -9,6 +9,7 @@ using KamiLib.Window;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Mappy.Controllers;
|
||||
using Mappy.Data;
|
||||
using Mappy.Helpers;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using Map = Lumina.Excel.Sheets.Map;
|
||||
@@ -47,7 +48,17 @@ public class MinimapWindow : Window
|
||||
protected override unsafe void DrawContents()
|
||||
{
|
||||
if (System.SystemConfig.MinimapDrawUnderOtherUI)
|
||||
ImGuiP.BringWindowToDisplayBack(ImGuiP.GetCurrentWindow());
|
||||
{
|
||||
var win = ImGuiP.GetCurrentWindow();
|
||||
var pos = ImGui.GetWindowPos();
|
||||
var size = ImGui.GetWindowSize();
|
||||
var mouse = ImGui.GetMousePos();
|
||||
var cursorOverMinimap = mouse.X >= pos.X && mouse.X <= pos.X + size.X && mouse.Y >= pos.Y && mouse.Y <= pos.Y + size.Y;
|
||||
if (cursorOverMinimap)
|
||||
ImGuiP.BringWindowToDisplayFront(win);
|
||||
else
|
||||
ImGuiP.BringWindowToDisplayBack(win);
|
||||
}
|
||||
|
||||
var agent = AgentMap.Instance();
|
||||
// Try loading from Lumina first so minimap can show without ever opening the area map
|
||||
@@ -129,6 +140,11 @@ public class MinimapWindow : Window
|
||||
DrawCoordinateBar(totalWidth, bottomBarHeight, scale);
|
||||
}
|
||||
|
||||
// Action menu ">>" button at top-right of minimap
|
||||
if (System.SystemConfig.MinimapShowActionMenuButton) {
|
||||
DrawActionMenuButton(totalWidth, topBarHeight, minimapSide);
|
||||
}
|
||||
|
||||
// Restore default padding for the next window is done in plugin Draw callback (PopStyleVar after all windows).
|
||||
}
|
||||
|
||||
@@ -320,6 +336,61 @@ public class MinimapWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawActionMenuButton(float totalWidth, float topBarHeight, float _)
|
||||
{
|
||||
const string buttonLabel = ">>";
|
||||
var pad = 6f * ImGuiHelpers.GlobalScale;
|
||||
var textSize = ImGui.CalcTextSize(buttonLabel);
|
||||
var buttonSize = textSize + new Vector2(pad * 2, pad);
|
||||
var windowPos = ImGui.GetWindowPos();
|
||||
var screenPos = new Vector2(
|
||||
windowPos.X + totalWidth - buttonSize.X - pad,
|
||||
windowPos.Y + topBarHeight + pad);
|
||||
var buttonMin = screenPos;
|
||||
var buttonMax = screenPos + buttonSize;
|
||||
|
||||
var drawList = ImGui.GetForegroundDrawList();
|
||||
var isHovered = ImGui.IsMouseHoveringRect(buttonMin, buttonMax);
|
||||
var isClicked = isHovered && ImGui.IsMouseClicked(ImGuiMouseButton.Left);
|
||||
|
||||
if (isClicked)
|
||||
ImGui.OpenPopup("minimap_action_popup");
|
||||
|
||||
var bgColor = isHovered ? new Vector4(0.25f, 0.25f, 0.3f, 0.98f) : new Vector4(0.12f, 0.12f, 0.18f, 0.98f);
|
||||
var borderColor = new Vector4(1f, 1f, 1f, 0.9f);
|
||||
var textColor = new Vector4(1f, 1f, 1f, 1f);
|
||||
|
||||
drawList.AddRectFilled(buttonMin, buttonMax, ImGui.GetColorU32(bgColor), 3f);
|
||||
drawList.AddRect(buttonMin, buttonMax, ImGui.GetColorU32(borderColor), 3f, ImDrawFlags.None, 1.5f);
|
||||
var textPos = screenPos + new Vector2((buttonSize.X - textSize.X) * 0.5f, (buttonSize.Y - textSize.Y) * 0.5f);
|
||||
drawList.AddText(textPos, ImGui.GetColorU32(textColor), buttonLabel);
|
||||
|
||||
if (isHovered)
|
||||
{
|
||||
ImGui.SetNextWindowBgAlpha(1f);
|
||||
using var tooltip = ImRaii.Tooltip();
|
||||
ImGui.Text("Automations");
|
||||
}
|
||||
|
||||
var popupX = windowPos.X + totalWidth + pad;
|
||||
var popupY = windowPos.Y + topBarHeight;
|
||||
ImGui.SetNextWindowPos(new Vector2(popupX, popupY), ImGuiCond.Appearing);
|
||||
if (ImGui.BeginPopup("minimap_action_popup", ImGuiWindowFlags.NoMove))
|
||||
{
|
||||
if (ImGui.MenuItem("Desynth all items in inventory"))
|
||||
MinimapActions.InvokeDesynth();
|
||||
if (ImGui.MenuItem("Extract Materia"))
|
||||
MinimapActions.InvokeExtract();
|
||||
if (ImGui.MenuItem("Repair"))
|
||||
MinimapActions.InvokeRepair();
|
||||
if (ImGui.MenuItem("Equip Gear"))
|
||||
MinimapActions.InvokeEquip();
|
||||
if (ImGui.MenuItem("Open Coffers"))
|
||||
MinimapActions.InvokeCoffers();
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStyle()
|
||||
{
|
||||
if (System.SystemConfig.MinimapLockPosition)
|
||||
|
||||
Reference in New Issue
Block a user