diff --git a/Dalamud/Fools/FoolsManager.cs b/Dalamud/Fools/FoolsManager.cs index 8297bead3..2d82b72b0 100644 --- a/Dalamud/Fools/FoolsManager.cs +++ b/Dalamud/Fools/FoolsManager.cs @@ -78,7 +78,8 @@ internal class FoolsManager : IDisposable, IServiceType new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo", typeof(PixelImperfectPlugin)), new("DailyLifeDuty", "DailyLifeDutyPlugin", "Easily Track Daily and Weekly tasks... in real life", "MidoriKami", typeof(DailyLifeDutyPlugin)), - new("Oops, Maybe Lalafells!", "OopsMaybeLalafellsPlugin", "Turn everyone into Lalafells? Maybe. We haven't quite tested it yet.", "Chrip", typeof(OopsMaybeLalafells)) + new("Oops, Maybe Lalafells!", "OopsMaybeLalafellsPlugin", "Turn everyone into Lalafells? Maybe. We haven't quite tested it yet.", "Chrip", typeof(OopsMaybeLalafells)), + new("Screensaver", "ScreensaverPlugin", "Prevent burn-in on loading screens.", "NotNite", typeof(ScreensaverPlugin)), }; } diff --git a/Dalamud/Fools/Plugins/ScreensaverPlugin.cs b/Dalamud/Fools/Plugins/ScreensaverPlugin.cs new file mode 100644 index 000000000..af1c1b858 --- /dev/null +++ b/Dalamud/Fools/Plugins/ScreensaverPlugin.cs @@ -0,0 +1,68 @@ +using System; +using System.IO; +using System.Numerics; +using Dalamud.Game.ClientState.Conditions; +using Dalamud.Interface; +using Dalamud.Interface.Internal; +using ImGuiNET; +using ImGuiScene; +using static ImGuiNET.ImGuiWindowFlags; + +namespace Dalamud.Fools.Plugins; + +public class ScreensaverPlugin : IFoolsPlugin +{ + private readonly TextureWrap logoTexture; + private readonly Condition condition; + + private int x; + private int y; + + private bool xDir = true; + private bool yDir = true; + + private double lastTime; + + public ScreensaverPlugin() + { + var interfaceManager = Service.Get(); + var dalamud = Service.Get(); + this.condition = Service.Get(); + + this.logoTexture = + interfaceManager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "logo.png"))!; + } + + public void DrawUi() + { + var time = Environment.TickCount64 / 1000.0; + var diff = time - this.lastTime; + diff = diff > 1 ? 1 : diff; + this.lastTime = time; + + if (!this.condition[ConditionFlag.BetweenAreas]) + { + return; + } + + var textureSize = new Vector2(100); + var maxSize = ImGui.GetMainViewport().Size - textureSize; + this.xDir = this.xDir ? this.x < maxSize.X : this.x > 0; + this.yDir = this.yDir ? this.y < maxSize.Y : this.y > 0; + + this.x += (int)(diff * (this.xDir ? 1 : -1) * 100); + this.y += (int)(diff * (this.yDir ? 1 : -1) * 100); + + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); + ImGuiHelpers.ForceNextWindowMainViewport(); + ImGuiHelpers.SetNextWindowPosRelativeMainViewport(new Vector2(this.x, this.y)); + ImGui.Begin("Screensaver", NoInputs | NoNav | NoTitleBar | NoScrollbar | NoBackground); + ImGui.SetWindowSize(textureSize); + ImGui.Image(this.logoTexture.ImGuiHandle, textureSize); + } + + public void Dispose() + { + this.logoTexture.Dispose(); + } +}