Skip to content

Commit

Permalink
v1.1.1 Full schematic quantities option added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobitege committed Dec 3, 2022
1 parent 4830df8 commit 351c510
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 241 deletions.
9 changes: 6 additions & 3 deletions DU-Industry-Tool/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<userSettings>
<DU_Industry_Tool.Properties.Settings>
<setting name="ProdListDirectory" serializeAs="String">
<value/>
<value />
</setting>
<setting name="LaunchProdList" serializeAs="String">
<value>False</value>
</setting>
<setting name="LastProductionList" serializeAs="String">
<value/>
<value />
</setting>
<setting name="LastLeftTop" serializeAs="String">
<value>0, 0</value>
Expand All @@ -29,11 +29,14 @@
<value>True</value>
</setting>
<setting name="RecentProdLists" serializeAs="String">
<value/>
<value />
</setting>
<setting name="ThemeId" serializeAs="String">
<value>-1</value>
</setting>
<setting name="FullSchematicQuantities" serializeAs="String">
<value>True</value>
</setting>
</DU_Industry_Tool.Properties.Settings>
</userSettings>
<System.Windows.Forms.ApplicationConfigurationSection>
Expand Down
2 changes: 1 addition & 1 deletion DU-Industry-Tool/Classes/Calculator2OutputClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Fill(CalculatorClass calc)
_tlview.BeginInvoke((MethodInvoker)delegate()
{
_tlview.Collapse(x);
MessageBox.Show(ex.Message, "Recipes Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBox.Show(ex.Message, @"Recipes Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
});
return new ArrayList();
}
Expand Down
41 changes: 24 additions & 17 deletions DU-Industry-Tool/Classes/CalculatorClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ public static void Collect(CalculatorClass calc)
{
if (prod.IsByproduct || !CreateByKey(prod.Type, out var pCalc))
continue;
pCalc.GetTalents();
if (pCalc.IsPlasma || string.IsNullOrEmpty(pCalc.SchematicType))
continue;
pCalc.GetTalents();
// TODO determine correct schematics needed (pures, products)!
if (pCalc.IsBatchmode)
{
if (pCalc.BatchOutput != null)
{
if (pCalc.CalcSchematicFromQty(prod.SchemaType, prod.Quantity, (decimal)pCalc.BatchOutput,
if (pCalc.CalcSchematicFromQty(pCalc.SchematicType, prod.Quantity, (decimal)pCalc.BatchOutput,
out var cnt, out var minCost1, out var _, out var _))
{
calc.AddSchema(pCalc.SchematicType, cnt, minCost1);
Expand All @@ -173,12 +173,10 @@ public static void Collect(CalculatorClass calc)
}
}
else
if (CalcSchematic(pCalc.SchematicType, prod.Quantity, out var minCost2, out _, out _))
{
if (CalcSchematic(prod.SchemaType, prod.Quantity, out var minCost2, out _, out _))
{
calc.AddSchema(pCalc.SchematicType, (int)Math.Ceiling(prod.Quantity), minCost2);
calc.AddSchematicCost(minCost2);
}
calc.AddSchema(pCalc.SchematicType, (int)Math.Ceiling(prod.Quantity), minCost2);
calc.AddSchematicCost(minCost2);
}
}
}
Expand All @@ -196,7 +194,11 @@ public static void Collect(CalculatorClass calc)
var batches = ProductQuantity;
if (calc.IsBatchmode && calc.BatchOutput > 0)
{
batches = Math.Floor(ProductQuantity / (decimal)calc.BatchOutput);
batches = ProductQuantity / (decimal)calc.BatchOutput;
if (DUData.FullSchematicQuantities)
{
batches = Math.Floor(batches);
}
}
if (CalcSchematic(calc.SchematicType, (int)batches, out var minCost, out _, out _))
{
Expand All @@ -212,7 +214,7 @@ public static void Collect(CalculatorClass calc)
/// </summary>
public static bool CalcSchematic(string schematicId, decimal qtySchematic,
out decimal minCost, out decimal copyCost,
out int qtyCopies)
out decimal qtyCopies)
{
minCost = 0M;
copyCost = 0M;
Expand All @@ -224,12 +226,13 @@ public static bool CalcSchematic(string schematicId, decimal qtySchematic,
return false;
}

qtySchematic = Math.Ceiling(qtySchematic);
minCost = Math.Round(schemata.Cost * qtySchematic); // cost is a breakdown to x1 schematic
//qtySchematic = Math.Ceiling(qtySchematic);
minCost = Math.Round(schemata.Cost * qtySchematic); // cost is a breakdown to x1 schematic
// number of copy jobs that need to be started to cover all needed schematics,
// (which depends on the batch size of a copy, e.g. 10 per copy process):
qtyCopies = (int)Math.Ceiling(qtySchematic / (decimal)Math.Max(1, schemata.BatchSize));
// copyCost is the single schematic cose multiplied by batch size and the number of copies:
qtyCopies = qtySchematic / (decimal)Math.Max(1, schemata.BatchSize);
qtyCopies = Math.Ceiling(qtyCopies);
// copyCost is the single schematic cost multiplied by batch size and the number of copies:
copyCost = schemata.Cost * schemata.BatchSize * qtyCopies;
copyCost = Math.Round(copyCost, 2);
return true;
Expand Down Expand Up @@ -258,10 +261,14 @@ private static void CollectSchematics(CalculatorClass calc, SummationType sumTyp
tmp.Quantity = val.Qty;
tmp.GetTalents();
if (tmp.BatchOutput == null) continue;// happens (on purpose)
tmp.Quantity = (int)Math.Ceiling(tmp.Quantity / (decimal)tmp.BatchOutput);
tmp.Quantity = tmp.Quantity / (decimal)tmp.BatchOutput;
if (DUData.FullSchematicQuantities)
{
tmp.Quantity = (int)Math.Ceiling(tmp.Quantity);
}
val.QtySchemata = tmp.Quantity;

if (!CalcSchematic(val.SchematicType, (int)tmp.Quantity,
if (!CalcSchematic(val.SchematicType, tmp.Quantity,
out var minCost, out _, out var copies))
{
continue;
Expand Down Expand Up @@ -777,7 +784,7 @@ public List<string> GetTalents()
}

public bool CalcSchematicFromQty(string schematicType, decimal qty, decimal batchOutput,
out int batches, out decimal minCost, out decimal copyCost, out int qtyCopies)
out int batches, out decimal minCost, out decimal copyCost, out decimal qtyCopies)
{
minCost = 0M;
copyCost = 0M;
Expand All @@ -792,7 +799,7 @@ public bool CalcSchematicFromQty(string schematicType, decimal qty, decimal batc
{
qty /= batchOutput;
}
batches = (int)Math.Ceiling(qty);
batches = DUData.FullSchematicQuantities ? (int)Math.Ceiling(qty) : (int)qty;
return Calculator.CalcSchematic(schematicType, (int)batches, out minCost, out copyCost, out qtyCopies);
}
}
Expand Down
2 changes: 2 additions & 0 deletions DU-Industry-Tool/Classes/DUData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
using DocumentFormat.OpenXml;
using Krypton.Toolkit;
using Newtonsoft.Json;

Expand Down Expand Up @@ -253,6 +254,7 @@ public static class DUData
///<br>which can contain any amount of items and is created with the</br>
///<br>help of the Production List dialogue/ribbon buttons.</br>
///</summary>
public static bool FullSchematicQuantities { get; set; }
public static bool ProductionListMode { get; set; }
public static SchematicRecipe CompoundRecipe { get; set; }
public static readonly string CompoundName = "COMPOUNDLIST";
Expand Down
4 changes: 4 additions & 0 deletions DU-Industry-Tool/DU-Industry-Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<PropertyGroup>
<ApplicationIcon>reshot-icon-factory.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="ObjectListView, Version=2.9.1.37415, Culture=neutral, PublicKeyToken=b1c5bf581481bcd4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -170,6 +173,7 @@
<EmbeddedResource Include="Forms\SkillForm.resx">
<DependentUpon>SkillForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="changelog.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
21 changes: 8 additions & 13 deletions DU-Industry-Tool/Forms/ContentDocumentTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial class ContentDocumentTree : UserControl, IContentDocument
{
private bool expand = false;
private byte[] treeListViewViewState;
private float fontSize;

private Random _rand;
private readonly string[] _funHints = new[]
Expand Down Expand Up @@ -47,6 +48,7 @@ public ContentDocumentTree()
{
InitializeComponent();
HideAll();
fontSize = Font.Size;
}

public void HideAll()
Expand Down Expand Up @@ -362,7 +364,9 @@ public void SetupGrid(CalculatorClass calc)
olvColumnQty.AspectGetter = x => (x is RecipeCalculation t && t.Qty > 0 ? $"{t.Qty:N2}" : "");
olvColumnAmt.AspectGetter = x => (x is RecipeCalculation t && t.Amt > 0 ? $"{t.Amt:N2}" : "");

olvColumnSchemataQ.AspectGetter = x => (x is RecipeCalculation t && t.QtySchemata > 0 ? $"{t.QtySchemata:N0}" : "");
olvColumnSchemataQ.AspectGetter = x => (x is RecipeCalculation t && t.QtySchemata > 0
? (DUData.FullSchematicQuantities ? $"{t.QtySchemata:N0}" : $"{t.QtySchemata:N2}")
: "");
olvColumnSchemataA.AspectGetter = x => (x is RecipeCalculation t && t.AmtSchemata > 0 ? $"{t.AmtSchemata:N2}" : "");

olvColumnTier.AspectGetter = x => (x is RecipeCalculation t && t.Tier > 0 ? $"{t.Tier}" : "");
Expand All @@ -389,6 +393,7 @@ public void SetupGrid(CalculatorClass calc)
private static DataGridViewRow CreateTalentsRow(Talent talent)
{
var row = new DataGridViewRow();
row.Height = 32;
row.Cells.Add(new DataGridViewTextBoxCell());
row.Cells.Add(new KryptonDataGridViewNumericUpDownCell());
row.Cells[0].ValueType = typeof(string);
Expand Down Expand Up @@ -532,21 +537,11 @@ private void BtnFontDownOnClick(object sender, EventArgs e)

private void SetFont(float fontDelta)
{
var fontSize = this.Font.Size;
if ((fontDelta < 0 && fontSize > 8) || (fontDelta > 0 && fontSize < 15))
if ((fontDelta < 0 && fontSize > 9) || (fontDelta > 0 && fontSize < 18))
{
fontSize += fontDelta;
treeListView.Font = new Font("Segoe UI", fontSize, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
}
Font = new Font("Segoe UI", fontSize, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
foreach (var ct in this.Controls.OfType<KryptonLabel>())
{
ct.Font = Font;
}
foreach (var ct in this.Controls.OfType<Label>())
{
ct.Font = Font;
}
treeListView.Font = Font;
}
}
}
Loading

0 comments on commit 351c510

Please sign in to comment.