Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 22, 2024
1 parent a2f6bc8 commit c3577a2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 54 deletions.
20 changes: 12 additions & 8 deletions ActionTimelineEx/Configurations/RotationSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,25 @@ public class RotationSetting
return GCDs[Math.Max(0, index)];
}

public void Draw()
public void Draw(float heightReduce)
{
var gcdHeight = Plugin.Settings.GCDIconSize;
var spacing = Plugin.Settings.IconSpacing;
var drawList = ImGui.GetWindowDrawList();
var drawList = ImGui.GetBackgroundDrawList();

var pos = ImGui.GetWindowPos() + new Vector2(gcdHeight * 0.2f,
var wholeHeight = ImGui.GetWindowPos().Y - heightReduce;
var windowPos = ImGui.GetWindowPos() + Vector2.UnitY * heightReduce;

var pos = windowPos + new Vector2(gcdHeight * 0.2f,
Plugin.Settings.VerticalDraw
? (Plugin.Settings.Reverse
? ImGui.GetWindowSize().Y - gcdHeight * 1.4f
? wholeHeight - gcdHeight * 1.4f
: gcdHeight * 0.2f)
: ImGui.GetWindowSize().Y / 2 - gcdHeight / 2);
var maxX = ImGui.GetWindowPos().X + ImGui.GetWindowSize().X;
var minY = ImGui.GetWindowPos().Y;
var maxY = minY + ImGui.GetWindowSize().Y;
: wholeHeight / 2 - gcdHeight / 2);

var maxX = windowPos.X + ImGui.GetWindowSize().X;
var minY = windowPos.Y;
var maxY = minY + wholeHeight;
var minPosX = pos.X;

var nextAction = RotationHelper.ActiveAction;
Expand Down
2 changes: 1 addition & 1 deletion ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public float GcdTime
}


[JsonProperty()]
[JsonProperty]
private Dictionary<Job, RotationsSetting> _rotationHelpers = [];

[JsonIgnore]
Expand Down
49 changes: 14 additions & 35 deletions ActionTimelineEx/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,29 @@ internal static class RotationHelper

internal static readonly List<ActionSetting> SuccessActions = [];

private static int _index;
public static int GcdUsedCount
{
get => _index;
private set
{
if (_index == value) return;
_index = value;
public static int GcdUsedCount { get; private set; }
public static byte oGcdUsedCount { get; private set; }

UpdateHighlight();
}
}

private static byte _subIndex = 0;
public static byte oGcdUsedCount
public static void Init()
{
get => _subIndex;
private set
{
if (_subIndex == value) return;
_subIndex = value;

UpdateHighlight();
}
ActionEffect.ActionEffectEvent += ActionFromSelf;
Svc.DutyState.DutyWiped += DutyState_DutyWiped;
Svc.DutyState.DutyCompleted += DutyState_DutyWiped;
Svc.ClientState.TerritoryChanged += ClientState_TerritoryChanged;
ClientState_TerritoryChanged(Svc.ClientState.TerritoryType);
_highLight = new();
Svc.Framework.Update += Framework_Update;
}

private static void UpdateHighlight()
private static void Framework_Update(Dalamud.Plugin.Services.IFramework framework)
{
if (!Plugin.Settings.DrawRotation) return;

if (_highLight == null) return;
_highLight.Color = Plugin.Settings.RotationHighlightColor;
_highLight.HotbarIDs.Clear();

if (!Plugin.Settings.DrawRotation) return;

var action = ActiveAction;
if (action == null) return;
HotbarID? hotBar = null;
Expand Down Expand Up @@ -83,23 +72,13 @@ private static void UpdateHighlight()
_highLight.HotbarIDs.Add(hotBar.Value);
}

public static void Init()
{
ActionEffect.ActionEffectEvent += ActionFromSelf;
Svc.DutyState.DutyWiped += DutyState_DutyWiped;
Svc.DutyState.DutyCompleted += DutyState_DutyWiped;
Svc.ClientState.TerritoryChanged += ClientState_TerritoryChanged;
ClientState_TerritoryChanged(Svc.ClientState.TerritoryType);
_highLight = new();
UpdateHighlight();
}

public static void Dispose()
{
ActionEffect.ActionEffectEvent -= ActionFromSelf;
Svc.DutyState.DutyWiped -= DutyState_DutyWiped;
Svc.DutyState.DutyCompleted -= DutyState_DutyWiped;
Svc.ClientState.TerritoryChanged -= ClientState_TerritoryChanged;
Svc.Framework.Update -= Framework_Update;
}

private static void ClientState_TerritoryChanged(ushort obj)
Expand Down
10 changes: 7 additions & 3 deletions ActionTimelineEx/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ public void Dispose()

public static void PluginCommand(string str)
{
if (str == "reset")
switch(str)
{
RotationHelper.Clear();
return;
case "reset":
RotationHelper.Clear();
return;
case "toggle":
RotationHelperWindow._open = !RotationHelperWindow._open;
return;
}
_settingsWindow.Toggle();
}
Expand Down
12 changes: 5 additions & 7 deletions ActionTimelineEx/Windows/RotationHelperWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace ActionTimelineEx.Windows;
internal static class RotationHelperWindow
{
private static Vector2 _size = default;
private static bool _open = true, _changed = false;
internal static bool _open = true;
private static bool _changed = false;
public static void Draw()
{
var setting = Plugin.Settings;
Expand Down Expand Up @@ -61,6 +62,8 @@ public static void Draw()
}
}

var heightReduce = ImGui.GetCursorPosY();

if (_open)
{
ImGui.SameLine();
Expand All @@ -82,7 +85,7 @@ public static void Draw()
ImGui.GetStyle().WindowBorderSize = 0;
try
{
DrawContent();
RotationHelper.RotationSetting.Draw(heightReduce);
}
finally
{
Expand All @@ -93,9 +96,4 @@ public static void Draw()
}
}
}

private static void DrawContent()
{
RotationHelper.RotationSetting.Draw();
}
}

0 comments on commit c3577a2

Please sign in to comment.