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

Commit

Permalink
fix: changed the way to saving the rotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 18, 2024
1 parent 047ccca commit e0c52dc
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 46 deletions.
19 changes: 9 additions & 10 deletions ActionTimelineEx/Configurations/Actions/ActionSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,23 @@ public bool IsMatched(uint id, ActionSettingType type)

public void DrawIcon(ImDrawListPtr drawList, Vector2 point, float size, bool passed, ActionSetting? activeAction)
{
IconType iconType = passed ? IconType.Blacked
: Highlight ? IconType.Highlight : IconType.Normal;
drawList.DrawActionIcon(IconId, Type is ActionSettingType.Item, point, size, iconType);
if (!string.IsNullOrEmpty(DisplayName) && DrawHelper.IsInRect(point, new Vector2(size)))
ImGui.SetTooltip(DisplayName);
if (passed)
{
if (!RotationHelper.SuccessActions.Contains(this))
{
ImGuiHelper.DrawSlotHighlight(drawList, point, size, ImGui.ColorConvertFloat4ToU32(Plugin.Settings.RotationFailedColor));
}
}
else

IconType iconType = passed ? IconType.Blacked
: Highlight ? IconType.Highlight : IconType.Normal;
drawList.DrawActionIcon(IconId, Type is ActionSettingType.Item, point, size, iconType);
if (!string.IsNullOrEmpty(DisplayName) && DrawHelper.IsInRect(point, new Vector2(size)))
ImGui.SetTooltip(DisplayName);

if (!passed && activeAction == this)
{
if (activeAction == this)
{
ImGuiHelper.DrawSlotHighlight(drawList, point, size, ImGui.ColorConvertFloat4ToU32(Plugin.Settings.RotationHighlightColor));
}
ImGuiHelper.DrawSlotHighlight(drawList, point, size, ImGui.ColorConvertFloat4ToU32(Plugin.Settings.RotationHighlightColor));
}
}
}
19 changes: 16 additions & 3 deletions ActionTimelineEx/Configurations/Actions/ActionSettingAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ public override void OnClick(object obj)
base.OnClick(obj);
if (obj is not ActionSetting setting) return;

ImGui.OpenPopup(setting.GetHashCode().ToString());
}

public override void OnTick(object obj)
{
base.OnTick(obj);

if (obj is not ActionSetting setting) return;

switch (setting.Type)
{
case ActionSettingType.Action:
ActionSelectorPopup(setting, setting.GetHashCode().ToString());
ActionSelectorPopup(setting, setting.GetHashCode().ToString(), setting is GCDAction);
break;

case ActionSettingType.Item:
Expand Down Expand Up @@ -56,6 +65,7 @@ private static void ItemSelectorPopup(ActionSetting setting, string popUpId)

var actions = Svc.Data.GetExcelSheet<Item>()?.Where(i =>
{
if(i.ItemSearchCategory.Row != 43) return false;
unsafe
{
if (InventoryManager.Instance()->GetInventoryItemCount(i.RowId, true) > 0) return true;
Expand Down Expand Up @@ -94,12 +104,13 @@ private static void ItemSelectorPopup(ActionSetting setting, string popUpId)
}
}
}
private static void ActionSelectorPopup(ActionSetting setting, string popUpId)
private static void ActionSelectorPopup(ActionSetting setting, string popUpId, bool isGcd)
{
using var popUp = ImRaii.Popup(popUpId);
if (!popUp.Success) return;

var actions = Svc.Data.GetExcelSheet<Action>()?.Where(ActionHelper.IsInJob);
var actions = Svc.Data.GetExcelSheet<Action>()?.Where(a => a.IsInJob() && !a.IsPvP && a.IsGcd() == isGcd);

if (actions == null || !actions.Any()) return;

_group.ClearCollapsingHeader();
Expand Down Expand Up @@ -137,6 +148,8 @@ private static void ActionSelectorPopup(ActionSetting setting, string popUpId)
}
});
}

_group.Draw();
}
}

2 changes: 1 addition & 1 deletion ActionTimelineEx/Configurations/Actions/GCDAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public float Draw(ImDrawListPtr drawList, Vector2 point, bool pass, ActionSettin
int index = 0;
foreach (var oGcd in oGCDs)
{
oGcd.DrawIcon(drawList, point, ogcd, index < RotationHelper.SubIndex, activeAction);
oGcd.DrawIcon(drawList, point, ogcd, pass && index < RotationHelper.oGcdUsedCount, activeAction);
if (!oGcd.IsEmpty) index++;

point += new Vector2(ogcd + spacing, 0);
Expand Down
3 changes: 1 addition & 2 deletions ActionTimelineEx/Configurations/Actions/oGCDAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public class oGCDAction : ActionSetting
private ActionSettingType _type = ActionSettingType.Action;

[UI("Type")]

internal ActionSettingType ActionType
public ActionSettingType ActionType
{
get => _type;
set
Expand Down
21 changes: 13 additions & 8 deletions ActionTimelineEx/Configurations/RotationSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using ImGuiNET;
using System.Numerics;
using XIVConfigUI.Attributes;
using static FFXIVClientStructs.FFXIV.Client.UI.AddonAOZNotebook;

namespace ActionTimelineEx.Configurations;
public class RotationSetting
Expand All @@ -19,14 +18,20 @@ public class RotationSetting

public ActionSetting? GetNextAction(int index, byte subIndex)
{
if (index >= GCDs.Count) return null;
var thisIndex = index - 1;
if (thisIndex >= GCDs.Count) return null;

var thisGcd = GCDs[Math.Max(0, thisIndex)];

var gcd = GCDs[index];
if (gcd == null) return null;
if (thisGcd == null) return null;
if (index == 0) return thisGcd;

if (subIndex == 0) return gcd;
var result = thisGcd.oGCDs.Where(i => !i.IsEmpty).Skip(subIndex).FirstOrDefault();

return gcd.oGCDs.Where(i => !i.IsEmpty).Skip(subIndex - 1).FirstOrDefault();
if (result != null) return result;

if (index >= GCDs.Count) return null;
return GCDs[index];
}

public void Draw()
Expand All @@ -50,7 +55,7 @@ public void Draw()

for (var i = 0; i < GCDs.Count; i++)
{
if (i < RotationHelper.Index - 1) continue;
if (i < RotationHelper.GcdUsedCount - 1) continue;

var item = GCDs[i];

Expand All @@ -68,7 +73,7 @@ public void Draw()
}
}

var width = item.Draw(drawList, pos, i < RotationHelper.Index, nextAction);
var width = item.Draw(drawList, pos, i < RotationHelper.GcdUsedCount, nextAction);

pos += new Vector2(width + spacing, 0);

Expand Down
2 changes: 1 addition & 1 deletion ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Settings : IPluginConfiguration
public Vector4 RotationUnlockedBackgroundColor { get; set; } = new(0f, 0f, 0f, 0.75f);

[UI("Rotation Highlight Color", Parent = nameof(DrawRotation))]
public Vector4 RotationHighlightColor { get; set; } = new Vector4(0.8f, 0.9f, 1, 1);
public Vector4 RotationHighlightColor { get; set; } = new Vector4(1f, 1f, 0.8f, 1);

[UI("Rotation Failed Color", Parent = nameof(DrawRotation))]
public Vector4 RotationFailedColor { get; set; } = new Vector4(0.8f, 0.5f, 0.5f, 1);
Expand Down
39 changes: 20 additions & 19 deletions ActionTimelineEx/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ namespace ActionTimelineEx.Helpers;
internal static class RotationHelper
{
private static DrawingHighlightHotbar? _highLight;
public static ActionSetting? ActiveAction => RotationSetting.GetNextAction(Index, SubIndex);
public static ActionSetting? ActiveAction => RotationSetting.GetNextAction(GcdUsedCount, oGcdUsedCount);

public static RotationSetting RotationSetting => Plugin.Settings.RotationHelper.RotationSetting;

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

private static int _count;
public static int Index
private static int _index;
public static int GcdUsedCount
{
get => _count;
get => _index;
private set
{
if (_count == value) return;
_count = value;
if (_index == value) return;
_index = value;

UpdateHighlight();
}
}

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

UpdateHighlight();
}
Expand Down Expand Up @@ -136,15 +136,16 @@ private static void ActionFromSelf(ActionEffectSet set)
ActionSetting? nextAction;
if (IsGcd(set))
{
nextAction = SubIndex == 0 ? RotationSetting.GetNextAction(Index, 0)
: RotationSetting.GetNextAction(Index + 1, 0);
SubIndex = 0;
Index++;
nextAction = oGcdUsedCount == 0 ? RotationSetting.GetNextAction(GcdUsedCount, 0)
: RotationSetting.GetNextAction(GcdUsedCount + 1, 0);

oGcdUsedCount = 0;
GcdUsedCount++;
}
else
{
nextAction = RotationSetting.GetNextAction(Index, SubIndex);
SubIndex++;
nextAction = RotationSetting.GetNextAction(GcdUsedCount, oGcdUsedCount);
oGcdUsedCount++;
}

if (nextAction == null) return;
Expand Down Expand Up @@ -220,8 +221,8 @@ private static bool IsGcd(in ActionEffectSet set)

public static void Clear()
{
Index = 0;
SubIndex = 0;
GcdUsedCount = 0;
oGcdUsedCount = 0;
SuccessActions.Clear();
}
}
27 changes: 26 additions & 1 deletion ActionTimelineEx/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,30 @@
"ActionTimelineEx.Configurations.ActionSettingType.Item": "Item",
"ActionTimelineEx.Configurations.ActionSettingName.IsLast": "Is the Last Ability during GCD",
"ActionTimelineEx.Configurations.ActionSettingDescription": "Heavy Swing (GCD)",
"ActionTimelineEx.Configurations.SettingsName.Reverse": "Reverse Draw"
"ActionTimelineEx.Configurations.SettingsName.Reverse": "Reverse Draw",
"ActionTimelineEx.Configurations.SettingsName.OnlyShowRotationWhenWeaponOn": "Only Show when Weapon On",
"ActionTimelineEx.Configurations.SettingsName.RotationFailedColor": "Rotation Failed Color",
"ActionTimelineEx.Configurations.SettingsName.IgnoreItems": "Ignore Items",
"ActionTimelineEx.Configurations.SettingsName.IgnoreSystemActions": "Ignore System Actions",
"ActionTimelineEx.Configurations.SettingsName.IgnoreRoleActions": "Ignore Role Actions",
"ActionTimelineEx.Configurations.SettingsName.IgnoreLimitBreaks": "Ignore Limit Breaks",
"ActionTimelineEx.Configurations.SettingsName.IgnoreDutyActions": "Ignore Duty Actions",
"ActionTimelineEx.Configurations.RotationSettingName.GCDs": "GCDs",
"ActionTimelineEx.Configurations.Actions.GCDAction": "GCD",
"ActionTimelineEx.Configurations.Actions.ActionSettingName.Highlight": "Is this Action Highlight",
"ActionTimelineEx.Configurations.Actions.GCDActionName.oGCDs": "oGCDs",
"ActionTimelineEx.Configurations.Actions.oGCDAction": "oGCD",
"ActionTimelineEx.Helpers.ActionType.GCD": "GCD",
"ActionTimelineEx.Helpers.ActionType.oGCD": "oGCD",
"ActionTimelineEx.Helpers.ActionType.RoleAction": "RoleAction",
"ActionTimelineEx.Helpers.ActionType.SystemAction": "SystemAction",
"ActionTimelineEx.Helpers.ActionType.LimitBreak": "LimitBreak",
"ActionTimelineEx.Helpers.ActionType.DutyAction": "DutyAction",
"ActionTimelineEx.Configurations.Actions.GCDActionDescription": "Inner Chaos (GCD)",
"ActionTimelineEx.Configurations.Actions.oGCDActionName.ActionType": "Type",
"ActionTimelineEx.Configurations.Actions.ActionSettingType.Action": "Action",
"ActionTimelineEx.Configurations.Actions.ActionSettingType.Item": "Item",
"ActionTimelineEx.Configurations.Actions.oGCDActionDescription": "Infuriate (oGCD)",
"ActionTimelineEx.Configurations.Actions.ActionSetting": "ActionSetting",
"ActionTimelineEx.Configurations.Actions.ActionSettingDescription": "Heavy Swing (GCD)"
}

0 comments on commit e0c52dc

Please sign in to comment.