public static string Description(this FPSPluginFont value) { var fi = value.GetType().GetField(value.ToString()); var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : value.ToString()); }
private string GetFontPath(FPSPluginFont font) { if (string.IsNullOrEmpty(AssemblyLocation)) { return(null); } return(font switch { FPSPluginFont.DalamudDefault => Path.Combine(Assembly.GetAssembly(typeof(DalamudPluginInterface)).Location, "..", "UIRes", "NotoSansCJKjp-Medium.otf"), _ => Path.Combine(Path.GetDirectoryName(AssemblyLocation) ?? "", "font.ttf"), });
public bool DrawConfigUI() { var drawConfig = true; var windowFlags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse; ImGui.Begin($"{plugin.Name} Config##fpsPluginConfigWindow", ref drawConfig, windowFlags); var changed = false; changed |= ImGui.Checkbox("Show Display##fpsPluginEnabledSetting", ref Enable); ImGui.SameLine(); ImGui.TextDisabled("/pfps [show|hide|toggle]"); changed |= ImGui.Checkbox("Lock Display##fpsPluginLockSetting", ref Locked); changed |= ImGui.Checkbox("Show Decimals##fpsPluginDecimalsSetting", ref ShowDecimals); changed |= ImGui.Checkbox("Show Average##fpsPluginShowAverageSetting", ref ShowAverage); changed |= ImGui.Checkbox("Show Minimum##fpsPluginShowMinimumSetting", ref ShowMinimum); changed |= ImGui.Checkbox("Multiline##fpsPluginMultiline", ref MultiLine); changed |= ImGui.InputInt("Tracking Timespan (Seconds)", ref HistorySnapshotCount, 1, 60); if (ImGui.TreeNode("Style Options###fpsPluginStyleOptions")) { changed |= ImGui.SliderFloat("Background Opacity##fpsPluginOpacitySetting", ref Alpha, 0, 1); if (ImGui.BeginCombo("Font##fpsPluginFontSelect", this.Font.Description())) { foreach (var v in (FPSPluginFont[])Enum.GetValues(typeof(FPSPluginFont))) { if (ImGui.Selectable($"{v.Description()}##fpsPluginFont_{v}")) { this.Font = v; changed = true; FontChangeTime = DateTime.Now.Ticks; } } ImGui.EndCombo(); } if (ImGui.SliderFloat("Font Size##fpsPluginFontSizeSetting", ref FontSize, 6, 90, "%.0f")) { FontChangeTime = DateTime.Now.Ticks; changed = true; } ImGui.SameLine(); if (ImGui.SmallButton("Reload Font")) { plugin.ReloadFont(); } changed |= ImGui.ColorEdit4("Text Colour##fpsPluginColorSetting", ref Colour); changed |= ImGui.SliderFloat("Corner Rounding###fpsPluginCornerRounding", ref WindowCornerRounding, 0f, 20f, "%.0f"); changed |= ImGui.SliderFloat2("Window Padding###fpsPluginWindowPadding", ref WindowPadding, 0f, 20f, "%.0f"); ImGui.TreePop(); } #if DEBUG if (ImGui.TreeNode("Debug##fpsPlugin")) { ImGui.InputText("Test Text", ref TestText, 100, ImGuiInputTextFlags.Multiline); ImGui.TreePop(); } #endif ImGui.Separator(); if (ImGui.Button("Restore Default##fpsPluginDefaultsButton")) { LoadDefaults(); changed = true; } if (changed) { if (HistorySnapshotCount < 1) { HistorySnapshotCount = 1; } if (HistorySnapshotCount > 10000) { HistorySnapshotCount = 10000; } Save(); } ImGui.SameLine(); ImGui.PushStyleColor(ImGuiCol.Button, 0xFF5E5BFF); ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF5E5BAA); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF5E5BDD); var c = ImGui.GetCursorPos(); ImGui.SetCursorPosX(ImGui.GetWindowContentRegionWidth() - ImGui.CalcTextSize("Support on Ko-fi").X - ImGui.GetStyle().FramePadding.X * 2); if (ImGui.Button("Support on Ko-fi")) { Process.Start("https://ko-fi.com/Caraxi"); } ImGui.SetCursorPos(c); ImGui.PopStyleColor(3); ImGui.End(); return(drawConfig); }