v1.0.0.13: User-placed map notes with Title/Description; custom icon; notes on minimap
Made-with: Cursor
This commit is contained in:
@@ -38,6 +38,9 @@ public static class DrawHelpers
|
||||
|
||||
public const uint QuestionMarkIcon = 60071;
|
||||
|
||||
/// <summary>Sentinel IconId for user-placed map notes (custom-drawn white page with writing).</summary>
|
||||
public const uint MapNoteIconId = 65000;
|
||||
|
||||
/// <summary>
|
||||
/// Offset Vector of SelectedX, SelectedY, scaled with SelectedSizeFactor
|
||||
/// </summary>
|
||||
@@ -143,9 +146,7 @@ public static class DrawHelpers
|
||||
|
||||
private static void DrawIcon(MarkerInfo markerInfo)
|
||||
{
|
||||
var texture = Service.TextureProvider.GetFromGameIcon(markerInfo.IconId).GetWrapOrEmpty();
|
||||
var scale = System.SystemConfig.ScaleWithZoom ? markerInfo.Scale : 1.0f;
|
||||
|
||||
var iconScale = System.SystemConfig.IconScale;
|
||||
|
||||
if (markerInfo.IconId is 60401 or 60402) {
|
||||
@@ -158,11 +159,27 @@ public static class DrawHelpers
|
||||
iconScale = 0.42f;
|
||||
}
|
||||
|
||||
ImGui.SetCursorPos(markerInfo.Position + markerInfo.Offset - texture.Size * iconScale / 2.0f * scale * System.IconConfig.IconSettingMap[markerInfo.IconId].Scale);
|
||||
var cursorScreenPos = ImGui.GetCursorScreenPos();
|
||||
var iconSize = texture.Size * scale * iconScale * System.IconConfig.IconSettingMap[markerInfo.IconId].Scale;
|
||||
var setting = System.IconConfig.IconSettingMap[markerInfo.IconId];
|
||||
var sizeMultiplier = scale * iconScale * setting.Scale;
|
||||
|
||||
ImGui.Image(texture.Handle, iconSize, Vector2.Zero, Vector2.One, System.IconConfig.IconSettingMap[markerInfo.IconId].Color);
|
||||
Vector2 iconSize;
|
||||
Vector2 cursorScreenPos;
|
||||
|
||||
if (markerInfo.IconId == MapNoteIconId) {
|
||||
// Custom-drawn white page with writing icon (roughly 24x30 aspect)
|
||||
iconSize = new Vector2(20f, 26f) * sizeMultiplier;
|
||||
ImGui.SetCursorPos(markerInfo.Position + markerInfo.Offset - iconSize / 2f);
|
||||
cursorScreenPos = ImGui.GetCursorScreenPos();
|
||||
ImGui.InvisibleButton($"mapnote_{markerInfo.Position.X}_{markerInfo.Position.Y}", iconSize);
|
||||
DrawMapNoteIcon(cursorScreenPos, iconSize, setting.Color);
|
||||
}
|
||||
else {
|
||||
var texture = Service.TextureProvider.GetFromGameIcon(markerInfo.IconId).GetWrapOrEmpty();
|
||||
iconSize = texture.Size * sizeMultiplier;
|
||||
ImGui.SetCursorPos(markerInfo.Position + markerInfo.Offset - iconSize / 2f);
|
||||
cursorScreenPos = ImGui.GetCursorScreenPos();
|
||||
ImGui.Image(texture.Handle, iconSize, Vector2.Zero, Vector2.One, setting.Color);
|
||||
}
|
||||
|
||||
if (DebugMode) {
|
||||
foreach (var x in Enumerable.Range(-1, 3)) {
|
||||
@@ -241,7 +258,14 @@ public static class DrawHelpers
|
||||
if (markerInfo.PrimaryText?.Invoke() is { Length: > 0 } primaryText) {
|
||||
using var tooltip = ImRaii.Tooltip();
|
||||
|
||||
ImGui.Image(Service.TextureProvider.GetFromGameIcon(markerInfo.IconId).GetWrapOrEmpty().Handle, ImGuiHelpers.ScaledVector2(32.0f, 32.0f));
|
||||
if (markerInfo.IconId == MapNoteIconId) {
|
||||
var iconSize = ImGuiHelpers.ScaledVector2(24f, 31f);
|
||||
DrawMapNoteIcon(ImGui.GetCursorScreenPos(), iconSize, Vector4.One);
|
||||
ImGui.Dummy(iconSize);
|
||||
}
|
||||
else {
|
||||
ImGui.Image(Service.TextureProvider.GetFromGameIcon(markerInfo.IconId).GetWrapOrEmpty().Handle, ImGuiHelpers.ScaledVector2(32.0f, 32.0f));
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 7.5f * ImGuiHelpers.GlobalScale);
|
||||
@@ -257,6 +281,34 @@ public static class DrawHelpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Draw a custom "white page with writing" icon for map notes, centered at the given position.</summary>
|
||||
public static void DrawMapNoteIconCentered(Vector2 center, Vector2 size, Vector4 tint) =>
|
||||
DrawMapNoteIcon(center - size * 0.5f, size, tint);
|
||||
|
||||
/// <summary>Draw a custom "white page with writing" icon for map notes.</summary>
|
||||
private static void DrawMapNoteIcon(Vector2 topLeft, Vector2 size, Vector4 tint)
|
||||
{
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
var p1 = topLeft;
|
||||
var p2 = topLeft + size;
|
||||
var rounding = MathF.Min(size.X * 0.15f, size.Y * 0.12f);
|
||||
var white = ImGui.GetColorU32(new Vector4(0.98f, 0.98f, 0.96f, tint.W));
|
||||
var border = ImGui.GetColorU32(new Vector4(0.7f, 0.7f, 0.65f, tint.W));
|
||||
var writing = ImGui.GetColorU32(new Vector4(0.25f, 0.22f, 0.2f, tint.W));
|
||||
var padding = size * 0.12f;
|
||||
var lineHeight = (size.Y - padding.Y * 2f) / 4f;
|
||||
var lineLeft = p1.X + padding.X;
|
||||
var lineRight = p2.X - padding.X;
|
||||
|
||||
drawList.AddRectFilled(p1, p2, white, rounding);
|
||||
drawList.AddRect(p1, p2, border, rounding, 0, 1.2f);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var y = p1.Y + padding.Y + lineHeight * (i + 0.5f);
|
||||
var w = (i == 1 ? 0.9f : 0.7f) * (lineRight - lineLeft);
|
||||
drawList.AddLine(new Vector2(lineLeft, y), new Vector2(lineLeft + w, y), writing, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDisallowedIcon(uint iconId) =>
|
||||
iconId switch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user