2022-09-07 06:05:13 +00:00
|
|
|
using Dalamud.Interface;
|
2022-09-09 10:19:14 +00:00
|
|
|
using Dalamud.Interface.Style;
|
2022-09-07 06:05:13 +00:00
|
|
|
using ImGuiNET;
|
|
|
|
|
2022-09-09 05:29:20 +00:00
|
|
|
namespace OrangeGuidanceTomestone.Helpers;
|
2022-09-07 06:05:13 +00:00
|
|
|
|
2022-09-09 10:19:14 +00:00
|
|
|
internal static class ImGuiHelper {
|
2022-09-07 17:49:14 +00:00
|
|
|
private static bool InternalIconButton(Func<string, bool> func, FontAwesomeIcon icon, string? id = null) {
|
2022-09-07 06:05:13 +00:00
|
|
|
var label = icon.ToIconString();
|
|
|
|
if (id != null) {
|
|
|
|
label += $"##{id}";
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui.PushFont(UiBuilder.IconFont);
|
2022-09-07 17:49:14 +00:00
|
|
|
var ret = func(label);
|
2022-09-07 06:05:13 +00:00
|
|
|
ImGui.PopFont();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-09-07 17:49:14 +00:00
|
|
|
internal static bool SmallIconButton(FontAwesomeIcon icon, string? id = null) {
|
|
|
|
return InternalIconButton(ImGui.SmallButton, icon, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static bool IconButton(FontAwesomeIcon icon, string? id = null) {
|
|
|
|
return InternalIconButton(ImGui.Button, icon, id);
|
|
|
|
}
|
|
|
|
|
2022-09-07 06:05:13 +00:00
|
|
|
internal static void HelpIcon(string text) {
|
|
|
|
var colour = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled];
|
|
|
|
ImGui.PushStyleColor(ImGuiCol.Text, colour);
|
|
|
|
ImGui.TextUnformatted("(?)");
|
|
|
|
ImGui.PopStyleColor();
|
|
|
|
|
2022-09-09 10:19:14 +00:00
|
|
|
TextTooltip(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static unsafe ImGuiListClipperPtr Clipper(int itemsCount) {
|
|
|
|
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
|
|
|
clipper.Begin(itemsCount);
|
|
|
|
|
|
|
|
return clipper;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static void TextTooltip(string tooltip) {
|
2022-09-07 06:05:13 +00:00
|
|
|
if (!ImGui.IsItemHovered()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var width = ImGui.CalcTextSize("m") * 40;
|
|
|
|
ImGui.BeginTooltip();
|
|
|
|
ImGui.PushTextWrapPos(width.X);
|
2022-09-09 10:19:14 +00:00
|
|
|
ImGui.TextUnformatted(tooltip);
|
2022-09-07 06:05:13 +00:00
|
|
|
ImGui.PopTextWrapPos();
|
|
|
|
ImGui.EndTooltip();
|
|
|
|
}
|
2022-09-08 19:37:58 +00:00
|
|
|
|
2022-09-09 10:19:14 +00:00
|
|
|
internal static void WarningText(string text) {
|
|
|
|
var style = StyleModel.GetConfiguredStyle() ?? StyleModel.GetFromCurrent();
|
|
|
|
var dalamudOrange = style.BuiltInColors?.DalamudOrange;
|
|
|
|
if (dalamudOrange != null) {
|
|
|
|
ImGui.PushStyleColor(ImGuiCol.Text, dalamudOrange.Value);
|
|
|
|
}
|
2022-09-08 19:37:58 +00:00
|
|
|
|
2022-09-09 10:19:14 +00:00
|
|
|
ImGui.PushTextWrapPos();
|
|
|
|
ImGui.TextUnformatted(text);
|
|
|
|
ImGui.PopTextWrapPos();
|
|
|
|
|
|
|
|
if (dalamudOrange != null) {
|
|
|
|
ImGui.PopStyleColor();
|
|
|
|
}
|
2022-09-08 19:37:58 +00:00
|
|
|
}
|
2022-09-07 06:05:13 +00:00
|
|
|
}
|