mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 12:44:16 +01:00
Merge pull request #465 from daemitus/clientState
This commit is contained in:
commit
2550b097bb
11 changed files with 1074 additions and 22 deletions
|
|
@ -1,14 +1,16 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using Dalamud.Game.ClientState.Actors;
|
using Dalamud.Game.ClientState.Actors;
|
||||||
using Dalamud.Game.ClientState.Actors.Types;
|
using Dalamud.Game.ClientState.Actors.Types;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Game.ClientState.Fates;
|
using Dalamud.Game.ClientState.Fates;
|
||||||
using Dalamud.Game.Internal;
|
using Dalamud.Game.ClientState.GamePad;
|
||||||
|
using Dalamud.Game.ClientState.Keys;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState
|
||||||
|
|
@ -93,7 +95,7 @@ namespace Dalamud.Game.ClientState
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that gets fired when a duty is ready.
|
/// Event that gets fired when a duty is ready.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<ContentFinderCondition> CfPop;
|
public event EventHandler<Lumina.Excel.GeneratedSheets.ContentFinderCondition> CfPop;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the table of all present actors.
|
/// Gets the table of all present actors.
|
||||||
|
|
@ -194,7 +196,7 @@ namespace Dalamud.Game.ClientState
|
||||||
return this.setupTerritoryTypeHook.Original(manager, terriType);
|
return this.setupTerritoryTypeHook.Original(manager, terriType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NetworkHandlersOnCfPop(object sender, ContentFinderCondition e)
|
private void NetworkHandlersOnCfPop(object sender, Lumina.Excel.GeneratedSheets.ContentFinderCondition e)
|
||||||
{
|
{
|
||||||
this.CfPop?.Invoke(this, e);
|
this.CfPop?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState.Conditions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides access to conditions (generally player state). You can check whether a player is in combat, mounted, etc.
|
/// Provides access to conditions (generally player state). You can check whether a player is in combat, mounted, etc.
|
||||||
|
|
@ -37,7 +37,7 @@ namespace Dalamud.Game.ClientState
|
||||||
{
|
{
|
||||||
var idx = (int)flag;
|
var idx = (int)flag;
|
||||||
|
|
||||||
if (idx > MaxConditionEntries || idx < 0)
|
if (idx < 0 || idx >= MaxConditionEntries)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return *(bool*)(this.ConditionArrayBase + idx);
|
return *(bool*)(this.ConditionArrayBase + idx);
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState.Conditions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Possible state flags (or conditions as they're called internally) that can be set on the local client.
|
/// Possible state flags (or conditions as they're called internally) that can be set on the local client.
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState.GamePad
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bitmask of the Button ushort used by the game.
|
/// Bitmask of the Button ushort used by the game.
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState.Structs
|
namespace Dalamud.Game.ClientState.GamePad
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Struct which gets populated by polling the gamepads.
|
/// Struct which gets populated by polling the gamepads.
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using Dalamud.Game.ClientState.Structs;
|
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState.GamePad
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exposes the game gamepad state to dalamud.
|
/// Exposes the game gamepad state to dalamud.
|
||||||
|
|
@ -24,7 +23,7 @@ namespace Dalamud.Game.ClientState
|
||||||
private int rightStickY;
|
private int rightStickY;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GamepadState" /> class.
|
/// Initializes a new instance of the <see cref="GamepadState" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="resolver">Resolver knowing the pointer to the GamepadPoll function.</param>
|
/// <param name="resolver">Resolver knowing the pointer to the GamepadPoll function.</param>
|
||||||
public GamepadState(ClientStateAddressResolver resolver)
|
public GamepadState(ClientStateAddressResolver resolver)
|
||||||
|
|
@ -43,12 +42,10 @@ namespace Dalamud.Game.ClientState
|
||||||
|
|
||||||
private delegate int ControllerPoll(IntPtr controllerInput);
|
private delegate int ControllerPoll(IntPtr controllerInput);
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the pointer to the current instance of the GamepadInput struct.
|
/// Gets the pointer to the current instance of the GamepadInput struct.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IntPtr GamepadInput { get; private set; }
|
public IntPtr GamepadInputAddress { get; private set; }
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the state of the left analogue stick in the left direction between 0 (not tilted) and 1 (max tilt).
|
/// Gets the state of the left analogue stick in the left direction between 0 (not tilted) and 1 (max tilt).
|
||||||
|
|
@ -189,9 +186,7 @@ namespace Dalamud.Game.ClientState
|
||||||
var original = this.gamepadPoll.Original(gamepadInput);
|
var original = this.gamepadPoll.Original(gamepadInput);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if DEBUG
|
this.GamepadInputAddress = gamepadInput;
|
||||||
this.GamepadInput = gamepadInput;
|
|
||||||
#endif
|
|
||||||
var input = (GamepadInput*)gamepadInput;
|
var input = (GamepadInput*)gamepadInput;
|
||||||
this.leftStickX = input->LeftStickX;
|
this.leftStickX = input->LeftStickX;
|
||||||
this.leftStickY = input->LeftStickY;
|
this.leftStickY = input->LeftStickY;
|
||||||
|
|
@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState.Keys
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper around the game keystate buffer, which contains the pressed state for all keyboard keys, indexed by virtual vkCode.
|
/// Wrapper around the game keystate buffer, which contains the pressed state for all keyboard keys, indexed by virtual vkCode.
|
||||||
|
|
@ -52,6 +52,13 @@ namespace Dalamud.Game.ClientState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get or set the keypressed state for a given VirtualKey enum.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vk">The virtual key to change.</param>
|
||||||
|
/// <returns>Whether the specified key is currently pressed.</returns>
|
||||||
|
public bool this[VirtualKey vk] => this[(int)vk];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears the pressed state for all keys.
|
/// Clears the pressed state for all keys.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
1044
Dalamud/Game/ClientState/Keys/VirtualKey.cs
Normal file
1044
Dalamud/Game/ClientState/Keys/VirtualKey.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -8,6 +8,7 @@ using System.Threading;
|
||||||
|
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
|
using Dalamud.Game.ClientState.GamePad;
|
||||||
using Dalamud.Game.Internal.DXGI;
|
using Dalamud.Game.Internal.DXGI;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.Hooking.Internal;
|
using Dalamud.Hooking.Internal;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Game.ClientState.Actors.Types;
|
using Dalamud.Game.ClientState.Actors.Types;
|
||||||
using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
|
using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
|
using Dalamud.Game.ClientState.GamePad;
|
||||||
using Dalamud.Game.ClientState.Structs.JobGauge;
|
using Dalamud.Game.ClientState.Structs.JobGauge;
|
||||||
using Dalamud.Game.Gui.Addons;
|
using Dalamud.Game.Gui.Addons;
|
||||||
using Dalamud.Game.Gui.Toast;
|
using Dalamud.Game.Gui.Toast;
|
||||||
|
|
@ -758,13 +760,13 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
$"R3 {resolve(GamepadButtons.R3)} ");
|
$"R3 {resolve(GamepadButtons.R3)} ");
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
ImGui.Text($"GamepadInput 0x{this.dalamud.ClientState.GamepadState.GamepadInput.ToInt64():X}");
|
ImGui.Text($"GamepadInput 0x{this.dalamud.ClientState.GamepadState.GamepadInputAddress.ToInt64():X}");
|
||||||
|
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||||
|
|
||||||
if (ImGui.IsItemClicked())
|
if (ImGui.IsItemClicked())
|
||||||
ImGui.SetClipboardText($"0x{this.dalamud.ClientState.GamepadState.GamepadInput.ToInt64():X}");
|
ImGui.SetClipboardText($"0x{this.dalamud.ClientState.GamepadState.GamepadInputAddress.ToInt64():X}");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DrawHelper(
|
DrawHelper(
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Interface.Internal;
|
using Dalamud.Interface.Internal;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using ImGuiScene;
|
using ImGuiScene;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue