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

Commit

Permalink
feat: add an extra library to use.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 16, 2023
1 parent e63e51d commit 82df403
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 23 deletions.
3 changes: 2 additions & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public class PluginConfiguration : IPluginConfiguration
public string PositionalErrorText = string.Empty;
public float CountDownAhead = 0.6f;

public int NamePlateIconId = 61437; // 61435
public int NamePlateIconId = 61437; // 61435, 0
public bool ShowActionFlag = false;


Expand All @@ -144,6 +144,7 @@ public class PluginConfiguration : IPluginConfiguration
public float HealthRatioDot = 1.2f;

public bool InDebug = false;
public string[] OtherLibs = new string[0];

public List<TargetingType> TargetingTypes { get; set; } = new List<TargetingType>();
public int TargetingIndex { get; set; } = 0;
Expand Down
4 changes: 4 additions & 0 deletions RotationSolver/Localization/Strings_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internal partial class Strings
public string ConfigWindow_EventItem { get; set; } = "Event";
public string ConfigWindow_ActionItem { get; set; } = "Action";
public string ConfigWindow_HelpItem { get; set; } = "Help";
public string ConfigWindow_RotationDev { get; set; } = "RotationDev";

public string ConfigWindow_ActionItem_Description { get; set; }
= "Modify the usage for each action.";
Expand Down Expand Up @@ -79,6 +80,9 @@ internal partial class Strings
public string ConfigWindow_Helper_CopyCommand { get; set; } = "Right-click to copy command";
public string ConfigWindow_Helper_InsertCommand { get; set; } = "Insert \"{0}\" first in 5s";
public string ConfigWindow_Rotation_Description { get; set; } = "You can enable the function for each job you want and configure the setting about how to use actions.";

public string ConfigWindow_RotationDev_Description { get; set; } = "You can get some extra rotation development information here.";

public string ConfigWindow_Rotation_KeyName { get; set; } = "The key name is";
public string ConfigWindow_Events_AddEvent { get; set; } = "AddEvents";
public string ConfigWindow_Events_Description { get; set; } = "In this window, you can set what macro will be trigger after using an action.";
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public override unsafe void Draw()
ImGui.EndTabItem();
}

if (ImGui.BeginTabItem(LocalizationManager.RightLang.ConfigWindow_RotationDev))
{
DrawRotationDevTab();
ImGui.EndTabItem();
}

if (Service.Config.InDebug && ImGui.BeginTabItem("Debug"))
{
DrawDebugTab();
Expand Down
7 changes: 0 additions & 7 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,7 @@ private void DrawParamAdvanced()

ImGui.Separator();

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_InDebug,
ref Service.Config.InDebug);

if (Service.Config.InDebug)
{
ImGui.TextColored(ImGuiColors.DalamudRed,
LocalizationManager.RightLang.ConfigWindow_Param_InDebugWarning);
}
}

private void DrawParamDisplay()
Expand Down
10 changes: 0 additions & 10 deletions RotationSolver/UI/RotationConfigWindow_Rotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ private void DrawRotationTab()
{
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Rotation_Description);

if (ImGui.Button("Dev Wiki"))
{
Util.OpenLink("https://archidog1998.github.io/RotationSolver/#/RotationDev/");
}
ImGui.SameLine();
if (ImGui.Button("Load Rotations"))
{
RotationUpdater.GetAllCustomRotations();
}

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

if (ImGui.BeginTabBar("Job Items"))
Expand Down
66 changes: 66 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_RotationDev.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Dalamud.Interface.Colors;
using Dalamud.Utility;
using ImGuiNET;
using RotationSolver.Basic;
using RotationSolver.Localization;
using RotationSolver.Updaters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Windows.RotationConfigWindow;

internal partial class RotationConfigWindow
{
private void DrawRotationDevTab()
{
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_RotationDev_Description);

if (ImGui.Button("Load Rotations"))
{
RotationUpdater.GetAllCustomRotations();
}

ImGui.SameLine();
if (ImGui.Button("Dev Wiki"))
{
Util.OpenLink("https://archidog1998.github.io/RotationSolver/#/RotationDev/");
}

ImGui.SameLine();

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_InDebug,
ref Service.Config.InDebug);

if (Service.Config.InDebug)
{
ImGui.TextColored(ImGuiColors.DalamudRed,
LocalizationManager.RightLang.ConfigWindow_Param_InDebugWarning);
}

int removeIndex = -1;
for (int i = 0; i < Service.Config.OtherLibs.Length; i++)
{
ImGui.InputText($"##OtherLib{i}", ref Service.Config.OtherLibs[i], 1024);
ImGui.SameLine();
if (ImGui.Button($"X##Remove{i}"))
{
removeIndex = i;
}
}
if(removeIndex > -1)
{
var list = Service.Config.OtherLibs.ToList();
list.RemoveAt(removeIndex);
Service.Config.OtherLibs = list.ToArray();
}

string str = string.Empty;
if(ImGui.InputText($"##OtherLibExtra", ref str, 1024))
{
Service.Config.OtherLibs = Service.Config.OtherLibs.Append(str).ToArray();
}
}
}
24 changes: 19 additions & 5 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,31 @@ public record CustomRotationGroup(ClassJobID jobId, ClassJobID[] classJobIds, IC

public static void GetAllCustomRotations()
{
var assembly = from l in Directory.GetFiles(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location), "*.dll")
where !_locs.Any(l.Contains)
select RotationLoadContext.LoadFrom(l);
var directories = Service.Config.OtherLibs
.Select(s => s.Trim()).Append(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ICustomRotation)).Location));

AuthorHashes = (from a in assembly
#if DEBUG
foreach (var dir in directories)
{
foreach (var item in Directory.GetFiles(dir, "*.dll"))
{
Service.ChatGui.Print(item);
}
}
#endif

var assemblies = from dir in directories
from l in Directory.GetFiles(dir, "*.dll")
where !_locs.Any(l.Contains)
select RotationLoadContext.LoadFrom(l);

AuthorHashes = (from a in assemblies
select a.GetCustomAttribute<AuthorHashAttribute>() into author
where author != null
select author.Hash).ToArray();

_customRotations = (
from a in assembly
from a in assemblies
from t in a.GetTypes()
where t.GetInterfaces().Contains(typeof(ICustomRotation))
&& !t.IsAbstract && !t.IsInterface
Expand Down

0 comments on commit 82df403

Please sign in to comment.