feat: add button to remove character from cache

This commit is contained in:
Anna 2021-02-18 18:48:31 -05:00
parent 578e27b88c
commit 9285baa877
1 changed files with 35 additions and 1 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
namespace ExpandedSearchInfo {
@ -17,6 +18,21 @@ namespace ExpandedSearchInfo {
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
}
private static bool IconButton(FontAwesomeIcon icon, string? id = null) {
ImGui.PushFont(UiBuilder.IconFont);
var text = icon.ToIconString();
if (id != null) {
text += $"##{id}";
}
var result = ImGui.Button(text);
ImGui.PopFont();
return result;
}
private void Draw() {
// check if the examine window is open
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("CharacterInspect", 1);
@ -68,10 +84,28 @@ namespace ExpandedSearchInfo {
ImGui.TreePush();
if (ImGui.Button($"Open in browser##{i}")) {
if (IconButton(FontAwesomeIcon.ExternalLinkAlt, $"open-{i}")) {
Process.Start(section.Uri.ToString());
}
if (ImGui.IsItemHovered()) {
ImGui.BeginTooltip();
ImGui.TextUnformatted("Open in browser.");
ImGui.EndTooltip();
}
ImGui.SameLine();
if (IconButton(FontAwesomeIcon.Redo, $"refresh-{i}")) {
this.Plugin.Repository.SearchInfos.TryRemove(actorId, out _);
}
if (ImGui.IsItemHovered()) {
ImGui.BeginTooltip();
ImGui.TextUnformatted("Clear the cache. Re-examine this character to redownload information.");
ImGui.EndTooltip();
}
section.Draw();
ImGui.TreePop();