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

Commit

Permalink
fix: add an option for the additional conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 24, 2023
1 parent 9d7434e commit 40200be
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 18 deletions.
19 changes: 11 additions & 8 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
using Dalamud.Utility;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using FFXIVClientStructs.STD;
using RotationSolver.Basic.Configuration.Conditions;
using System;

namespace RotationSolver.Basic.Configuration;

Expand Down Expand Up @@ -38,12 +35,16 @@ public int GetValue(PluginConfigInt config)

public bool GetValue(PluginConfigBool config)
{
var rotation = DataCenter.RightNowRotation;
var set = DataCenter.RightSet;
if (rotation != null && set != null)
if (config != PluginConfigBool.UseAdditionalConditions
&& GetBoolRaw(PluginConfigBool.UseAdditionalConditions))
{
if (GetEnableBoolRaw(config) && set.GetEnableCondition(config).IsTrue(rotation)) return true;
if (GetDisableBoolRaw(config) && set.GetDisableCondition(config).IsTrue(rotation)) return false;
var rotation = DataCenter.RightNowRotation;
var set = DataCenter.RightSet;
if (rotation != null && set != null)
{
if (GetEnableBoolRaw(config) && set.GetEnableCondition(config).IsTrue(rotation)) return true;
if (GetDisableBoolRaw(config) && set.GetDisableCondition(config).IsTrue(rotation)) return false;
}
}

return GetBoolRaw(config);
Expand Down Expand Up @@ -362,6 +363,8 @@ public enum PluginConfigBool : byte
[Default(true)] UseResourcesAction,
[Default(true)] SayHelloToUsers,
[Default(false)] JustSayHelloOnce,

[Default(false)] UseAdditionalConditions,
}

public enum PluginConfigFloat : byte
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal static class ConfigTranslation
_ => string.Empty,
};


public static string ToName(this JobConfigInt config) => config switch
{
JobConfigInt.AddDotGCDCount => LocalizationManager.RightLang.ConfigWindow_Param_AddDotGCDCount,
Expand Down Expand Up @@ -58,6 +57,7 @@ internal static class ConfigTranslation
PluginConfigBool.UseStopCasting => LocalizationManager.RightLang.ConfigWindow_Param_UseStopCasting,
PluginConfigBool.SayHelloToUsers => LocalizationManager.RightLang.ConfigWindow_Basic_SayHelloToUsers,
PluginConfigBool.JustSayHelloOnce => LocalizationManager.RightLang.ConfigWindow_Basic_JustSayHelloOnce,
PluginConfigBool.UseAdditionalConditions => LocalizationManager.RightLang.ConfigWindow_Basic_UseAdditionalConditions,

// UI
PluginConfigBool.HideWarning => LocalizationManager.RightLang.ConfigWindow_UI_HideWarning,
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -785,5 +785,6 @@ internal class Strings
public string ConfigWindow_Auto_BurstConditionSet { get; set; } = "Burst Forced Condition";
public string ConfigWindow_Auto_SpeedConditionSet { get; set; } = "Speed Forced Condition";
public string ConfigWindow_ConditionSetDesc { get; set; } = "The Condition set you chose, click to modify.";
public string ConfigWindow_Basic_UseAdditionalConditions { get; set; } = "Use additional conditions";

}
2 changes: 2 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ private static void DrawBasicOthers()

new CheckBoxSearchPlugin(PluginConfigBool.SayHelloToUsers),
new CheckBoxSearchPlugin(PluginConfigBool.JustSayHelloOnce),

new CheckBoxSearchPlugin(PluginConfigBool.UseAdditionalConditions),
};

private static readonly ISearchable[] _basicSwitchTurnOn = new ISearchable[]
Expand Down
18 changes: 11 additions & 7 deletions RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using RotationSolver.Basic.Configuration;
using RotationSolver.Basic.Configuration.Conditions;
using RotationSolver.Localization;
using RotationSolver.UI.SearchableConfigs;
using RotationSolver.Updaters;

namespace RotationSolver.UI.SearchableSettings;

Expand All @@ -24,13 +22,14 @@ private abstract class CheckBoxConditionAbstract : CheckBoxSearch

public override string ID => _config.ToString() + Name;

public override bool ShowInChild => Service.Config.GetValue(PluginConfigBool.UseAdditionalConditions);

public CheckBoxConditionAbstract(PluginConfigBool config) : base()
{
_config = config;
AdditionalDraw = () =>
{
GetCondition(DataCenter.Job)?.DrawMain(DataCenter.RightNowRotation);
ImGui.Separator();
};
}

Expand Down Expand Up @@ -110,15 +109,16 @@ protected override ConditionSet GetCondition(Job job)

public override string Command => _config.ToCommand();

private static readonly Action _emptyAction = () => { };
public override bool AlwaysShowChildren => Service.Config.GetValue(PluginConfigBool.UseAdditionalConditions);

public CheckBoxSearchPlugin(PluginConfigBool config, params ISearchable[] children)
:base(new ISearchable[]
:base(config == PluginConfigBool.UseAdditionalConditions ? children
:new ISearchable[]
{
new CheckBoxEnable(config), new CheckBoxDisable(config),
}.Concat(children).ToArray())
{
_config = config;
AdditionalDraw = _emptyAction;
}

protected override bool GetValue(Job job)
Expand All @@ -145,6 +145,8 @@ internal abstract class CheckBoxSearch : Searchable

public Action AdditionalDraw { get; set; } = null;

public virtual bool AlwaysShowChildren => false;

public CheckBoxSearch(params ISearchable[] children)
{
Children = children;
Expand All @@ -162,6 +164,8 @@ protected virtual void DrawChildren(Job job)
var lastIs = false;
foreach (var child in Children)
{
if (!child.ShowInChild) continue;

var thisIs = child is CheckBoxSearch c && c.Action != ActionID.None && IconSet.GetTexture(c.Action, out var texture);
if (lastIs && thisIs)
{
Expand Down Expand Up @@ -207,7 +211,7 @@ protected override void DrawMain(Job job)
}
else if (hasSub)
{
if (enable && hasChild || hasAdditional)
if (enable || AlwaysShowChildren)
{
var x = ImGui.GetCursorPosX();
var drawBody = ImGui.TreeNode(name);
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/UI/SearchableConfigs/ISearchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal interface ISearchable
CheckBoxSearch Parent { get; set; }

string SearchingKeys { get; }
bool ShowInChild { get; }

void Draw(Job job);
}
3 changes: 2 additions & 1 deletion RotationSolver/UI/SearchableConfigs/Searchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Localization;
using RotationSolver.UI.SearchableSettings;
using RotationSolver.Updaters;

namespace RotationSolver.UI.SearchableConfigs;

Expand Down Expand Up @@ -34,6 +33,8 @@ internal abstract class Searchable : ISearchable
/// </summary>
public Job[] Jobs { get; set; }

public virtual bool ShowInChild => true;

public unsafe void Draw(Job job)
{
var canDraw = true;
Expand Down

0 comments on commit 40200be

Please sign in to comment.