feat: add option to disable native screenshots
This commit is contained in:
parent
c2001fca1c
commit
12996e5ea3
|
@ -28,6 +28,7 @@ public class Configuration : IPluginConfiguration {
|
|||
""";
|
||||
|
||||
public GamepadButtons GamepadKeybind = GamepadButtons.L1 | GamepadButtons.Start;
|
||||
public bool DisableNativeScreenshots = true;
|
||||
|
||||
private int _templateHashCode;
|
||||
private Template? _template;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
using Dalamud.Hooking;
|
||||
using Dalamud.Utility.Signatures;
|
||||
|
||||
namespace Screenie;
|
||||
|
||||
internal unsafe class GameFunctions : IDisposable {
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
private delegate byte TakeScreenshotDelegate(nint a1, nint a2, nint a3);
|
||||
|
||||
[Signature("E8 ?? ?? ?? ?? 84 C0 75 22 F3 0F 10 05", DetourName = nameof(TakeScreenshotDetour))]
|
||||
private Hook<TakeScreenshotDelegate> _takeScreenshotHook;
|
||||
|
||||
internal GameFunctions(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
|
||||
|
||||
this._takeScreenshotHook!.Enable();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this._takeScreenshotHook.Dispose();
|
||||
}
|
||||
|
||||
private byte TakeScreenshotDetour(nint a1, nint a2, nint a3) {
|
||||
if (this.Plugin.Config.DisableNativeScreenshots) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this._takeScreenshotHook.Original(a1, a2, a3);
|
||||
}
|
||||
}
|
|
@ -43,6 +43,9 @@ public sealed class Plugin : IDalamudPlugin {
|
|||
[PluginService]
|
||||
internal IGameGui GameGui { get; init; }
|
||||
|
||||
[PluginService]
|
||||
internal IGameInteropProvider GameInteropProvider { get; init; }
|
||||
|
||||
[PluginService]
|
||||
internal IGamepadState GamepadState { get; init; }
|
||||
|
||||
|
@ -50,6 +53,7 @@ public sealed class Plugin : IDalamudPlugin {
|
|||
internal IObjectTable ObjectTable { get; init; }
|
||||
|
||||
internal Configuration Config { get; }
|
||||
internal GameFunctions GameFunctions { get; }
|
||||
internal PenumbraIpc Penumbra { get; }
|
||||
internal Database Database { get; }
|
||||
internal LinkHandlers LinkHandlers { get; }
|
||||
|
@ -60,6 +64,7 @@ public sealed class Plugin : IDalamudPlugin {
|
|||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public Plugin() {
|
||||
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
this.GameFunctions = new GameFunctions(this);
|
||||
this.Penumbra = new PenumbraIpc(this);
|
||||
this.Database = new Database(this);
|
||||
this.LinkHandlers = new LinkHandlers(this);
|
||||
|
@ -79,6 +84,7 @@ public sealed class Plugin : IDalamudPlugin {
|
|||
this.LinkHandlers.Dispose();
|
||||
this.Database.Dispose();
|
||||
// this.Penumbra.Dispose();
|
||||
this.GameFunctions.Dispose();
|
||||
}
|
||||
|
||||
internal void SaveConfig() {
|
||||
|
|
|
@ -124,6 +124,8 @@ internal class SettingsTab : ITab {
|
|||
}
|
||||
}
|
||||
|
||||
anyChanged |= ImGui.Checkbox("Disable vanilla in-game screenshots", ref this.Plugin.Config.DisableNativeScreenshots);
|
||||
|
||||
if (anyChanged) {
|
||||
this.Plugin.SaveConfig();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue