This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5df63d2
commit f172d0e
Showing
20 changed files
with
406 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,87 @@ | ||
using Dalamud.Game.Command; | ||
using FFXIVClientStructs.FFXIV.Client.Game.UI; | ||
using Lumina.Excel.GeneratedSheets; | ||
using RotationSolver.Basic; | ||
using RotationSolver.Basic.Data; | ||
using RotationSolver.Localization; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace RotationSolver.Commands | ||
namespace RotationSolver.Commands; | ||
|
||
public static partial class RSCommands | ||
{ | ||
public static partial class RSCommands | ||
internal static TargetingType TargetingType | ||
{ | ||
internal static TargetingType TargetingType | ||
get | ||
{ | ||
get | ||
if (Service.Config.TargetingTypes.Count == 0) | ||
{ | ||
if (Service.Config.TargetingTypes.Count == 0) | ||
{ | ||
Service.Config.TargetingTypes.Add(TargetingType.Big); | ||
Service.Config.TargetingTypes.Add(TargetingType.Small); | ||
Service.Config.Save(); | ||
} | ||
|
||
return Service.Config.TargetingTypes[Service.Config.TargetingIndex %= Service.Config.TargetingTypes.Count]; | ||
Service.Config.TargetingTypes.Add(TargetingType.Big); | ||
Service.Config.TargetingTypes.Add(TargetingType.Small); | ||
Service.Config.Save(); | ||
} | ||
|
||
return Service.Config.TargetingTypes[Service.Config.TargetingIndex %= Service.Config.TargetingTypes.Count]; | ||
} | ||
} | ||
|
||
internal static void Enable() | ||
=> Service.CommandManager.AddHandler(Service.Command, new CommandInfo(OnCommand) | ||
{ | ||
HelpMessage = LocalizationManager.RightLang.Commands_Rotation, | ||
ShowInHelp = true, | ||
}); | ||
internal static void Enable() | ||
=> Service.CommandManager.AddHandler(Service.Command, new CommandInfo(OnCommand) | ||
{ | ||
HelpMessage = LocalizationManager.RightLang.Commands_Rotation, | ||
ShowInHelp = true, | ||
}); | ||
|
||
internal static void Disable() => Service.CommandManager.RemoveHandler(Service.Command); | ||
|
||
internal static void Disable() => Service.CommandManager.RemoveHandler(Service.Command); | ||
private static void OnCommand(string command, string arguments) | ||
{ | ||
DoOneCommand(arguments); | ||
} | ||
|
||
private static void OnCommand(string command, string arguments) | ||
private static void DoOneCommand(string str) | ||
{ | ||
if (TryGetOneEnum<StateCommandType>(str, out var stateType)) | ||
{ | ||
DoStateCommandType(stateType); | ||
} | ||
else if (TryGetOneEnum<SpecialCommandType>(str, out var specialType)) | ||
{ | ||
DoSpecialCommandType(specialType); | ||
} | ||
else if (TryGetOneEnum<OtherCommandType>(str, out var otherType)) | ||
{ | ||
DoOtherCommand(otherType, str.Substring(otherType.ToString().Length).Trim()); | ||
} | ||
else | ||
{ | ||
DoOneCommand(arguments); | ||
RotationSolverPlugin.OpenConfigWindow(); | ||
} | ||
} | ||
|
||
private static void DoOneCommand(string str) | ||
private static bool TryGetOneEnum<T>(string str, out T type) where T : struct, Enum | ||
{ | ||
type = default; | ||
try | ||
{ | ||
if (TryGetOneEnum<StateCommandType>(str, out var stateType)) | ||
{ | ||
DoStateCommandType(stateType); | ||
} | ||
else if (TryGetOneEnum<SpecialCommandType>(str, out var specialType)) | ||
{ | ||
DoSpecialCommandType(specialType); | ||
} | ||
else if (TryGetOneEnum<OtherCommandType>(str, out var otherType)) | ||
{ | ||
DoOtherCommand(otherType, str.Substring(otherType.ToString().Length).Trim()); | ||
} | ||
else | ||
{ | ||
RotationSolverPlugin.OpenConfigWindow(); | ||
} | ||
type = Enum.GetValues<T>().First(c => str.StartsWith(c.ToString(), StringComparison.OrdinalIgnoreCase)); | ||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
private static bool TryGetOneEnum<T>(string str, out T type) where T : struct, Enum | ||
internal static string GetCommandStr<T>(this T command, string extraCommand = "") | ||
where T : struct, Enum | ||
{ | ||
var cmdStr = Service.Command + " " + command.ToString(); | ||
if (!string.IsNullOrEmpty(extraCommand)) | ||
{ | ||
type = default; | ||
try | ||
{ | ||
type = Enum.GetValues<T>().First(c => str.StartsWith(c.ToString(), StringComparison.OrdinalIgnoreCase)); | ||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
cmdStr += " " + extraCommand; | ||
} | ||
return cmdStr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.