Skip to content

Commit

Permalink
Support the search box (ctrl+F)
Browse files Browse the repository at this point in the history
  • Loading branch information
veger committed Nov 24, 2022
1 parent 82e191a commit 7bb0da7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions YAFC/Workspace/SummaryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public override void BuildElement(ImGui gui, ProjectPage page)
using var grid = gui.EnterInlineGrid(ElementWidth, ElementSpacing);
foreach (KeyValuePair<string, GoodDetails> goodInfo in view.allGoods)
{
if (!view.searchQuery.Match(goodInfo.Key))
{
continue;
}

float amountAvailable = YAFCRounding((goodInfo.Value.totalProvided > 0 ? goodInfo.Value.totalProvided : 0) + goodInfo.Value.extraProduced);
float amountNeeded = YAFCRounding((goodInfo.Value.totalProvided < 0 ? -goodInfo.Value.totalProvided : 0) + goodInfo.Value.totalNeeded);
if (view.model.showOnlyIssues && (Math.Abs(amountAvailable - amountNeeded) < Epsilon || amountNeeded == 0))
Expand Down Expand Up @@ -127,6 +132,7 @@ struct GoodDetails
}

private Project project;
private SearchQuery searchQuery;

private readonly ScrollArea scrollArea;
private readonly SummaryDataColumn goodsColumn;
Expand Down Expand Up @@ -279,6 +285,13 @@ static private float YAFCRounding(float value)
return result;
}

public override void SetSearchQuery(SearchQuery query)
{
searchQuery = query;
bodyContent.Rebuild();
scrollArea.Rebuild();
}

public override void CreateModelDropdown(ImGui gui, Type type, Project project)
{
}
Expand Down

0 comments on commit 7bb0da7

Please # to comment.