Skip to content

Commit 1bf64ac

Browse files
committed
fix for API 9
1 parent cae4ffc commit 1bf64ac

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

ZoomTilt/Plugin.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Dalamud.Game.Command;
1+
using Dalamud.Game.Command;
22
using Dalamud.IoC;
33
using Dalamud.Plugin;
44
using Dalamud.Interface.Windowing;
@@ -7,9 +7,10 @@
77
using System;
88
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
99
using ZoomTilt.Structures;
10-
using Dalamud.Game.Gui;
11-
using Dalamud.Logging;
1210
using Dalamud.Game.ClientState.Conditions;
11+
using Dalamud.Game.Config;
12+
using Dalamud.Plugin.Services;
13+
using FFXIVClientStructs.FFXIV.Client.System.Framework;
1314

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

25+
private MainWindow mainWindow { get; init; }
26+
2427
public class Dalamud {
2528
public static void Initialize(DalamudPluginInterface pluginInterface) =>
2629
pluginInterface.Create<Dalamud>();
@@ -30,23 +33,28 @@ public static void Initialize(DalamudPluginInterface pluginInterface) =>
3033
public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
3134
[PluginService]
3235
[RequiredVersion("1.0")]
33-
public static CommandManager CommandManager { get; private set; } = null!;
36+
public static ICommandManager CommandManager { get; private set; } = null!;
37+
38+
[PluginService]
39+
[RequiredVersion("1.0")]
40+
public static IFramework Framework { get; private set; } = null!;
3441

3542
[PluginService]
3643
[RequiredVersion("1.0")]
37-
public static Framework Framework { get; private set; } = null!;
44+
public static ISigScanner SigScanner { get; private set; } = null!;
3845

3946
[PluginService]
4047
[RequiredVersion("1.0")]
41-
public static SigScanner SigScanner { get; private set; } = null!;
48+
public static IChatGui Chat { get; private set; } = null!;
4249

4350
[PluginService]
4451
[RequiredVersion("1.0")]
45-
public static ChatGui Chat { get; private set; } = null!;
52+
public static ICondition Condition { get; private set; } = null!;
4653

4754
[PluginService]
4855
[RequiredVersion("1.0")]
49-
public static Condition Condition { get; private set; } = null!;
56+
public static IGameConfig GameConfig{ get; private set; } = null!;
57+
5058
}
5159

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

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

68-
windowSystem.AddWindow(new MainWindow(this));
75+
mainWindow = new MainWindow(this);
76+
windowSystem.AddWindow(mainWindow);
6977

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

100108
private float desiredTiltOffset;
101109
private float currentTiltOffset;
102-
public void Update(Framework framework) {
110+
public void Update(IFramework framework) {
103111
if (!Configuration.Enabled) return;
104112

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

133143
/* This didn't work
@@ -199,7 +209,7 @@ private void DrawUI() {
199209
}
200210

201211
public void DrawConfigUI() {
202-
windowSystem.GetWindow("ZoomTilt")!.IsOpen = true;
212+
mainWindow!.IsOpen = true;
203213
}
204214
}
205215
}

ZoomTilt/ZoomTilt.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Authors>Tenrys</Authors>
55
<Company></Company>
6-
<Version>1.0.0.0</Version>
6+
<Version>1.0.0.1</Version>
77
<Description>Change 3rd person camera angle depending on camera zoom.</Description>
88
<Copyright></Copyright>
99
<PackageProjectUrl>https://github.com/Tenrys/ZoomTilt</PackageProjectUrl>
@@ -25,27 +25,26 @@
2525
<DebugSymbols>false</DebugSymbols>
2626
</PropertyGroup>
2727

28-
<!--
28+
<!--
2929
<ItemGroup>
3030
<Content Include="..\Data\goat.png">
3131
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3232
<Visible>false</Visible>
3333
</Content>
34-
</ItemGroup>
34+
</ItemGroup>
3535
-->
3636

3737
<PropertyGroup>
3838
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
3939
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
4040
</PropertyGroup>
4141

42-
<PropertyGroup
43-
Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
42+
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
4443
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
4544
</PropertyGroup>
4645

4746
<ItemGroup>
48-
<PackageReference Include="DalamudPackager" Version="2.1.10" />
47+
<PackageReference Include="DalamudPackager" Version="2.1.12" />
4948
<Reference Include="FFXIVClientStructs">
5049
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
5150
<Private>false</Private>

ZoomTilt/packages.lock.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{
2-
"version": 1,
3-
"dependencies": {
4-
"net7.0-windows7.0": {
5-
"DalamudPackager": {
6-
"type": "Direct",
7-
"requested": "[2.1.10, )",
8-
"resolved": "2.1.10",
9-
"contentHash": "S6NrvvOnLgT4GDdgwuKVJjbFo+8ZEj+JsEYk9ojjOR/MMfv1dIFpT8aRJQfI24rtDcw1uF+GnSSMN4WW1yt7fw=="
10-
}
11-
}
12-
}
13-
}
1+
{
2+
"version": 1,
3+
"dependencies": {
4+
"net7.0-windows7.0": {
5+
"DalamudPackager": {
6+
"type": "Direct",
7+
"requested": "[2.1.12, )",
8+
"resolved": "2.1.12",
9+
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)