Updates for v9, begin ui rework

This commit is contained in:
Asriel Camora
2023-10-01 03:43:11 -07:00
parent 36b9e4fb6d
commit d9e78166d9
20 changed files with 785 additions and 62 deletions
+20 -1
View File
@@ -4,7 +4,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
namespace Craftimizer.Plugin;
internal static class ImGuiUtils
@@ -158,4 +157,24 @@ internal static class ImGuiUtils
ImGui.SetTooltip("Open in Browser");
}
}
public static void AlignCentered(float width)
{
var availWidth = ImGui.GetContentRegionAvail().X;
if (availWidth > width)
ImGui.SetCursorPosX(ImGui.GetCursorPos().X + (availWidth - width) / 2);
}
// https://stackoverflow.com/a/67855985
public static void TextCentered(string text)
{
AlignCentered(ImGui.CalcTextSize(text).X);
ImGui.TextUnformatted(text);
}
public static bool ButtonCentered(string text)
{
AlignCentered(ImGui.CalcTextSize(text).X + ImGui.GetStyle().FramePadding.Y * 2);
return ImGui.Button(text);
}
}