Skip to content

Commit

Permalink
Fix High-Res Screenshots tweak (Caraxi#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
DJ-Huntress authored Jul 22, 2024
1 parent f41992c commit 1b8044b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
1 change: 0 additions & 1 deletion SimpleTweaksPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<Compile Remove="Tweaks\FixedShadowDistance.cs"/>
<Compile Remove="Tweaks\FurnitureClocksCustomTime.cs"/>
<Compile Remove="Tweaks\GearsetSaveCurrent.cs"/>
<Compile Remove="Tweaks\HighResScreenshots.cs"/>
<Compile Remove="Tweaks\HouseLightCommand.cs"/>
<Compile Remove="Tweaks\JokeTweaks.cs"/>
<Compile Remove="Tweaks\KeyInterrupt.cs"/>
Expand Down
31 changes: 15 additions & 16 deletions Tweaks/HighResScreenshots.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Dalamud.Interface.Utility;
using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using SimpleTweaksPlugin.Debugging;
using SimpleTweaksPlugin.TweakSystem;
Expand All @@ -17,11 +17,10 @@
namespace SimpleTweaksPlugin.Tweaks;

[Changelog("1.9.7.1", "Re-added 'Use ReShade' option")]
[TweakName("Screenshot Improvements")]
[TweakDescription("Allows taking higher resolution screenshots, Hiding Dalamud & Game UIs and removing the copyright notice from screenshots.")]
[TweakAuthor("NotNite")]
public unsafe class HighResScreenshots : Tweak {
public override string Name => "Screenshot Improvements";
public override string Description => "Allows taking higher resolution screenshots, Hiding Dalamud & Game UIs and removing the copyright notice from screenshots.";
protected override string Author => "NotNite";

private nint copyrightShaderAddress;

public class Configs : TweakConfig {
Expand Down Expand Up @@ -53,7 +52,7 @@ public class Configs : TweakConfig {

private bool updatingReShadeKeybind = false;

protected override DrawConfigDelegate DrawConfigTree => (ref bool hasChanged) => {
protected void DrawConfig(ref bool hasChanged) {
ImGui.TextWrapped(
"This tweak will increase the resolution of screenshots taken in game. It will NOT increase the scale of your HUD/plugin windows.");
ImGui.TextWrapped("Your HUD will appear smaller while the screenshot is processing.");
Expand Down Expand Up @@ -145,9 +144,9 @@ public class Configs : TweakConfig {
ImGui.Unindent();
ImGui.Unindent();
}
};
}

public override void Setup() {
protected override void Setup() {
AddChangelogNewTweak("1.8.2.0");
AddChangelog("1.8.3.0", "Added option to hide dalamud UI for screenshot.");
AddChangelog("1.8.5.0", "Added option to hide game UI for screenshots.");
Expand All @@ -160,12 +159,12 @@ public override void Setup() {
protected override void Enable() {
Config = LoadConfig<Configs>() ?? new Configs();

if (!Service.SigScanner.TryScanText("49 8B 57 30 45 33 C9", out copyrightShaderAddress)) {
if (!Service.SigScanner.TryScanText("48 8B 57 ?? 45 33 C9 48 8B 06 45 33 C0 48 8B CE 48 8B 52 ?? FF 50 ?? 48 8B 06 4C 8D 4C 24", out copyrightShaderAddress)) {
copyrightShaderAddress = 0;
}

isInputIDClickedHook ??=
Common.Hook<IsInputIDClickedDelegate>("E9 ?? ?? ?? ?? 83 7F 44 02", IsInputIDClickedDetour);
Common.Hook<IsInputIDClickedDelegate>("E9 ?? ?? ?? ?? 83 7F ?? ?? 0F 8F ?? ?? ?? ?? BA ?? ?? ?? ?? 48 8B CB", IsInputIDClickedDetour);
isInputIDClickedHook?.Enable();

base.Enable();
Expand All @@ -176,7 +175,7 @@ protected override void Enable() {
private uint oldHeight;
private bool isRunning;

const int ScreenshotButton = 543;
const int ScreenshotButton = 546;
public bool originalUiVisibility;
byte[] originalCopyrightBytes = null;
// IsInputIDClicked is called from Client::UI::UIInputModule.CheckScreenshotState, which is polled
Expand Down Expand Up @@ -212,8 +211,8 @@ private byte IsInputIDClickedDetour(nint a1, int a2) {


if (Config.HideGameUi) {
var raptureAtkModule = Framework.Instance()->GetUiModule()->GetRaptureAtkModule();
originalUiVisibility = !raptureAtkModule->RaptureAtkUnitManager.Flags.HasFlag(RaptureAtkModuleFlags.UiHidden);
var raptureAtkModule = Framework.Instance()->GetUIModule()->GetRaptureAtkModule();
originalUiVisibility = !raptureAtkModule->RaptureAtkUnitManager.Flags.HasFlag(AtkUnitManagerFlags.UiHidden);
if (originalUiVisibility) {
raptureAtkModule->SetUiVisibility(false);
}
Expand All @@ -238,8 +237,8 @@ private byte IsInputIDClickedDetour(nint a1, int a2) {
Service.Framework.RunOnTick(() => {
UIDebug.FreeExclusiveDraw();
if (Config.HideGameUi) {
var raptureAtkModule = Framework.Instance()->GetUiModule()->GetRaptureAtkModule();
if (originalUiVisibility && raptureAtkModule->RaptureAtkUnitManager.Flags.HasFlag(RaptureAtkModuleFlags.UiHidden)) {
var raptureAtkModule = Framework.Instance()->GetUIModule()->GetRaptureAtkModule();
if (originalUiVisibility && raptureAtkModule->RaptureAtkUnitManager.Flags.HasFlag(AtkUnitManagerFlags.UiHidden)) {
raptureAtkModule->SetUiVisibility(true);
}
}
Expand Down

0 comments on commit 1b8044b

Please sign in to comment.