Skip to content

Commit

Permalink
Properly access ConfigPos and ConfigSize for each window.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurochi51 committed Jun 20, 2024
1 parent 7e30eeb commit 6ee2605
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
10 changes: 1 addition & 9 deletions TickTracker/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,19 @@ public bool WindowCondition(WindowType window)
/// <summary>
/// Saves the size and position for the indicated <paramref name="window"/>.
/// </summary>
public bool UpdateWindowConfig(Vector2 currentPos, Vector2 currentSize, WindowType window)
public void UpdateWindowConfig(Vector2 currentPos, Vector2 currentSize, WindowType window)
{
var configChanged = false;
if (window is WindowType.HpWindow)
{
if (!currentPos.Equals(config.HPBarPosition))
{
config.HPBarPosition = currentPos;
config.Save(pluginInterface);
configChanged = true;
}
if (!currentSize.Equals(config.HPBarSize))
{
config.HPBarSize = currentSize;
config.Save(pluginInterface);
configChanged = true;
}
}
if (window is WindowType.MpWindow)
Expand All @@ -119,13 +116,11 @@ public bool UpdateWindowConfig(Vector2 currentPos, Vector2 currentSize, WindowTy
{
config.MPBarPosition = currentPos;
config.Save(pluginInterface);
configChanged = true;
}
if (!currentSize.Equals(config.MPBarSize))
{
config.MPBarSize = currentSize;
config.Save(pluginInterface);
configChanged = true;
}
}
if (window is WindowType.GpWindow)
Expand All @@ -134,16 +129,13 @@ public bool UpdateWindowConfig(Vector2 currentPos, Vector2 currentSize, WindowTy
{
config.GPBarPosition = currentPos;
config.Save(pluginInterface);
configChanged = true;
}
if (!currentSize.Equals(config.GPBarSize))
{
config.GPBarSize = currentSize;
config.Save(pluginInterface);
configChanged = true;
}
}
return configChanged;
}

/// <summary>
Expand Down
10 changes: 3 additions & 7 deletions TickTracker/Windows/BarWindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public abstract class BarWindowBase : Window
public double PreviousProgress { get; set; }
public Vector2 WindowPosition { get; protected set; }
public Vector2 WindowSize { get; protected set; }
protected Vector2 ConfigPos { get; set; }
protected Vector2 ConfigSize { get; set; }
protected abstract Vector2 ConfigPos { get; }
protected abstract Vector2 ConfigSize { get; }

private const FontAwesomeIcon RegenIcon = FontAwesomeIcon.Forward;
private const FontAwesomeIcon FastIcon = FontAwesomeIcon.FastForward;
Expand Down Expand Up @@ -159,11 +159,7 @@ protected void UpdateWindow()
}
if (IsFocused)
{
if (utilities.UpdateWindowConfig(windowPos, windowSize, WindowType))
{
ConfigSize = windowSize;
ConfigPos = windowPos;
}
utilities.UpdateWindowConfig(windowPos, windowSize, WindowType);
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions TickTracker/Windows/GPBar.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
using ImGuiNET;
using System.Numerics;

using Dalamud.Plugin.Services;
using TickTracker.Enums;
using TickTracker.Helpers;
using TickTracker.Enums;

namespace TickTracker.Windows;

public class GPBar : BarWindowBase
{
private readonly Configuration config;
protected override Vector2 ConfigSize => config.GPBarSize;
protected override Vector2 ConfigPos => config.GPBarPosition;

public GPBar(IClientState _clientState, IPluginLog _pluginLog, Utilities _utilities, Configuration _config) : base(_clientState, _pluginLog, _utilities, _config, WindowType.GpWindow, "GPBarWindow")
{
config = _config;
Size = ConfigSize = config.GPBarSize;
Position = ConfigPos = config.GPBarPosition;
Size = config.GPBarSize;
Position = config.GPBarPosition;
}

public override void Draw()
Expand Down
12 changes: 8 additions & 4 deletions TickTracker/Windows/HPBar.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
using ImGuiNET;
using System.Numerics;

using Dalamud.Plugin.Services;
using TickTracker.Enums;
using TickTracker.Helpers;
using TickTracker.Enums;

namespace TickTracker.Windows;

public class HPBar : BarWindowBase
{
private readonly Configuration config;
protected override Vector2 ConfigSize => config.HPBarSize;
protected override Vector2 ConfigPos => config.HPBarPosition;

public HPBar(IClientState _clientState, IPluginLog _pluginLog, Utilities _utilities, Configuration _config) : base(_clientState, _pluginLog, _utilities, _config, WindowType.HpWindow, "HPBarWindow")
{
config = _config;
Size = ConfigSize = config.HPBarSize;
Position = ConfigPos = config.HPBarPosition;
Size = config.HPBarSize;
Position = config.HPBarPosition;
}

public override void Draw()
Expand Down
12 changes: 8 additions & 4 deletions TickTracker/Windows/MPBar.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
using ImGuiNET;
using System.Numerics;

using Dalamud.Plugin.Services;
using TickTracker.Enums;
using TickTracker.Helpers;
using TickTracker.Enums;

namespace TickTracker.Windows;

public class MPBar : BarWindowBase
{
private readonly Configuration config;
protected override Vector2 ConfigSize => config.MPBarSize;
protected override Vector2 ConfigPos => config.MPBarPosition;

public MPBar(IClientState _clientState, IPluginLog _pluginLog, Utilities _utilities, Configuration _config) : base(_clientState, _pluginLog, _utilities, _config, WindowType.MpWindow, "MPBarWindow")
{
config = _config;
Size = ConfigSize = config.MPBarSize;
Position = ConfigPos = config.MPBarPosition;
Size = config.MPBarSize;
Position = config.MPBarPosition;
}

public override void Draw()
Expand Down

0 comments on commit 6ee2605

Please sign in to comment.