mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-28 19:39:19 +01:00
Merge #277
This commit is contained in:
commit
5baf0b6d8b
7 changed files with 73 additions and 37 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
<OutputPath></OutputPath>
|
<OutputPath></OutputPath>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>Portable</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<DocumentationFile>$(SolutionDir)\bin\Dalamud.xml</DocumentationFile>
|
<DocumentationFile>$(SolutionDir)\bin\Dalamud.xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="Feature">
|
<PropertyGroup Label="Feature">
|
||||||
|
|
@ -30,6 +30,9 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Resources\Lumina.Generated.dll" />
|
<None Remove="Resources\Lumina.Generated.dll" />
|
||||||
<None Remove="stylecop.json" />
|
<None Remove="stylecop.json" />
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Dalamud.Game.Internal.DXGI
|
||||||
// This(code after the function head - offset of it) was picked to avoid running into issues with other hooks being installed into this function.
|
// This(code after the function head - offset of it) was picked to avoid running into issues with other hooks being installed into this function.
|
||||||
Present = scanner.ScanModule("41 8B F0 8B FA 89 54 24 ?? 48 8B D9 48 89 4D ?? C6 44 24 ?? 00") - 0x37;
|
Present = scanner.ScanModule("41 8B F0 8B FA 89 54 24 ?? 48 8B D9 48 89 4D ?? C6 44 24 ?? 00") - 0x37;
|
||||||
|
|
||||||
ResizeBuffers = scanner.ScanModule("45 8B CC 45 8B C5 33 D2 48 8B CF E8 ?? ?? ?? ?? 44 8B C0 48 8D 55 ?? 48 8D 4D ?? E8 ?? ?? ?? ?? 38 9F E8 02 00 00") - 0xA9;
|
ResizeBuffers = scanner.ScanModule("48 8B C4 55 41 54 41 55 41 56 41 57 48 8D 68 B1 48 81 EC ?? ?? ?? ?? 48 C7 45 ?? ?? ?? ?? ?? 48 89 58 10 48 89 70 18 48 89 78 20 45 8B F9 45 8B E0 44 8B EA 48 8B F9 8B 45 7F 89 44 24 30 8B 75 77 89 74 24 28 44 89 4C 24");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Dalamud.Game.Chat.SeStringHandling.Payloads;
|
using Dalamud.Game.Chat.SeStringHandling.Payloads;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
|
using ImGuiNET;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using SharpDX;
|
using SharpDX;
|
||||||
|
|
||||||
|
|
@ -289,6 +290,8 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
// Read current ViewProjectionMatrix plus game window size
|
// Read current ViewProjectionMatrix plus game window size
|
||||||
var viewProjectionMatrix = new Matrix();
|
var viewProjectionMatrix = new Matrix();
|
||||||
float width, height;
|
float width, height;
|
||||||
|
var windowPos = ImGui.GetMainViewport().Pos;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
var rawMatrix = (float*) (matrixSingleton + 0x1b4).ToPointer();
|
var rawMatrix = (float*) (matrixSingleton + 0x1b4).ToPointer();
|
||||||
|
|
||||||
|
|
@ -303,10 +306,12 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
|
|
||||||
screenPos = new Vector2(pCoords.X / pCoords.Z, pCoords.Y / pCoords.Z);
|
screenPos = new Vector2(pCoords.X / pCoords.Z, pCoords.Y / pCoords.Z);
|
||||||
|
|
||||||
screenPos.X = 0.5f * width * (screenPos.X + 1f);
|
screenPos.X = 0.5f * width * (screenPos.X + 1f) + windowPos.X;
|
||||||
screenPos.Y = 0.5f * height * (1f - screenPos.Y);
|
screenPos.Y = 0.5f * height * (1f - screenPos.Y) + windowPos.Y;
|
||||||
|
|
||||||
return pCoords.Z > 0;
|
return pCoords.Z > 0 &&
|
||||||
|
screenPos.X > windowPos.X && screenPos.X < windowPos.X + width &&
|
||||||
|
screenPos.Y > windowPos.Y && screenPos.Y < windowPos.Y + height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -318,6 +323,18 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
/// <returns>True if successful. On false, worldPos's contents are undefined</returns>
|
/// <returns>True if successful. On false, worldPos's contents are undefined</returns>
|
||||||
public bool ScreenToWorld(Vector2 screenPos, out Vector3 worldPos, float rayDistance = 100000.0f)
|
public bool ScreenToWorld(Vector2 screenPos, out Vector3 worldPos, float rayDistance = 100000.0f)
|
||||||
{
|
{
|
||||||
|
// The game is only visible in the main viewport, so if the cursor is outside
|
||||||
|
// of the game window, do not bother calculating anything
|
||||||
|
var windowPos = ImGui.GetMainViewport().Pos;
|
||||||
|
var windowSize = ImGui.GetMainViewport().Size;
|
||||||
|
|
||||||
|
if (screenPos.X < windowPos.X || screenPos.X > windowPos.X + windowSize.X ||
|
||||||
|
screenPos.Y < windowPos.Y || screenPos.Y > windowPos.Y + windowSize.Y)
|
||||||
|
{
|
||||||
|
worldPos = new Vector3();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get base object with matrices
|
// Get base object with matrices
|
||||||
var matrixSingleton = this.getMatrixSingleton();
|
var matrixSingleton = this.getMatrixSingleton();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ namespace Dalamud.Interface
|
||||||
// AT
|
// AT
|
||||||
case 2:
|
case 2:
|
||||||
this.DrawActorTable();
|
this.DrawActorTable();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
|
|
@ -289,20 +290,15 @@ namespace Dalamud.Interface
|
||||||
return isOpen;
|
return isOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawActorTable()
|
private void DrawActorTable() {
|
||||||
{
|
|
||||||
var stateString = string.Empty;
|
var stateString = string.Empty;
|
||||||
|
|
||||||
// LocalPlayer is null in a number of situations (at least with the current visible-actors list)
|
// LocalPlayer is null in a number of situations (at least with the current visible-actors list)
|
||||||
// which would crash here.
|
// which would crash here.
|
||||||
if (this.dalamud.ClientState.Actors.Length == 0)
|
if (this.dalamud.ClientState.Actors.Length == 0)
|
||||||
{
|
|
||||||
ImGui.TextUnformatted("Data not ready.");
|
ImGui.TextUnformatted("Data not ready.");
|
||||||
}
|
|
||||||
else if (this.dalamud.ClientState.LocalPlayer == null)
|
else if (this.dalamud.ClientState.LocalPlayer == null)
|
||||||
{
|
|
||||||
ImGui.TextUnformatted("LocalPlayer null.");
|
ImGui.TextUnformatted("LocalPlayer null.");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stateString +=
|
stateString +=
|
||||||
|
|
@ -324,40 +320,53 @@ namespace Dalamud.Interface
|
||||||
ImGui.Checkbox("Draw actors on screen", ref this.drawActors);
|
ImGui.Checkbox("Draw actors on screen", ref this.drawActors);
|
||||||
ImGui.SliderFloat("Draw Distance", ref this.maxActorDrawDistance, 2f, 40f);
|
ImGui.SliderFloat("Draw Distance", ref this.maxActorDrawDistance, 2f, 40f);
|
||||||
|
|
||||||
for (var i = 0; i < this.dalamud.ClientState.Actors.Length; i++)
|
for (var i = 0; i < this.dalamud.ClientState.Actors.Length; i++) {
|
||||||
{
|
|
||||||
var actor = this.dalamud.ClientState.Actors[i];
|
var actor = this.dalamud.ClientState.Actors[i];
|
||||||
|
|
||||||
if (actor == null)
|
if (actor == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
this.PrintActor(actor, i.ToString());
|
PrintActor(actor, i.ToString());
|
||||||
|
|
||||||
if (this.drawActors &&
|
if (this.drawActors &&
|
||||||
this.dalamud.Framework.Gui.WorldToScreen(actor.Position, out var screenCoords))
|
this.dalamud.Framework.Gui.WorldToScreen(actor.Position, out var screenCoords)) {
|
||||||
{
|
// So, while WorldToScreen will return false if the point is off of game client screen, to
|
||||||
ImGui.PushID("ActorWindow" + i);
|
// to avoid performance issues, we have to manually determine if creating a window would
|
||||||
ImGui.SetNextWindowPos(new Vector2(screenCoords.X, screenCoords.Y));
|
// produce a new viewport, and skip rendering it if so
|
||||||
|
var actorText =
|
||||||
|
$"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name}";
|
||||||
|
|
||||||
|
var screenPos = ImGui.GetMainViewport().Pos;
|
||||||
|
var screenSize = ImGui.GetMainViewport().Size;
|
||||||
|
|
||||||
|
var windowSize = ImGui.CalcTextSize(actorText);
|
||||||
|
|
||||||
|
// Add some extra safety padding
|
||||||
|
windowSize.X += ImGui.GetStyle().WindowPadding.X + 10;
|
||||||
|
windowSize.Y += ImGui.GetStyle().WindowPadding.Y + 10;
|
||||||
|
|
||||||
|
if (screenCoords.X + windowSize.X > screenPos.X + screenSize.X ||
|
||||||
|
screenCoords.Y + windowSize.Y > screenPos.Y + screenSize.Y)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (actor.YalmDistanceX > this.maxActorDrawDistance)
|
if (actor.YalmDistanceX > this.maxActorDrawDistance)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ImGui.SetNextWindowBgAlpha(
|
ImGui.SetNextWindowPos(new Vector2(screenCoords.X, screenCoords.Y));
|
||||||
Math.Max(1f - (actor.YalmDistanceX / this.maxActorDrawDistance), 0.2f));
|
|
||||||
if (ImGui.Begin(
|
|
||||||
"Actor" + i,
|
|
||||||
ImGuiWindowFlags.NoDecoration |
|
|
||||||
ImGuiWindowFlags.AlwaysAutoResize |
|
|
||||||
ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoMove |
|
|
||||||
ImGuiWindowFlags.NoMouseInputs |
|
|
||||||
ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav))
|
|
||||||
{
|
|
||||||
ImGui.Text(
|
|
||||||
$"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name}");
|
|
||||||
ImGui.End();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.PopID();
|
ImGui.SetNextWindowBgAlpha(Math.Max(1f - actor.YalmDistanceX / this.maxActorDrawDistance,
|
||||||
|
0.2f));
|
||||||
|
if (ImGui.Begin($"Actor{i}##ActorWindow{i}",
|
||||||
|
ImGuiWindowFlags.NoDecoration |
|
||||||
|
ImGuiWindowFlags.AlwaysAutoResize |
|
||||||
|
ImGuiWindowFlags.NoSavedSettings |
|
||||||
|
ImGuiWindowFlags.NoMove |
|
||||||
|
ImGuiWindowFlags.NoMouseInputs |
|
||||||
|
ImGuiWindowFlags.NoDocking |
|
||||||
|
ImGuiWindowFlags.NoFocusOnAppearing |
|
||||||
|
ImGuiWindowFlags.NoNav))
|
||||||
|
ImGui.Text(actorText);
|
||||||
|
ImGui.End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ namespace Dalamud.Interface
|
||||||
ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Vector4(0, 0, 0, 1));
|
ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Vector4(0, 0, 0, 1));
|
||||||
ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 1));
|
ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 1));
|
||||||
|
|
||||||
ImGui.SetNextWindowPos(new Vector2(0, 0), ImGuiCond.Always);
|
var mainViewportPos = ImGui.GetMainViewport().Pos;
|
||||||
|
ImGui.SetNextWindowPos(new Vector2(mainViewportPos.X, mainViewportPos.Y), ImGuiCond.Always);
|
||||||
ImGui.SetNextWindowBgAlpha(1);
|
ImGui.SetNextWindowBgAlpha(1);
|
||||||
|
|
||||||
if (ImGui.Begin("DevMenu Opener", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoSavedSettings))
|
if (ImGui.Begin("DevMenu Opener", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoSavedSettings))
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ namespace Dalamud.Interface
|
||||||
// So... not great, but much better than constantly crashing on unload
|
// So... not great, but much better than constantly crashing on unload
|
||||||
this.Disable();
|
this.Disable();
|
||||||
System.Threading.Thread.Sleep(500);
|
System.Threading.Thread.Sleep(500);
|
||||||
|
|
||||||
this.scene?.Dispose();
|
this.scene?.Dispose();
|
||||||
this.presentHook.Dispose();
|
this.presentHook.Dispose();
|
||||||
this.resizeBuffersHook.Dispose();
|
this.resizeBuffersHook.Dispose();
|
||||||
|
|
@ -228,6 +228,7 @@ namespace Dalamud.Interface
|
||||||
private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags)
|
private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags)
|
||||||
{
|
{
|
||||||
if (this.scene == null) {
|
if (this.scene == null) {
|
||||||
|
|
||||||
this.scene = new RawDX11Scene(swapChain);
|
this.scene = new RawDX11Scene(swapChain);
|
||||||
|
|
||||||
this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(this.dalamud.StartInfo.ConfigurationPath), "dalamudUI.ini");
|
this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(this.dalamud.StartInfo.ConfigurationPath), "dalamudUI.ini");
|
||||||
|
|
@ -357,7 +358,12 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
private IntPtr ResizeBuffersDetour(IntPtr swapChain, uint bufferCount, uint width, uint height, uint newFormat, uint swapChainFlags)
|
private IntPtr ResizeBuffersDetour(IntPtr swapChain, uint bufferCount, uint width, uint height, uint newFormat, uint swapChainFlags)
|
||||||
{
|
{
|
||||||
Log.Verbose($"Calling resizebuffers {bufferCount} {width} {height} {newFormat} {swapChainFlags}");
|
Log.Verbose($"Calling resizebuffers swap@{swapChain.ToInt64():X}{bufferCount} {width} {height} {newFormat} {swapChainFlags}");
|
||||||
|
|
||||||
|
// We have to ensure we're working with the main swapchain,
|
||||||
|
// as viewports might be resizing as well
|
||||||
|
if (swapChain != this.scene.SwapChain.NativePointer)
|
||||||
|
return resizeBuffersHook.Original(swapChain, bufferCount, width, height, newFormat, swapChainFlags);
|
||||||
|
|
||||||
this.scene?.OnPreResize();
|
this.scene?.OnPreResize();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit a1b3dc2c5645001ebf93c3cb3294f02defc319b6
|
Subproject commit b3c22cae545f293e06d03037e30c83d5b9a77dd2
|
||||||
Loading…
Add table
Add a link
Reference in a new issue