mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Use new font functionality.
This commit is contained in:
parent
2e0e125913
commit
80ce6fe21f
2 changed files with 11 additions and 9 deletions
|
|
@ -2,6 +2,7 @@ using Dalamud.Game.ClientState.Objects;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.GameFonts;
|
using Dalamud.Interface.GameFonts;
|
||||||
|
using Dalamud.Interface.ManagedFontAtlas;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
@ -28,7 +29,7 @@ public sealed class CollectionPanel : IDisposable
|
||||||
private readonly InheritanceUi _inheritanceUi;
|
private readonly InheritanceUi _inheritanceUi;
|
||||||
private readonly ModStorage _mods;
|
private readonly ModStorage _mods;
|
||||||
|
|
||||||
private readonly GameFontHandle _nameFont;
|
private readonly IFontHandle _nameFont;
|
||||||
|
|
||||||
private static readonly IReadOnlyDictionary<CollectionType, (string Name, uint Border)> Buttons = CreateButtons();
|
private static readonly IReadOnlyDictionary<CollectionType, (string Name, uint Border)> Buttons = CreateButtons();
|
||||||
private static readonly IReadOnlyList<(CollectionType, bool, bool, string, uint)> AdvancedTree = CreateTree();
|
private static readonly IReadOnlyList<(CollectionType, bool, bool, string, uint)> AdvancedTree = CreateTree();
|
||||||
|
|
@ -47,7 +48,7 @@ public sealed class CollectionPanel : IDisposable
|
||||||
_mods = mods;
|
_mods = mods;
|
||||||
_individualAssignmentUi = new IndividualAssignmentUi(communicator, actors, manager);
|
_individualAssignmentUi = new IndividualAssignmentUi(communicator, actors, manager);
|
||||||
_inheritanceUi = new InheritanceUi(manager, _selector);
|
_inheritanceUi = new InheritanceUi(manager, _selector);
|
||||||
_nameFont = pi.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Jupiter23));
|
_nameFont = pi.UiBuilder.FontAtlas.NewGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Jupiter23));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
@ -426,7 +427,7 @@ public sealed class CollectionPanel : IDisposable
|
||||||
ImGui.Dummy(Vector2.One);
|
ImGui.Dummy(Vector2.One);
|
||||||
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
|
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
|
||||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
|
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
|
||||||
using var font = ImRaii.PushFont(_nameFont.ImFont, _nameFont.Available);
|
using var f = _nameFont.Available ? _nameFont.Push() : null;
|
||||||
var name = Name(collection);
|
var name = Name(collection);
|
||||||
var size = ImGui.CalcTextSize(name).X;
|
var size = ImGui.CalcTextSize(name).X;
|
||||||
var pos = ImGui.GetContentRegionAvail().X - size + ImGui.GetStyle().FramePadding.X * 2;
|
var pos = ImGui.GetContentRegionAvail().X - size + ImGui.GetStyle().FramePadding.X * 2;
|
||||||
|
|
@ -445,7 +446,7 @@ public sealed class CollectionPanel : IDisposable
|
||||||
if (_inUseCache.Count == 0 && collection.DirectParentOf.Count == 0)
|
if (_inUseCache.Count == 0 && collection.DirectParentOf.Count == 0)
|
||||||
{
|
{
|
||||||
ImGui.Dummy(Vector2.One);
|
ImGui.Dummy(Vector2.One);
|
||||||
using var font = ImRaii.PushFont(_nameFont.ImFont, _nameFont.Available);
|
using var f = _nameFont.Available ? _nameFont.Push() : null;
|
||||||
ImGuiUtil.DrawTextButton("Collection is not used.", new Vector2(ImGui.GetContentRegionAvail().X, buttonHeight),
|
ImGuiUtil.DrawTextButton("Collection is not used.", new Vector2(ImGui.GetContentRegionAvail().X, buttonHeight),
|
||||||
Colors.PressEnterWarningBg);
|
Colors.PressEnterWarningBg);
|
||||||
ImGui.Dummy(Vector2.One);
|
ImGui.Dummy(Vector2.One);
|
||||||
|
|
@ -512,7 +513,7 @@ public sealed class CollectionPanel : IDisposable
|
||||||
ImGuiUtil.DrawTextButton("Inherited by", ImGui.GetContentRegionAvail() with { Y = 0 }, 0);
|
ImGuiUtil.DrawTextButton("Inherited by", ImGui.GetContentRegionAvail() with { Y = 0 }, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
using var font = ImRaii.PushFont(_nameFont.ImFont, _nameFont.Available);
|
using var f = _nameFont.Available ? _nameFont.Push() : null;
|
||||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale);
|
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale);
|
||||||
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
|
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
|
||||||
ImGuiUtil.DrawTextButton(Name(collection.DirectParentOf[0]), Vector2.Zero, 0);
|
ImGuiUtil.DrawTextButton(Name(collection.DirectParentOf[0]), Vector2.Zero, 0);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Dalamud.Interface.GameFonts;
|
using Dalamud.Interface.GameFonts;
|
||||||
|
using Dalamud.Interface.ManagedFontAtlas;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
|
|
@ -14,14 +15,14 @@ namespace Penumbra.UI.ModsTab;
|
||||||
public class ModPanelHeader : IDisposable
|
public class ModPanelHeader : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary> We use a big, nice game font for the title. </summary>
|
/// <summary> We use a big, nice game font for the title. </summary>
|
||||||
private readonly GameFontHandle _nameFont;
|
private readonly IFontHandle _nameFont;
|
||||||
|
|
||||||
private readonly CommunicatorService _communicator;
|
private readonly CommunicatorService _communicator;
|
||||||
|
|
||||||
public ModPanelHeader(DalamudPluginInterface pi, CommunicatorService communicator)
|
public ModPanelHeader(DalamudPluginInterface pi, CommunicatorService communicator)
|
||||||
{
|
{
|
||||||
_communicator = communicator;
|
_communicator = communicator;
|
||||||
_nameFont = pi.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Jupiter23));
|
_nameFont = pi.UiBuilder.FontAtlas.NewGameFontHandle(new GameFontStyle(GameFontFamilyAndSize.Jupiter23));
|
||||||
_communicator.ModDataChanged.Subscribe(OnModDataChange, ModDataChanged.Priority.ModPanelHeader);
|
_communicator.ModDataChanged.Subscribe(OnModDataChange, ModDataChanged.Priority.ModPanelHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ public class ModPanelHeader : IDisposable
|
||||||
var name = $" {mod.Name} ";
|
var name = $" {mod.Name} ";
|
||||||
if (name != _modName)
|
if (name != _modName)
|
||||||
{
|
{
|
||||||
using var font = ImRaii.PushFont(_nameFont.ImFont, _nameFont.Available);
|
using var f = _nameFont.Available ? _nameFont.Push() : null;
|
||||||
_modName = name;
|
_modName = name;
|
||||||
_modNameWidth = ImGui.CalcTextSize(name).X + 2 * (ImGui.GetStyle().FramePadding.X + 2 * UiHelpers.Scale);
|
_modNameWidth = ImGui.CalcTextSize(name).X + 2 * (ImGui.GetStyle().FramePadding.X + 2 * UiHelpers.Scale);
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +122,7 @@ public class ModPanelHeader : IDisposable
|
||||||
|
|
||||||
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
|
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
|
||||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
|
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * UiHelpers.Scale);
|
||||||
using var font = ImRaii.PushFont(_nameFont.ImFont, _nameFont.Available);
|
using var f = _nameFont.Available ? _nameFont.Push() : null;
|
||||||
ImGuiUtil.DrawTextButton(_modName, Vector2.Zero, 0);
|
ImGuiUtil.DrawTextButton(_modName, Vector2.Zero, 0);
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue