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 Jan 18, 2022
1 parent 1c64660 commit 898ea84
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion YAFC/Workspace/SummaryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct GoodDetails
}

private Project project;
private SearchQuery searchQuery;

private readonly ScrollArea scrollArea;
private readonly DataColumn<ProjectPage> goodsColumn;
Expand Down Expand Up @@ -92,6 +93,12 @@ protected void BuildSummaryTable(ImGui gui, ProjectPage page)
{
foreach (KeyValuePair<string, GoodDetails> goodInfo in allGoods)
{
if (!searchQuery.Match(goodInfo.Key))
{
Console.WriteLine("skip=" + goodInfo.Key);
continue;
}

float amountAvailable = YAFCRounding((goodInfo.Value.totalProvided > 0 ? goodInfo.Value.totalProvided : 0) + goodInfo.Value.extraProduced);
var amountNeeded = YAFCRounding((goodInfo.Value.totalProvided < 0 ? -goodInfo.Value.totalProvided : 0) + goodInfo.Value.totalNeeded);
if (model.showOnlyIssues && (Math.Abs(amountAvailable - amountNeeded) < Epsilon || amountNeeded == 0))
Expand Down Expand Up @@ -255,12 +262,19 @@ private void Recalculate(bool visualOnly)
private void SetProviderAmount(ProductionLink element, ProjectPage page, float newAmount)
{
element.RecordUndo().amount = newAmount;
// Hack force recalculate the page 9and make sure to catch the content change event caused by the recalculation)
// Hack force recalculate the page (and make sure to catch the content change event caused by the recalculation)
page.SetActive(true);
page.SetToRecalculate();
page.SetActive(false);
}

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 898ea84

Please sign in to comment.