v1.0.0.13: User-placed map notes with Title/Description; custom icon; notes on minimap
Made-with: Cursor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
@@ -17,14 +17,26 @@ public unsafe class MapContextMenu
|
||||
|
||||
if (!contextMenu) return;
|
||||
|
||||
if (ImGui.MenuItem("Place Flag")) {
|
||||
var cursorPosition = ImGui.GetMousePosOnOpeningCurrentPopup(); // Get initial cursor position (screen relative)
|
||||
var mapChildOffset = mapDrawOffset; // Get the screen position we started drawing the map at
|
||||
var mapDrawPositionOffset = System.MapRenderer.DrawPosition; // Get the map texture top left offset vector
|
||||
var textureClickLocation = (cursorPosition - mapChildOffset - mapDrawPositionOffset) / MapRenderer.MapRenderer.Scale; // Math
|
||||
var result = textureClickLocation - new Vector2(1024.0f, 1024.0f); // One of our vectors made the map centered, undo it.
|
||||
var scaledResult = result / DrawHelpers.GetMapScaleFactor() + DrawHelpers.GetRawMapOffsetVector(); // Apply offset x/y and scalefactor
|
||||
var cursorPosition = ImGui.GetMousePosOnOpeningCurrentPopup();
|
||||
var textureClickLocation = (cursorPosition - mapDrawOffset - System.MapRenderer.DrawPosition) / MapRenderer.MapRenderer.Scale;
|
||||
var result = textureClickLocation - new Vector2(1024.0f, 1024.0f);
|
||||
var scaledResult = result / DrawHelpers.GetMapScaleFactor() + DrawHelpers.GetRawMapOffsetVector();
|
||||
var noteAtCursor = System.MapNoteConfig.FindNoteAt(
|
||||
AgentMap.Instance()->SelectedTerritoryId, AgentMap.Instance()->SelectedMapId, scaledResult.X, scaledResult.Y);
|
||||
|
||||
if (ImGui.MenuItem("Place Note")) {
|
||||
MapWindow.PendingMapNotePosition = (AgentMap.Instance()->SelectedTerritoryId, AgentMap.Instance()->SelectedMapId, scaledResult.X, scaledResult.Y);
|
||||
MapWindow.RequestOpenAddNotePopup();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Remove Note", false, noteAtCursor is not null)) {
|
||||
if (noteAtCursor is { } note) {
|
||||
System.MapNoteConfig.Notes.Remove(note);
|
||||
System.MapNoteConfig.Save();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Place Flag")) {
|
||||
AgentMap.Instance()->FlagMarkerCount = 0;
|
||||
AgentMap.Instance()->SetFlagMapMarker(AgentMap.Instance()->SelectedTerritoryId, AgentMap.Instance()->SelectedMapId, scaledResult.X, scaledResult.Y);
|
||||
AgentChatLog.Instance()->InsertTextCommandParam(1048, false);
|
||||
@@ -65,5 +77,9 @@ public unsafe class MapContextMenu
|
||||
if (ImGui.MenuItem("Open Flag List", false, System.WindowManager.GetWindow<FlagHistoryWindow>() is null)) {
|
||||
System.WindowManager.AddWindow(new FlagHistoryWindow(), WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn);
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Open Note List", false, System.WindowManager.GetWindow<MapNoteListWindow>() is null)) {
|
||||
System.WindowManager.AddWindow(new MapNoteListWindow(), WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user