Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CraftingMenu/CraftingSequenceMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private static void DrawCurrencyAndAutoSuccessSection(CraftingStepInput step)
var currencyItem = step.CurrencyItem;
var availableWidth = ImGui.GetContentRegionAvail().X * 0.75f;
ImGui.SetNextItemWidth(availableWidth);
if (ImGui.InputTextWithHint("Currency Item", "Case Sensitive Currency BaseName \"Orb of Transmutation\"...", ref currencyItem, 100_000))
if (ImGui.InputTextWithHint("Currency Item", "Case Sensitive Currency BaseName \"Orb of Transmutation\"...", ref currencyItem, 2_000))
step.CurrencyItem = currencyItem;

var autoSuccess = step.AutomaticSuccess;
Expand Down Expand Up @@ -383,7 +383,7 @@ private static void DrawBranchEditor(CraftingStepInput step, CraftingStepBranchI
{
using (new ErrorStyling())
{
if (ImGui.InputTextWithHint("##conditionName", "Branch Name", ref branchName, 100_000))
if (ImGui.InputTextWithHint("##conditionName", "Branch Name", ref branchName, 2_000))
step.Branches[branchIndex].ConditionalGroups[0].Conditionals[0].Name = branchName;
}

Expand All @@ -396,7 +396,7 @@ private static void DrawBranchEditor(CraftingStepInput step, CraftingStepBranchI
}
else
{
if (ImGui.InputTextWithHint("##conditionName", "Branch Name", ref branchName, 100_000))
if (ImGui.InputTextWithHint("##conditionName", "Branch Name", ref branchName, 2_000))
step.Branches[branchIndex].ConditionalGroups[0].Conditionals[0].Name = branchName;
}

Expand Down Expand Up @@ -640,7 +640,7 @@ private static void DrawConditionalChecks(CraftingStepInput step, int stepIndex,
{
var availableWidth = ImGui.GetContentRegionAvail().X * 0.75f;
ImGui.SetNextItemWidth(availableWidth);
if (ImGui.InputTextWithHint("##conditionName", "Name of condition...", ref checkKey, 100_000))
if (ImGui.InputTextWithHint("##conditionName", "Name of condition...", ref checkKey, 2_000))
step.ConditionalGroups[groupIndex].Conditionals[conditionalIndex].Name = checkKey;
}

Expand All @@ -655,7 +655,7 @@ private static void DrawConditionalChecks(CraftingStepInput step, int stepIndex,
{
var availableWidth = ImGui.GetContentRegionAvail().X * 0.75f;
ImGui.SetNextItemWidth(availableWidth);
if (ImGui.InputTextWithHint("##conditionName", "Name of condition...", ref checkKey, 100_000))
if (ImGui.InputTextWithHint("##conditionName", "Name of condition...", ref checkKey, 2_000))
step.ConditionalGroups[groupIndex].Conditionals[conditionalIndex].Name = checkKey;
}

Expand Down Expand Up @@ -1233,7 +1233,7 @@ private static void DrawFileOptions()
return;

ImGui.Indent();
ImGui.InputTextWithHint("##SaveAs", "File Path...", ref _fileSaveName, 100_000);
ImGui.InputTextWithHint("##SaveAs", "File Path...", ref _fileSaveName, 2_000);
ImGui.SameLine();

if (ImGui.Button("Save To File"))
Expand Down Expand Up @@ -1342,7 +1342,7 @@ private static void DrawImportSettings()
LoadCoEDataData();
}

ImGui.InputTextWithHint("##CoEImport", "Craft of Exile Export String..", ref _coeImportData, 10_000_000);
ImGui.InputTextWithHint("##CoEImport", "Craft of Exile Export String..", ref _coeImportData, 500_000);
ImGui.SameLine();
if (ImGui.Button("Import CoE Data"))
{
Expand Down
38 changes: 33 additions & 5 deletions WheresMyCraftAtSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ public class RunOptions
public CustomNode InventorySectionSelector { get; }
public int[,] InventoryCraftingSlots { get; set; } = new int[5, 12];

// The filter highlight used to be evaluated per slot per frame, which rebuilds an
// ItemData for every item every frame (~1.4ms each, ~84ms/frame with a full bag).
// Cache the matches and refresh at most every 200ms, or when the query text changes.
[JsonIgnore]
private readonly bool[,] _filterMatchCache = new bool[5, 12];

[JsonIgnore]
private readonly System.Diagnostics.Stopwatch _filterCacheAge = System.Diagnostics.Stopwatch.StartNew();

[JsonIgnore]
private string _filterCacheKey = null;

public RunOptions(StylingDooDads Styling)
{
ToggleAll.OnPressed = () =>
Expand Down Expand Up @@ -109,7 +121,26 @@ public RunOptions(StylingDooDads Styling)
filter = new ItemFilter([query]);
}
}


var cacheKey = ApplyFilter ? InventoryFilter.Value ?? "" : null;
if (_filterCacheKey != cacheKey || _filterCacheAge.ElapsedMilliseconds > 200)
{
_filterCacheKey = cacheKey;
_filterCacheAge.Restart();
Array.Clear(_filterMatchCache, 0, _filterMatchCache.Length);

if (filter != null)
{
foreach (var invItem in itemsInInventory)
{
if (invItem.PosX is >= 0 and < 12 && invItem.PosY is >= 0 and < 5)
{
_filterMatchCache[invItem.PosY, invItem.PosX] =
FilterHandler.IsItemMatchingCondition(invItem.Item, filter);
}
}
}
}

var numb = 1;
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 1));
Expand All @@ -122,10 +153,7 @@ public RunOptions(StylingDooDads Styling)
var isValidItemInSlot = itemsInInventory.Any(item => item.PosX == col && item.PosY == row);
if (isValidItemInSlot && Styling.CustomMenuStyling)
{
var isFiltered = ApplyFilter &&
filter != null &&
InventoryHandler.TryGetInventoryItemFromSlot(new Vector2(col, row), out var item) &&
FilterHandler.IsItemMatchingCondition(item.Item, filter);
var isFiltered = ApplyFilter && _filterMatchCache[row, col];
ImGui.PushStyleColor(ImGuiCol.FrameBg,
isFiltered ? Styling.InventoryVisualizer.Filtered.Value.ToImgui() : Styling.InventoryVisualizer.BackgroundNormal.Value.ToImgui());
ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, Styling.InventoryVisualizer.BackgroundHovered.Value.ToImgui());
Expand Down