Skip to content

Commit 0dac21f

Browse files
committed
Tooplip improvements, NEIE improvements, furnaces now can't do recipes with more than 1 input
1 parent aab2a42 commit 0dac21f

File tree

5 files changed

+38
-15
lines changed

5 files changed

+38
-15
lines changed

YAFC/Widgets/ObjectTooltip.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,25 @@ private void BuildIconRow(ImGui gui, IReadOnlyList<FactorioObject> objects, int
6161
return;
6262
}
6363

64+
var arr = new List<FactorioObject>(count);
65+
arr.AddRange(objects);
66+
arr.Sort(DataUtils.DefaultOrdering);
67+
6468
if (count <= maxRows)
6569
{
6670
for (var i = 0; i < count; i++)
67-
gui.BuildFactorioObjectButtonWithText(objects[i]);
71+
gui.BuildFactorioObjectButtonWithText(arr[i]);
6872
return;
6973
}
7074

71-
var arr = new List<FactorioObject>(count);
72-
arr.AddRange(objects);
73-
arr.Sort(DataUtils.DefaultOrdering);
74-
7575
var index = 0;
76-
var rows = Math.Min(((count-1) / itemsPerRow)+1, maxRows);
76+
if (count - 1 < (maxRows - 1) * itemsPerRow)
77+
{
78+
gui.BuildFactorioObjectButtonWithText(arr[0]);
79+
index++;
80+
}
81+
82+
var rows = Math.Min(((count-1-index) / itemsPerRow)+1, maxRows);
7783
for (var i = 0; i < rows; i++)
7884
{
7985
using (gui.EnterRow())

YAFC/Windows/NeverEnoughItemsPanel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public RecipeEntry(Recipe recipe, bool isProduction, Goods currentItem, bool atC
4747
entryStatus = EntryStatus.NotAccessibleWithCurrentMilestones;
4848
else
4949
{
50-
var waste = recipe.RecipeWaste();
50+
var waste = recipe.RecipeWaste(atCurrentMilestones);
5151
if (waste > 0.95f)
5252
entryStatus = EntryStatus.Wasteful;
5353
else if (waste > 0f)
@@ -158,7 +158,7 @@ private void DrawRecipeEntry(ImGui gui, RecipeEntry entry, bool production)
158158
var bgColor = SchemeColor.Background;
159159
var isBuilding = gui.isBuilding;
160160
var recipe = entry.recipe;
161-
var waste = recipe.RecipeWaste();
161+
var waste = recipe.RecipeWaste(atCurrentMilestones);
162162
if (isBuilding)
163163
{
164164
if (entry.entryStatus == EntryStatus.NotAccessible)
@@ -231,7 +231,7 @@ private void DrawRecipeEntry(ImGui gui, RecipeEntry entry, bool production)
231231
bgColor = SchemeColor.Secondary;
232232
else
233233
{
234-
rect.Width *= (1f - entry.recipe.RecipeWaste());
234+
rect.Width *= (1f - waste);
235235
gui.DrawRectangle(rect, SchemeColor.Secondary);
236236
}
237237
gui.DrawRectangle(gui.lastRect, bgColor);
@@ -334,7 +334,7 @@ public override void Build(ImGui gui)
334334
gui.DrawRectangle(gui.lastRect, SchemeColor.Primary);
335335
gui.BuildText("This color is estimated recipe efficiency");
336336
gui.DrawRectangle(gui.lastRect, SchemeColor.Secondary);
337-
if (gui.BuildCheckBox("Current milestones only", atCurrentMilestones, out atCurrentMilestones, allocator:RectAllocator.RightRow))
337+
if (gui.BuildCheckBox("Current milestones info", atCurrentMilestones, out atCurrentMilestones, allocator:RectAllocator.RightRow))
338338
{
339339
var item = current;
340340
current = null;
@@ -359,7 +359,7 @@ int IComparer<RecipeEntry>.Compare(RecipeEntry x, RecipeEntry y)
359359
return y.entryStatus - x.entryStatus;
360360
if (x.flow != y.flow)
361361
return y.flow.CompareTo(x.flow);
362-
return x.recipe.RecipeWaste().CompareTo(y.recipe.RecipeWaste());
362+
return x.recipe.RecipeWaste(atCurrentMilestones).CompareTo(y.recipe.RecipeWaste(atCurrentMilestones));
363363
}
364364
}
365365
}

YAFCmodel/Analysis/CostAnalysis.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ public override void Compute(Project project, ErrorCollector warnings)
315315
continue;
316316
var productCost = 0f;
317317
foreach (var product in recipe.products)
318-
productCost += product.amount * product.goods.Cost();
319-
recipeWastePercentage[recipe] = 1f - productCost / cost[recipe];
318+
productCost += product.amount * export[product.goods];
319+
recipeWastePercentage[recipe] = 1f - productCost / export[recipe];
320320
}
321321
}
322322
else

YAFCmodel/Data/DataUtils.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,24 @@ namespace YAFC.Model
1515
{
1616
public static class DataUtils
1717
{
18-
public static readonly FactorioObjectComparer<FactorioObject> DefaultOrdering = new FactorioObjectComparer<FactorioObject>((x, y) => x.Cost().CompareTo(y.Cost()));
18+
public static readonly FactorioObjectComparer<FactorioObject> DefaultOrdering = new FactorioObjectComparer<FactorioObject>((x, y) =>
19+
{
20+
var yflow = y.ApproximateFlow();
21+
var xflow = x.ApproximateFlow();
22+
if (xflow != yflow)
23+
return xflow.CompareTo(yflow);
24+
25+
var rx = x as Recipe;
26+
var ry = y as Recipe;
27+
if (rx != null || ry != null)
28+
{
29+
var xwaste = rx?.RecipeWaste() ?? 0;
30+
var ywaste = ry?.RecipeWaste() ?? 0;
31+
return xwaste.CompareTo(ywaste);
32+
}
33+
34+
return y.Cost().CompareTo(x.Cost());
35+
});
1936
public static readonly FactorioObjectComparer<Goods> FuelOrdering = new FactorioObjectComparer<Goods>((x, y) =>
2037
{
2138
if (x.fuelValue <= 0f && y.fuelValue <= 0f)

YAFCparser/Data/FactorioDataDeserializer_Entity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private void DeserializeEntity(LuaTable table)
225225
ParseModules(table, entity);
226226
entity.power = ParseEnergy(usesPower);
227227
entity.craftingSpeed = table.Get("crafting_speed", 1f);
228-
entity.itemInputs = table.Get("ingredient_count", 255);
228+
entity.itemInputs = entity.factorioType == "furnace" ? table.Get("source_inventory_size", 1) : table.Get("ingredient_count", 255);
229229
if (table.Get("fluid_boxes", out LuaTable fluidBoxes))
230230
entity.fluidInputs = CountFluidBoxes(fluidBoxes, true);
231231
Recipe fixedRecipe = null;

0 commit comments

Comments
 (0)