Skip to content

Commit

Permalink
fix for API 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenrys committed Oct 4, 2023
1 parent cae4ffc commit 1bf64ac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
36 changes: 23 additions & 13 deletions ZoomTilt/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dalamud.Game.Command;
using Dalamud.Game.Command;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Interface.Windowing;
Expand All @@ -7,9 +7,10 @@
using System;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using ZoomTilt.Structures;
using Dalamud.Game.Gui;
using Dalamud.Logging;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.Config;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.System.Framework;

namespace ZoomTilt {
public sealed unsafe class Plugin : IDalamudPlugin {
Expand All @@ -21,6 +22,8 @@ public sealed unsafe class Plugin : IDalamudPlugin {
private ConfigModule* configModule { get; init; }
private CameraManager* cameraManager { get; init; }

private MainWindow mainWindow { get; init; }

public class Dalamud {
public static void Initialize(DalamudPluginInterface pluginInterface) =>
pluginInterface.Create<Dalamud>();
Expand All @@ -30,23 +33,28 @@ public static void Initialize(DalamudPluginInterface pluginInterface) =>
public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService]
[RequiredVersion("1.0")]
public static CommandManager CommandManager { get; private set; } = null!;
public static ICommandManager CommandManager { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static IFramework Framework { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static Framework Framework { get; private set; } = null!;
public static ISigScanner SigScanner { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static SigScanner SigScanner { get; private set; } = null!;
public static IChatGui Chat { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static ChatGui Chat { get; private set; } = null!;
public static ICondition Condition { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static Condition Condition { get; private set; } = null!;
public static IGameConfig GameConfig{ get; private set; } = null!;

}

public Plugin(DalamudPluginInterface pluginInterface
Expand All @@ -55,7 +63,6 @@ public Plugin(DalamudPluginInterface pluginInterface
// this.pluginInterface = pluginInterface;
// this.commandManager = commandManager;
// this.framework = framework;
this.configModule = ConfigModule.Instance();
this.cameraManager = (CameraManager*)Dalamud.SigScanner.GetStaticAddressFromSig("4C 8D 35 ?? ?? ?? ?? 85 D2"); // g_ControlSystem_CameraManager

Configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
Expand All @@ -65,7 +72,8 @@ public Plugin(DalamudPluginInterface pluginInterface
// var imagePath = Path.Combine(pluginInterface.AssemblyLocation.Directory?.FullName!, "goat.png");
// var goatImage = pluginInterface.UiBuilder.LoadImage(imagePath);

windowSystem.AddWindow(new MainWindow(this));
mainWindow = new MainWindow(this);
windowSystem.AddWindow(mainWindow);

Dalamud.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand) {
HelpMessage = "A useful message to display in /xlhelp"
Expand Down Expand Up @@ -99,7 +107,7 @@ public static double Lerp(double delta, double from, double to) {

private float desiredTiltOffset;
private float currentTiltOffset;
public void Update(Framework framework) {
public void Update(IFramework framework) {
if (!Configuration.Enabled) return;

var currentZoom = cameraManager->WorldCamera->CurrentZoom;
Expand Down Expand Up @@ -127,7 +135,9 @@ public void Update(Framework framework) {
framework.UpdateDelta.TotalMilliseconds / 100f,
currentTiltOffset, desiredTiltOffset
);
configModule->SetOption(ConfigOption.TiltOffset, (int)Math.Round(currentTiltOffset));
// [15:33]Cara: its a float with a valid range of -0.08 to 0.21
var actualTiltOffset = (currentTiltOffset / 100 * (0.21 - (-0.08))) + (-0.08);
Dalamud.GameConfig.Set(UiControlOption.TiltOffset, (float)actualTiltOffset);
}

/* This didn't work
Expand Down Expand Up @@ -199,7 +209,7 @@ private void DrawUI() {
}

public void DrawConfigUI() {
windowSystem.GetWindow("ZoomTilt")!.IsOpen = true;
mainWindow!.IsOpen = true;
}
}
}
11 changes: 5 additions & 6 deletions ZoomTilt/ZoomTilt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors>Tenrys</Authors>
<Company></Company>
<Version>1.0.0.0</Version>
<Version>1.0.0.1</Version>
<Description>Change 3rd person camera angle depending on camera zoom.</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Tenrys/ZoomTilt</PackageProjectUrl>
Expand All @@ -25,27 +25,26 @@
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<!--
<!--
<ItemGroup>
<Content Include="..\Data\goat.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
</ItemGroup>
</ItemGroup>
-->

<PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup
Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
Expand Down
26 changes: 13 additions & 13 deletions ZoomTilt/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.10, )",
"resolved": "2.1.10",
"contentHash": "S6NrvvOnLgT4GDdgwuKVJjbFo+8ZEj+JsEYk9ojjOR/MMfv1dIFpT8aRJQfI24rtDcw1uF+GnSSMN4WW1yt7fw=="
}
}
}
}
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
}
}
}
}

0 comments on commit 1bf64ac

Please sign in to comment.