mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
title screen menu: some visual fixes
Use SeStringRenderer to render menu entries Clamp alpha values to avoid flickering
This commit is contained in:
parent
c79b1cd83a
commit
2e77e90532
1 changed files with 15 additions and 21 deletions
|
|
@ -11,6 +11,7 @@ using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Game.Gui;
|
using Dalamud.Game.Gui;
|
||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
using Dalamud.Interface.Animation.EasingFunctions;
|
using Dalamud.Interface.Animation.EasingFunctions;
|
||||||
|
using Dalamud.Interface.ImGuiSeStringRenderer;
|
||||||
using Dalamud.Interface.ManagedFontAtlas;
|
using Dalamud.Interface.ManagedFontAtlas;
|
||||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||||
using Dalamud.Interface.Textures.TextureWraps;
|
using Dalamud.Interface.Textures.TextureWraps;
|
||||||
|
|
@ -50,11 +51,11 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
private readonly Lazy<IFontHandle> myFontHandle;
|
private readonly Lazy<IFontHandle> myFontHandle;
|
||||||
private readonly Lazy<IDalamudTextureWrap> shadeTexture;
|
private readonly Lazy<IDalamudTextureWrap> shadeTexture;
|
||||||
private readonly AddonLifecycleEventListener versionStringListener;
|
private readonly AddonLifecycleEventListener versionStringListener;
|
||||||
|
|
||||||
private readonly Dictionary<Guid, InOutCubic> shadeEasings = new();
|
private readonly Dictionary<Guid, InOutCubic> shadeEasings = new();
|
||||||
private readonly Dictionary<Guid, InOutQuint> moveEasings = new();
|
private readonly Dictionary<Guid, InOutQuint> moveEasings = new();
|
||||||
private readonly Dictionary<Guid, InOutCubic> logoEasings = new();
|
private readonly Dictionary<Guid, InOutCubic> logoEasings = new();
|
||||||
|
|
||||||
private readonly IConsoleVariable<bool> showTsm;
|
private readonly IConsoleVariable<bool> showTsm;
|
||||||
|
|
||||||
private InOutCubic? fadeOutEasing;
|
private InOutCubic? fadeOutEasing;
|
||||||
|
|
@ -62,7 +63,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
private State state = State.Hide;
|
private State state = State.Hide;
|
||||||
|
|
||||||
private int lastLoadedPluginCount = -1;
|
private int lastLoadedPluginCount = -1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TitleScreenMenuWindow"/> class.
|
/// Initializes a new instance of the <see cref="TitleScreenMenuWindow"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -91,7 +92,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNavFocus)
|
ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNavFocus)
|
||||||
{
|
{
|
||||||
this.showTsm = consoleManager.AddVariable("dalamud.show_tsm", "Show the Title Screen Menu", true);
|
this.showTsm = consoleManager.AddVariable("dalamud.show_tsm", "Show the Title Screen Menu", true);
|
||||||
|
|
||||||
this.clientState = clientState;
|
this.clientState = clientState;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.gameGui = gameGui;
|
this.gameGui = gameGui;
|
||||||
|
|
@ -124,7 +125,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
|
|
||||||
framework.Update += this.FrameworkOnUpdate;
|
framework.Update += this.FrameworkOnUpdate;
|
||||||
this.scopedFinalizer.Add(() => framework.Update -= this.FrameworkOnUpdate);
|
this.scopedFinalizer.Add(() => framework.Update -= this.FrameworkOnUpdate);
|
||||||
|
|
||||||
this.versionStringListener = new AddonLifecycleEventListener(AddonEvent.PreDraw, "_TitleRevision", this.OnVersionStringDraw);
|
this.versionStringListener = new AddonLifecycleEventListener(AddonEvent.PreDraw, "_TitleRevision", this.OnVersionStringDraw);
|
||||||
addonLifecycle.RegisterListener(this.versionStringListener);
|
addonLifecycle.RegisterListener(this.versionStringListener);
|
||||||
this.scopedFinalizer.Add(() => addonLifecycle.UnregisterListener(this.versionStringListener));
|
this.scopedFinalizer.Add(() => addonLifecycle.UnregisterListener(this.versionStringListener));
|
||||||
|
|
@ -136,7 +137,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
Show,
|
Show,
|
||||||
FadeOut,
|
FadeOut,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether drawing is allowed.
|
/// Gets or sets a value indicating whether drawing is allowed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -165,7 +166,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
if (!this.AllowDrawing || !this.showTsm.Value)
|
if (!this.AllowDrawing || !this.showTsm.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var scale = ImGui.GetIO().FontGlobalScale;
|
var scale = ImGui.GetIO().FontGlobalScale;
|
||||||
var entries = this.titleScreenMenu.PluginEntries;
|
var entries = this.titleScreenMenu.PluginEntries;
|
||||||
|
|
||||||
|
|
@ -174,7 +175,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
|
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
|
||||||
|
|
||||||
Service<InterfaceManager>.Get().OverrideGameCursor = !hovered;
|
Service<InterfaceManager>.Get().OverrideGameCursor = !hovered;
|
||||||
|
|
||||||
switch (this.state)
|
switch (this.state)
|
||||||
{
|
{
|
||||||
case State.Show:
|
case State.Show:
|
||||||
|
|
@ -251,7 +252,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
|
|
||||||
this.fadeOutEasing.Update();
|
this.fadeOutEasing.Update();
|
||||||
|
|
||||||
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value))
|
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)Math.Max(this.fadeOutEasing.Value, 0)))
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
|
|
@ -392,21 +393,14 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
|
|
||||||
if (overrideAlpha)
|
if (overrideAlpha)
|
||||||
{
|
{
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, showText ? (float)logoEasing.Value : 0f);
|
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, showText ? (float)Math.Min(logoEasing.Value, 1) : 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop shadow
|
// Drop shadow
|
||||||
using (ImRaii.PushColor(ImGuiCol.Text, 0xFF000000))
|
|
||||||
{
|
|
||||||
for (int i = 0, to = (int)Math.Ceiling(1 * scale); i < to; i++)
|
|
||||||
{
|
|
||||||
ImGui.SetCursorPos(new Vector2(cursor.X, cursor.Y + i));
|
|
||||||
ImGui.Text(entry.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.SetCursorPos(cursor);
|
ImGui.SetCursorPos(cursor);
|
||||||
ImGui.Text(entry.Name);
|
var renderStyle = default(SeStringDrawParams);
|
||||||
|
renderStyle.FontSize = TargetFontSizePx;
|
||||||
|
ImGuiHelpers.CompileSeStringWrapped($"<edge(1)><shadow(1)>{entry.Name}<shadow(0)><edge(0)>", renderStyle);
|
||||||
|
|
||||||
if (overrideAlpha)
|
if (overrideAlpha)
|
||||||
{
|
{
|
||||||
|
|
@ -439,7 +433,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
|
|
||||||
var addon = (AtkUnitBase*)drawArgs.Addon;
|
var addon = (AtkUnitBase*)drawArgs.Addon;
|
||||||
var textNode = addon->GetTextNodeById(3);
|
var textNode = addon->GetTextNodeById(3);
|
||||||
|
|
||||||
// look and feel init. should be harmless to set.
|
// look and feel init. should be harmless to set.
|
||||||
textNode->TextFlags |= (byte)TextFlags.MultiLine;
|
textNode->TextFlags |= (byte)TextFlags.MultiLine;
|
||||||
textNode->AlignmentType = AlignmentType.TopLeft;
|
textNode->AlignmentType = AlignmentType.TopLeft;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue