Skip to content

Commit

Permalink
Merge pull request #617 from FFXIV-CombatReborn/further-ui-work
Browse files Browse the repository at this point in the history
Internal language, UI/error display, ShowToggledSettingsInChat
  • Loading branch information
LTS-FFXIV authored Feb 20, 2025
2 parents cdd1bc0 + 549a75d commit bccdc11
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 169 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/ConditionBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static implicit operator bool(ConditionBoolean condition)
{
if (!Service.Config.UseAdditionalConditions) return condition.Value;
var rotation = DataCenter.CurrentRotation;
var set = DataCenter.RightSet;
var set = DataCenter.CurrentConditionValue;
if (rotation != null)
{
if (condition.Enable && set.GetEnableCondition(condition.Key).IsTrue(rotation)) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace RotationSolver.Basic.Configuration.Conditions;

internal class MajorConditionSet(string name = MajorConditionSet.conditionName)
internal class MajorConditionValue(string name = MajorConditionValue.conditionName)
{
const string conditionName = "Unnamed";

Expand Down Expand Up @@ -114,7 +114,7 @@ public void Save(string folder)
File.WriteAllText(path, str);
}

public static MajorConditionSet[] Read(string folder)
public static MajorConditionValue[] Read(string folder)
{
if (!Directory.Exists(folder)) return [];

Expand All @@ -124,14 +124,14 @@ public static MajorConditionSet[] Read(string folder)

try
{
return JsonConvert.DeserializeObject<MajorConditionSet>(str, new IConditionConverter());
return JsonConvert.DeserializeObject<MajorConditionValue>(str, new IConditionConverter());
}
catch (Exception ex)
{
Svc.Log.Warning(ex, $"Failed to load the ConditionSet from {p}");
Svc.Chat.Print($"Failed to load the ConditionSet from {p}");
return null;
}
}).OfType<MajorConditionSet>().Where(set => !string.IsNullOrEmpty(set.Name)).ToArray();
}).OfType<MajorConditionValue>().Where(set => !string.IsNullOrEmpty(set.Name)).ToArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class NamedCondition : DelayCondition
public string ConditionName = "Not Chosen";
protected override bool IsTrueInside(ICustomRotation rotation)
{
foreach (var pair in DataCenter.RightSet.NamedConditions)
foreach (var pair in DataCenter.CurrentConditionValue.NamedConditions)
{
if (pair.Name != ConditionName) continue;

Expand Down
6 changes: 3 additions & 3 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ public const string
PvPFilter = JobFilterType.NoHealer, PvEFilter = JobFilterType.NoHealer)]
private static readonly bool _onlyHealSelfWhenNoHealer = false;

[ConditionBool, UI("Show action toggled action and state feedback in chat.",
[ConditionBool, UI("Show toggled setting and new value in chat.",
Filter = UiInformation)]
private static readonly bool _showToggledActionInChat = false;
private static readonly bool _ShowToggledSettingInChat = false;

[ConditionBool, UI("Record knockback actions", Filter = List2)]
private static readonly bool _recordKnockbackies = false;
Expand Down Expand Up @@ -500,7 +500,7 @@ public const string
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _healWhenNothingTodo = true;

[UI("The duration of special windows set by commands",
[UI("The duration of special windows opened by /macro commands by default.",
Filter = BasicTimer, Section = 1)]
[Range(1, 20, ConfigUnitType.Seconds, 1f)]
public float SpecialDuration { get; set; } = 3;
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ internal static IBattleChara? HostileTarget
/// <summary>
/// This one never be null.
/// </summary>
public static MajorConditionSet RightSet
public static MajorConditionValue CurrentConditionValue
{
get
{
if (ConditionSets == null || ConditionSets.Length == 0)
{
ConditionSets = new[] { new MajorConditionSet() };
ConditionSets = new[] { new MajorConditionValue() };
}

var index = Service.Config.ActionSequencerIndex;
Expand All @@ -56,7 +56,7 @@ public static MajorConditionSet RightSet
}
}

internal static MajorConditionSet[] ConditionSets { get; set; } = Array.Empty<MajorConditionSet>();
internal static MajorConditionValue[] ConditionSets { get; set; } = Array.Empty<MajorConditionValue>();

/// <summary>
/// Only recorded 15s hps.
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal static void UpdateRotationState()
(Service.Config.AutoOffBetweenArea && (Svc.Condition[ConditionFlag.BetweenAreas] || Svc.Condition[ConditionFlag.BetweenAreas51])) ||
(Service.Config.CancelStateOnCombatBeforeCountdown && Service.CountDownTime > 0.2f && DataCenter.InCombat) ||
(ActionUpdater.AutoCancelTime != DateTime.MinValue && DateTime.Now > ActionUpdater.AutoCancelTime) ||
(DataCenter.RightSet.SwitchCancelConditionSet?.IsTrue(DataCenter.CurrentRotation) ?? false))
(DataCenter.CurrentConditionValue.SwitchCancelConditionSet?.IsTrue(DataCenter.CurrentRotation) ?? false))
{
CancelState();
#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
Expand Down Expand Up @@ -235,14 +235,14 @@ internal static void UpdateRotationState()
_lastCountdownTime = 0;
CancelState();
}
else if (DataCenter.RightSet.SwitchManualConditionSet?.IsTrue(DataCenter.CurrentRotation) ?? false)
else if (DataCenter.CurrentConditionValue.SwitchManualConditionSet?.IsTrue(DataCenter.CurrentRotation) ?? false)
{
if (!DataCenter.State)
{
DoStateCommandType(StateCommandType.Manual);
}
}
else if (DataCenter.RightSet.SwitchAutoConditionSet?.IsTrue(DataCenter.CurrentRotation) ?? false)
else if (DataCenter.CurrentConditionValue.SwitchAutoConditionSet?.IsTrue(DataCenter.CurrentRotation) ?? false)
{
if (!DataCenter.State)
{
Expand Down
10 changes: 5 additions & 5 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static void UpdateSetting(string settingName, string? command)
property.SetValue(Service.Config, convertedValue);
command = convertedValue?.ToString();

if (Service.Config.ShowToggledActionInChat)
if (Service.Config.ShowToggledSettingInChat)
{
Svc.Chat.Print($"Changed setting {property.Name} to {command}");
}
Expand Down Expand Up @@ -227,14 +227,14 @@ private static Enum GetNextEnumValue(Enum currentEnumValue)

private static void ToggleActionCommand(string str)
{
foreach (var act in RotationUpdater.RightRotationActions)
foreach (var act in RotationUpdater.CurrentRotationActions)
{
if (str.StartsWith(act.Name))
{
var flag = str[act.Name.Length..].Trim();
act.IsEnabled = bool.TryParse(flag, out var parse) ? parse : !act.IsEnabled;

if (Service.Config.ShowToggledActionInChat)
if (Service.Config.ShowToggledSettingInChat)
{
Svc.Chat.Print($"Toggled {act.Name} : {act.IsEnabled}");
}
Expand All @@ -258,7 +258,7 @@ private static void DoActionCommand(string str)

if (double.TryParse(timeStr, out var time))
{
foreach (var iAct in RotationUpdater.RightRotationActions)
foreach (var iAct in RotationUpdater.CurrentRotationActions)
{
if (actName.Equals(iAct.Name, StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -288,7 +288,7 @@ private static void DoRotationCommand(ICustomRotation customCombo, string str)
{
if (config.DoCommand(configs, str))
{
if (Service.Config.ShowToggledActionInChat)
if (Service.Config.ShowToggledSettingInChat)
{
Svc.Chat.Print($"Changed setting {config.DisplayName} to {config.Value}");
return;
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static unsafe void DoStateCommandType(StateCommandType stateType, int ind
{
stateType = AdjustStateType(stateType, ref index);
}

UpdateState(stateType, role);
return stateType;
});
Expand Down Expand Up @@ -78,18 +77,23 @@ private static void UpdateState(StateCommandType stateType, JobRole role)
DataCenter.State = false;
DataCenter.IsManual = false;
ActionUpdater.NextAction = ActionUpdater.NextGCDAction = null;
if (Service.Config.ShowToggledSettingInChat) {Svc.Chat.Print($"Targeting : Off");}
break;


case StateCommandType.Auto:
DataCenter.IsManual = false;
DataCenter.State = true;
ActionUpdater.AutoCancelTime = DateTime.MinValue;
if (Service.Config.ShowToggledSettingInChat) {Svc.Chat.Print($"Auto Targeting : {Service.Config.TargetingTypes[Service.Config.TargetingIndex]}");}
break;


case StateCommandType.Manual:
DataCenter.IsManual = true;
DataCenter.State = true;
ActionUpdater.AutoCancelTime = DateTime.MinValue;
if (Service.Config.ShowToggledSettingInChat) {Svc.Chat.Print($"Targeting : Manual");}
break;
}

Expand Down
9 changes: 3 additions & 6 deletions RotationSolver/Data/UiString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace RotationSolver.Data
{
internal enum UiString
{
[Description("The condition set you chose. Click to modify.")]
[Description("The condition value you chose. Click to modify.")]
ConfigWindow_ConditionSetDesc,

[Description("Condition Set")]
[Description("Condition Value")]
ConfigWindow_ConditionSet,

[Description("Action Condition")]
Expand Down Expand Up @@ -43,9 +43,6 @@ internal enum UiString
[Description("Analyzes PvE combat information in every frame and finds the best action.")]
ConfigWindow_About_Punchline,

[Description("Game")]
ConfigWindow_Helper_GameVersion,

[Description("Invalid Rotation! \nPlease update to the latest version or contact {0}!")]
ConfigWindow_Rotation_InvalidRotation,

Expand Down Expand Up @@ -343,7 +340,7 @@ internal enum UiString
[Description("Move")]
InfoWindowMove,

[Description("Search...")]
[Description("Setting Search")]
ConfigWindow_Searching,

[Description("Timer")]
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private static void DrawAfter(this ICondition condition, ICustomRotation rotatio
private static void DrawAfter(this NamedCondition namedCondition, ICustomRotation _)
{
ImGuiHelper.SearchCombo($"##Comparation{namedCondition.GetHashCode()}", namedCondition.ConditionName, ref searchTxt,
DataCenter.RightSet.NamedConditions.Select(p => p.Name).ToArray(), i => i.ToString(), i =>
DataCenter.CurrentConditionValue.NamedConditions.Select(p => p.Name).ToArray(), i => i.ToString(), i =>
{
namedCondition.ConditionName = i;
}, UiString.ConfigWindow_Condition_ConditionName.GetDescription());
Expand Down
Loading

0 comments on commit bccdc11

Please sign in to comment.