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

Commit

Permalink
feat: add assembly rotation author feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 13, 2023
1 parent 58a77e2 commit 5b85f81
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
1 change: 1 addition & 0 deletions RotationSolver.Default/RotationSolver.Default.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<PlatformTarget>x64</PlatformTarget>
<DalamudLibPath>$(AppData)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<Platforms>AnyCPU</Platforms>
<Authors>ArchiTed</Authors>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 1 addition & 6 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ public static partial class RSCommands
{
private static DateTime _fastClickStopwatch = DateTime.Now;

static readonly string[] _allowedAssembly = new string[]
{

};

internal static unsafe void DoAnAction(bool isGCD)
{
if (StateType == StateCommandType.Cancel) return;
if(SocialUpdater.InHighEndDuty && RotationUpdater.RightNowRotation.GetType().Assembly.FullName is string str && !_allowedAssembly.Contains(str))
if(SocialUpdater.InHighEndDuty && RotationUpdater.RightNowRotation.IsAllowed(out var str))
{
Service.ToastGui.ShowError(string.Format(LocalizationManager.RightLang.HighEndBan, str));
return;
Expand Down
32 changes: 32 additions & 0 deletions RotationSolver/RotationHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RotationSolver.Basic.Rotations;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver;

internal static class RotationHelper
{
const string DefaultAssembly = "";
static readonly string[] _allowedAssembly = new string[]
{
DefaultAssembly,
};

public static bool IsDefault(this ICustomRotation rotation)
=> DefaultAssembly == rotation.GetType().Assembly.FullName;

public static bool IsAllowed(this ICustomRotation rotation, out string name)
{
name = rotation.GetType().Assembly.GetName().Name;
return _allowedAssembly.Contains(rotation.GetType().Assembly.FullName);
}

public static string GetAuthor(this ICustomRotation rotation)
{
return FileVersionInfo.GetVersionInfo(rotation.GetType().Assembly.Location)?.CompanyName ?? "Unnamed";
}
}
7 changes: 6 additions & 1 deletion RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,12 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
}

ImGui.SameLine();
ImGui.TextDisabled(" - " + LocalizationManager.RightLang.Configwindow_Helper_GameVersion + ": ");
ImGui.TextDisabled(" - ");
ImGui.SameLine();
ImGui.TextColored(rotation.IsAllowed(out _) ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed,
rotation.GetAuthor());
ImGui.SameLine();
ImGui.TextDisabled(" - " + LocalizationManager.RightLang.Configwindow_Helper_GameVersion + ": ");
ImGui.SameLine();
ImGui.Text(rotation.GameVersion);
ImGui.SameLine();
Expand Down
8 changes: 4 additions & 4 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ private static void GetAllCustomRotations()
Service.ChatGui.Print(t.FullName);
}

var assemblies = new Assembly[] { typeof(RotationUpdater).Assembly };
Assemblies = new Assembly[] { typeof(RotationUpdater).Assembly };

_customRotations = (from a in assemblies
_customRotations = (from a in Assemblies
from t in a.GetTypes()
where t.GetInterfaces().Contains(typeof(ICustomRotation))
&& !t.IsAbstract && !t.IsInterface
Expand Down Expand Up @@ -109,8 +109,8 @@ public static void UpdateRotation()
internal static ICustomRotation GetChooseRotation(CustomRotationGroup group, string name)
{
var rotation = group.rotations.FirstOrDefault(r => r.RotationName == name);
//rotation ??= group.rotations.FirstOrDefault(r => r.GetType().GetCustomAttribute<DefaultRotationAttribute>() != null);
rotation ??= group.rotations.FirstOrDefault(r => r.GetType().Name.Contains("Default"));
rotation ??= group.rotations.FirstOrDefault(RotationHelper.IsDefault);
rotation ??= group.rotations.FirstOrDefault(r => r.IsAllowed(out _));
rotation ??= group.rotations.FirstOrDefault();
return rotation;
}
Expand Down

0 comments on commit 5b85f81

Please sign in to comment.