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 19, 2024
1 parent be19002 commit d2bfb15
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 36 deletions.
17 changes: 17 additions & 0 deletions ActionTimelineEx/Configurations/Actions/ActionSettingAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using System;
using System.Numerics;
using XIVConfigUI;
using XIVConfigUI.Attributes;
Expand All @@ -13,6 +14,22 @@
namespace ActionTimelineEx.Configurations.Actions;
internal class ActionSettingAttribute() : ListUIAttribute(0)
{
private TimeSpan _time = TimeSpan.Zero;
public override string DrawIndex(object obj, int index)
{
if (obj is not GCDAction setting) return string.Empty;

if (index == 0) _time = TimeSpan.Zero;

var result = $"{(int)_time.TotalMinutes}:{_time.Seconds:D2}.{_time.Milliseconds.ToString()[0]}";
var time = setting.GcdOverride == 0
? Plugin.Settings.RotationHelper.GcdTime
: setting.GcdOverride;

_time = _time.Add(TimeSpan.FromSeconds(time));
return result;
}

public override uint GetIcon(object obj)
{
if (obj is not ActionSetting setting)
Expand Down
11 changes: 3 additions & 8 deletions ActionTimelineEx/Configurations/Actions/GCDAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ public class GCDAction : ActionSetting
{
internal override ActionSettingType Type => ActionSettingType.Action;

[UI]
public string Display
{
get
{
return string.Empty;
}
}
[Range(0, 20, ConfigUnitType.Seconds)]
[UI("Recast time override")]
public float GcdOverride { get; set; } = 0;

[UI]
public List<oGCDAction> oGCDs { get; set; } = [];
Expand Down
2 changes: 2 additions & 0 deletions ActionTimelineEx/Configurations/RotationSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class RotationSetting

public ActionSetting? GetNextAction(int index, byte subIndex)
{
if (GCDs.Count == 0) return null;

var thisIndex = index - 1;
if (thisIndex >= GCDs.Count) return null;

Expand Down
2 changes: 2 additions & 0 deletions ActionTimelineEx/Configurations/RotationsSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class RotationsSetting

public List<RotationSetting> RotationSettings { get; set; } = [];

public float GcdTime { get; set; } = 2.5f;

[JsonIgnore]
public RotationSetting RotationSetting
{
Expand Down
9 changes: 9 additions & 0 deletions ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ public int RotationChoice
[UI("Record Rotation", 2)]
public bool RecordRotation { get; set; } = false;

[JsonIgnore]
[UI("Gcd Time", 2)]
public float GcdTime
{
get => RotationHelper.GcdTime;
set => RotationHelper.GcdTime = value;
}


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

Expand Down
11 changes: 1 addition & 10 deletions ActionTimelineEx/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,7 @@ private static void UpdateHighlight()
_highLight.Color = Plugin.Settings.RotationHighlightColor;
_highLight.HotbarIDs.Clear();

ActionSetting? action = null;
try
{
action = ActiveAction;
}
catch
{
return;
}

var action = ActiveAction;
if (action == null) return;
HotbarID? hotBar = null;

Expand Down
6 changes: 5 additions & 1 deletion ActionTimelineEx/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,9 @@
"ActionTimelineEx.Configurations.Actions.ActionSettingType.Item": "Item",
"ActionTimelineEx.Configurations.Actions.oGCDActionDescription": "Infuriate (oGCD)",
"ActionTimelineEx.Configurations.Actions.ActionSetting": "ActionSetting",
"ActionTimelineEx.Configurations.Actions.ActionSettingDescription": "Heavy Swing (GCD)"
"ActionTimelineEx.Configurations.Actions.ActionSettingDescription": "Heavy Swing (GCD)",
"ActionTimelineEx.Configurations.Actions.ActionSettingName.ActionID": "Action ID",
"ActionTimelineEx.Configurations.Actions.GCDActionName.RecastOverride": "Recast override time",
"ActionTimelineEx.Configurations.SettingsName.GcdTime": "Gcd Time",
"ActionTimelineEx.Configurations.Actions.GCDActionName.GcdOverride": "Recast time override"
}
2 changes: 1 addition & 1 deletion ActionTimelineEx/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ private static bool ShowTimeline()

public static void OpenConfigUi()
{
_settingsWindow.IsOpen = true;
_settingsWindow.IsOpen = !_settingsWindow.IsOpen;
}
}
69 changes: 53 additions & 16 deletions ActionTimelineEx/Windows/RotationHelperWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
using ECommons.GameHelpers;
using ImGuiNET;
using System.Numerics;
using XIVConfigUI;

namespace ActionTimelineEx.Windows;
internal static class RotationHelperWindow
{
private static Vector2 _size = default;
private static bool _open = true, _changed = false;
public static void Draw()
{
var setting = Plugin.Settings;
Expand All @@ -24,35 +27,69 @@ public static void Draw()
{
flag |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
}
if (!_open)
{
flag |= ImGuiWindowFlags.AlwaysAutoResize;
}

Vector4 bgColor = setting.RotationLocked ? setting.RotationLockedBackgroundColor : setting.RotationUnlockedBackgroundColor;
using var bgColorPush = ImRaii.PushColor(ImGuiCol.WindowBg, bgColor);

ImGui.SetNextWindowSize(new Vector2(560, 100) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);
ImGui.SetNextWindowPos(new Vector2(200, 200) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver);

if (_changed)
{
ImGui.SetNextWindowSize(_size);
_changed = false;
}

if (ImGui.Begin("Rotation Helper Window", flag))
{
//Double click to clear.
if (DrawHelper.IsInRect(ImGui.GetWindowPos(), ImGui.GetWindowSize()) && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
{
RotationHelper.Clear();
}
var rotations = Plugin.Settings.RotationHelper;

var padding = ImGui.GetStyle().WindowPadding;
var border = ImGui.GetStyle().WindowBorderSize;
ImGui.GetStyle().WindowPadding = default;
ImGui.GetStyle().WindowBorderSize = 0;
try
if (ImGui.Checkbox("##Open", ref _open))
{
DrawContent();
if (_open)
{
_changed = true;
ImGui.End();
return;
}
else
{
_size = ImGui.GetWindowSize();
}
}
finally

if (_open)
{
ImGui.End();
ImGui.GetStyle().WindowPadding = padding;
ImGui.GetStyle().WindowBorderSize = border;
ImGui.SameLine();
var index = rotations.ChoiceIndex;
if (ImGuiHelper.SelectableCombo("Change Rotation", [.. rotations.RotationSettings.Select(i => i.Name)], ref index))
{
rotations.ChoiceIndex = index;
}

//Double click to clear.
if (DrawHelper.IsInRect(ImGui.GetWindowPos(), ImGui.GetWindowSize()) && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
{
RotationHelper.Clear();
}

var padding = ImGui.GetStyle().WindowPadding;
var border = ImGui.GetStyle().WindowBorderSize;
ImGui.GetStyle().WindowPadding = default;
ImGui.GetStyle().WindowBorderSize = 0;
try
{
DrawContent();
}
finally
{
ImGui.End();
ImGui.GetStyle().WindowPadding = padding;
ImGui.GetStyle().WindowBorderSize = border;
}
}
}
}
Expand Down

0 comments on commit d2bfb15

Please sign in to comment.