Initial HSMappy release (fork of Mappy)
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static unsafe class AddonAreaMapExtensions
|
||||
{
|
||||
public static void ForceOffscreen(this ref AddonAreaMap addon)
|
||||
{
|
||||
if (!addon.IsReady) return;
|
||||
if (addon.RootNode is null) return;
|
||||
|
||||
addon.RootNode->SetPositionFloat(-9001.0f, -9001.0f);
|
||||
}
|
||||
|
||||
public static void RestorePosition(this ref AddonAreaMap addon)
|
||||
{
|
||||
if (!addon.IsReady) return;
|
||||
if (addon.RootNode is null) return;
|
||||
|
||||
addon.RootNode->SetPositionFloat(addon.X, addon.Y);
|
||||
}
|
||||
|
||||
public static bool IsOffscreen(this ref AddonAreaMap addon)
|
||||
{
|
||||
if (!addon.IsReady) return false;
|
||||
if (addon.RootNode is null) return false;
|
||||
|
||||
var xAdjusted = addon.RootNode->X < -9000.0f;
|
||||
var yAdjusted = addon.RootNode->Y < -9000.0f;
|
||||
|
||||
return xAdjusted && yAdjusted;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
|
||||
using FFXIVClientStructs.Interop;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static unsafe class FateContextExtensions
|
||||
{
|
||||
public static Vector4 GetColor(this Pointer<FateContext> context, float alpha = 0.33f)
|
||||
{
|
||||
var timeRemaining = GetTimeRemaining(context);
|
||||
if (timeRemaining <= TimeSpan.FromSeconds(300) && timeRemaining.TotalSeconds > 0) {
|
||||
var hue = (float)(timeRemaining.TotalSeconds / 300.0f * 25.0f);
|
||||
|
||||
var hsvColor = new ColorHelpers.HsvaColor(hue / 100.0f, 1.0f, 1.0f, alpha);
|
||||
return ColorHelpers.HsvToRgb(hsvColor);
|
||||
}
|
||||
|
||||
return KnownColor.White.Vector();
|
||||
}
|
||||
|
||||
public static TimeSpan GetTimeRemaining(this Pointer<FateContext> context)
|
||||
{
|
||||
if (context.Value->Duration is 0) return TimeSpan.Zero;
|
||||
|
||||
return TimeSpan.FromSeconds(context.Value->StartTimeEpoch + context.Value->Duration - DateTimeOffset.Now.ToUnixTimeSeconds());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Numerics;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Mappy.Classes;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static class GameObjectExtensions
|
||||
{
|
||||
public static Vector2 GetMapPosition(this IGameObject obj) => new Vector2(obj.Position.X, obj.Position.Z) * DrawHelpers.GetMapScaleFactor();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using Mappy.Classes;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
// Represents standard non-dynamic map markers, things that don't change, and may reference datasheet data with their key data
|
||||
public static class MapMarkerBaseExtensions
|
||||
{
|
||||
public static void Draw(this MapMarkerBase marker, Vector2 offset, float scale)
|
||||
{
|
||||
var tooltipText = marker.Subtext.AsDalamudSeString();
|
||||
|
||||
DrawHelpers.DrawMapMarker(new MarkerInfo
|
||||
{
|
||||
// Divide by 16, as it seems they use a fixed scalar
|
||||
// Add 1024 * scale, to offset from top-left, to center-based coordinate
|
||||
// Add offset for drawing relative to map when its moved around
|
||||
Position = new Vector2(marker.X, marker.Y) / 16.0f * scale + DrawHelpers.GetMapCenterOffsetVector() * scale,
|
||||
Offset = offset,
|
||||
Scale = scale,
|
||||
Radius = marker.Scale,
|
||||
RadiusColor = KnownColor.MediumPurple.Vector(),
|
||||
IconId = marker.IconId,
|
||||
PrimaryText =
|
||||
() => tooltipText.TextValue.IsNullOrEmpty() && System.SystemConfig.ShowMiscTooltips ? System.TooltipCache.GetValue(marker.IconId) : tooltipText.ToString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Numerics;
|
||||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using Mappy.Classes;
|
||||
using MarkerInfo = Mappy.Classes.MarkerInfo;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
// MapMarkerData struct represents dynamic markers that have information like radius, and other fields.
|
||||
public static class MapMarkerDataExtensions
|
||||
{
|
||||
public static void Draw(this MapMarkerData marker, Vector2 offset, float scale)
|
||||
{
|
||||
if ((marker.Flags & 1) == 1) return;
|
||||
|
||||
DrawHelpers.DrawMapMarker(new MarkerInfo
|
||||
{
|
||||
Position = (marker.Position.AsMapVector() * DrawHelpers.GetMapScaleFactor() - DrawHelpers.GetMapOffsetVector() + DrawHelpers.GetMapCenterOffsetVector()) * scale,
|
||||
Offset = offset,
|
||||
Scale = scale,
|
||||
IconId = marker.IconId,
|
||||
Radius = marker.Radius,
|
||||
RadiusColor = System.SystemConfig.AreaColor,
|
||||
RadiusOutlineColor = System.SystemConfig.AreaOutlineColor,
|
||||
PrimaryText = () => GetMarkerPrimaryText(marker),
|
||||
IsDynamicMarker = true,
|
||||
ObjectiveId = marker.ObjectiveId,
|
||||
MarkerType = (MarkerType)marker.MarkerType,
|
||||
DataId = marker.DataId,
|
||||
});
|
||||
}
|
||||
|
||||
private static unsafe string GetMarkerPrimaryText(MapMarkerData marker)
|
||||
{
|
||||
if (marker.TooltipString is null) return string.Empty;
|
||||
if (marker.TooltipString->StringPtr.Value is null) return string.Empty;
|
||||
if (marker.TooltipString->StringPtr.ExtractText().IsNullOrEmpty()) return string.Empty;
|
||||
|
||||
var text = marker.TooltipString->StringPtr.ExtractText();
|
||||
return marker.RecommendedLevel is 0 ? text : $"Lv. {marker.RecommendedLevel} {text}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Mappy.Classes;
|
||||
using Map = Lumina.Excel.Sheets.Map;
|
||||
using MarkerInfo = Mappy.Classes.MarkerInfo;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static class MapMarkerInfoExtensions
|
||||
{
|
||||
public static void Draw(this MapMarkerInfo marker, Vector2 offset, float scale)
|
||||
{
|
||||
var tooltipText = marker.MapMarker.Subtext.AsDalamudSeString();
|
||||
|
||||
var markerInfo = new MarkerInfo
|
||||
{
|
||||
// Divide by 16, as it seems they use a fixed scalar
|
||||
// Add 1024 * scale, to offset from top-left, to center-based coordinate
|
||||
// Add offset for drawing relative to map when it's moved around
|
||||
Position = new Vector2(marker.MapMarker.X, marker.MapMarker.Y) / 16.0f * scale + DrawHelpers.GetMapCenterOffsetVector() * scale,
|
||||
Offset = offset,
|
||||
Scale = scale,
|
||||
Radius = marker.MapMarker.Scale,
|
||||
RadiusColor = KnownColor.MediumPurple.Vector(),
|
||||
IconId = marker.MapMarker.IconId,
|
||||
PrimaryText = GetMarkerPrimaryTooltip(marker, tooltipText),
|
||||
OnLeftClicked = () => OnMarkerClicked(ref marker),
|
||||
SecondaryText = () => GetTooltip(ref marker),
|
||||
};
|
||||
|
||||
if (marker.MapMarker.IconId is 0 && marker.MapMarker.Index is not 0) {
|
||||
TryDrawText(marker, markerInfo, tooltipText);
|
||||
}
|
||||
else {
|
||||
DrawHelpers.DrawMapMarker(markerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private static void TryDrawText(MapMarkerInfo marker, MarkerInfo markerInfo, SeString tooltipText)
|
||||
{
|
||||
if (!System.SystemConfig.ShowTextLabels) return;
|
||||
|
||||
var textTypeScalar = marker.MapMarker.SubtextStyle switch
|
||||
{
|
||||
1 => System.SystemConfig.LargeAreaTextScale,
|
||||
_ => System.SystemConfig.SmallAreaTextScale,
|
||||
};
|
||||
|
||||
if (System.SystemConfig.ScaleTextWithZoom) {
|
||||
markerInfo.Scale *= textTypeScalar * 0.33f;
|
||||
}
|
||||
else {
|
||||
markerInfo.Scale = textTypeScalar * 0.33f;
|
||||
}
|
||||
|
||||
DrawHelpers.DrawText(markerInfo, tooltipText);
|
||||
}
|
||||
|
||||
private static void OnMarkerClicked(ref MapMarkerInfo marker)
|
||||
{
|
||||
switch (marker.DataType) {
|
||||
case 1: // MapLinkMarker
|
||||
OnMapLinkMarkerClicked(ref marker);
|
||||
break;
|
||||
|
||||
case 2: // InstanceLink
|
||||
OnInstanceLinkClicked(ref marker);
|
||||
break;
|
||||
|
||||
case 3: // Aetheryte
|
||||
OnAetheryteClicked(ref marker);
|
||||
break;
|
||||
|
||||
case 4: // Aethernet
|
||||
OnAethernetClicked(ref marker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnMapLinkMarkerClicked(ref MapMarkerInfo marker)
|
||||
{
|
||||
if (marker.DataKey is 0) return;
|
||||
if (DrawHelpers.IsDisallowedIcon(marker.MapMarker.IconId)) return;
|
||||
|
||||
System.IntegrationsController.OpenMap(marker.DataKey);
|
||||
}
|
||||
|
||||
private static void OnInstanceLinkClicked(ref MapMarkerInfo _)
|
||||
{
|
||||
// Might consider opening contents finder to this duty, maybe
|
||||
}
|
||||
|
||||
private static void OnAetheryteClicked(ref MapMarkerInfo marker)
|
||||
{
|
||||
if (marker.DataKey is 0) return;
|
||||
|
||||
System.Teleporter.Teleport(marker.DataKey);
|
||||
}
|
||||
|
||||
private static void OnAethernetClicked(ref MapMarkerInfo marker)
|
||||
{
|
||||
var aetheryte = GetAetheryteForAethernet(marker.DataKey);
|
||||
if (aetheryte is null) return;
|
||||
if (aetheryte.Value.RowId is 0) return;
|
||||
|
||||
System.Teleporter.Teleport(aetheryte.Value.RowId);
|
||||
}
|
||||
|
||||
private static string GetTooltip(ref MapMarkerInfo marker)
|
||||
{
|
||||
switch (marker.DataType)
|
||||
{
|
||||
case 1: // MapLinkMarker
|
||||
return GetMapLinkTooltip(ref marker);
|
||||
|
||||
case 2: // InstanceLink
|
||||
return GetInstanceLinkTooltip(ref marker);
|
||||
|
||||
case 3: // Aetheryte
|
||||
return GetAetheryteTooltip(ref marker);
|
||||
|
||||
case 4: // Aethernet
|
||||
return GetAethernetTooltip(ref marker);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static string GetMapLinkTooltip(ref MapMarkerInfo marker)
|
||||
{
|
||||
if (marker.DataKey is 0) return string.Empty;
|
||||
if (DrawHelpers.IsDisallowedIcon(marker.MapMarker.IconId)) return string.Empty;
|
||||
|
||||
var map = Service.DataManager.GetExcelSheet<Map>().GetRow(marker.DataKey);
|
||||
var mapPlaceName = map.PlaceName.ValueNullable?.Name.ExtractText() ?? string.Empty;
|
||||
|
||||
return $"Open Map {mapPlaceName}";
|
||||
}
|
||||
|
||||
private static string GetInstanceLinkTooltip(ref MapMarkerInfo marker)
|
||||
{
|
||||
return $"Instance Link {marker.DataKey}";
|
||||
}
|
||||
|
||||
private static string GetAetheryteTooltip(ref MapMarkerInfo marker)
|
||||
{
|
||||
if (marker.DataKey is 0) return string.Empty;
|
||||
|
||||
var aetheryteTeleportCost = GetAetheryteTeleportGilCost(marker.DataKey);
|
||||
if (aetheryteTeleportCost is null) return "Not attuned to aetheryte";
|
||||
|
||||
var aetheryte = Service.DataManager.GetExcelSheet<Aetheryte>().GetRow(marker.DataKey);
|
||||
var aetherytePlaceName = aetheryte.PlaceName.ValueNullable?.Name.ExtractText() ?? string.Empty;
|
||||
var aetheryteCost = GetAetheryteTeleportCost(marker.DataKey);
|
||||
|
||||
return $"Teleport to {aetherytePlaceName} {aetheryteCost}";
|
||||
}
|
||||
|
||||
private static string GetAethernetTooltip(ref MapMarkerInfo marker)
|
||||
{
|
||||
if (marker.DataKey is 0) return string.Empty;
|
||||
|
||||
var aetheryte = GetAetheryteForAethernet(marker.DataKey);
|
||||
if (aetheryte is null) return string.Empty;
|
||||
if (aetheryte.Value.RowId is 0) return string.Empty;
|
||||
|
||||
var aetherytePlaceName = aetheryte.Value.PlaceName.ValueNullable?.Name.ExtractText() ?? string.Empty;
|
||||
|
||||
return $"Teleport to {aetherytePlaceName} {GetAetheryteTeleportCost(aetheryte.Value.RowId)}";
|
||||
}
|
||||
|
||||
private static Aetheryte? GetAetheryteForAethernet(uint aethernetKey) => System.AetheryteAethernetCache.GetValue(aethernetKey);
|
||||
|
||||
private static uint? GetAetheryteTeleportGilCost(uint aethernetKey) => Service.AetheryteList.FirstOrDefault(entry => entry.AetheryteId == aethernetKey)?.GilCost;
|
||||
|
||||
private static string GetAetheryteTeleportCost(uint targetDataKey) => $"({GetAetheryteTeleportGilCost(targetDataKey) ?? 0:n0} {SeIconChar.Gil.ToIconChar()})";
|
||||
|
||||
private static Func<string> GetMarkerPrimaryTooltip(MapMarkerInfo marker, SeString tooltipText)
|
||||
{
|
||||
if (DrawHelpers.IsDisallowedIcon(marker.MapMarker.IconId)) return () => string.Empty;
|
||||
if (!System.SystemConfig.ShowMiscTooltips) return () => string.Empty;
|
||||
if (!tooltipText.TextValue.IsNullOrEmpty()) return tooltipText.ToString;
|
||||
|
||||
return marker.DataType switch
|
||||
{
|
||||
4 => () => Service.DataManager.GetExcelSheet<PlaceName>().GetRow(marker.DataKey).Name.ExtractText(),
|
||||
_ => () => System.TooltipCache.GetValue(marker.MapMarker.IconId) ?? string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Numerics;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static class MiniMapGatheringMarkerExtensions
|
||||
{
|
||||
public static void Draw(this MiniMapGatheringMarker marker, Vector2 offset, float scale)
|
||||
{
|
||||
if (marker.ShouldRender is 0) return;
|
||||
|
||||
marker.MapMarker.Scale = 50;
|
||||
marker.MapMarker.Draw(offset, scale);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Numerics;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using Mappy.Classes;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static class TempMapMarkerExtensions
|
||||
{
|
||||
public static void Draw(this TempMapMarker marker, Vector2 offset, float scale)
|
||||
{
|
||||
DrawHelpers.DrawMapMarker(new MarkerInfo
|
||||
{
|
||||
// Divide by 16, as it seems they use a fixed scalar
|
||||
// Add 1024 * scale, to offset from top-left, to center-based coordinate
|
||||
// Add offset for drawing relative to map when its moved around
|
||||
Position = (new Vector2(marker.MapMarker.X, marker.MapMarker.Y) / 16.0f * DrawHelpers.GetMapScaleFactor() + DrawHelpers.GetCombinedOffsetVector()) * scale,
|
||||
Offset = offset,
|
||||
Scale = scale,
|
||||
IconId = marker.MapMarker.IconId,
|
||||
Radius = marker.MapMarker.Scale,
|
||||
PrimaryText = () => marker.TooltipText.ToString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace Mappy.Extensions;
|
||||
|
||||
public static class VectorExtensions
|
||||
{
|
||||
public static Vector2 AsMapVector(this Vector3 vector) => new(vector.X, vector.Z);
|
||||
}
|
||||
Reference in New Issue
Block a user