mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
Add Screensaver plugin
This commit is contained in:
parent
29da285091
commit
6cfb205bb8
2 changed files with 70 additions and 1 deletions
|
|
@ -78,7 +78,8 @@ internal class FoolsManager : IDisposable, IServiceType
|
||||||
new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo",
|
new("Pixel Imperfect", "PixelImperfectPlugin", "Whoops... we messed up the math on that one.", "Halpo",
|
||||||
typeof(PixelImperfectPlugin)),
|
typeof(PixelImperfectPlugin)),
|
||||||
new("DailyLifeDuty", "DailyLifeDutyPlugin", "Easily Track Daily and Weekly tasks... in real life", "MidoriKami", typeof(DailyLifeDutyPlugin)),
|
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)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
68
Dalamud/Fools/Plugins/ScreensaverPlugin.cs
Normal file
68
Dalamud/Fools/Plugins/ScreensaverPlugin.cs
Normal file
|
|
@ -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<InterfaceManager>.Get();
|
||||||
|
var dalamud = Service<Dalamud>.Get();
|
||||||
|
this.condition = Service<Condition>.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue