diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index df7e2f179..fe2fc97a6 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -290,7 +290,9 @@ namespace Dalamud.Configuration.Internal /// public bool ShowTsm { get; set; } = true; - public bool? Fools22Newer { get; set; } = false; + public bool AskedFools22 { get; set; } = false; + + public bool Fools22Newer { get; set; } = false; /// /// Load a configuration from the provided path. diff --git a/Dalamud/Fools22.cs b/Dalamud/Fools22.cs index 1ea68e613..256ed08dd 100644 --- a/Dalamud/Fools22.cs +++ b/Dalamud/Fools22.cs @@ -1,13 +1,13 @@ using System; using System.Diagnostics; using System.IO; -using System.Media; using System.Numerics; using System.Threading.Tasks; using Dalamud.Configuration.Internal; using Dalamud.Data; using Dalamud.Game; +using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.Gui; using Dalamud.Game.Network; @@ -86,6 +86,7 @@ public class Fools22 : IDisposable var chatGui = Service.Get(); var dataMgr = Service.Get(); var gameNetwork = Service.Get(); + var clientState = Service.Get(); this.erDeathBgTexture = interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "er_death_bg.png"))!; this.erNormalDeathTexture = interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "fools22", "er_normal_death.png"))!; @@ -108,6 +109,21 @@ public class Fools22 : IDisposable framework.Update += this.FrameworkOnUpdate; chatGui.ChatMessage += this.ChatGuiOnChatMessage; gameNetwork.NetworkMessage += this.GameNetworkOnNetworkMessage; + clientState.Login += ClientStateOnLogin; + } + + private void ClientStateOnLogin(object? sender, EventArgs e) + { + var config = Service.Get(); + + if (!(DateTime.Now.Month == 4 && DateTime.Now.Day == 1)) + return; + + if (config.AskedFools22) + return; + + var di = Service.Get(); + di.OpenFaWindow(); } private unsafe void GameNetworkOnNetworkMessage(IntPtr dataptr, ushort opcode, uint sourceactorid, uint targetactorid, NetworkMessageDirection direction) @@ -332,7 +348,7 @@ public class Fools22 : IDisposable { var config = Service.Get(); - if (!(config.Fools22Newer ?? true)) + if (!config.Fools22Newer) return false; if (!(DateTime.Now.Month == 4 && DateTime.Now.Day == 1)) @@ -389,7 +405,8 @@ public class Fools22 : IDisposable if (!(seEnabled && masterEnabled)) return 0; - return masterVolume / 100F; + var vol = masterVolume / 100F; + return Math.Clamp(vol, 0f, 1f); } catch (Exception ex) { diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index ee56e749f..e924774d9 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -53,6 +53,7 @@ namespace Dalamud.Interface.Internal private readonly SelfTestWindow selfTestWindow; private readonly StyleEditorWindow styleEditorWindow; private readonly TitleScreenMenuWindow titleScreenMenuWindow; + private readonly FoolsAskWindow faWindow; private readonly TextureWrap logoTexture; private readonly TextureWrap tsmLogoTexture; @@ -91,6 +92,7 @@ namespace Dalamud.Interface.Internal this.selfTestWindow = new SelfTestWindow() { IsOpen = false }; this.styleEditorWindow = new StyleEditorWindow() { IsOpen = false }; this.titleScreenMenuWindow = new TitleScreenMenuWindow() { IsOpen = false }; + this.faWindow = new FoolsAskWindow() { IsOpen = false }; this.WindowSystem.AddWindow(this.changelogWindow); this.WindowSystem.AddWindow(this.colorDemoWindow); @@ -106,6 +108,7 @@ namespace Dalamud.Interface.Internal this.WindowSystem.AddWindow(this.selfTestWindow); this.WindowSystem.AddWindow(this.styleEditorWindow); this.WindowSystem.AddWindow(this.titleScreenMenuWindow); + this.WindowSystem.AddWindow(this.faWindow); ImGuiManagedAsserts.AssertsEnabled = configuration.AssertsEnabledAtStartup; @@ -247,6 +250,8 @@ namespace Dalamud.Interface.Internal /// public void OpenStyleEditor() => this.styleEditorWindow.IsOpen = true; + public void OpenFaWindow() => this.faWindow.IsOpen = true; + #endregion #region Close diff --git a/Dalamud/Interface/Internal/Windows/FoolsAskWindow.cs b/Dalamud/Interface/Internal/Windows/FoolsAskWindow.cs new file mode 100644 index 000000000..20bedfbc6 --- /dev/null +++ b/Dalamud/Interface/Internal/Windows/FoolsAskWindow.cs @@ -0,0 +1,100 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Numerics; +using Dalamud.Configuration.Internal; +using Dalamud.Interface.Colors; +using Dalamud.Interface.Windowing; +using Dalamud.Utility; +using ImGuiNET; +using ImGuiScene; + +namespace Dalamud.Interface.Internal.Windows +{ + /// + /// For major updates, an in-game Changelog window. + /// + internal sealed class FoolsAskWindow : Window, IDisposable + { + private readonly string assemblyVersion = Util.AssemblyVersion; + + private readonly TextureWrap logoTexture; + + /// + /// Initializes a new instance of the class. + /// + public FoolsAskWindow() + : base("New in Dalamud!", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse) + { + this.Namespace = "DalamudChangelogWindow"; + + var interfaceManager = Service.Get(); + var dalamud = Service.Get(); + + this.logoTexture = + interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "logo.png"))!; + } + + /// + public override void Draw() + { + this.Size = new Vector2(885, 250); + this.SizeCondition = ImGuiCond.Always; + this.Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse; + + ImGui.TextWrapped("Today, we are proud to announce \"Dalamud: Prepare To Die Edition\".\nIt's a new initiative intended to improve your immersion when playing FFXIV, featuring all new and unintrusive visual and sound effects.\nIt's only available today, so join while you can."); + + ImGuiHelpers.ScaledDummy(10); + + ImGui.TextWrapped("You can choose to opt-in here - thank you for your support!"); + + ImGui.SameLine(); + ImGuiHelpers.ScaledDummy(0); + var imgCursor = ImGui.GetCursorPos(); + + ImGuiHelpers.ScaledDummy(40); + + ImGuiHelpers.ScaledDummy(240); + + ImGui.SameLine(); + + var btnSize = new Vector2(140, 40); + + var config = Service.Get(); + + if (ImGui.Button("No, don't ask again", btnSize)) + { + config.AskedFools22 = true; + config.Fools22Newer = false; + config.Save(); + + this.IsOpen = false; + } + + ImGui.SameLine(); + + if (ImGui.Button("Yes!", btnSize)) + { + config.AskedFools22 = true; + config.Fools22Newer = true; + config.Save(); + + this.IsOpen = false; + } + + imgCursor.X += 750; + imgCursor.Y -= 30; + ImGui.SetCursorPos(imgCursor); + + ImGui.Image(this.logoTexture.ImGuiHandle, new Vector2(100)); + } + + /// + /// Dispose this window. + /// + public void Dispose() + { + this.logoTexture.Dispose(); + } + } +} diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 67cca1eb2..a3adb3780 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -175,7 +175,7 @@ namespace Dalamud.Interface.Internal.Windows this.dtrOrder = configuration.DtrOrder; this.dtrIgnore = configuration.DtrIgnore; - this.doFools22 = configuration.Fools22Newer ?? true; + this.doFools22 = configuration.Fools22Newer; } ///