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

Commit

Permalink
fix: better ui, and add copy paste features.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 12, 2024
1 parent 87904a9 commit 656d20c
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 35 deletions.
1 change: 1 addition & 0 deletions ActionTimelineEx/Configurations/RotationsSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class RotationsSetting
{
public string Choice { get; set; } = "Default";

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

[JsonIgnore]
Expand Down
51 changes: 25 additions & 26 deletions ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using ECommons.GameHelpers;
using Newtonsoft.Json;
using System.Numerics;
using XIVConfigUI.Attributes;

Expand Down Expand Up @@ -52,31 +51,6 @@ public class Settings : IPluginConfiguration
[UI("Draw Rotation", 1)]
public bool DrawRotation { get; set; } = false;

[JsonIgnore]
[TimelineChoices]
[UI("Rotation Choice", Parent = nameof(DrawRotation))]
public string RotationChoice
{
get => EditSetting?.Choice ?? "Default";
set
{
if (EditSetting == null) return;
EditSetting.Choice = value;
}
}

[JsonIgnore]
[UI("Rotation Name", Parent = nameof(DrawRotation))]
public string RotationName
{
get => EditSetting?.RotationSetting.Name ?? "Default";
set
{
if (EditSetting == null) return;
EditSetting.RotationSetting.Name = value;
}
}

[UI("Locked", Parent = nameof(DrawRotation))]
public bool RotationLocked { get; set; } = false;

Expand Down Expand Up @@ -104,6 +78,31 @@ public string RotationName
[UI("Show the wrong clicking", Parent = nameof(DrawRotation))]
public bool ShowWrongClick { get; set; } = true;

[JsonIgnore]
[TimelineChoices]
[UI("Rotation Choice", 2)]
public string RotationChoice
{
get => EditSetting?.Choice ?? "Default";
set
{
if (EditSetting == null) return;
EditSetting.Choice = value;
}
}

[JsonIgnore]
[UI("Rotation Name", 2)]
public string RotationName
{
get => EditSetting?.RotationSetting.Name ?? "Default";
set
{
if (EditSetting == null) return;
EditSetting.RotationSetting.Name = value;
}
}

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

Expand Down
3 changes: 1 addition & 2 deletions ActionTimelineEx/Helpers/DrawHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ActionTimelineEx.Configurations;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures;
using Dalamud.Interface.Textures.TextureWraps;
using ECommons.DalamudServices;
using ImGuiNET;
Expand Down
10 changes: 6 additions & 4 deletions ActionTimelineEx/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace ActionTimelineEx.Helpers;
internal static class RotationHelper
{
private static DrawingHighlightHotbar? _highLight;
public static ActionSetting? ActiveActon => Actions.FirstOrDefault();
public static ActionSetting? ActiveAction => Actions.FirstOrDefault();

public static IEnumerable< ActionSetting> Actions => RotationSetting.Actions.Skip((int)Count);
public static IEnumerable<ActionSetting> Actions => RotationSetting.Actions.Skip((int)Count);

public static RotationSetting RotationSetting => Plugin.Settings.GetSetting(Svc.ClientState.TerritoryType).RotationSetting;

Expand All @@ -35,11 +35,13 @@ private set

private static void UpdateHighlight()
{
if (!Plugin.Settings.DrawRotation) return;

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

var action = ActiveActon;
var action = ActiveAction;
if (action == null) return;

HotbarID? hotbar = null;
Expand Down Expand Up @@ -111,7 +113,7 @@ private static void ActionFromSelf(ActionEffectSet set)
if (set.Source.EntityId != Player.Object.EntityId || !Plugin.Settings.DrawRotation) return;
if (set.Action == null) return;

var action = ActiveActon;
var action = ActiveAction;
if (action == null) return;

var succeed = set.Action.RowId == action.ActionId;
Expand Down
3 changes: 2 additions & 1 deletion ActionTimelineEx/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,6 @@
"ActionTimelineEx.Configurations.ActionSettingName.Type": "Type",
"ActionTimelineEx.Configurations.ActionSettingName.Id": "Id",
"ActionTimelineEx.Configurations.ActionSettingDescription": "Maim (GCD)",
"ActionTimelineEx.Configurations.UiString.RotationReset": "Reset Count"
"ActionTimelineEx.Configurations.UiString.RotationReset": "Reset Count",
"ActionTimeline.SettingsName.ShowWrongClick": "Show the wrong clicking"
}
37 changes: 35 additions & 2 deletions ActionTimelineEx/Windows/RotationHelperItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using System.Collections.Generic;
using System.ComponentModel;
using System.Numerics;
using XIVConfigUI;
Expand Down Expand Up @@ -40,20 +42,51 @@ public override void Draw(ConfigWindow window)
_group ??= new CollapsingHeaderGroup(new()
{
{ () => UiString.RotationSetting.Local(), () => DrawSetting(window) },
{ () => UiString.Rotation.Local(), () => ConditionDrawer.Draw(setting.RotationSetting.Actions) },
{ () => UiString.Rotation.Local(), () => DrawRotation(window, setting.RotationSetting)},
});

_group.Draw();
base.Draw(window);
}

private static void DrawSetting(ConfigWindow window)
{
window.Collection.DrawItems(1);
}

private static void DrawRotation(ConfigWindow window, RotationSetting setting)
{
if (ImGui.Button(UiString.RotationReset.Local()))
{
RotationHelper.Clear();
}
window.Collection.DrawItems(1);

ImGui.SameLine();

if (ImGui.Button(LocalString.CopyToClipboard.Local()))
{
var str = JsonHelper.SerializeObject(setting.Actions);
ImGui.SetClipboardText(str);
}

ImGui.SameLine();

if (ImGui.Button(LocalString.FromClipboard.Local()))
{
var str = ImGui.GetClipboardText();

try
{
setting.Actions = JsonHelper.DeserializeObject<List<ActionSetting>>(str)!;
}
catch (Exception ex)
{
Svc.Log.Warning(ex, "Failed to load the timeline.");
}
}

window.Collection.DrawItems(2);
ConditionDrawer.Draw(setting.Actions);
}

private static void DrawTerritoryHeader()
Expand Down

0 comments on commit 656d20c

Please sign in to comment.