Miscellaneous improvements (#1537)

This commit is contained in:
srkizer 2023-11-27 06:58:26 +09:00 committed by GitHub
parent a6ea4aa56a
commit 7a0de45f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1136 additions and 279 deletions

View file

@ -18,39 +18,39 @@ internal class DataWindow : Window
{
private readonly IDataWindowWidget[] modules =
{
new ServicesWidget(),
new AddressesWidget(),
new ObjectTableWidget(),
new FateTableWidget(),
new SeFontTestWidget(),
new FontAwesomeTestWidget(),
new PartyListWidget(),
new BuddyListWidget(),
new PluginIpcWidget(),
new ConditionWidget(),
new GaugeWidget(),
new CommandWidget(),
new AddonWidget(),
new AddonInspectorWidget(),
new AddonLifecycleWidget(),
new AddonWidget(),
new AddressesWidget(),
new AetherytesWidget(),
new AtkArrayDataBrowserWidget(),
new BuddyListWidget(),
new CommandWidget(),
new ConditionWidget(),
new ConfigurationWidget(),
new DataShareWidget(),
new DtrBarWidget(),
new FateTableWidget(),
new FlyTextWidget(),
new FontAwesomeTestWidget(),
new GamepadWidget(),
new GaugeWidget(),
new HookWidget(),
new IconBrowserWidget(),
new ImGuiWidget(),
new KeyStateWidget(),
new NetworkMonitorWidget(),
new ObjectTableWidget(),
new PartyListWidget(),
new PluginIpcWidget(),
new SeFontTestWidget(),
new ServicesWidget(),
new StartInfoWidget(),
new TargetWidget(),
new ToastWidget(),
new FlyTextWidget(),
new ImGuiWidget(),
new TexWidget(),
new KeyStateWidget(),
new GamepadWidget(),
new ConfigurationWidget(),
new TaskSchedulerWidget(),
new HookWidget(),
new AetherytesWidget(),
new DtrBarWidget(),
new TexWidget(),
new ToastWidget(),
new UIColorWidget(),
new DataShareWidget(),
new NetworkMonitorWidget(),
new IconBrowserWidget(),
new AddonLifecycleWidget(),
};
private readonly IOrderedEnumerable<IDataWindowWidget> orderedModules;

View file

@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Linq;
namespace Dalamud.Interface.Internal.Windows;
namespace Dalamud.Interface.Internal.Windows.Data;
/// <summary>
/// Class representing a date window entry.

View file

@ -28,8 +28,14 @@ public class AddonLifecycleWidget : IDataWindowWidget
/// <inheritdoc/>
public void Load()
{
this.AddonLifecycle = Service<AddonLifecycle>.GetNullable();
if (this.AddonLifecycle is not null) this.Ready = true;
Service<AddonLifecycle>
.GetAsync()
.ContinueWith(
r =>
{
this.AddonLifecycle = r.Result;
this.Ready = true;
});
}
/// <inheritdoc/>

View file

@ -38,12 +38,30 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
public void Draw()
{
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
this.iconCategories ??= FontAwesomeHelpers.GetCategories();
this.iconCategories ??= new[] { "(Show All)", "(Undefined)" }
.Concat(FontAwesomeHelpers.GetCategories().Skip(1))
.ToArray();
if (this.iconSearchChanged)
{
this.icons = FontAwesomeHelpers.SearchIcons(this.iconSearchInput, this.iconCategories[this.selectedIconCategory]);
if (this.iconSearchInput == string.Empty && this.selectedIconCategory <= 1)
{
var en = InterfaceManager.IconFont.GlyphsWrapped()
.Select(x => (FontAwesomeIcon)x.Codepoint)
.Where(x => (ushort)x is >= 0xE000 and < 0xF000);
en = this.selectedIconCategory == 0
? en.Concat(FontAwesomeHelpers.SearchIcons(string.Empty, string.Empty))
: en.Except(FontAwesomeHelpers.SearchIcons(string.Empty, string.Empty));
this.icons = en.Distinct().Order().ToList();
}
else
{
this.icons = FontAwesomeHelpers.SearchIcons(
this.iconSearchInput,
this.selectedIconCategory <= 1 ? string.Empty : this.iconCategories[this.selectedIconCategory]);
}
this.iconNames = this.icons.Select(icon => Enum.GetName(icon)!).ToList();
this.iconSearchChanged = false;
}

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@ -46,7 +45,7 @@ public class ProfilerWindow : Window
ImGui.Text("Timings");
var childHeight = Math.Max(300, 20 * (2 + this.occupied.Count));
var childHeight = Math.Max(300, 20 * (2.5f + this.occupied.Count));
if (ImGui.BeginChild("Timings", new Vector2(0, childHeight), true))
{
@ -115,7 +114,7 @@ public class ProfilerWindow : Window
parentDepthDict[timingHandle.Id] = depth;
startX = Math.Max(startX, 0);
endX = Math.Max(endX, 0);
endX = Math.Max(endX, startX + (ImGuiHelpers.GlobalScale * 16));
Vector4 rectColor;
if (this.occupied[depth].Count % 2 == 0)
@ -129,11 +128,6 @@ public class ProfilerWindow : Window
if (maxRectDept < depth)
maxRectDept = (uint)depth;
if (startX == endX)
{
continue;
}
var minPos = pos + new Vector2((uint)startX, 20 * depth);
var maxPos = pos + new Vector2((uint)endX, 20 * (depth + 1));
@ -231,22 +225,22 @@ public class ProfilerWindow : Window
ImGui.EndChild();
var sliderMin = (float)this.min / 1000f;
if (ImGui.SliderFloat("Start", ref sliderMin, (float)actualMin / 1000f, (float)this.max / 1000f, "%.1fs"))
if (ImGui.SliderFloat("Start", ref sliderMin, (float)actualMin / 1000f, (float)this.max / 1000f, "%.2fs"))
{
this.min = sliderMin * 1000f;
}
var sliderMax = (float)this.max / 1000f;
if (ImGui.SliderFloat("End", ref sliderMax, (float)this.min / 1000f, (float)actualMax / 1000f, "%.1fs"))
if (ImGui.SliderFloat("End", ref sliderMax, (float)this.min / 1000f, (float)actualMax / 1000f, "%.2fs"))
{
this.max = sliderMax * 1000f;
}
var sizeShown = (float)(this.max - this.min);
var sizeActual = (float)(actualMax - actualMin);
if (ImGui.SliderFloat("Size", ref sizeShown, sizeActual / 10f, sizeActual, "%.1fs"))
var sizeShown = (float)(this.max - this.min) / 1000f;
var sizeActual = (float)(actualMax - actualMin) / 1000f;
if (ImGui.SliderFloat("Size", ref sizeShown, sizeActual / 10f, sizeActual, "%.2fs"))
{
this.max = this.min + sizeShown;
this.max = this.min + (sizeShown * 1000f);
}
ImGui.Text("Min: " + actualMin.ToString("0.000"));
@ -257,6 +251,7 @@ public class ProfilerWindow : Window
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Internals")]
private class RectInfo
{
// ReSharper disable once NotNullOrRequiredMemberIsNotInitialized <- well you're wrong
internal TimingHandle Timing;
internal Vector2 MinPos;
internal Vector2 MaxPos;

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using CheapLoc;
using Dalamud.Configuration.Internal;
@ -16,6 +17,16 @@ namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class SettingsTabLook : SettingsTab
{
private static readonly (string, float)[] GlobalUiScalePresets =
{
("9.6pt##DalamudSettingsGlobalUiScaleReset96", 9.6f / InterfaceManager.DefaultFontSizePt),
("12pt##DalamudSettingsGlobalUiScaleReset12", 12f / InterfaceManager.DefaultFontSizePt),
("14pt##DalamudSettingsGlobalUiScaleReset14", 14f / InterfaceManager.DefaultFontSizePt),
("18pt##DalamudSettingsGlobalUiScaleReset18", 18f / InterfaceManager.DefaultFontSizePt),
("24pt##DalamudSettingsGlobalUiScaleReset24", 24f / InterfaceManager.DefaultFontSizePt),
("36pt##DalamudSettingsGlobalUiScaleReset36", 36f / InterfaceManager.DefaultFontSizePt),
};
private float globalUiScale;
private float fontGamma;
@ -135,55 +146,22 @@ public class SettingsTabLook : SettingsTab
{
var interfaceManager = Service<InterfaceManager>.Get();
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
ImGui.AlignTextToFramePadding();
ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global Font Scale"));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 3);
if (ImGui.Button("9.6pt##DalamudSettingsGlobalUiScaleReset96"))
{
this.globalUiScale = 9.6f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button("12pt##DalamudSettingsGlobalUiScaleReset12"))
var buttonSize =
GlobalUiScalePresets
.Select(x => ImGui.CalcTextSize(x.Item1, 0, x.Item1.IndexOf('#')))
.Aggregate(Vector2.Zero, Vector2.Max)
+ (ImGui.GetStyle().FramePadding * 2);
foreach (var (buttonLabel, scale) in GlobalUiScalePresets)
{
this.globalUiScale = 1.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button("14pt##DalamudSettingsGlobalUiScaleReset14"))
{
this.globalUiScale = 14.0f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button("18pt##DalamudSettingsGlobalUiScaleReset18"))
{
this.globalUiScale = 18.0f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button("24pt##DalamudSettingsGlobalUiScaleReset24"))
{
this.globalUiScale = 24.0f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button("36pt##DalamudSettingsGlobalUiScaleReset36"))
{
this.globalUiScale = 36.0f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
ImGui.SameLine();
if (ImGui.Button(buttonLabel, buttonSize) && Math.Abs(this.globalUiScale - scale) > float.Epsilon)
{
ImGui.GetIO().FontGlobalScale = this.globalUiScale = scale;
interfaceManager.RebuildFonts();
}
}
var globalUiScaleInPt = 12f * this.globalUiScale;
@ -198,10 +176,9 @@ public class SettingsTabLook : SettingsTab
ImGuiHelpers.ScaledDummy(5);
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
ImGui.AlignTextToFramePadding();
ImGui.Text(Loc.Localize("DalamudSettingsFontGamma", "Font Gamma"));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 3);
if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset") + "##DalamudSettingsFontGammaReset"))
{
this.fontGamma = 1.4f;