forked from meoiswa/MagitekStratagem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6fba6ce
Showing
15 changed files
with
659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.vs/ | ||
obj/ | ||
bin/ | ||
|
||
# Tobii dont sue me pls. | ||
**/lib/tobii*.dll | ||
|
||
*.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"workspaceKeybindings.buildOnSave.enabled": true // setting can be anything you want | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "shell", | ||
"args": [ | ||
"build", | ||
// Ask dotnet build to generate full paths for file names. | ||
"/property:GenerateFullPaths=true", | ||
// Do not generate summary otherwise it leads to duplicate errors in Problems panel | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"group": "build", | ||
"presentation": { | ||
"reveal": "silent" | ||
}, | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Tobii Plugin for Dalamud | ||
|
||
Experimental Tobii integration for FFXIV | ||
|
||
You will need to supply your own, as licensing won't allow me to distribute: | ||
- lib/tobii_gameintegration_x64.dll | ||
- lib/tobii_gameintegration_x86.dll | ||
- lib/Tobii.GameIntegration.Net.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29709.97 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tobii", "Tobii\Tobii.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Release|x64 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.ActiveCfg = Debug|x64 | ||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|x64 | ||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|x64 | ||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|x64 | ||
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.ActiveCfg = Debug|x64 | ||
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.Build.0 = Debug|x64 | ||
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.ActiveCfg = Release|x64 | ||
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.Build.0 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Dalamud.Game; | ||
using Dalamud.Game.ClientState; | ||
using Dalamud.Game.ClientState.Conditions; | ||
using Dalamud.Game.ClientState.Objects; | ||
using Dalamud.Game.Gui; | ||
using Dalamud.IoC; | ||
using Dalamud.Plugin; | ||
|
||
namespace TobiiPlugin | ||
{ | ||
public class Service | ||
{ | ||
#pragma warning disable CS8618 | ||
[PluginService] public static Condition Condition { get; private set; } | ||
[PluginService] public static Framework Framework { get; private set; } | ||
[PluginService] public static ChatGui ChatGui { get; private set; } | ||
[PluginService] public static ObjectTable ObjectTable { get; private set; } | ||
[PluginService] public static ClientState ClientState { get; private set; } | ||
[PluginService] public static GameGui GameGui { get; private set; } | ||
[PluginService] public static TargetManager TargetManager { get; private set; } | ||
#pragma warning restore CS8618 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Authors>Meoiswa</Authors> | ||
<Company></Company> | ||
<Version>3.1.0.0</Version> | ||
<Description>Automatic Camera Adjustements</Description> | ||
<Copyright></Copyright> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0-windows</TargetFramework> | ||
<Platforms>x64</Platforms> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="images\icon.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Tobii.GameIntegration.Net"> | ||
<HintPath>lib\Tobii.GameIntegration.Net.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="lib\tobii_gameintegration_x64.dll" Link="%(Filename)%(Extension)"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="lib\tobii_gameintegration_x86.dll" Link="%(Filename)%(Extension)"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="DalamudPackager" Version="2.1.10" /> | ||
<Reference Include="FFXIVClientStructs"> | ||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json"> | ||
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="Dalamud"> | ||
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="ImGui.NET"> | ||
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
<Reference Include="ImGuiScene"> | ||
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath> | ||
<Private>false</Private> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Author": "Meoiswa", | ||
"Name": "Tobii", | ||
"Punchline": "Look at me!", | ||
"Description": "Tobii integration for FFXIV", | ||
"InternalName": "Tobii", | ||
"ApplicableVersion": "any", | ||
"Tags": [ | ||
"UI" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
using System; | ||
using System.IO; | ||
using Dalamud.Game; | ||
using Dalamud.Game.ClientState.Conditions; | ||
using Dalamud.Game.ClientState.Objects; | ||
using Dalamud.Game.Command; | ||
using Dalamud.Game.Gui; | ||
using Dalamud.Interface; | ||
using Dalamud.Interface.Windowing; | ||
using Dalamud.IoC; | ||
using Dalamud.Logging; | ||
using Dalamud.Plugin; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using Dalamud.Game.ClientState.Objects.Types; | ||
|
||
using GameObjectStruct = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject; | ||
using CameraManager = FFXIVClientStructs.FFXIV.Client.Graphics.Scene.CameraManager; | ||
using System.Numerics; | ||
using ImGuiNET; | ||
|
||
namespace TobiiPlugin | ||
{ | ||
public sealed class TobiiPlugin : IDalamudPlugin | ||
{ | ||
public string Name => "Tobii"; | ||
|
||
private const string commandName = "/tobii"; | ||
|
||
public DalamudPluginInterface PluginInterface { get; init; } | ||
public CommandManager CommandManager { get; init; } | ||
public ChatGui ChatGui { get; init; } | ||
public Configuration Configuration { get; init; } | ||
public WindowSystem WindowSystem { get; init; } | ||
public Condition Condition { get; init; } | ||
public ObjectTable ObjectTable { get; init; } | ||
|
||
public TobiiUI Window { get; init; } | ||
public TobiiService TobiiService { get; init; } | ||
public GameObject? ClosestMatch { get; private set; } | ||
|
||
public TobiiPlugin( | ||
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, | ||
[RequiredVersion("1.0")] CommandManager commandManager, | ||
[RequiredVersion("1.0")] ChatGui chatGui) | ||
{ | ||
pluginInterface.Create<Service>(); | ||
|
||
PluginInterface = pluginInterface; | ||
CommandManager = commandManager; | ||
ChatGui = chatGui; | ||
WindowSystem = new("TobiiPlugin"); | ||
|
||
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); | ||
Configuration.Initialize(this); | ||
|
||
Condition = Service.Condition; | ||
ObjectTable = Service.ObjectTable; | ||
|
||
Window = new TobiiUI(this) | ||
{ | ||
IsOpen = Configuration.IsVisible | ||
}; | ||
|
||
WindowSystem.AddWindow(Window); | ||
|
||
CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) | ||
{ | ||
HelpMessage = "opens the configuration window" | ||
}); | ||
|
||
TobiiService = new TobiiService(); | ||
|
||
Service.Framework.Update += OnUpdate; | ||
PluginInterface.UiBuilder.Draw += DrawUI; | ||
PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
TobiiService.Shutdown(); | ||
|
||
Service.Framework.Update -= OnUpdate; | ||
PluginInterface.UiBuilder.Draw -= DrawUI; | ||
PluginInterface.UiBuilder.OpenConfigUi -= DrawConfigUI; | ||
|
||
WindowSystem.RemoveAllWindows(); | ||
|
||
CommandManager.RemoveHandler(commandName); | ||
} | ||
|
||
public void SaveConfiguration() | ||
{ | ||
var configJson = JsonConvert.SerializeObject(Configuration, Formatting.Indented); | ||
File.WriteAllText(PluginInterface.ConfigFile.FullName, configJson); | ||
} | ||
|
||
private void SetVisible(bool isVisible) | ||
{ | ||
Configuration.IsVisible = isVisible; | ||
Configuration.Save(); | ||
|
||
Window.IsOpen = Configuration.IsVisible; | ||
} | ||
|
||
private void OnCommand(string command, string args) | ||
{ | ||
SetVisible(!Configuration.IsVisible); | ||
} | ||
|
||
private void DrawUI() | ||
{ | ||
WindowSystem.Draw(); | ||
} | ||
|
||
private void DrawConfigUI() | ||
{ | ||
SetVisible(!Configuration.IsVisible); | ||
} | ||
|
||
public void OnUpdate(Framework framework) | ||
{ | ||
var player = Service.ClientState.LocalPlayer; | ||
var position = player?.Position ?? new Vector3(); | ||
|
||
if (Configuration.Enabled && Condition.Any() && player != null && TobiiService.IsTracking) | ||
{ | ||
TobiiService.Update(); | ||
|
||
unsafe | ||
{ | ||
var size = ImGui.GetIO().DisplaySize; | ||
Vector2 gazeScreenPos = new Vector2( | ||
TobiiService.LastGazeX * (size.X / 2) + (size.X / 2), | ||
-TobiiService.LastGazeY * (size.Y / 2) + (size.Y / 2)); | ||
|
||
if (Service.GameGui.ScreenToWorld(gazeScreenPos, out Vector3 worldPos)) | ||
{ | ||
var closestDistance = float.MaxValue; | ||
|
||
foreach (var actor in ObjectTable) | ||
{ | ||
if (actor == null) | ||
{ | ||
continue; | ||
} | ||
var gos = (GameObjectStruct*)actor.Address; | ||
if (gos->GetIsTargetable() && actor != player) | ||
{ | ||
var distance = FFXIVClientStructs.FFXIV.Common.Math.Vector3.Distance(worldPos, actor.Position); | ||
if (ClosestMatch == null) | ||
{ | ||
ClosestMatch = actor; | ||
closestDistance = distance; | ||
continue; | ||
} | ||
|
||
if (closestDistance > distance) | ||
{ | ||
ClosestMatch = actor; | ||
closestDistance = distance; | ||
} | ||
} | ||
} | ||
|
||
Service.TargetManager.Target = ClosestMatch; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.