From 43955fcb35181a81c8aeec5ed081aa1fbefb7305 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com>
Date: Tue, 7 Nov 2023 20:04:49 +0800
Subject: [PATCH] fix: add combat type for rotation and its config.
---
.../RotationConfig/IRotationConfig.cs | 5 ++
.../RotationConfig/IRotationConfigSet.cs | 62 +++++++++++++++++++
.../RotationConfig/RotationConfigBase.cs | 4 +-
.../RotationConfig/RotationConfigBoolean.cs | 4 +-
.../RotationConfig/RotationConfigCombo.cs | 2 +-
.../RotationConfig/RotationConfigFloat.cs | 9 +--
.../RotationConfig/RotationConfigInt.cs | 3 +-
.../RotationConfig/RotationConfigSet.cs | 41 ++++++++++--
.../RotationConfig/RotationConfigString.cs | 3 +-
RotationSolver.Basic/Data/CombatType.cs | 28 +++++++++
RotationSolver.Basic/Helpers/TargetFilter.cs | 2 +-
.../Rotations/Basic/BLU_Base.cs | 4 +-
.../Rotations/CustomRotation_BasicInfo.cs | 1 +
.../Rotations/ICustomRotation.cs | 5 ++
RotationSolver/Localization/Localization.json | 3 +-
RotationSolver/UI/RotationConfigWindow.cs | 34 ++++++++++
16 files changed, 187 insertions(+), 23 deletions(-)
create mode 100644 RotationSolver.Basic/Data/CombatType.cs
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfig.cs b/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfig.cs
index 42957fdc9..fa60b80e8 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfig.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfig.cs
@@ -22,6 +22,11 @@ public interface IRotationConfig
///
string DefaultValue { get; }
+ ///
+ /// Type of this config, pvp, pve, or both.
+ ///
+ CombatType Type { get; }
+
///
/// Get the value of this.
///
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfigSet.cs b/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfigSet.cs
index ba4cff9c6..c2f6b4524 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfigSet.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/IRotationConfigSet.cs
@@ -20,8 +20,22 @@ public interface IRotationConfigSet : IEnumerable
///
///
///
+ [Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetFloat(string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f);
+ ///
+ /// Set the float.
+ ///
+ /// tye unit type
+ /// the combat type
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IRotationConfigSet SetFloat(ConfigUnitType unit, CombatType type, string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f);
+
///
/// Set the string.
///
@@ -29,8 +43,19 @@ public interface IRotationConfigSet : IEnumerable
///
///
///
+ [Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetString(string name, string value, string displayName);
+ ///
+ /// Set the string.
+ ///
+ /// the combat type
+ ///
+ ///
+ ///
+ ///
+ IRotationConfigSet SetString(CombatType type, string name, string value, string displayName);
+
///
/// Set the bool.
///
@@ -38,8 +63,19 @@ public interface IRotationConfigSet : IEnumerable
///
///
///
+ [Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetBool(string name, bool value, string displayName);
+ ///
+ ///
+ ///
+ /// the combat type
+ ///
+ ///
+ ///
+ ///
+ IRotationConfigSet SetBool(CombatType type, string name, bool value, string displayName);
+
///
/// Set the combo.
///
@@ -48,8 +84,20 @@ public interface IRotationConfigSet : IEnumerable
///
///
///
+ [Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetCombo(string name, int value, string displayName, params string[] items);
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IRotationConfigSet SetCombo(CombatType type, string name, int value, string displayName, params string[] items);
+
///
/// Set the int.
///
@@ -60,8 +108,22 @@ public interface IRotationConfigSet : IEnumerable
///
///
///
+ [Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetInt(string name, int value, string displayName, int min = 0, int max = 10, int speed = 1);
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IRotationConfigSet SetInt(CombatType type, string name, int value, string displayName, int min = 0, int max = 10, int speed = 1);
+
///
/// Set the value.
///
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs
index 1499a0e17..c26d27ea9 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBase.cs
@@ -7,12 +7,14 @@ internal abstract class RotationConfigBase : IRotationConfig
public string Name { get; }
public string DefaultValue { get; }
public string DisplayName { get; }
+ public CombatType Type { get; }
- public RotationConfigBase(string name, string value, string displayName)
+ public RotationConfigBase(string name, string value, string displayName, CombatType type)
{
Name = name;
DefaultValue = value;
DisplayName = displayName;
+ Type = type;
}
public string GetValue(Job job, string rotationName)
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBoolean.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBoolean.cs
index 205e6114b..63a9179d5 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBoolean.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigBoolean.cs
@@ -2,7 +2,9 @@
internal class RotationConfigBoolean : RotationConfigBase
{
- public RotationConfigBoolean(string name, bool value, string displayName) : base(name, value.ToString(), displayName)
+
+ public RotationConfigBoolean(string name, bool value, string displayName, CombatType type)
+ : base(name, value.ToString(), displayName, type)
{
}
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigCombo.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigCombo.cs
index f5f3c3540..67a32f4cc 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigCombo.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigCombo.cs
@@ -5,7 +5,7 @@ namespace RotationSolver.Basic.Configuration.RotationConfig;
internal class RotationConfigCombo : RotationConfigBase
{
public string[] Items { get; set; }
- public RotationConfigCombo(string name, int value, string displayName, string[] items) : base(name, value.ToString(), displayName)
+ public RotationConfigCombo(string name, int value, string displayName, string[] items, CombatType type) : base(name, value.ToString(), displayName, type)
{
Items = items;
}
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigFloat.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigFloat.cs
index b93c7ac41..7c7beb25e 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigFloat.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigFloat.cs
@@ -7,14 +7,7 @@ internal class RotationConfigFloat : RotationConfigBase
public ConfigUnitType UnitType { get; set; }
- [Obsolete("Please use the one with unit type!", true)]
- public RotationConfigFloat(string name, float value, string displayName, float min, float max, float speed)
- :this(name, value, displayName, min, max, speed, ConfigUnitType.None)
- {
-
- }
-
- public RotationConfigFloat(string name, float value, string displayName, float min, float max, float speed, ConfigUnitType unitType) : base(name, value.ToString(), displayName)
+ public RotationConfigFloat(string name, float value, string displayName, float min, float max, float speed, ConfigUnitType unitType, CombatType type) : base(name, value.ToString(), displayName, type)
{
Min = min;
Max = max;
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigInt.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigInt.cs
index 7542d11fc..d288225e5 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigInt.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigInt.cs
@@ -4,7 +4,8 @@ internal class RotationConfigInt : RotationConfigBase
{
public int Min, Max, Speed;
- public RotationConfigInt(string name, int value, string displayName, int min, int max, int speed) : base(name, value.ToString(), displayName)
+ public RotationConfigInt(string name, int value, string displayName, int min, int max, int speed, CombatType type)
+ : base(name, value.ToString(), displayName, type)
{
Min = min;
Max = max;
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigSet.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigSet.cs
index e23b7d711..77f05584b 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigSet.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigSet.cs
@@ -16,33 +16,63 @@ public RotationConfigSet(Job job, string rotationName)
}
#region Set
+ [Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetFloat(string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f)
{
- Configs.Add(new RotationConfigFloat(name, value, displayName, min, max, speed));
+ return SetFloat(ConfigUnitType.None, CombatType.Both, name, value, displayName, min, max, speed);
+ }
+
+ public IRotationConfigSet SetFloat(ConfigUnitType unit, CombatType type, string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f)
+ {
+ Configs.Add(new RotationConfigFloat(name, value, displayName, min, max, speed, unit, type));
return this;
}
+ [Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetString(string name, string value, string displayName)
{
- Configs.Add(new RotationConfigString(name, value, displayName));
+ return SetString(CombatType.Both, name, value, displayName);
+ }
+
+ public IRotationConfigSet SetString(CombatType type, string name, string value, string displayName)
+ {
+ Configs.Add(new RotationConfigString(name, value, displayName, type));
return this;
}
+ [Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetBool(string name, bool value, string displayName)
{
- Configs.Add(new RotationConfigBoolean(name, value, displayName));
+ return SetBool(CombatType.Both, name, value, displayName);
+ }
+
+ public IRotationConfigSet SetBool(CombatType type, string name, bool value, string displayName)
+ {
+ Configs.Add(new RotationConfigBoolean(name, value, displayName, type));
return this;
}
+ [Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetCombo(string name, int value, string displayName, params string[] items)
{
- Configs.Add(new RotationConfigCombo(name, value, displayName, items));
+ return SetCombo(CombatType.Both, name, value, displayName, items);
+ }
+
+ public IRotationConfigSet SetCombo(CombatType type, string name, int value, string displayName, params string[] items)
+ {
+ Configs.Add(new RotationConfigCombo(name, value, displayName, items, type));
return this;
}
+ [Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetInt(string name, int value, string displayName, int min = 0, int max = 10, int speed = 1)
{
- Configs.Add(new RotationConfigInt(name, value, displayName, min, max, speed));
+ return SetInt(CombatType.Both, name, value, displayName, min, max, speed);
+ }
+
+ public IRotationConfigSet SetInt(CombatType type, string name, int value, string displayName, int min = 0, int max = 10, int speed = 1)
+ {
+ Configs.Add(new RotationConfigInt(name, value, displayName, min, max, speed, type));
return this;
}
@@ -101,7 +131,6 @@ public string GetDisplayString(string name)
public IEnumerator GetEnumerator() => Configs.GetEnumerator();
-
IEnumerator IEnumerable.GetEnumerator() => Configs.GetEnumerator();
diff --git a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigString.cs b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigString.cs
index e7c6a7a29..4f4cae9be 100644
--- a/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigString.cs
+++ b/RotationSolver.Basic/Configuration/RotationConfig/RotationConfigString.cs
@@ -2,7 +2,8 @@
internal class RotationConfigString : RotationConfigBase
{
- public RotationConfigString(string name, string value, string displayName) : base(name, value, displayName)
+ public RotationConfigString(string name, string value, string displayName, CombatType type)
+ : base(name, value, displayName, type)
{
}
diff --git a/RotationSolver.Basic/Data/CombatType.cs b/RotationSolver.Basic/Data/CombatType.cs
new file mode 100644
index 000000000..4e5f93b87
--- /dev/null
+++ b/RotationSolver.Basic/Data/CombatType.cs
@@ -0,0 +1,28 @@
+namespace RotationSolver.Basic.Data;
+
+///
+/// The type of the combat
+///
+[Flags]
+public enum CombatType : byte
+{
+ ///
+ /// None of them! (Invalid)
+ ///
+ None = 0,
+
+ ///
+ /// Only for PvP.
+ ///
+ PvP = 1 << 0,
+
+ ///
+ /// Only for PvE.
+ ///
+ PvE = 1 << 1,
+
+ ///
+ /// PvP and PvE.
+ ///
+ Both = PvP | PvE,
+}
diff --git a/RotationSolver.Basic/Helpers/TargetFilter.cs b/RotationSolver.Basic/Helpers/TargetFilter.cs
index 13351b328..cf0ee8e86 100644
--- a/RotationSolver.Basic/Helpers/TargetFilter.cs
+++ b/RotationSolver.Basic/Helpers/TargetFilter.cs
@@ -144,7 +144,7 @@ private static T FindMoveTargetScreenCenter(IEnumerable charas) where T :
/// Find the one being attacked.
///
///
- ///
+ ///
///
public static BattleChara FindAttackedTarget(IEnumerable charas, bool _)
{
diff --git a/RotationSolver.Basic/Rotations/Basic/BLU_Base.cs b/RotationSolver.Basic/Rotations/Basic/BLU_Base.cs
index 384d84045..a5a1cc80d 100644
--- a/RotationSolver.Basic/Rotations/Basic/BLU_Base.cs
+++ b/RotationSolver.Basic/Rotations/Basic/BLU_Base.cs
@@ -1037,8 +1037,8 @@ protected override bool EmergencyGCD(out IAction act)
protected override IRotationConfigSet CreateConfiguration()
{
return base.CreateConfiguration()
- .SetCombo("BlueId", 2, "Role", "Tank", "Healer", "DPS")
- .SetCombo("AttackType", 2, "Type", "Both", "Magic", "Physic");
+ .SetCombo(CombatType.PvE, "BlueId", 2, "Role", "Tank", "Healer", "DPS")
+ .SetCombo(CombatType.PvE, "AttackType", 2, "Type", "Both", "Magic", "Physic");
}
///
diff --git a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
index c98f0ecb6..cb267bd09 100644
--- a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
+++ b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
@@ -10,6 +10,7 @@ namespace RotationSolver.Basic.Rotations;
public abstract partial class CustomRotation : ICustomRotation
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
+ public virtual CombatType Type => CombatType.None;
public abstract Job[] Jobs { get; }
diff --git a/RotationSolver.Basic/Rotations/ICustomRotation.cs b/RotationSolver.Basic/Rotations/ICustomRotation.cs
index 2ae0a7b76..9ec0e7595 100644
--- a/RotationSolver.Basic/Rotations/ICustomRotation.cs
+++ b/RotationSolver.Basic/Rotations/ICustomRotation.cs
@@ -9,6 +9,11 @@ namespace RotationSolver.Basic.Rotations;
///
public interface ICustomRotation : ITexture
{
+ ///
+ /// The type of this rotation, pvp, pve, or both.
+ ///
+ CombatType Type { get; }
+
///
/// The average count of not recommend members using.
///
diff --git a/RotationSolver/Localization/Localization.json b/RotationSolver/Localization/Localization.json
index f777126d5..7d1ebcf9f 100644
--- a/RotationSolver/Localization/Localization.json
+++ b/RotationSolver/Localization/Localization.json
@@ -261,7 +261,8 @@
"ActionConditionType_MaxCharges": "Max Charges",
"TargetConditionType_HasStatus": "Has Status",
"TargetConditionType_IsDying": "Is Dying",
- "TargetConditionType_IsBoss": "Is Boss",
+ "TargetConditionType_IsBossFromTTK": "Is Boss From TTK",
+ "TargetConditionType_IsBossFromIcon": "Is Boss From Icon",
"TargetConditionType_InCombat": "In Combat",
"TargetConditionType_Distance": "Distance",
"TargetConditionType_StatusEnd": "Status End",
diff --git a/RotationSolver/UI/RotationConfigWindow.cs b/RotationSolver/UI/RotationConfigWindow.cs
index 61d168fa9..6effebeea 100644
--- a/RotationSolver/UI/RotationConfigWindow.cs
+++ b/RotationSolver/UI/RotationConfigWindow.cs
@@ -422,6 +422,7 @@ private void DrawHeader(float wholeWidth)
private void DrawRotationIcon(ICustomRotation rotation, float iconSize)
{
+ var cursor = ImGui.GetCursorPos();
if (rotation.GetTexture(out var jobIcon) && ImGuiHelper.SilenceImageButton(jobIcon.ImGuiHandle,
Vector2.One * iconSize, _activeTab == RotationConfigWindowTab.Rotation))
{
@@ -429,8 +430,32 @@ private void DrawRotationIcon(ICustomRotation rotation, float iconSize)
_searchResults = Array.Empty();
}
var desc = rotation.Name + $" ({rotation.RotationName})";
+ var type = rotation.Type;
+ if (type.HasFlag(CombatType.PvE))
+ {
+ desc += " PvE";
+ }
+ if(type.HasFlag(CombatType.PvP))
+ {
+ desc += " PvP";
+ }
if (!string.IsNullOrEmpty(rotation.Description)) desc += "\n \n" + rotation.Description;
ImguiTooltips.HoveredTooltip(desc);
+
+ var icon = type switch
+ {
+ CombatType.Both => 61540u,
+ CombatType.PvE => 61542u,
+ CombatType.PvP => 61544u,
+ _ => 61523u,
+ };
+
+ if(IconSet.GetTexture(icon, out var texture))
+ {
+ ImGui.SetCursorPos(cursor + Vector2.One * iconSize / 2);
+
+ ImGui.Image(texture.ImGuiHandle, Vector2.One * iconSize / 2);
+ }
}
private static void DrawRotationCombo(float comboSize, ICustomRotation[] rotations, ICustomRotation rotation, string gameVersion)
@@ -1091,6 +1116,15 @@ private static void DrawRotationConfiguration()
foreach (var config in set.Configs)
{
+ if(DataCenter.Territory?.IsPvpZone ?? false)
+ {
+ if (!config.Type.HasFlag(CombatType.PvP)) continue;
+ }
+ else
+ {
+ if (!config.Type.HasFlag(CombatType.PvE)) continue;
+ }
+
var key = config.Name;
var name = $"##{config.GetHashCode()}_{config.Name}";
string command = ToCommandStr(OtherCommandType.Rotations, config.Name, config.DefaultValue);