Skip to content

Commit

Permalink
Merge pull request #5 from FFXIV-CombatReborn/Dev-IcWa
Browse files Browse the repository at this point in the history
IcWa - Fixed nullable warnings, added height settings modified UI to be a little cleaner and added scale parameter to UI to avoid errors on little percentage UI
  • Loading branch information
IncognitoWater authored Jul 4, 2024
2 parents 22b1520 + 5b92d95 commit c94c1a1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Configuration : IPluginConfiguration
[JsonIgnore] public static readonly float ZoomMaxDefault = 20f;
[JsonIgnore] public static readonly float AngleMinDefault = -1.483529806f;
[JsonIgnore] public static readonly float AngleMaxDefault = 0.7853981853f;
[JsonIgnore] public static readonly float HeightCamPositionDefault = 0.0f;

public int Version { get; set; }

Expand All @@ -28,6 +29,8 @@ public class Configuration : IPluginConfiguration
public float ZoomMin = ZoomMinDefault;
public float ZoomMax = ZoomMaxDefault;

public float HeightCamPosition = HeightCamPositionDefault;


// Add any other properties or methods here.
[JsonIgnore] private IDalamudPluginInterface _pluginInterface;
Expand Down
10 changes: 10 additions & 0 deletions EasyZoomRebornPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ ITextureProvider textureProvider
Marshal.StructureToPtr(10000f, MaxFloat, true);
PiFloat = Marshal.AllocHGlobal(4);
Marshal.StructureToPtr((float)Math.PI, PiFloat, true);
MinFloatHeight = Marshal.AllocHGlobal(4);
Marshal.StructureToPtr(-3f, MinFloatHeight, true);
MaxFloatHeight = Marshal.AllocHGlobal(4);
Marshal.StructureToPtr(3f, MaxFloatHeight, true);

Configuration = (Configuration)pluginInterface.GetPluginConfig() ?? new Configuration();
Configuration.Initialize(pluginInterface);
Expand Down Expand Up @@ -151,10 +155,14 @@ private void ClientState_OnLogin()
public static IntPtr AngleMin => (IntPtr)(&Cam->minVRotation);
public static IntPtr AngleMax => (IntPtr)(&Cam->maxVRotation);

public static IntPtr HeightCamPosition => (IntPtr)(&Cam->lookAtHeightOffset);


public static IntPtr ZeroFloat;
public static IntPtr PiFloat;
public static IntPtr MaxFloat;
public static IntPtr MinFloatHeight;
public static IntPtr MaxFloatHeight;

internal static void SetCamDistanceNoReset(bool on)
{
Expand Down Expand Up @@ -218,6 +226,8 @@ protected virtual void Dispose(bool disposing)
Marshal.FreeHGlobal(ZeroFloat);
Marshal.FreeHGlobal(MaxFloat);
Marshal.FreeHGlobal(PiFloat);
Marshal.FreeHGlobal(MinFloatHeight);
Marshal.FreeHGlobal(MaxFloatHeight);
_getZoomDeltaHook?.Dispose();

}
Expand Down
31 changes: 27 additions & 4 deletions SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ public override void Draw()
{
if (Utils.TryGetTextureWrap(imageUrl, out var texture))
{
ImGui.Image(texture.ImGuiHandle, new(texture.Width/4, texture.Height/4));
// Calculate padding for ImGui image
Vector2 windowSize = ImGui.GetContentRegionAvail();
Vector2 imageSize = new(texture.Width / 3 * _scale, texture.Height / 3 * _scale);
Vector2 padding = (windowSize - imageSize) * 0.5f;
ImGui.Dummy(new Vector2(0, padding.Y - 20.0f));
ImGui.SameLine(padding.X);
ImGui.Image(texture.ImGuiHandle, imageSize);
}

if (ImGui.Button("Support on Ko-fi", new Vector2(104 * _scale, 24 * _scale)))

// Center the ImGui button
Vector2 buttonSize = new Vector2(104 * _scale, 24 * _scale);
float buttonPosX = (ImGui.GetContentRegionAvail().X - buttonSize.X) * 0.5f;
ImGui.SetCursorPosX(buttonPosX);

if (ImGui.Button("Support on Ko-fi", buttonSize))
{
OpenUrl("https://ko-fi.com/incognitowater");
}
Expand Down Expand Up @@ -115,6 +126,18 @@ public void DrawGeneralTab()
EasyZoomRebornPlugin.Configuration.ZoomMax = Marshal.PtrToStructure<float>(ZoomMax);
EasyZoomRebornPlugin.Configuration.Save();
}

if (ImGui.DragScalar("Camera Height", ImGuiDataType.Float, HeightCamPosition, 0.05f, MinFloatHeight, MaxFloatHeight, Marshal.PtrToStructure<float>(HeightCamPosition).ToString(), ImGuiSliderFlags.Logarithmic))
{
EasyZoomRebornPlugin.Configuration.HeightCamPosition = Marshal.PtrToStructure<float>(HeightCamPosition);
EasyZoomRebornPlugin.Configuration.Save();
}
if (ImGui.IsItemHovered() && ImGui.IsMouseDown(ImGuiMouseButton.Right))
{
Marshal.StructureToPtr(HeightCamPositionDefault, HeightCamPosition, true);
EasyZoomRebornPlugin.Configuration.HeightCamPosition = Marshal.PtrToStructure<float>(HeightCamPosition);
EasyZoomRebornPlugin.Configuration.Save();
}
ImGui.Spacing();
}

Expand Down Expand Up @@ -154,7 +177,7 @@ public static void OpenUrl(string url)
public SettingsWindow(string name) : base(name)
{
Flags = ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollWithMouse;
Size = new Vector2(400, 250);
Size = new Vector2(400 * _scale, 300 *_scale);
}
}
}
3 changes: 2 additions & 1 deletion Utils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Interface.Textures.TextureWraps;
#nullable enable
using Dalamud.Interface.Textures.TextureWraps;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down

0 comments on commit c94c1a1

Please sign in to comment.