make changelog fades less obnoxious, open on title screen instead

This commit is contained in:
goat 2024-06-30 00:14:10 +02:00
parent d97890940e
commit 41e3803787
3 changed files with 59 additions and 10 deletions

View file

@ -199,11 +199,6 @@ internal class ChatHandlers : IServiceType
Type = XivChatType.Notice, Type = XivChatType.Notice,
}); });
if (ChangelogWindow.WarrantsChangelog())
{
dalamudInterface.OpenChangelogWindow();
}
this.configuration.LastVersion = assemblyVersion; this.configuration.LastVersion = assemblyVersion;
this.configuration.QueueSave(); this.configuration.QueueSave();
} }

View file

@ -133,7 +133,9 @@ internal class DalamudInterface : IInternalDisposableService
this.changelogWindow = new ChangelogWindow( this.changelogWindow = new ChangelogWindow(
this.titleScreenMenuWindow, this.titleScreenMenuWindow,
fontAtlasFactory, fontAtlasFactory,
dalamudAssetManager) { IsOpen = false }; dalamudAssetManager,
gameGui,
framework) { IsOpen = false };
this.profilerWindow = new ProfilerWindow() { IsOpen = false }; this.profilerWindow = new ProfilerWindow() { IsOpen = false };
this.branchSwitcherWindow = new BranchSwitcherWindow() { IsOpen = false }; this.branchSwitcherWindow = new BranchSwitcherWindow() { IsOpen = false };
this.hitchSettingsWindow = new HitchSettingsWindow() { IsOpen = false }; this.hitchSettingsWindow = new HitchSettingsWindow() { IsOpen = false };

View file

@ -5,6 +5,8 @@ using System.Numerics;
using CheapLoc; using CheapLoc;
using Dalamud.Configuration.Internal; using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Gui;
using Dalamud.Interface.Animation.EasingFunctions; using Dalamud.Interface.Animation.EasingFunctions;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
@ -17,6 +19,7 @@ using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Internal.AutoUpdate; using Dalamud.Plugin.Internal.AutoUpdate;
using Dalamud.Plugin.Services;
using Dalamud.Storage.Assets; using Dalamud.Storage.Assets;
using Dalamud.Utility; using Dalamud.Utility;
@ -39,8 +42,12 @@ internal sealed class ChangelogWindow : Window, IDisposable
The Dalamud/plugin installer UI has been refreshed The Dalamud/plugin installer UI has been refreshed
"; ";
private static readonly TimeSpan TitleScreenWaitTime = TimeSpan.FromSeconds(0.5f);
private readonly TitleScreenMenuWindow tsmWindow; private readonly TitleScreenMenuWindow tsmWindow;
private readonly GameGui gameGui;
private readonly DisposeSafety.ScopedFinalizer scopedFinalizer = new(); private readonly DisposeSafety.ScopedFinalizer scopedFinalizer = new();
private readonly IFontAtlas privateAtlas; private readonly IFontAtlas privateAtlas;
private readonly Lazy<IFontHandle> bannerFont; private readonly Lazy<IFontHandle> bannerFont;
@ -53,19 +60,19 @@ internal sealed class ChangelogWindow : Window, IDisposable
Point2 = new Vector2(2f), Point2 = new Vector2(2f),
}; };
private readonly InOutCubic bodyFade = new(TimeSpan.FromSeconds(1.3f)) private readonly InOutCubic bodyFade = new(TimeSpan.FromSeconds(0.8f))
{ {
Point1 = Vector2.Zero, Point1 = Vector2.Zero,
Point2 = Vector2.One, Point2 = Vector2.One,
}; };
private readonly InOutCubic titleFade = new(TimeSpan.FromSeconds(1f)) private readonly InOutCubic titleFade = new(TimeSpan.FromSeconds(0.5f))
{ {
Point1 = Vector2.Zero, Point1 = Vector2.Zero,
Point2 = Vector2.One, Point2 = Vector2.One,
}; };
private readonly InOutCubic fadeOut = new(TimeSpan.FromSeconds(0.8f)) private readonly InOutCubic fadeOut = new(TimeSpan.FromSeconds(0.5f))
{ {
Point1 = Vector2.One, Point1 = Vector2.One,
Point2 = Vector2.Zero, Point2 = Vector2.Zero,
@ -82,6 +89,9 @@ internal sealed class ChangelogWindow : Window, IDisposable
private Dictionary<string, int> currentFtueLevels = new(); private Dictionary<string, int> currentFtueLevels = new();
private DateTime? isEligibleSince;
private bool openedThroughEligibility;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ChangelogWindow"/> class. /// Initializes a new instance of the <see cref="ChangelogWindow"/> class.
/// </summary> /// </summary>
@ -91,9 +101,13 @@ internal sealed class ChangelogWindow : Window, IDisposable
public ChangelogWindow( public ChangelogWindow(
TitleScreenMenuWindow tsmWindow, TitleScreenMenuWindow tsmWindow,
FontAtlasFactory fontAtlasFactory, FontAtlasFactory fontAtlasFactory,
DalamudAssetManager assets) DalamudAssetManager assets,
GameGui gameGui,
Framework framework)
: base("What's new in Dalamud?##ChangelogWindow", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse, true) : base("What's new in Dalamud?##ChangelogWindow", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse, true)
{ {
this.gameGui = gameGui;
this.tsmWindow = tsmWindow; this.tsmWindow = tsmWindow;
this.Namespace = "DalamudChangelogWindow"; this.Namespace = "DalamudChangelogWindow";
this.privateAtlas = this.scopedFinalizer.Add( this.privateAtlas = this.scopedFinalizer.Add(
@ -108,6 +122,9 @@ internal sealed class ChangelogWindow : Window, IDisposable
// If we are going to show a changelog, make sure we have the font ready, otherwise it will hitch // If we are going to show a changelog, make sure we have the font ready, otherwise it will hitch
if (WarrantsChangelog()) if (WarrantsChangelog())
_ = this.bannerFont.Value; _ = this.bannerFont.Value;
framework.Update += this.FrameworkOnUpdate;
this.scopedFinalizer.Add(() => framework.Update -= this.FrameworkOnUpdate);
} }
private enum State private enum State
@ -519,6 +536,41 @@ internal sealed class ChangelogWindow : Window, IDisposable
{ {
} }
private void FrameworkOnUpdate(IFramework unused)
{
if (!WarrantsChangelog())
return;
if (this.IsOpen)
return;
if (this.openedThroughEligibility)
return;
var isEligible = this.gameGui.GetAddonByName("_TitleMenu", 1) != IntPtr.Zero;
var charaSelect = this.gameGui.GetAddonByName("CharaSelect", 1);
var charaMake = this.gameGui.GetAddonByName("CharaMake", 1);
var titleDcWorldMap = this.gameGui.GetAddonByName("TitleDCWorldMap", 1);
if (charaMake != IntPtr.Zero || charaSelect != IntPtr.Zero || titleDcWorldMap != IntPtr.Zero)
isEligible = false;
if (this.isEligibleSince == null && isEligible)
{
this.isEligibleSince = DateTime.Now;
}
else if (this.isEligibleSince != null && !isEligible)
{
this.isEligibleSince = null;
}
if (this.isEligibleSince != null && DateTime.Now - this.isEligibleSince > TitleScreenWaitTime)
{
this.IsOpen = true;
this.openedThroughEligibility = true;
}
}
private static class FtueLevels private static class FtueLevels
{ {
public static class AutoUpdate public static class AutoUpdate