Initial HSMappy release (fork of Mappy)

Made-with: Cursor
This commit is contained in:
2026-02-26 03:54:51 -05:00
commit 9659f7a7d1
72 changed files with 6625 additions and 0 deletions
@@ -0,0 +1,69 @@
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using KamiLib.Window;
using Mappy.Data;
using Mappy.Windows;
namespace Mappy.Classes.MapWindowComponents;
public unsafe class MapContextMenu
{
public void Draw(Vector2 mapDrawOffset)
{
using var contextMenu = ImRaii.ContextPopup("Mappy_Context_Menu");
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
AgentMap.Instance()->FlagMarkerCount = 0;
AgentMap.Instance()->SetFlagMapMarker(AgentMap.Instance()->SelectedTerritoryId, AgentMap.Instance()->SelectedMapId, scaledResult.X, scaledResult.Y);
AgentChatLog.Instance()->InsertTextCommandParam(1048, false);
}
if (ImGui.MenuItem("Remove Flag", false, AgentMap.Instance()->FlagMarkerCount is not 0)) {
AgentMap.Instance()->FlagMarkerCount = 0;
}
ImGuiHelpers.ScaledDummy(5.0f);
if (ImGui.MenuItem("Center on Player", false, Service.ObjectTable.LocalPlayer is not null) && Service.ObjectTable.LocalPlayer is not null) {
System.IntegrationsController.OpenOccupiedMap();
System.MapRenderer.CenterOnGameObject(Service.ObjectTable.LocalPlayer);
}
if (ImGui.MenuItem("Center on Map")) {
System.SystemConfig.FollowPlayer = false;
System.MapRenderer.DrawOffset = Vector2.Zero;
}
ImGuiHelpers.ScaledDummy(5.0f);
if (ImGui.MenuItem("Lock Zoom", "", ref System.SystemConfig.ZoomLocked)) {
SystemConfig.Save();
}
ImGuiHelpers.ScaledDummy(5.0f);
if (ImGui.MenuItem("Open Quest List", false, System.WindowManager.GetWindow<QuestListWindow>() is null)) {
System.WindowManager.AddWindow(new QuestListWindow(), WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn);
}
if (ImGui.MenuItem("Open Fate List", false, System.WindowManager.GetWindow<FateListWindow>() is null)) {
System.WindowManager.AddWindow(new FateListWindow(), WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn);
}
if (ImGui.MenuItem("Open Flag List", false, System.WindowManager.GetWindow<FlagHistoryWindow>() is null)) {
System.WindowManager.AddWindow(new FlagHistoryWindow(), WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn);
}
}
}
@@ -0,0 +1,52 @@
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
namespace Mappy.Classes.MapWindowComponents;
public unsafe class MapCoordinateBar
{
public void Draw(bool isMapHovered, Vector2 mapDrawOffset)
{
var coordinateBarSize = new Vector2(ImGui.GetContentRegionMax().X, 20.0f * ImGuiHelpers.GlobalScale);
ImGui.SetCursorPos(ImGui.GetContentRegionMax() - coordinateBarSize);
using var childBackgroundStyle = ImRaii.PushColor(ImGuiCol.ChildBg, Vector4.Zero with { W = System.SystemConfig.CoordinateBarFade });
using var coordinateChild = ImRaii.Child("coordinate_child", coordinateBarSize);
if (!coordinateChild) return;
var offsetX = -AgentMap.Instance()->SelectedOffsetX;
var offsetY = -AgentMap.Instance()->SelectedOffsetY;
var scale = AgentMap.Instance()->SelectedMapSizeFactor;
var characterMapPosition = MapUtil.WorldToMap(Service.ObjectTable.LocalPlayer?.Position ?? Vector3.Zero, offsetX, offsetY, 0, (uint)scale);
var characterPosition = $"Character {characterMapPosition.X:F1} {characterMapPosition.Y:F1}";
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 2.0f * ImGuiHelpers.GlobalScale);
var characterStringSize = ImGui.CalcTextSize(characterPosition);
ImGui.SetCursorPosX(ImGui.GetContentRegionMax().X / 3.0f - characterStringSize.X / 2.0f);
if (AgentMap.Instance()->SelectedMapId == AgentMap.Instance()->CurrentMapId) {
ImGui.TextColored(System.SystemConfig.CoordinateTextColor, characterPosition);
}
if (isMapHovered) {
var cursorPosition = ImGui.GetMousePos() - mapDrawOffset;
cursorPosition -= System.MapRenderer.DrawPosition;
cursorPosition /= MapRenderer.MapRenderer.Scale;
cursorPosition -= new Vector2(1024.0f, 1024.0f);
cursorPosition -= new Vector2(offsetX, offsetY);
cursorPosition /= AgentMap.Instance()->SelectedMapSizeFactorFloat;
var cursorMapPosition = MapUtil.WorldToMap(new Vector3(cursorPosition.X, 0.0f, cursorPosition.Y), offsetX, offsetY, 0, (uint)scale);
var cursorPositionString = $"Cursor {cursorMapPosition.X:F1} {cursorMapPosition.Y:F1}";
var cursorStringSize = ImGui.CalcTextSize(characterPosition);
ImGui.SameLine(ImGui.GetContentRegionMax().X * 2.0f / 3.0f - cursorStringSize.X / 2.0f);
ImGui.TextColored(System.SystemConfig.CoordinateTextColor, cursorPositionString);
}
}
}
@@ -0,0 +1,162 @@
using System.Linq;
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiLib.Extensions;
using KamiLib.Window;
using Lumina.Excel.Sheets;
using Mappy.Windows;
using MapType = Lumina.Excel.Sheets.MapType;
namespace Mappy.Classes.MapWindowComponents;
public unsafe class MapToolbar
{
public void Draw()
{
var toolbarSize = new Vector2(ImGui.GetContentRegionMax().X, 33.0f * ImGuiHelpers.GlobalScale);
using var childBackgroundStyle = ImRaii.PushColor(ImGuiCol.ChildBg, Vector4.Zero with { W = System.SystemConfig.ToolbarFade });
using var toolbarChild = ImRaii.Child("toolbar_child", toolbarSize);
if (!toolbarChild) return;
ImGui.SetCursorPos(new Vector2(5.0f, 5.0f));
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.ArrowUp, "up", "Open Parent Map")) {
var valueArgs = new AtkValue
{
Type = ValueType.Int, Int = 5,
};
var returnValue = new AtkValue();
AgentMap.Instance()->ReceiveEvent(&returnValue, &valueArgs, 1, 0);
}
ImGui.SameLine();
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.LayerGroup, "layers", "Show Map Layers")) {
ImGui.OpenPopup("Mappy_Show_Layers");
}
DrawLayersContextMenu();
ImGui.SameLine();
using (var _ = ImRaii.PushColor(ImGuiCol.Button, ImGui.GetStyle().GetColor(ImGuiCol.ButtonActive), System.SystemConfig.FollowPlayer)) {
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.LocationArrow, "follow", "Toggle Follow Player")) {
System.SystemConfig.FollowPlayer = !System.SystemConfig.FollowPlayer;
if (System.SystemConfig.FollowPlayer) {
System.IntegrationsController.OpenOccupiedMap();
}
}
}
ImGui.SameLine();
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.ArrowsToCircle, "centerPlayer", "Center on Player") && Service.ObjectTable.LocalPlayer is not null) {
// Don't center on player if we are already following the player.
if (!System.SystemConfig.FollowPlayer) {
System.IntegrationsController.OpenOccupiedMap();
System.MapRenderer.CenterOnGameObject(Service.ObjectTable.LocalPlayer);
}
}
ImGui.SameLine();
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.MapMarked, "centerMap", "Center on Map")) {
System.SystemConfig.FollowPlayer = false;
System.MapRenderer.DrawOffset = Vector2.Zero;
}
ImGui.SameLine();
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.Search, "search", "Search for Map")) {
System.WindowManager.AddWindow(new MapSelectionWindow
{
SingleSelectionCallback = selection =>
{
if (selection?.Map != null) {
if (AgentMap.Instance()->SelectedMapId != selection.Map.RowId) {
System.IntegrationsController.OpenMap(selection.Map.RowId);
}
if (selection.MarkerLocation is { } location) {
System.SystemConfig.FollowPlayer = false;
System.MapRenderer.DrawOffset = -location + DrawHelpers.GetMapCenterOffsetVector();
}
}
},
}, WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn);
}
var offset = System.SystemConfig.HideWindowFrame ? 50.0f : 25.0f;
ImGui.SameLine();
ImGui.SetCursorPosX(ImGui.GetContentRegionMax().X - offset * ImGuiHelpers.GlobalScale - ImGui.GetStyle().ItemSpacing.X);
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.Cog, "settings", "Open Settings")) {
System.ConfigWindow.UnCollapseOrShow();
ImGui.SetWindowFocus(System.ConfigWindow.WindowName);
}
if (!System.SystemConfig.HideWindowFrame) return;
ImGui.SameLine();
if (MappyGuiTweaks.IconButton(FontAwesomeIcon.Times, "closeMap", "Close Map"))
{
System.MapWindow.Close();
}
}
private void DrawLayersContextMenu()
{
using var contextMenu = ImRaii.Popup("Mappy_Show_Layers");
if (!contextMenu) return;
var currentMap = Service.DataManager.GetExcelSheet<Map>().GetRow(AgentMap.Instance()->SelectedMapId);
if (currentMap.RowId is 0) return;
// If this is a region map
if (currentMap.MapType.RowId == 3) {
foreach (var marker in AgentMap.Instance()->MapMarkers) {
if (!DrawHelpers.IsRegionIcon(marker.MapMarker.IconId)) continue;
var label = marker.MapMarker.Subtext.AsDalamudSeString();
if (ImGui.MenuItem(label.ToString())) {
System.IntegrationsController.OpenMap(marker.DataKey);
System.SystemConfig.FollowPlayer = false;
System.MapRenderer.DrawOffset = Vector2.Zero;
}
}
}
// Any other map
else {
var layers = Service.DataManager.GetExcelSheet<Map>()
.Where(eachMap => eachMap.PlaceName.RowId == currentMap.PlaceName.RowId)
.Where(eachMap => eachMap.MapIndex != 0)
.OrderBy(eachMap => eachMap.MapIndex)
.ToList();
if (layers.Count is 0) {
ImGui.Text("No layers for this map");
}
foreach (var layer in layers) {
if (ImGui.MenuItem(layer.PlaceNameSub.Value.Name.ExtractText(), "", AgentMap.Instance()->SelectedMapId == layer.RowId)) {
System.IntegrationsController.OpenMap(layer.RowId);
System.SystemConfig.FollowPlayer = false;
System.MapRenderer.DrawOffset = Vector2.Zero;
}
}
}
}
}