mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: add update window
This commit is contained in:
parent
d0907df5d2
commit
4ae45492e6
5 changed files with 129 additions and 5 deletions
|
|
@ -290,7 +290,9 @@ namespace Dalamud.Configuration.Internal
|
|||
/// </summary>
|
||||
public bool ShowTsm { get; set; } = true;
|
||||
|
||||
public bool? Fools22Newer { get; set; } = false;
|
||||
public bool AskedFools22 { get; set; } = false;
|
||||
|
||||
public bool Fools22Newer { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Load a configuration from the provided path.
|
||||
|
|
|
|||
|
|
@ -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<ChatGui>.Get();
|
||||
var dataMgr = Service<DataManager>.Get();
|
||||
var gameNetwork = Service<GameNetwork>.Get();
|
||||
var clientState = Service<ClientState>.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<DalamudConfiguration>.Get();
|
||||
|
||||
if (!(DateTime.Now.Month == 4 && DateTime.Now.Day == 1))
|
||||
return;
|
||||
|
||||
if (config.AskedFools22)
|
||||
return;
|
||||
|
||||
var di = Service<DalamudInterface>.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<DalamudConfiguration>.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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// </summary>
|
||||
public void OpenStyleEditor() => this.styleEditorWindow.IsOpen = true;
|
||||
|
||||
public void OpenFaWindow() => this.faWindow.IsOpen = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Close
|
||||
|
|
|
|||
100
Dalamud/Interface/Internal/Windows/FoolsAskWindow.cs
Normal file
100
Dalamud/Interface/Internal/Windows/FoolsAskWindow.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// For major updates, an in-game Changelog window.
|
||||
/// </summary>
|
||||
internal sealed class FoolsAskWindow : Window, IDisposable
|
||||
{
|
||||
private readonly string assemblyVersion = Util.AssemblyVersion;
|
||||
|
||||
private readonly TextureWrap logoTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FoolsAskWindow"/> class.
|
||||
/// </summary>
|
||||
public FoolsAskWindow()
|
||||
: base("New in Dalamud!", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
|
||||
{
|
||||
this.Namespace = "DalamudChangelogWindow";
|
||||
|
||||
var interfaceManager = Service<InterfaceManager>.Get();
|
||||
var dalamud = Service<Dalamud>.Get();
|
||||
|
||||
this.logoTexture =
|
||||
interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "logo.png"))!;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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<DalamudConfiguration>.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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose this window.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.logoTexture.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue