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

Commit

Permalink
feat: add a duty start or end event for macro usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 13, 2023
1 parent 72cc363 commit fcfbd53
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 49 deletions.
19 changes: 16 additions & 3 deletions RotationSolver/Configuration/ActionEventInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
namespace RotationSolver.Configuration;
using ImGuiNET;
using RotationSolver.Localization;

namespace RotationSolver.Configuration;

public class ActionEventInfo : MacroInfo
{
public string Name { get; set; }

public string Name;

public ActionEventInfo()
{
Name = "";
}

public override void DisplayMacro()
{
if (ImGui.InputText($"{LocalizationManager.RightLang.Configwindow_Events_ActionName}##ActionName{GetHashCode()}",
ref Name, 100))
{
Service.Configuration.Save();
}

base.DisplayMacro();
}
}
45 changes: 38 additions & 7 deletions RotationSolver/Configuration/MacroInfo.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Game.ClientState.Objects.Types;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using ImGuiNET;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Updaters;

namespace RotationSolver.Configuration;

public class MacroInfo
{
public int MacroIndex { get; set; }
public bool IsShared { get; set; }
public int MacroIndex;
public bool IsShared;

public MacroInfo()
{
MacroIndex = -1;
IsShared = false;
}

public unsafe bool AddMacro(GameObject tar = null)
{
if (MacroIndex < 0 || MacroIndex > 99) return false;

MacroUpdater.Macros.Enqueue(new MacroItem(tar, IsShared ?
RaptureMacroModule.Instance->Shared[MacroIndex] :
RaptureMacroModule.Instance->Individual[MacroIndex]));

return true;
}

public virtual void DisplayMacro()
{
if (ImGui.DragInt($"{LocalizationManager.RightLang.Configwindow_Events_MacroIndex}##MacroIndex{GetHashCode()}",
ref MacroIndex, 1, 0, 99))
{
Service.Configuration.Save();
}

ImGui.SameLine();
ImGuiHelper.Spacing();

if (ImGui.Checkbox($"{LocalizationManager.RightLang.Configwindow_Events_ShareMacro}##ShareMacro{GetHashCode()}",
ref IsShared))
{
Service.Configuration.Save();
}
}
}
2 changes: 2 additions & 0 deletions RotationSolver/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public class PluginConfiguration : IPluginConfiguration
public int MoveTargetAngle = 24;
public List<TargetingType> TargetingTypes { get; set; } = new List<TargetingType>();
public int TargetingIndex { get; set; } = 0;
public MacroInfo DutyStart { get; set; } = new MacroInfo();
public MacroInfo DutyEnd { get; set; } = new MacroInfo();
public void Save()
{
Service.Interface.SavePluginConfig(this);
Expand Down
4 changes: 3 additions & 1 deletion RotationSolver/Localization/Strings_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ internal partial class Strings
public string Configwindow_Events_Description { get; set; } = "In this window, you can set what macro will be trigger after using an action.";
public string Configwindow_Events_ActionName { get; set; } = "Action Name";
public string Configwindow_Events_MacroIndex { get; set; } = "Macro No.";
public string Configwindow_Events_ShareMacro { get; set; } = "Shared Macro No.";
public string Configwindow_Events_ShareMacro { get; set; } = "Is Shared";
public string Configwindow_Events_RemoveEvent { get; set; } = "Delete Event";
public string Configwindow_Events_DutyStart { get; set; } = "Duty Start: ";
public string Configwindow_Events_DutyEnd{ get; set; } = "Duty End: ";
public string Configwindow_Params_Description { get; set; } = "In this window, you can set the parameters about the using way of actions.";
public string Configwindow_Param_NeverReplaceIcon { get; set; } = "Never Replace Icons";
public string Configwindow_Param_NeverReplaceIconDesc { get; set; } = "Icon replacement: Repose is automatically displayed as the next skill to be used";
Expand Down
4 changes: 4 additions & 0 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private void DutyState_DutyCompleted(object sender, ushort e)
{
#if DEBUG
Service.ChatGui.Print("Succeed!");
Service.Configuration.DutyStart.AddMacro();
#endif
}

Expand All @@ -79,6 +80,9 @@ private void DutyState_DutyStarted(object sender, ushort e)
var str = territory.PlaceName?.Value?.Name.ToString() ?? "High-end Duty";
Service.ToastGui.ShowError(string.Format(LocalizationManager.RightLang.HighEndWarning, str));
}
#if DEBUG
Service.Configuration.DutyEnd.AddMacro();
#endif
}

internal static void ChangeUITranslation()
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/SigReplacers/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private static unsafe void RecordAction(GameObject tar, Action action, byte flag
foreach (var item in Service.Configuration.Events)
{
if (!new Regex(item.Name).Match(action.Name).Success) continue;
if (MacroUpdater.AddMacro(item, tar)) break;
if (item.AddMacro(tar)) break;
}

#if DEBUG
Expand Down
11 changes: 0 additions & 11 deletions RotationSolver/Updaters/MacroUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,4 @@ public static void UpdateMacro()
}
}
}

public static unsafe bool AddMacro(MacroInfo info, GameObject tar)
{
if (info.MacroIndex < 0 || info.MacroIndex > 99) return false;

Macros.Enqueue(new MacroItem(tar, info.IsShared ?
RaptureMacroModule.Instance->Shared[info.MacroIndex] :
RaptureMacroModule.Instance->Individual[info.MacroIndex]));

return true;
}
}
43 changes: 17 additions & 26 deletions RotationSolver/Windows/RotationConfigWindow_Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,30 @@ private void DrawEventTab()

ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f));

#if DEBUG
ImGui.Text(LocalizationManager.RightLang.Configwindow_Events_DutyStart);
ImGui.SameLine();
ImGuiHelper.Spacing();
Service.Configuration.DutyStart.DisplayMacro();

ImGui.Text(LocalizationManager.RightLang.Configwindow_Events_DutyEnd);
ImGui.SameLine();
ImGuiHelper.Spacing();
Service.Configuration.DutyEnd.DisplayMacro();
#endif

if (ImGui.BeginChild("Events List", new Vector2(0f, -1f), true))
{
for (int i = 0; i < Service.Configuration.Events.Count; i++)
foreach (var eve in Service.Configuration.Events)
{
string name = Service.Configuration.Events[i].Name;
if (ImGui.InputText($"{LocalizationManager.RightLang.Configwindow_Events_ActionName}##ActionName{i}",
ref name, 50))
{
Service.Configuration.Events[i].Name = name;
Service.Configuration.Save();
}

int macroindex = Service.Configuration.Events[i].MacroIndex;
if (ImGui.DragInt($"{LocalizationManager.RightLang.Configwindow_Events_MacroIndex}##MacroIndex{i}",
ref macroindex, 1, 0, 99))
{
Service.Configuration.Events[i].MacroIndex = macroindex;
Service.Configuration.Save();
}

bool isShared = Service.Configuration.Events[i].IsShared;
if (ImGui.Checkbox($"{LocalizationManager.RightLang.Configwindow_Events_ShareMacro}##ShareMacro{i}",
ref isShared))
{
Service.Configuration.Events[i].IsShared = isShared;
Service.Configuration.Save();
}
eve.DisplayMacro();

ImGui.SameLine();
ImGuiHelper.Spacing();
if (ImGui.Button($"{LocalizationManager.RightLang.Configwindow_Events_RemoveEvent}##RemoveEvent{i}"))

if (ImGui.Button($"{LocalizationManager.RightLang.Configwindow_Events_RemoveEvent}##RemoveEvent{GetHashCode()}"))
{
Service.Configuration.Events.RemoveAt(i);
Service.Configuration.Events.Remove(eve);
Service.Configuration.Save();
}
ImGui.Separator();
Expand Down

0 comments on commit fcfbd53

Please sign in to comment.