66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using Dalamud.Game.Command;
|
|
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
|
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
|
|
|
namespace Screenie;
|
|
|
|
internal class Command : IDisposable {
|
|
private Plugin Plugin { get; }
|
|
private const string CommandName = "/screenie";
|
|
|
|
internal Command(Plugin plugin) {
|
|
this.Plugin = plugin;
|
|
|
|
this.Plugin.CommandManager.AddHandler(CommandName, new CommandInfo(this.OnCommand));
|
|
}
|
|
|
|
public void Dispose() {
|
|
this.Plugin.CommandManager.RemoveHandler(CommandName);
|
|
}
|
|
|
|
private static unsafe void SetUiVisibility(bool wantVisible) {
|
|
var atkModule = Framework.Instance()->GetUiModule()->GetRaptureAtkModule();
|
|
var hidden = atkModule->RaptureAtkUnitManager.Flags.HasFlag(RaptureAtkModuleFlags.UiHidden);
|
|
if (wantVisible && hidden) {
|
|
atkModule->SetUiVisibility(true);
|
|
}
|
|
|
|
if (!wantVisible && !hidden) {
|
|
atkModule->SetUiVisibility(false);
|
|
}
|
|
}
|
|
|
|
private void OnCommand(string command, string arguments) {
|
|
// TODO: eventually be able to do like /screenie --no-ui --format png
|
|
// etc.
|
|
if (arguments == "config") {
|
|
this.Plugin.Ui.Visible ^= true;
|
|
return;
|
|
}
|
|
|
|
unsafe {
|
|
var device = Device.Instance();
|
|
var oldWidth = device->Width;
|
|
var oldHeight = device->Height;
|
|
|
|
device->NewWidth = 3840;
|
|
device->NewHeight = 2160;
|
|
device->RequestResolutionChange = 1;
|
|
|
|
SetUiVisibility(false);
|
|
|
|
this.Plugin.Framework.RunOnTick(() => {
|
|
this.Plugin.SaveScreenshot();
|
|
|
|
this.Plugin.Framework.RunOnTick(() => {
|
|
SetUiVisibility(true);
|
|
device->NewWidth = oldWidth;
|
|
device->NewHeight = oldHeight;
|
|
device->RequestResolutionChange = 1;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|