forked from aly/qstbak
51 lines
2.1 KiB
C#
51 lines
2.1 KiB
C#
using System;
|
|
using System.Numerics;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
|
|
namespace Questionable.Windows.Utils;
|
|
|
|
internal static class CycleSelectionUi
|
|
{
|
|
private const float Rounding = 6f;
|
|
|
|
public static bool DrawRunningBanner(string text, Vector4 color, FontAwesomeIcon icon)
|
|
{
|
|
ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList();
|
|
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
|
|
float fontSize = ImGui.GetFontSize();
|
|
string text2 = icon.ToIconString();
|
|
float x = ImGui.GetContentRegionAvail().X;
|
|
Vector2 vector;
|
|
using (ImRaii.PushFont(UiBuilder.IconFont))
|
|
{
|
|
vector = ImGui.CalcTextSize(text2);
|
|
}
|
|
float frameHeight = ImGui.GetFrameHeight();
|
|
float num = MathF.Max(MathF.Max(vector.Y, ImGui.GetTextLineHeight()), frameHeight);
|
|
float num2 = 12f + num + 12f;
|
|
Vector2 pMin = cursorScreenPos;
|
|
Vector2 pMax = cursorScreenPos + new Vector2(x, num2);
|
|
float w = 0.08f + 0.04f * (0.5f + 0.5f * MathF.Sin((float)ImGui.GetTime() * 2f));
|
|
Vector4 vector2 = color;
|
|
vector2.W = w;
|
|
Vector4 input = vector2;
|
|
vector2 = color;
|
|
vector2.W = 0.25f;
|
|
Vector4 input2 = vector2;
|
|
windowDrawList.AddRectFilled(pMin, pMax, ImGui.ColorConvertFloat4ToU32(input), 6f);
|
|
windowDrawList.AddRect(pMin, pMax, ImGui.ColorConvertFloat4ToU32(input2), 6f, ImDrawFlags.None, 1f);
|
|
windowDrawList.AddText(pos: new Vector2(pMin.X + 12f, pMin.Y + 12f + (num - vector.Y) / 2f), font: UiBuilder.IconFont, fontSize: fontSize, col: ImGui.ColorConvertFloat4ToU32(color), text: text2);
|
|
float num3 = pMin.X + 12f + vector.X + 6f;
|
|
float num4 = pMax.X - 12f - frameHeight;
|
|
Vector2 pos = new Vector2(num3, pMin.Y + 12f + (num - ImGui.GetTextLineHeight()) / 2f);
|
|
windowDrawList.AddText(pos, ImGui.ColorConvertFloat4ToU32(color), UiThemeUtils.TruncateToWidth(text, num4 - ImGui.GetStyle().ItemSpacing.X - num3));
|
|
ImGui.Dummy(new Vector2(x, num2));
|
|
Vector2 cursorPos = ImGui.GetCursorPos();
|
|
ImGui.SetCursorScreenPos(new Vector2(num4, pMin.Y + (num2 - frameHeight) / 2f));
|
|
bool result = UiThemeUtils.IconButton(FontAwesomeIcon.Stop, frameHeight);
|
|
ImGui.SetCursorPos(cursorPos);
|
|
return result;
|
|
}
|
|
}
|