mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-18 05:27:43 +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";
|
public const string ResolvedName = "Random";
|
||||||
private Design? _currentDesign;
|
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 _)
|
public string ResolveName(bool _)
|
||||||
=> ResolvedName;
|
=> ResolvedName;
|
||||||
|
|
@ -40,6 +41,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
||||||
|
|
||||||
public bool Equals(IDesignStandIn? other)
|
public bool Equals(IDesignStandIn? other)
|
||||||
=> other is RandomDesign r
|
=> other is RandomDesign r
|
||||||
|
&& r.ResetOnRedraw == ResetOnRedraw
|
||||||
&& string.Equals(RandomPredicate.GeneratePredicateString(r.Predicates), RandomPredicate.GeneratePredicateString(Predicates),
|
&& string.Equals(RandomPredicate.GeneratePredicateString(r.Predicates), RandomPredicate.GeneratePredicateString(Predicates),
|
||||||
StringComparison.OrdinalIgnoreCase);
|
StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
|
@ -48,7 +50,7 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
||||||
|
|
||||||
public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication)
|
public IEnumerable<(IDesignStandIn Design, ApplicationType Flags, JobFlag Jobs)> AllLinks(bool newApplication)
|
||||||
{
|
{
|
||||||
if (newApplication)
|
if (newApplication || ResetOnRedraw)
|
||||||
_currentDesign = rng.Design(Predicates);
|
_currentDesign = rng.Design(Predicates);
|
||||||
else
|
else
|
||||||
_currentDesign ??= rng.Design(Predicates);
|
_currentDesign ??= rng.Design(Predicates);
|
||||||
|
|
@ -61,22 +63,32 @@ public class RandomDesign(RandomDesignGenerator rng) : IDesignStandIn
|
||||||
|
|
||||||
public void AddData(JObject jObj)
|
public void AddData(JObject jObj)
|
||||||
{
|
{
|
||||||
jObj["Restrictions"] = RandomPredicate.GeneratePredicateString(Predicates);
|
jObj["Restrictions"] = RandomPredicate.GeneratePredicateString(Predicates);
|
||||||
|
jObj["ResetOnRedraw"] = ResetOnRedraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ParseData(JObject jObj)
|
public void ParseData(JObject jObj)
|
||||||
{
|
{
|
||||||
var restrictions = jObj["Restrictions"]?.ToObject<string>() ?? string.Empty;
|
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)
|
public bool ChangeData(object data)
|
||||||
{
|
{
|
||||||
if (data is not List<IDesignPredicate> predicates)
|
if (data is List<IDesignPredicate> predicates)
|
||||||
return false;
|
{
|
||||||
|
Predicates = predicates;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Predicates = predicates;
|
if (data is bool resetOnRedraw)
|
||||||
return true;
|
{
|
||||||
|
ResetOnRedraw = resetOnRedraw;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ForcedRedraw
|
public bool ForcedRedraw
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ public class Glamourer : IDalamudPlugin
|
||||||
ReadOnlySpan<string> relevantPlugins =
|
ReadOnlySpan<string> relevantPlugins =
|
||||||
[
|
[
|
||||||
"Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge",
|
"Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge",
|
||||||
"LoporritSync", "GagSpeak", "RoleplayingVoiceDalamud",
|
"LoporritSync", "GagSpeak", "ProjectGagSpeak", "RoleplayingVoiceDalamud",
|
||||||
];
|
];
|
||||||
var plugins = _services.GetService<IDalamudPluginInterface>().InstalledPlugins
|
var plugins = _services.GetService<IDalamudPluginInterface>().InstalledPlugins
|
||||||
.GroupBy(p => p.InternalName)
|
.GroupBy(p => p.InternalName)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using ImGuiNET;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
using OtterGui.Raii;
|
using OtterGui.Raii;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
|
using OtterGui.Text;
|
||||||
|
|
||||||
namespace Glamourer.Gui.Tabs.AutomationTab;
|
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.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y + ImGuiHelpers.GlobalScale);
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.Dummy(Vector2.Zero);
|
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();
|
var list = random.Predicates.ToList();
|
||||||
if (list.Count == 0)
|
if (list.Count == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue