mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: Add Dalamud Version to the Title Screen (#1939)
This commit is contained in:
parent
2a9ee760c6
commit
3435c346b6
2 changed files with 60 additions and 5 deletions
|
|
@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
|
||||||
using CheapLoc;
|
using CheapLoc;
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Console;
|
using Dalamud.Console;
|
||||||
|
using Dalamud.Game.Addon.Lifecycle;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Game.ClientState.Conditions;
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Game.ClientState.Keys;
|
using Dalamud.Game.ClientState.Keys;
|
||||||
|
|
@ -103,7 +104,8 @@ internal class DalamudInterface : IInternalDisposableService
|
||||||
ClientState clientState,
|
ClientState clientState,
|
||||||
TitleScreenMenu titleScreenMenu,
|
TitleScreenMenu titleScreenMenu,
|
||||||
GameGui gameGui,
|
GameGui gameGui,
|
||||||
ConsoleManager consoleManager)
|
ConsoleManager consoleManager,
|
||||||
|
AddonLifecycle addonLifecycle)
|
||||||
{
|
{
|
||||||
this.dalamud = dalamud;
|
this.dalamud = dalamud;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
|
@ -129,7 +131,8 @@ internal class DalamudInterface : IInternalDisposableService
|
||||||
framework,
|
framework,
|
||||||
gameGui,
|
gameGui,
|
||||||
titleScreenMenu,
|
titleScreenMenu,
|
||||||
consoleManager) { IsOpen = false };
|
consoleManager,
|
||||||
|
addonLifecycle) { IsOpen = false };
|
||||||
this.changelogWindow = new ChangelogWindow(
|
this.changelogWindow = new ChangelogWindow(
|
||||||
this.titleScreenMenuWindow,
|
this.titleScreenMenuWindow,
|
||||||
fontAtlasFactory,
|
fontAtlasFactory,
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,12 @@ using System.Numerics;
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Console;
|
using Dalamud.Console;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
|
using Dalamud.Game.Addon.Lifecycle;
|
||||||
|
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Game.Gui;
|
using Dalamud.Game.Gui;
|
||||||
|
using Dalamud.Game.Text;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Interface.Animation.EasingFunctions;
|
using Dalamud.Interface.Animation.EasingFunctions;
|
||||||
using Dalamud.Interface.ManagedFontAtlas;
|
using Dalamud.Interface.ManagedFontAtlas;
|
||||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||||
|
|
@ -14,10 +18,15 @@ using Dalamud.Interface.Textures.TextureWraps;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Interface.Utility.Raii;
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
|
using Dalamud.Plugin.Internal;
|
||||||
|
using Dalamud.Plugin.Internal.Types;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Dalamud.Storage.Assets;
|
using Dalamud.Storage.Assets;
|
||||||
|
using Dalamud.Support;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
||||||
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Internal.Windows;
|
namespace Dalamud.Interface.Internal.Windows;
|
||||||
|
|
@ -39,7 +48,8 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
private readonly IFontAtlas privateAtlas;
|
private readonly IFontAtlas privateAtlas;
|
||||||
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 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();
|
||||||
|
|
@ -49,7 +59,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
private InOutCubic? fadeOutEasing;
|
private InOutCubic? fadeOutEasing;
|
||||||
|
|
||||||
private State state = State.Hide;
|
private State state = State.Hide;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TitleScreenMenuWindow"/> class.
|
/// Initializes a new instance of the <see cref="TitleScreenMenuWindow"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -61,6 +71,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
/// <param name="titleScreenMenu">An instance of <see cref="TitleScreenMenu"/>.</param>
|
/// <param name="titleScreenMenu">An instance of <see cref="TitleScreenMenu"/>.</param>
|
||||||
/// <param name="gameGui">An instance of <see cref="GameGui"/>.</param>
|
/// <param name="gameGui">An instance of <see cref="GameGui"/>.</param>
|
||||||
/// <param name="consoleManager">An instance of <see cref="ConsoleManager"/>.</param>
|
/// <param name="consoleManager">An instance of <see cref="ConsoleManager"/>.</param>
|
||||||
|
/// <param name="addonLifecycle">An instance of <see cref="AddonLifecycle"/>.</param>
|
||||||
public TitleScreenMenuWindow(
|
public TitleScreenMenuWindow(
|
||||||
ClientState clientState,
|
ClientState clientState,
|
||||||
DalamudConfiguration configuration,
|
DalamudConfiguration configuration,
|
||||||
|
|
@ -69,7 +80,8 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
Framework framework,
|
Framework framework,
|
||||||
GameGui gameGui,
|
GameGui gameGui,
|
||||||
TitleScreenMenu titleScreenMenu,
|
TitleScreenMenu titleScreenMenu,
|
||||||
ConsoleManager consoleManager)
|
ConsoleManager consoleManager,
|
||||||
|
AddonLifecycle addonLifecycle)
|
||||||
: base(
|
: base(
|
||||||
"TitleScreenMenuOverlay",
|
"TitleScreenMenuOverlay",
|
||||||
ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar |
|
ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar |
|
||||||
|
|
@ -109,6 +121,10 @@ 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);
|
||||||
|
addonLifecycle.RegisterListener(this.versionStringListener);
|
||||||
|
this.scopedFinalizer.Add(() => addonLifecycle.UnregisterListener(this.versionStringListener));
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum State
|
private enum State
|
||||||
|
|
@ -414,5 +430,41 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
this.IsOpen = false;
|
this.IsOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsafe void OnVersionStringDraw(AddonEvent ev, AddonArgs args)
|
||||||
|
{
|
||||||
|
if (args is not AddonDrawArgs setupArgs) return;
|
||||||
|
|
||||||
|
var addon = (AtkUnitBase*)setupArgs.Addon;
|
||||||
|
var textNode = addon->GetTextNodeById(3);
|
||||||
|
|
||||||
|
// look and feel init. should be harmless to set.
|
||||||
|
textNode->TextFlags |= (byte)TextFlags.MultiLine;
|
||||||
|
textNode->AlignmentType = AlignmentType.TopLeft;
|
||||||
|
|
||||||
|
if (!this.configuration.ShowTsm || !this.showTsm.Value)
|
||||||
|
{
|
||||||
|
textNode->NodeText.SetString(addon->AtkValues[1].String);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pm = Service<PluginManager>.GetNullable();
|
||||||
|
|
||||||
|
var pluginCount = pm?.InstalledPlugins.Count(c => c.State == PluginState.Loaded) ?? 0;
|
||||||
|
|
||||||
|
var titleVersionText = new SeStringBuilder()
|
||||||
|
.AddText(addon->AtkValues[1].GetValueAsString())
|
||||||
|
.AddText("\n\n")
|
||||||
|
.AddUiForeground(SeIconChar.BoxedLetterD.ToIconString(), 539)
|
||||||
|
.AddUiForeground(561)
|
||||||
|
.AddText($" Dalamud: {Util.GetScmVersion()}")
|
||||||
|
.AddText($" - {pluginCount} {(pluginCount != 1 ? "plugins" : "plugin")} loaded")
|
||||||
|
.AddUiForegroundOff();
|
||||||
|
|
||||||
|
if (pm?.SafeMode ?? false)
|
||||||
|
titleVersionText.AddUiForeground(" [SAFE MODE]", 17);
|
||||||
|
|
||||||
|
textNode->NodeText.SetString(titleVersionText.Build().EncodeWithNullTerminator());
|
||||||
|
}
|
||||||
|
|
||||||
private void TitleScreenMenuEntryListChange() => this.privateAtlas.BuildFontsAsync();
|
private void TitleScreenMenuEntryListChange() => this.privateAtlas.BuildFontsAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue