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 Feb 15, 2024
1 parent 4a6016a commit 14bca05
Show file tree
Hide file tree
Showing 2 changed files with 14 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
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Date: soon(tm)
- Add summary view
- Checkbox to show only goods with 'issues': different consuming/producing amounts
- Balance producing side to match the consuming when clicking an 'issue'
- Support the search box (ctrl+F)
- other minor fixes
----------------------------------------------------------------------------------------------------------------------

0 comments on commit 14bca05

Please # to comment.