Skip to content

Commit c1e5bea

Browse files
committed
Added availability selection for quality under settings. Updated presets to include both 2.0 (default) and SA
1 parent 4a5aae9 commit c1e5bea

10 files changed

+1684
-1639
lines changed

Foreman/Foreman.csproj

+9
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@
385385
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
386386
</None>
387387
<None Include="packages.config" />
388+
<None Include="Presets\Factorio 2.0 Space Age.dat">
389+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
390+
</None>
391+
<None Include="Presets\Factorio 2.0 Space Age.json">
392+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
393+
</None>
394+
<None Include="Presets\Factorio 2.0 Space Age.pjson">
395+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
396+
</None>
388397
<None Include="Presets\Factorio 2.0 Vanilla.dat">
389398
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
390399
</None>

Foreman/Forms/MainForm.cs

+5
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ private async void SettingsButton_Click(object sender, EventArgs e)
378378
options.EnabledObjects.UnionWith(GraphViewer.DCache.Assemblers.Values.Where(r => r.Enabled));
379379
options.EnabledObjects.UnionWith(GraphViewer.DCache.Beacons.Values.Where(r => r.Enabled));
380380
options.EnabledObjects.UnionWith(GraphViewer.DCache.Modules.Values.Where(r => r.Enabled));
381+
options.EnabledObjects.UnionWith(GraphViewer.DCache.Qualities.Values.Where(r => r.Enabled));
381382

382383
using (SettingsForm form = new SettingsForm(options))
383384
{
@@ -405,6 +406,9 @@ private async void SettingsButton_Click(object sender, EventArgs e)
405406
beacon.Enabled = options.EnabledObjects.Contains(beacon);
406407
foreach (Module module in GraphViewer.DCache.Modules.Values)
407408
module.Enabled = options.EnabledObjects.Contains(module);
409+
foreach (Quality quality in GraphViewer.DCache.Qualities.Values)
410+
quality.Enabled = options.EnabledObjects.Contains(quality);
411+
GraphViewer.DCache.DefaultQuality.Enabled = true;
408412
GraphViewer.DCache.RocketAssembler.Enabled = GraphViewer.DCache.Assemblers["rocket-silo"]?.Enabled?? false;
409413
}
410414

@@ -459,6 +463,7 @@ private async void SettingsButton_Click(object sender, EventArgs e)
459463
Properties.Settings.Default.ShowUnavailable = options.DEV_ShowUnavailableItems;
460464
Properties.Settings.Default.Save();
461465

466+
GraphViewer.Graph.UpdateNodeMaxQualities();
462467
GraphViewer.Graph.UpdateNodeStates(true);
463468
GraphViewer.Graph.UpdateNodeValues();
464469

Foreman/Forms/SettingsForm.Designer.cs

+1,622-1,572
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Foreman/Forms/SettingsForm.cs

+29-3
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ public SettingsFormOptions(DataCache cache)
7070
private List<ListViewItem> unfilteredBeaconList;
7171
private List<ListViewItem> unfilteredModuleList;
7272
private List<ListViewItem> unfilteredRecipeList;
73+
private List<ListViewItem> unfilteredQualityList;
7374

7475
private List<ListViewItem> filteredAssemblerList;
7576
private List<ListViewItem> filteredMinerList;
7677
private List<ListViewItem> filteredPowerList;
7778
private List<ListViewItem> filteredBeaconList;
7879
private List<ListViewItem> filteredModuleList;
7980
private List<ListViewItem> filteredRecipeList;
81+
private List<ListViewItem> filteredQualityList;
8082

8183
private MouseHoverDetector mhDetector;
8284

@@ -89,25 +91,29 @@ public SettingsForm(SettingsFormOptions options)
8991
MainForm.SetDoubleBuffered(MinerListView);
9092
MainForm.SetDoubleBuffered(ModuleListView);
9193
MainForm.SetDoubleBuffered(RecipeListView);
94+
MainForm.SetDoubleBuffered(QualityListView);
9295

9396
AssemblerListView.Columns[0].Width = AssemblerListView.Width - 32;
9497
MinerListView.Columns[0].Width = MinerListView.Width - 32;
9598
ModuleListView.Columns[0].Width = ModuleListView.Width - 32;
9699
RecipeListView.Columns[0].Width = RecipeListView.Width - 32;
100+
QualityListView.Columns[0].Width = QualityListView.Width - 32;
97101

98102
unfilteredAssemblerList = new List<ListViewItem>();
99103
unfilteredMinerList = new List<ListViewItem>();
100104
unfilteredPowerList = new List<ListViewItem>();
101105
unfilteredBeaconList = new List<ListViewItem>();
102106
unfilteredModuleList = new List<ListViewItem>();
103107
unfilteredRecipeList = new List<ListViewItem>();
108+
unfilteredQualityList = new List<ListViewItem>();
104109

105110
filteredAssemblerList = new List<ListViewItem>();
106111
filteredMinerList = new List<ListViewItem>();
107112
filteredPowerList = new List<ListViewItem>();
108113
filteredBeaconList = new List<ListViewItem>();
109114
filteredModuleList = new List<ListViewItem>();
110115
filteredRecipeList = new List<ListViewItem>();
116+
filteredQualityList = new List<ListViewItem>();
111117

112118
SelectPresetMenuItem.Click += SelectPresetMenuItem_Click;
113119
DeletePresetMenuItem.Click += DeletePresetMenuItem_Click;
@@ -198,6 +204,7 @@ private void UpdateModList()
198204
}
199205
RecipeDifficultyLabel.Text = presetInfo.ExpensiveRecipes ? "Expensive" : "Normal";
200206
TechnologyDifficultyLabel.Text = presetInfo.ExpensiveTechnology ? "Expensive" : "Normal";
207+
201208
}
202209

203210
private void LoadUnfilteredLists()
@@ -211,13 +218,20 @@ private void LoadUnfilteredLists()
211218
LoadUnfilteredList(Options.DCache.Beacons.Values, unfilteredBeaconList);
212219
LoadUnfilteredList(Options.DCache.Modules.Values, unfilteredModuleList);
213220
LoadUnfilteredList(Options.DCache.Recipes.Values, unfilteredRecipeList);
221+
LoadUnfilteredList(Options.DCache.Qualities.Values, unfilteredQualityList);
214222

215223
UpdateFilteredLists();
216224
}
217225

218226
private void LoadUnfilteredList(IEnumerable<DataObjectBase> origin, List<ListViewItem> lviList)
219227
{
220-
foreach (DataObjectBase dObject in origin.OrderByDescending(a => a.Available).ThenBy(a => a.FriendlyName))
228+
IOrderedEnumerable<DataObjectBase> orderedList;
229+
if (origin is IEnumerable<Quality>)
230+
orderedList = origin.OrderByDescending(a => a.Available).ThenBy(a => a);
231+
else
232+
orderedList = origin.OrderByDescending(a => a.Available).ThenBy(a => a.FriendlyName);
233+
234+
foreach (DataObjectBase dObject in orderedList)
221235
{
222236
ListViewItem lvItem = new ListViewItem();
223237
if (dObject.Icon != null)
@@ -248,6 +262,7 @@ private void UpdateFilteredLists()
248262
UpdateFilteredList(unfilteredBeaconList, filteredBeaconList, BeaconListView);
249263
UpdateFilteredList(unfilteredModuleList, filteredModuleList, ModuleListView);
250264
UpdateFilteredList(unfilteredRecipeList, filteredRecipeList, RecipeListView);
265+
UpdateFilteredList(unfilteredQualityList, filteredQualityList, QualityListView);
251266
}
252267

253268
private void UpdateFilteredList(List<ListViewItem> unfilteredList, List<ListViewItem> filteredList, ListView owner)
@@ -442,6 +457,7 @@ private void ListView_MouseDoubleClick(object sender, MouseEventArgs e)
442457
private void BeaconListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { e.Item = filteredBeaconList[e.ItemIndex]; }
443458
private void ModuleListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { e.Item = filteredModuleList[e.ItemIndex]; }
444459
private void RecipeListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { e.Item = filteredRecipeList[e.ItemIndex]; }
460+
private void QualityListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { e.Item = filteredQualityList[e.ItemIndex]; }
445461

446462
private void RecipeListView_StartHover(object sender, MouseEventArgs e)
447463
{
@@ -616,7 +632,10 @@ private void EnableAllButton_Click(object sender, EventArgs e)
616632
foreach (Recipe recipe in Options.DCache.Recipes.Values.Where(r => r.Available))
617633
Options.EnabledObjects.Add(recipe);
618634

619-
UpdateEnabledStatus();
635+
foreach (Quality quality in Options.DCache.Qualities.Values.Where(r => r.Available))
636+
Options.EnabledObjects.Add(quality);
637+
638+
UpdateEnabledStatus();
620639
}
621640

622641
private void UpdateEnabledStatus()
@@ -647,6 +666,10 @@ private void UpdateEnabledStatus()
647666
filteredRecipeList.AddRange(unfilteredRecipeList);
648667
RecipeListView.VirtualListSize = filteredRecipeList.Count;
649668

669+
filteredQualityList.Clear();
670+
filteredQualityList.AddRange(unfilteredQualityList);
671+
QualityListView.VirtualListSize += filteredQualityList.Count;
672+
650673

651674
foreach (ListViewItem item in unfilteredAssemblerList)
652675
item.Checked = Options.EnabledObjects.Contains((DataObjectBase)item.Tag);
@@ -660,8 +683,11 @@ private void UpdateEnabledStatus()
660683
item.Checked = Options.EnabledObjects.Contains((DataObjectBase)item.Tag);
661684
foreach (ListViewItem item in unfilteredRecipeList)
662685
item.Checked = Options.EnabledObjects.Contains((DataObjectBase)item.Tag);
686+
foreach (ListViewItem item in unfilteredQualityList)
687+
item.Checked = Options.EnabledObjects.Contains((DataObjectBase)item.Tag);
663688

664-
UpdateFilteredLists();
689+
690+
UpdateFilteredLists();
665691
}
666692

667693
protected override void OnClosed(EventArgs e)

Foreman/Models/Nodes/RecipeNode.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ internal override NodeState GetUpdatedState()
289289

290290
}
291291

292-
public void UpdateInputsAndOutputs()
292+
public void UpdateInputsAndOutputs(bool forceUpdate = false)
293293
{
294-
if (!ioUpdateRequired)
294+
if (!ioUpdateRequired && !forceUpdate)
295295
return;
296296
ioUpdateRequired = false;
297297

@@ -358,13 +358,13 @@ public void UpdateInputsAndOutputs()
358358
currentProduct = new ItemQualityPair(item, currentProduct.Quality.NextQuality);
359359
if (currentMultiplier == 0)
360360
break;
361+
if (!currentProduct.Quality.Enabled || !currentProduct.Quality.Available)
362+
break;
361363

362364
outputList.Add(currentProduct);
363365
outputSet.Add(currentProduct, Math.Min(currentMultiplier, 1.0) * amount);
364366
outputSet[lastProduct] -= outputSet[currentProduct];
365367

366-
if (!currentProduct.Quality.Enabled || !currentProduct.Quality.Available)
367-
break;
368368
}
369369
}
370370
}

Foreman/Models/ProductionGraph.cs

+9
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ public void ClearGraph()
296296
lastNodeID = 0;
297297
}
298298

299+
public void UpdateNodeMaxQualities()
300+
{
301+
foreach(RecipeNode rnode in nodes.Where(n => n is RecipeNode).Cast<RecipeNode>())
302+
{
303+
rnode.UpdateInputsAndOutputs(true);
304+
rnode.UpdateState();
305+
}
306+
}
307+
299308
public void UpdateNodeStates(bool markAllAsDirty)
300309
{
301310
foreach (BaseNode node in nodes)
-86.2 KB
Binary file not shown.

Foreman/Presets/Factorio 2.0 Space Age.pjson

+5-59
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,14 @@
1212
"name": "base",
1313
"version": "2.0.13"
1414
},
15-
{
16-
"name": "belt-visualizer",
17-
"version": "2.0.2"
18-
},
19-
{
20-
"name": "vehicle-corpses",
21-
"version": "0.1.1"
22-
},
23-
{
24-
"name": "VehicleSnap",
25-
"version": "2.0.0"
26-
},
2715
{
2816
"name": "elevated-rails",
2917
"version": "2.0.13"
3018
},
31-
{
32-
"name": "even-distribution",
33-
"version": "2.0.2"
34-
},
35-
{
36-
"name": "flib",
37-
"version": "0.15.0"
38-
},
39-
{
40-
"name": "playtime",
41-
"version": "1.1.1"
42-
},
4319
{
4420
"name": "quality",
4521
"version": "2.0.13"
4622
},
47-
{
48-
"name": "Trashcan",
49-
"version": "1.0.5"
50-
},
51-
{
52-
"name": "Wr_Enhanced_Map_Colors",
53-
"version": "1.5.7"
54-
},
55-
{
56-
"name": "BottleneckLite",
57-
"version": "1.3.0"
58-
},
59-
{
60-
"name": "customizable-quality-names",
61-
"version": "1.0.0"
62-
},
6323
{
6424
"name": "space-age",
6525
"version": "2.0.13"
@@ -10070,20 +10030,6 @@
1007010030
],
1007110031
"research_unit_count": 2500,
1007210032
"localised_name": "Spidertron"
10073-
},
10074-
{
10075-
"name": "enable-logistics-tab",
10076-
"icon_name": "icon.t.enable-logistics-tab",
10077-
"enabled": false,
10078-
"essential": true,
10079-
"hidden": true,
10080-
"prerequisites": {},
10081-
"successors": {},
10082-
"recipes": {},
10083-
"alt_modifiers": {},
10084-
"research_unit_ingredients": {},
10085-
"research_unit_count": 1,
10086-
"localised_name": "Even Distribution"
1008710033
}
1008810034
],
1008910035
"recipes": [
@@ -39297,7 +39243,7 @@
3929739243
"mining_drill_resource_drain_multiplier": 1,
3929839244
"next_probability": 0.1,
3929939245
"next": "uncommon",
39300-
"localised_name": "Standard"
39246+
"localised_name": "Normal"
3930139247
},
3930239248
{
3930339249
"name": "uncommon",
@@ -39309,7 +39255,7 @@
3930939255
"mining_drill_resource_drain_multiplier": 0.83333331346511841,
3931039256
"next_probability": 0.1,
3931139257
"next": "rare",
39312-
"localised_name": "Improved"
39258+
"localised_name": "Uncommon"
3931339259
},
3931439260
{
3931539261
"name": "rare",
@@ -39321,7 +39267,7 @@
3932139267
"mining_drill_resource_drain_multiplier": 0.66666668653488159,
3932239268
"next_probability": 0.1,
3932339269
"next": "epic",
39324-
"localised_name": "Superior"
39270+
"localised_name": "Rare"
3932539271
},
3932639272
{
3932739273
"name": "epic",
@@ -39333,7 +39279,7 @@
3933339279
"mining_drill_resource_drain_multiplier": 0.5,
3933439280
"next_probability": 0.1,
3933539281
"next": "legendary",
39336-
"localised_name": "Exceptional"
39282+
"localised_name": "Epic"
3933739283
},
3933839284
{
3933939285
"name": "legendary",
@@ -39343,7 +39289,7 @@
3934339289
"level": 5,
3934439290
"beacon_power_multiplier": 0.1666666716337204,
3934539291
"mining_drill_resource_drain_multiplier": 0.1666666716337204,
39346-
"localised_name": "Flawless"
39292+
"localised_name": "Legendary"
3934739293
},
3934839294
{
3934939295
"name": "quality-unknown",
-21.1 KB
Binary file not shown.

Foreman/Presets/Factorio 2.0 Vanilla.pjson

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"name": "base",
13-
"version": "2.0.9"
13+
"version": "2.0.13"
1414
}
1515
],
1616
"technologies": [

0 commit comments

Comments
 (0)