Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add text description for Link Description.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 29, 2023
1 parent 0b3690d commit 45e71ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion RotationSolver.Basic/Attributes/LinkDescriptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public class LinkDescriptionAttribute : Attribute
static readonly List<string> _loadingTexture = new List<string>();

public TextureWrap Texture { get; private set; }
public string Description { get; private set; }
public string Path { get; }
public LinkDescriptionAttribute(string path)
public LinkDescriptionAttribute(string path, string description = "")
{
Path = path;
LoadTexture(path);
Description = description;
}

private void LoadTexture(string path)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Default/Melee/NIN_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace RotationSolver.Default.Melee;

[RotationDesc(ActionID.Mug)]
[SourceCode("https://github.com/ArchiDog1998/RotationSolver/blob/main/RotationSolver.Default/Melee/NIN_Default.cs")]
[LinkDescription("https://docs.google.com/spreadsheets/u/0/d/1BZZrqWMRrugCeiBICEgjCz2vRNXt_lRTxPnSQr24Em0/htmlview#")]
[LinkDescription("https://docs.google.com/spreadsheets/u/0/d/1BZZrqWMRrugCeiBICEgjCz2vRNXt_lRTxPnSQr24Em0/htmlview#", "Under the “Planner (With sample section)”")]
public sealed class NIN_Default : NIN_Base
{
public override string GameVersion => "6.0";
Expand Down
20 changes: 14 additions & 6 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,23 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
{
Util.OpenLink(texture.Path);
}
if (ImGui.IsItemHovered() && texture.Texture != null)
if (ImGui.IsItemHovered() && (texture.Texture != null || !string.IsNullOrEmpty( texture.Description)))
{
DrawTooltip(() =>
{
var ratio = Math.Min(1, Math.Min(display.X / texture.Texture.Width, display.Y / texture.Texture.Height));
var size = new Vector2(texture.Texture.Width * ratio,
texture.Texture.Height * ratio);
ImGui.Image(texture.Texture.ImGuiHandle, size);
}, "Picture" + texture.GetHashCode().ToString());
if(texture.Texture != null)
{
var ratio = Math.Min(1, Math.Min(display.X / texture.Texture.Width, display.Y / texture.Texture.Height));
var size = new Vector2(texture.Texture.Width * ratio,
texture.Texture.Height * ratio);
ImGui.Image(texture.Texture.ImGuiHandle, size);
}
if (!string.IsNullOrEmpty(texture.Description))
{
ImGui.Text(texture.Description);
}

}, "PictureDescription" + texture.GetHashCode().ToString());
}
}
}
Expand Down

0 comments on commit 45e71ea

Please sign in to comment.