muffin v7.5.12
This commit is contained in:
parent
3102923ce2
commit
911ed68baa
65 changed files with 2356 additions and 1539 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
|
@ -18,6 +19,8 @@ namespace Questionable.Windows.ConfigComponents;
|
|||
|
||||
internal sealed class BlacklistConfigComponent : ConfigComponent
|
||||
{
|
||||
private const string ClipboardPrefix = "qst:blacklist:";
|
||||
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
|
||||
private readonly QuestSelector _questSelector;
|
||||
|
|
@ -152,14 +155,62 @@ internal sealed class BlacklistConfigComponent : ConfigComponent
|
|||
}
|
||||
}
|
||||
_questSelector.DrawSelection();
|
||||
if (blacklistedQuests.Count > 0 && UiThemeUtils.DestructiveButton(FontAwesomeIcon.Trash, "Clear all"))
|
||||
DrawClipboardButtons(blacklistedQuests);
|
||||
if (blacklistedQuests.Count > 0)
|
||||
{
|
||||
base.Configuration.General.BlacklistedQuests.Clear();
|
||||
Save();
|
||||
ImGui.SameLine();
|
||||
if (UiThemeUtils.DestructiveButton(FontAwesomeIcon.Trash, "Clear all"))
|
||||
{
|
||||
base.Configuration.General.BlacklistedQuests.Clear();
|
||||
Save();
|
||||
}
|
||||
}
|
||||
UiThemeUtils.EndCard(contentStartPos, availableWidth, drawList);
|
||||
}
|
||||
|
||||
private void DrawClipboardButtons(HashSet<ElementId> blacklistedQuests)
|
||||
{
|
||||
using (ImRaii.Disabled(blacklistedQuests.Count == 0))
|
||||
{
|
||||
if (UiThemeUtils.IconTextButton(FontAwesomeIcon.Copy, "Copy"))
|
||||
{
|
||||
string s = string.Join(";", from x in blacklistedQuests
|
||||
orderby x.ToString()
|
||||
select x.ToString());
|
||||
ImGui.SetClipboardText("qst:blacklist:" + Convert.ToBase64String(Encoding.UTF8.GetBytes(s)));
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
string text = ThrottledClipboard.GetText();
|
||||
using (ImRaii.Disabled(!text.StartsWith("qst:blacklist:", StringComparison.InvariantCulture)))
|
||||
{
|
||||
if (UiThemeUtils.IconTextButton(FontAwesomeIcon.Paste, "Paste"))
|
||||
{
|
||||
ImportBlacklistedQuests(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportBlacklistedQuests(string clipboardText)
|
||||
{
|
||||
try
|
||||
{
|
||||
string s = clipboardText.Substring("qst:blacklist:".Length);
|
||||
int skippedCount;
|
||||
List<ElementId> list = ElementId.FromStrings(Encoding.UTF8.GetString(Convert.FromBase64String(s)).Split(";", StringSplitOptions.RemoveEmptyEntries), out skippedCount);
|
||||
if (list.Count != 0)
|
||||
{
|
||||
base.Configuration.General.BlacklistedQuests.Clear();
|
||||
base.Configuration.General.BlacklistedQuests.UnionWith(list);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_logger.LogDebug(exception, "Failed to import blacklisted quests from clipboard");
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCurrentlyAcceptedQuests()
|
||||
{
|
||||
List<Quest> currentlyAcceptedQuests = GetCurrentlyAcceptedQuests();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
|
@ -15,12 +14,9 @@ internal sealed class DebugConfigComponent : ConfigComponent
|
|||
{
|
||||
private readonly Dictionary<string, bool> _featurePausingOpenState = new Dictionary<string, bool>();
|
||||
|
||||
private readonly string? _cacheDirectory;
|
||||
|
||||
public DebugConfigComponent(IDalamudPluginInterface pluginInterface, Configuration configuration)
|
||||
: base(pluginInterface, configuration)
|
||||
{
|
||||
_cacheDirectory = pluginInterface.ConfigDirectory.FullName;
|
||||
}
|
||||
|
||||
public override void DrawTab()
|
||||
|
|
@ -61,45 +57,8 @@ internal sealed class DebugConfigComponent : ConfigComponent
|
|||
}
|
||||
UiThemeUtils.EndCard(item4, item5, item6);
|
||||
UiThemeUtils.SectionSpacing();
|
||||
UiThemeUtils.SectionHeader("Data Cache");
|
||||
var (contentStartPos, availableWidth, drawList) = UiThemeUtils.BeginCard();
|
||||
UiThemeUtils.WrappedText("NPC position and zone boundary caches are rebuilt automatically after game patches. Use this button to force a rebuild on next load.");
|
||||
bool flag = _cacheDirectory != null && (File.Exists(Path.Combine(_cacheDirectory, "npc-position-cache.bin")) || File.Exists(Path.Combine(_cacheDirectory, "zone-boundary-cache.bin")));
|
||||
long num = 0L;
|
||||
if (_cacheDirectory != null)
|
||||
{
|
||||
num += FileSize(Path.Combine(_cacheDirectory, "npc-position-cache.bin"));
|
||||
num += FileSize(Path.Combine(_cacheDirectory, "zone-boundary-cache.bin"));
|
||||
}
|
||||
using (ImRaii.Disabled(!flag))
|
||||
{
|
||||
if (ImGui.Button("Clear LGB Caches") && _cacheDirectory != null)
|
||||
{
|
||||
TryDelete(Path.Combine(_cacheDirectory, "npc-position-cache.bin"));
|
||||
TryDelete(Path.Combine(_cacheDirectory, "zone-boundary-cache.bin"));
|
||||
}
|
||||
if (flag && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
{
|
||||
ImU8String tooltip = new ImU8String(20, 1);
|
||||
tooltip.AppendLiteral("Current cache size: ");
|
||||
tooltip.AppendFormatted(FormatBytes(num));
|
||||
ImGui.SetTooltip(tooltip);
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextDisabled("(no cache files present)");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextDisabled("Takes effect on next plugin load.");
|
||||
}
|
||||
UiThemeUtils.EndCard(contentStartPos, availableWidth, drawList);
|
||||
UiThemeUtils.SectionSpacing();
|
||||
UiThemeUtils.SectionHeader("Danger Zone");
|
||||
var (contentStartPos2, availableWidth2, drawList2) = UiThemeUtils.BeginCard();
|
||||
var (contentStartPos, availableWidth, drawList) = UiThemeUtils.BeginCard();
|
||||
UiThemeUtils.WrappedTextColored(UiThemeUtils.StatusLocked, "Enabling any option below may cause unexpected behavior. Use at your own risk.");
|
||||
bool value4 = base.Configuration.Advanced.DisablePartyWatchdog;
|
||||
if (UiThemeUtils.WrappedCheckbox("Disable Party Watchdog", ref value4, "The Party Watchdog stops Questionable when entering certain zones with other party members, or when entering unsupported content. Disabling this allows Questionable to continue working while in a party, but may cause unexpected behavior in group content."))
|
||||
|
|
@ -109,7 +68,7 @@ internal sealed class DebugConfigComponent : ConfigComponent
|
|||
}
|
||||
DrawFeaturePausingSection("Pandora's Box Feature Pausing", PandorasBoxIpc.ConflictingFeatures, "Auto Active Time Maneuver", "Only applies when Auto-Solve QTE is enabled.", base.Configuration.Advanced.PandoraFeatureExclusions);
|
||||
DrawFeaturePausingSection("Bundle of Tweaks Feature Pausing", AutomatonIpc.ConflictingTweaks, "AutoSnipeQuests", "Only applies when AutoSnipe is enabled.", base.Configuration.Advanced.AutomatonTweakExclusions);
|
||||
UiThemeUtils.EndCard(contentStartPos2, availableWidth2, drawList2);
|
||||
UiThemeUtils.EndCard(contentStartPos, availableWidth, drawList);
|
||||
}
|
||||
|
||||
private void DrawFeaturePausingSection(string header, ImmutableHashSet<string> features, string conditionalFeature, string conditionalHelpText, HashSet<string> exclusions)
|
||||
|
|
@ -164,51 +123,4 @@ internal sealed class DebugConfigComponent : ConfigComponent
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void TryDelete(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static long FileSize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(path);
|
||||
long result;
|
||||
if (fileInfo != null && fileInfo.Exists)
|
||||
{
|
||||
long length = fileInfo.Length;
|
||||
result = length;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0L;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatBytes(long bytes)
|
||||
{
|
||||
if (bytes < 1048576)
|
||||
{
|
||||
if (bytes >= 1024)
|
||||
{
|
||||
return $"{(double)bytes / 1024.0:F1} KB";
|
||||
}
|
||||
return $"{bytes} B";
|
||||
}
|
||||
return $"{(double)bytes / 1048576.0:F1} MB";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ internal sealed class GeneralConfigComponent : ConfigComponent
|
|||
{
|
||||
UiThemeUtils.SectionHeader("Reward redemption");
|
||||
var (contentStartPos, availableWidth, drawList) = UiThemeUtils.BeginCard();
|
||||
ImGui.TextWrapped("Quest-reward items in your inventory are used automatically when you accept a quest. Choose which types to redeem.");
|
||||
ImGui.TextWrapped("Quest-reward items in your inventory are used automatically after quest completion and when you accept a quest. Choose which types to redeem.");
|
||||
ImGui.Spacing();
|
||||
UiThemeUtils.GridCheckbox[] array = new UiThemeUtils.GridCheckbox[RewardTypeOptions.Length];
|
||||
for (int i = 0; i < RewardTypeOptions.Length; i++)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Questionable.Controller;
|
||||
using Questionable.Controller.Conditions;
|
||||
using Questionable.Data;
|
||||
|
|
@ -21,6 +24,8 @@ namespace Questionable.Windows.ConfigComponents;
|
|||
|
||||
internal sealed class StopConditionComponent : ConfigComponent
|
||||
{
|
||||
private const string ClipboardPrefix = "qst:stop:";
|
||||
|
||||
private static readonly string[] ConditionModeNames = new string[2] { "Pause", "Stop" };
|
||||
|
||||
private static readonly string[] ConditionTypeNames = new string[7] { "Quest Complete", "Quest Accept", "Level", "Global Sequence", "Inventory Full", "Before Duty", "Gil Threshold" };
|
||||
|
|
@ -59,6 +64,8 @@ internal sealed class StopConditionComponent : ConfigComponent
|
|||
|
||||
private long _acceptedQuestsRefreshAtMs;
|
||||
|
||||
private StopCondition? _draggedCondition;
|
||||
|
||||
public StopConditionComponent(IDalamudPluginInterface pluginInterface, QuestSelector questSelector, QuestFunctions questFunctions, QuestRegistry questRegistry, QuestData questData, QuestTooltipComponent questTooltipComponent, UiUtils uiUtils, IObjectTable objectTable, QuestController questController, Configuration configuration, ILogger<StopConditionComponent> logger)
|
||||
: base(pluginInterface, configuration)
|
||||
{
|
||||
|
|
@ -131,31 +138,120 @@ internal sealed class StopConditionComponent : ConfigComponent
|
|||
private void DrawConditionsList()
|
||||
{
|
||||
List<StopCondition> conditions = base.Configuration.Stop.Conditions;
|
||||
DrawClipboardButtons(conditions);
|
||||
if (conditions.Count == 0)
|
||||
{
|
||||
ImGui.TextDisabled("No conditions configured.");
|
||||
return;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (UiThemeUtils.DestructiveButton(FontAwesomeIcon.Trash, "Clear all"))
|
||||
{
|
||||
conditions.Clear();
|
||||
Save();
|
||||
}
|
||||
int? indexToRemove = null;
|
||||
StopCondition stopCondition = null;
|
||||
int index = 0;
|
||||
float x = ImGui.GetContentRegionAvail().X;
|
||||
List<(Vector2, Vector2)> list = new List<(Vector2, Vector2)>();
|
||||
for (int i = 0; i < conditions.Count; i++)
|
||||
{
|
||||
Vector2 item = ImGui.GetCursorScreenPos() + new Vector2(0f, (0f - ImGui.GetStyle().ItemSpacing.Y) / 2f);
|
||||
using (ImRaii.PushId(i))
|
||||
{
|
||||
StopCondition condition = conditions[i];
|
||||
DrawConditionRow(condition, i, ref indexToRemove);
|
||||
StopCondition stopCondition2 = conditions[i];
|
||||
if (conditions.Count > 1)
|
||||
{
|
||||
ImGuiComponents.IconButton("##Move", FontAwesomeIcon.Bars);
|
||||
if (_draggedCondition == null && ImGui.IsItemActive() && ImGui.IsMouseDragging(ImGuiMouseButton.Left))
|
||||
{
|
||||
_draggedCondition = stopCondition2;
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("Drag to reorder");
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
DrawConditionRow(stopCondition2, i, ref indexToRemove);
|
||||
Vector2 item2 = new Vector2(item.X + x, ImGui.GetCursorScreenPos().Y - ImGui.GetStyle().ItemSpacing.Y + 2f);
|
||||
list.Add((item, item2));
|
||||
}
|
||||
}
|
||||
if (!ImGui.IsMouseDragging(ImGuiMouseButton.Left))
|
||||
{
|
||||
_draggedCondition = null;
|
||||
}
|
||||
else if (_draggedCondition != null)
|
||||
{
|
||||
int num = conditions.IndexOf(_draggedCondition);
|
||||
if (num >= 0)
|
||||
{
|
||||
var (pMin, pMax) = list[num];
|
||||
ImGui.GetWindowDrawList().AddRect(pMin, pMax, ImGui.ColorConvertFloat4ToU32(UiThemeUtils.CardBorderHighColor), 3f, ImDrawFlags.RoundCornersAll);
|
||||
int num2 = list.FindIndex(((Vector2 TopLeft, Vector2 BottomRight) tuple2) => ImGui.IsMouseHoveringRect(tuple2.TopLeft, tuple2.BottomRight, clip: true));
|
||||
if (num2 >= 0 && num != num2)
|
||||
{
|
||||
stopCondition = _draggedCondition;
|
||||
index = num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (indexToRemove.HasValue)
|
||||
{
|
||||
int valueOrDefault = indexToRemove.GetValueOrDefault();
|
||||
conditions.RemoveAt(valueOrDefault);
|
||||
_draggedCondition = null;
|
||||
Save();
|
||||
}
|
||||
else if (stopCondition != null)
|
||||
{
|
||||
conditions.Remove(stopCondition);
|
||||
conditions.Insert(index, stopCondition);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawClipboardButtons(List<StopCondition> conditions)
|
||||
{
|
||||
using (ImRaii.Disabled(conditions.Count == 0))
|
||||
{
|
||||
if (UiThemeUtils.IconTextButton(FontAwesomeIcon.Copy, "Copy"))
|
||||
{
|
||||
string s = JsonConvert.SerializeObject(conditions);
|
||||
ImGui.SetClipboardText("qst:stop:" + Convert.ToBase64String(Encoding.UTF8.GetBytes(s)));
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
string text = ThrottledClipboard.GetText();
|
||||
using (ImRaii.Disabled(!text.StartsWith("qst:stop:", StringComparison.InvariantCulture)))
|
||||
{
|
||||
if (UiThemeUtils.IconTextButton(FontAwesomeIcon.Paste, "Paste"))
|
||||
{
|
||||
ImportConditions(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportConditions(string clipboardText)
|
||||
{
|
||||
try
|
||||
{
|
||||
string s = clipboardText.Substring("qst:stop:".Length);
|
||||
List<StopCondition> list = JsonConvert.DeserializeObject<List<StopCondition>>(Encoding.UTF8.GetString(Convert.FromBase64String(s))) ?? new List<StopCondition>();
|
||||
list.RemoveAll((StopCondition x) => x?.IsSession ?? true);
|
||||
if (list.Count != 0)
|
||||
{
|
||||
base.Configuration.Stop.Conditions.Clear();
|
||||
base.Configuration.Stop.Conditions.AddRange(list);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_logger.LogDebug(exception, "Failed to import stop conditions from clipboard");
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawConditionRow(StopCondition condition, int index, ref int? indexToRemove)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue