mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +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 Dalamud.Configuration.Internal;
|
||||
using Dalamud.Console;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
|
|
@ -103,7 +104,8 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
ClientState clientState,
|
||||
TitleScreenMenu titleScreenMenu,
|
||||
GameGui gameGui,
|
||||
ConsoleManager consoleManager)
|
||||
ConsoleManager consoleManager,
|
||||
AddonLifecycle addonLifecycle)
|
||||
{
|
||||
this.dalamud = dalamud;
|
||||
this.configuration = configuration;
|
||||
|
|
@ -129,7 +131,8 @@ internal class DalamudInterface : IInternalDisposableService
|
|||
framework,
|
||||
gameGui,
|
||||
titleScreenMenu,
|
||||
consoleManager) { IsOpen = false };
|
||||
consoleManager,
|
||||
addonLifecycle) { IsOpen = false };
|
||||
this.changelogWindow = new ChangelogWindow(
|
||||
this.titleScreenMenuWindow,
|
||||
fontAtlasFactory,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,12 @@ using System.Numerics;
|
|||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Console;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface.Animation.EasingFunctions;
|
||||
using Dalamud.Interface.ManagedFontAtlas;
|
||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
|
|
@ -14,10 +18,15 @@ using Dalamud.Interface.Textures.TextureWraps;
|
|||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Storage.Assets;
|
||||
using Dalamud.Support;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows;
|
||||
|
|
@ -39,7 +48,8 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
private readonly IFontAtlas privateAtlas;
|
||||
private readonly Lazy<IFontHandle> myFontHandle;
|
||||
private readonly Lazy<IDalamudTextureWrap> shadeTexture;
|
||||
|
||||
private readonly AddonLifecycleEventListener versionStringListener;
|
||||
|
||||
private readonly Dictionary<Guid, InOutCubic> shadeEasings = new();
|
||||
private readonly Dictionary<Guid, InOutQuint> moveEasings = new();
|
||||
private readonly Dictionary<Guid, InOutCubic> logoEasings = new();
|
||||
|
|
@ -49,7 +59,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
private InOutCubic? fadeOutEasing;
|
||||
|
||||
private State state = State.Hide;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TitleScreenMenuWindow"/> class.
|
||||
/// </summary>
|
||||
|
|
@ -61,6 +71,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
/// <param name="titleScreenMenu">An instance of <see cref="TitleScreenMenu"/>.</param>
|
||||
/// <param name="gameGui">An instance of <see cref="GameGui"/>.</param>
|
||||
/// <param name="consoleManager">An instance of <see cref="ConsoleManager"/>.</param>
|
||||
/// <param name="addonLifecycle">An instance of <see cref="AddonLifecycle"/>.</param>
|
||||
public TitleScreenMenuWindow(
|
||||
ClientState clientState,
|
||||
DalamudConfiguration configuration,
|
||||
|
|
@ -69,7 +80,8 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
Framework framework,
|
||||
GameGui gameGui,
|
||||
TitleScreenMenu titleScreenMenu,
|
||||
ConsoleManager consoleManager)
|
||||
ConsoleManager consoleManager,
|
||||
AddonLifecycle addonLifecycle)
|
||||
: base(
|
||||
"TitleScreenMenuOverlay",
|
||||
ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar |
|
||||
|
|
@ -109,6 +121,10 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
|
||||
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
|
||||
|
|
@ -414,5 +430,41 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue