mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Add option to always reset random designs.
This commit is contained in:
parent
b90e68fbaf
commit
f3eb542940
3 changed files with 27 additions and 9 deletions
|
|
@ -12,7 +12,8 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
|||
public const string ResolvedName = "Random";
|
||||
private Design? _currentDesign;
|
||||
|
||||
public IReadOnlyList<IDesignPredicate> Predicates { get; private set; } = [];
|
||||
public IReadOnlyList<IDesignPredicate> Predicates { get; private set; } = [];
|
||||
public bool ResetOnRedraw { get; set; } = false;
|
||||
|
||||
public string ResolveName(bool _)
|
||||
=> ResolvedName;
|
||||
|
|
@ -40,6 +41,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
|||
|
||||
public bool Equals(IDesignStandIn? other)
|
||||
=> other is RandomDesign r
|
||||
&& r.ResetOnRedraw == ResetOnRedraw
|
||||
&& string.Equals(RandomPredicate.GeneratePredicateString(r.Predicates), RandomPredicate.GeneratePredicateString(Predicates),
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
|
|
@ -48,7 +50,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
|||
|
||||
public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication)
|
||||
{
|
||||
if (newApplication)
|
||||
if (newApplication || ResetOnRedraw)
|
||||
_currentDesign = rng.Design(Predicates);
|
||||
else
|
||||
_currentDesign ??= rng.Design(Predicates);
|
||||
|
|
@ -61,22 +63,32 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
|||
|
||||
public void AddData(JObject jObj)
|
||||
{
|
||||
jObj["Restrictions"] = RandomPredicate.GeneratePredicateString(Predicates);
|
||||
jObj["Restrictions"] = RandomPredicate.GeneratePredicateString(Predicates);
|
||||
jObj["ResetOnRedraw"] = ResetOnRedraw;
|
||||
}
|
||||
|
||||
public void ParseData(JObject jObj)
|
||||
{
|
||||
var restrictions = jObj["Restrictions"]?.ToObject<string>() ?? string.Empty;
|
||||
Predicates = RandomPredicate.GeneratePredicates(restrictions);
|
||||
Predicates = RandomPredicate.GeneratePredicates(restrictions);
|
||||
ResetOnRedraw = jObj["ResetOnRedraw"]?.ToObject<bool>() ?? false;
|
||||
}
|
||||
|
||||
public bool ChangeData(object data)
|
||||
{
|
||||
if (data is not List<IDesignPredicate> predicates)
|
||||
return false;
|
||||
if (data is List<IDesignPredicate> predicates)
|
||||
{
|
||||
Predicates = predicates;
|
||||
return true;
|
||||
}
|
||||
|
||||
Predicates = predicates;
|
||||
return true;
|
||||
if (data is bool resetOnRedraw)
|
||||
{
|
||||
ResetOnRedraw = resetOnRedraw;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ForcedRedraw
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ public class Glamourer : IDalamudPlugin
|
|||
ReadOnlySpan<string> relevantPlugins =
|
||||
[
|
||||
"Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge",
|
||||
"LoporritSync", "GagSpeak", "RoleplayingVoiceDalamud",
|
||||
"LoporritSync", "GagSpeak", "ProjectGagSpeak", "RoleplayingVoiceDalamud",
|
||||
];
|
||||
var plugins = _services.GetService<IDalamudPluginInterface>().InstalledPlugins
|
||||
.GroupBy(p => p.InternalName)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using ImGuiNET;
|
|||
using OtterGui;
|
||||
using OtterGui.Raii;
|
||||
using OtterGui.Services;
|
||||
using OtterGui.Text;
|
||||
|
||||
namespace Glamourer.Gui.Tabs.AutomationTab;
|
||||
|
||||
|
|
@ -385,6 +386,11 @@ public sealed class RandomRestrictionDrawer : IService, IDisposable
|
|||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y + ImGuiHelpers.GlobalScale);
|
||||
ImGui.Separator();
|
||||
ImGui.Dummy(Vector2.Zero);
|
||||
var reset = random.ResetOnRedraw;
|
||||
if (ImUtf8.Checkbox("Reset Chosen Design On Every Redraw"u8, ref reset))
|
||||
_autoDesignManager.ChangeData(_set!, _designIndex, reset);
|
||||
ImGui.Separator();
|
||||
ImGui.Dummy(Vector2.Zero);
|
||||
|
||||
var list = random.Predicates.ToList();
|
||||
if (list.Count == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue