diff --git a/ARKBreedingStats/BreedingPlan.cs b/ARKBreedingStats/BreedingPlan.cs index 3c5b934e..7af6e501 100644 --- a/ARKBreedingStats/BreedingPlan.cs +++ b/ARKBreedingStats/BreedingPlan.cs @@ -200,11 +200,11 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo crCountF = chosenF.Count; crCountM = chosenM.Count; - if (nudBPMutationLimit.Value >= 0) - { - chosenF = chosenF.Where(c => c.mutationsMaternal + c.mutationsPaternal <= nudBPMutationLimit.Value).ToList(); - chosenM = chosenM.Where(c => c.mutationsMaternal + c.mutationsPaternal <= nudBPMutationLimit.Value).ToList(); - } + //if (nudBPMutationLimit.Value >= 0) + //{ + // chosenF = chosenF.Where(c => c.mutationsMaternal + c.mutationsPaternal <= nudBPMutationLimit.Value).ToList(); + // chosenM = chosenM.Where(c => c.mutationsMaternal + c.mutationsPaternal <= nudBPMutationLimit.Value).ToList(); + //} bool creaturesMutationsFilteredOut = (crCountF != chosenF.Count) || (crCountM != chosenM.Count); @@ -259,7 +259,9 @@ private void AsyncCalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMo { foreach (Creature male in chosenM) { - if (male == female) continue; // happens if Properties.Settings.Default.IgnoreSexInBreedingPlan (when using S+ mutator) + if (male == female // happens if Properties.Settings.Default.IgnoreSexInBreedingPlan (when using S+ mutator) + || (nudBPMutationLimit.Value >= 0 && female.Mutations > nudBPMutationLimit.Value && male.Mutations > nudBPMutationLimit.Value) // if one pair is below the limit, show this pair + ) continue; t = 0; nrTS = 0; // number of possible top-stats eTS = 0; // expected number of top stats @@ -685,8 +687,8 @@ private void setParents(int comboIndex) crW.recalculateCreatureValues(levelStep); pedigreeCreatureBest.totalLevelUnknown = totalLevelUnknown; pedigreeCreatureWorst.totalLevelUnknown = totalLevelUnknown; - int mutationCounterMaternal = mother.mutationsMaternal + mother.mutationsPaternal; - int mutationCounterPaternal = father.mutationsMaternal + father.mutationsPaternal; + int mutationCounterMaternal = mother.Mutations; + int mutationCounterPaternal = father.Mutations; crB.mutationsMaternal = mutationCounterMaternal; crB.mutationsPaternal = mutationCounterPaternal; crW.mutationsMaternal = mutationCounterMaternal; diff --git a/ARKBreedingStats/Creature.cs b/ARKBreedingStats/Creature.cs index 91726579..07a78f44 100644 --- a/ARKBreedingStats/Creature.cs +++ b/ARKBreedingStats/Creature.cs @@ -58,7 +58,7 @@ public class Creature : IEquatable public DateTime domesticatedAt = new DateTime(0); public DateTime addedToLibrary = new DateTime(0); public bool neutered = false; - public int mutationCounter; // remove this field on 07-2018 + public int mutationCounter; // TODO. remove this field on 07-2018 public int mutationsMaternal; public int mutationsPaternal; public List tags = new List(); @@ -211,8 +211,15 @@ public void recalculateCreatureValues(int? levelStep) } calculateLevelFound(levelStep); } + + [XmlIgnore] + public int Mutations + { + get { return mutationsMaternal + mutationsPaternal; } + } } + public enum Sex { Unknown = 0, diff --git a/ARKBreedingStats/CreatureBox.cs b/ARKBreedingStats/CreatureBox.cs index d218c3d0..282fdf47 100644 --- a/ARKBreedingStats/CreatureBox.cs +++ b/ARKBreedingStats/CreatureBox.cs @@ -180,6 +180,7 @@ public void updateLabel() labelNotes.Text = creature.note; labelSpecies.Text = creature.species; pictureBox1.Image = CreatureColored.getColoredCreature(creature.colors, creature.species, colorRegionUseds); + tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(creature.species, creature.colors)); pictureBox1.Visible = true; } } diff --git a/ARKBreedingStats/CreatureColored.cs b/ARKBreedingStats/CreatureColored.cs index 1440f0e0..14ef20a3 100644 --- a/ARKBreedingStats/CreatureColored.cs +++ b/ARKBreedingStats/CreatureColored.cs @@ -6,7 +6,7 @@ namespace ARKBreedingStats { - class CreatureColored + static class CreatureColored { public static Bitmap getColoredCreature(int[] colorIds, string species, bool[] enabledColorRegions, int size = 128, int pieSize = 64, bool onlyColors = false, bool dontCache = false) { @@ -18,126 +18,147 @@ public static Bitmap getColoredCreature(int[] colorIds, string species, bool[] e rgb[c] = new int[] { cl.R, cl.G, cl.B }; } Bitmap bm = new Bitmap(size, size); - Graphics graph = Graphics.FromImage(bm); - graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - string imgFolder = "img/"; - // cachefilename - string cf = imgFolder + "cache/" + species.Substring(0, Math.Min(species.Length, 5)) + "_" + (species + string.Join("", colorIds.Select(i => i.ToString()).ToArray())).GetHashCode().ToString("X8") + ".png"; - if (!onlyColors && System.IO.File.Exists(imgFolder + species + ".png") && System.IO.File.Exists(imgFolder + species + "_m.png")) + using (Graphics graph = Graphics.FromImage(bm)) { - if (!System.IO.File.Exists(cf)) + graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + string imgFolder = "img/"; + // cachefilename + string cf = imgFolder + "cache/" + species.Substring(0, Math.Min(species.Length, 5)) + "_" + (species + string.Join("", colorIds.Select(i => i.ToString()).ToArray())).GetHashCode().ToString("X8") + ".png"; + if (!onlyColors && System.IO.File.Exists(imgFolder + species + ".png") && System.IO.File.Exists(imgFolder + species + "_m.png")) { - int defaultSizeOfTemplates = 256; - Bitmap bmC = new Bitmap(imgFolder + species + ".png"); - graph.DrawImage(new Bitmap(imgFolder + species + ".png"), 0, 0, defaultSizeOfTemplates, defaultSizeOfTemplates); - Bitmap mask = new Bitmap(defaultSizeOfTemplates, defaultSizeOfTemplates); - Graphics.FromImage(mask).DrawImage(new Bitmap(imgFolder + species + "_m.png"), 0, 0, defaultSizeOfTemplates, defaultSizeOfTemplates); - float o = 0, l; - Color c = Color.Black, bc = Color.Black; - int r, g, b, rMix, gMix, bMix; - bool imageFine = false; - try + if (!System.IO.File.Exists(cf)) { - for (int i = 0; i < bmC.Width; i++) + int defaultSizeOfTemplates = 256; + Bitmap bmC = new Bitmap(imgFolder + species + ".png"); + graph.DrawImage(new Bitmap(imgFolder + species + ".png"), 0, 0, defaultSizeOfTemplates, defaultSizeOfTemplates); + Bitmap mask = new Bitmap(defaultSizeOfTemplates, defaultSizeOfTemplates); + Graphics.FromImage(mask).DrawImage(new Bitmap(imgFolder + species + "_m.png"), 0, 0, defaultSizeOfTemplates, defaultSizeOfTemplates); + float o = 0, l; + Color c = Color.Black, bc = Color.Black; + int r, g, b, rMix, gMix, bMix; + bool imageFine = false; + try { - for (int j = 0; j < bmC.Height; j++) + for (int i = 0; i < bmC.Width; i++) { - bc = bmC.GetPixel(i, j); - if (bc.A > 0) + for (int j = 0; j < bmC.Height; j++) { - r = mask.GetPixel(i, j).R; - g = mask.GetPixel(i, j).G; - b = mask.GetPixel(i, j).B; - l = (Math.Max(bc.R, (Math.Max(bc.G, bc.B))) + Math.Min(bc.R, Math.Min(bc.G, bc.B))) / 510f; - for (int m = 0; m < 6; m++) + bc = bmC.GetPixel(i, j); + if (bc.A > 0) { - if (!enabledColorRegions[m] || colorIds[m] == 0) - continue; - switch (m) + r = mask.GetPixel(i, j).R; + g = mask.GetPixel(i, j).G; + b = mask.GetPixel(i, j).B; + l = (Math.Max(bc.R, (Math.Max(bc.G, bc.B))) + Math.Min(bc.R, Math.Min(bc.G, bc.B))) / 510f; + for (int m = 0; m < 6; m++) { - case 0: - o = Math.Max(0, r - g - b) / 255f; - break; - case 1: - o = Math.Max(0, g - r - b) / 255f; - break; - case 2: - o = Math.Max(0, b - r - g) / 255f; - break; - case 3: - o = Math.Min(g, b) / 255f; - break; - case 4: - o = Math.Min(r, g) / 255f; - break; - case 5: - o = Math.Min(r, b) / 255f; - break; + if (!enabledColorRegions[m] || colorIds[m] == 0) + continue; + switch (m) + { + case 0: + o = Math.Max(0, r - g - b) / 255f; + break; + case 1: + o = Math.Max(0, g - r - b) / 255f; + break; + case 2: + o = Math.Max(0, b - r - g) / 255f; + break; + case 3: + o = Math.Min(g, b) / 255f; + break; + case 4: + o = Math.Min(r, g) / 255f; + break; + case 5: + o = Math.Min(r, b) / 255f; + break; + } + if (o == 0) + continue; + rMix = bc.R + rgb[m][0] - 128; + if (rMix < 0) rMix = 0; + else if (rMix > 255) rMix = 255; + gMix = bc.G + rgb[m][1] - 128; + if (gMix < 0) gMix = 0; + else if (gMix > 255) gMix = 255; + bMix = bc.B + rgb[m][2] - 128; + if (bMix < 0) bMix = 0; + else if (bMix > 255) bMix = 255; + c = Color.FromArgb(rMix, gMix, bMix); + bc = Color.FromArgb(bc.A, (int)(o * c.R + (1 - o) * bc.R), (int)(o * c.G + (1 - o) * bc.G), (int)(o * c.B + (1 - o) * bc.B)); } - if (o == 0) - continue; - rMix = bc.R + rgb[m][0] - 128; - if (rMix < 0) rMix = 0; - else if (rMix > 255) rMix = 255; - gMix = bc.G + rgb[m][1] - 128; - if (gMix < 0) gMix = 0; - else if (gMix > 255) gMix = 255; - bMix = bc.B + rgb[m][2] - 128; - if (bMix < 0) bMix = 0; - else if (bMix > 255) bMix = 255; - c = Color.FromArgb(rMix, gMix, bMix); - bc = Color.FromArgb(bc.A, (int)(o * c.R + (1 - o) * bc.R), (int)(o * c.G + (1 - o) * bc.G), (int)(o * c.B + (1 - o) * bc.B)); + bmC.SetPixel(i, j, bc); } - bmC.SetPixel(i, j, bc); } } + imageFine = true; + } + catch + { + // error during drawing, maybe mask is smaller than image + } + if (imageFine) + { + if (!System.IO.Directory.Exists("img/cache")) + System.IO.Directory.CreateDirectory("img/cache"); + bmC.Save(cf); // safe in cache} } - imageFine = true; - } - catch - { - // error during drawing, maybe mask is smaller than image } - if (imageFine) + } + if (System.IO.File.Exists(cf)) + { + graph.CompositingMode = CompositingMode.SourceCopy; + graph.CompositingQuality = CompositingQuality.HighQuality; + graph.InterpolationMode = InterpolationMode.HighQualityBicubic; + graph.SmoothingMode = SmoothingMode.HighQuality; + graph.PixelOffsetMode = PixelOffsetMode.HighQuality; + graph.DrawImage(new Bitmap(cf), 0, 0, size, size); + } + else + { + // draw piechart + int pieAngle = enabledColorRegions.Count(c => c); + pieAngle = 360 / (pieAngle > 0 ? pieAngle : 1); + int pieNr = 0; + for (int c = 0; c < 6; c++) { - if (!System.IO.Directory.Exists("img/cache")) - System.IO.Directory.CreateDirectory("img/cache"); - bmC.Save(cf); // safe in cache} + if (enabledColorRegions[c]) + { + if (colorIds[c] > 0) + { + using (var b = new SolidBrush(CreatureColors.creatureColor(colorIds[c]))) + { + graph.FillPie(b, (size - pieSize) / 2, (size - pieSize) / 2, pieSize, pieSize, pieNr * pieAngle + 270, pieAngle); + } + } + pieNr++; + } } + graph.DrawEllipse(new Pen(Color.Gray), (size - pieSize) / 2, (size - pieSize) / 2, pieSize, pieSize); } } - if (System.IO.File.Exists(cf)) - { - graph.CompositingMode = CompositingMode.SourceCopy; - graph.CompositingQuality = CompositingQuality.HighQuality; - graph.InterpolationMode = InterpolationMode.HighQualityBicubic; - graph.SmoothingMode = SmoothingMode.HighQuality; - graph.PixelOffsetMode = PixelOffsetMode.HighQuality; - graph.DrawImage(new Bitmap(cf), 0, 0, size, size); - } - else + return bm; + } + + public static string RegionColorInfo(string species, int[] colorIds) + { + string creatureRegionColors = ""; + int si = Values.V.speciesIndex(species); + if (si >= 0) { - Brush b = new SolidBrush(Color.Black); - int pieAngle = enabledColorRegions.Count(c => c); - pieAngle = 360 / (pieAngle > 0 ? pieAngle : 1); - int pieNr = 0; - for (int c = 0; c < 6; c++) + var cs = Values.V.species[si].colors; + creatureRegionColors = "Colors:"; + for (int r = 0; r < 6; r++) { - if (enabledColorRegions[c]) + if (cs[r].name != null) { - if (colorIds[c] > 0) - { - b = new SolidBrush(CreatureColors.creatureColor(colorIds[c])); - graph.FillPie(b, (size - pieSize) / 2, (size - pieSize) / 2, pieSize, pieSize, pieNr * pieAngle + 270, pieAngle); - } - pieNr++; + creatureRegionColors += "\n" + cs[r].name + " (" + r.ToString() + "): " + CreatureColors.creatureColorName(colorIds[r]) + " (" + colorIds[r].ToString() + ")"; } } - graph.DrawEllipse(new Pen(Color.Gray), (size - pieSize) / 2, (size - pieSize) / 2, pieSize, pieSize); - b.Dispose(); } - graph.Dispose(); - return bm; + return creatureRegionColors; } } } diff --git a/ARKBreedingStats/CreatureInfoInput.cs b/ARKBreedingStats/CreatureInfoInput.cs index 7ee7cc03..e8e7225c 100644 --- a/ARKBreedingStats/CreatureInfoInput.cs +++ b/ARKBreedingStats/CreatureInfoInput.cs @@ -122,6 +122,16 @@ public Creature father parentComboBoxFather.preselectedCreatureGuid = (value == null ? Guid.Empty : value.guid); } } + public Guid motherId + { + get { return parentComboBoxMother.preselectedCreatureGuid; } + set { parentComboBoxMother.preselectedCreatureGuid = value; } + } + public Guid fatherId + { + get { return parentComboBoxFather.preselectedCreatureGuid; } + set { parentComboBoxFather.preselectedCreatureGuid = value; } + } public string CreatureNote { get { return textBoxNote.Text; } @@ -288,7 +298,7 @@ public int MutationCounterMother set { int v = value; - if (v > nudMutationsMother.Maximum) v = (int)nudMutationsMother.Maximum; + if (v > nudMutationsMother.Maximum || v < 0) v = (int)nudMutationsMother.Maximum; nudMutationsMother.Value = v; mutationManuallyChanged = false; } @@ -300,7 +310,7 @@ public int MutationCounterFather set { int v = value; - if (v > nudMutationsFather.Maximum) v = (int)nudMutationsFather.Maximum; + if (v > nudMutationsFather.Maximum || v < 0) v = (int)nudMutationsFather.Maximum; nudMutationsFather.Value = v; mutationManuallyChanged = false; } @@ -317,7 +327,7 @@ public int[] RegionColors regionColorChooser1.setCreature(Values.V.speciesNames[speciesIndex], regionColorIDs); } } - get { return (int[])regionColorIDs.Clone(); } + get { return regionColorChooser1.colorIDs; } } public int SpeciesIndex @@ -357,8 +367,8 @@ private void updateMutations() { if (!mutationManuallyChanged) { - nudMutationsMother.Value = (parentComboBoxMother.SelectedParent != null ? parentComboBoxMother.SelectedParent.mutationsMaternal + parentComboBoxMother.SelectedParent.mutationsPaternal : 0); - nudMutationsFather.Value = (parentComboBoxFather.SelectedParent != null ? parentComboBoxFather.SelectedParent.mutationsMaternal + parentComboBoxFather.SelectedParent.mutationsPaternal : 0); + nudMutationsMother.Value = (parentComboBoxMother.SelectedParent != null ? parentComboBoxMother.SelectedParent.Mutations : 0); + nudMutationsFather.Value = (parentComboBoxFather.SelectedParent != null ? parentComboBoxFather.SelectedParent.Mutations : 0); mutationManuallyChanged = false; } } @@ -483,8 +493,8 @@ internal void Clear() textBoxOwner.Clear(); mother = null; father = null; - parentComboBoxMother.SelectedIndex = 0; - parentComboBoxFather.SelectedIndex = 0; + parentComboBoxMother.Clear(); + parentComboBoxFather.Clear(); textBoxNote.Clear(); Cooldown = DateTime.Now; Grown = DateTime.Now; diff --git a/ARKBreedingStats/ExportedCreatureList.cs b/ARKBreedingStats/ExportedCreatureList.cs index 9a23b20f..17828650 100644 --- a/ARKBreedingStats/ExportedCreatureList.cs +++ b/ARKBreedingStats/ExportedCreatureList.cs @@ -56,7 +56,7 @@ public void loadFilesInFolder(string folderPath) string[] files = Directory.GetFiles(folderPath, "DinoExport*.ini"); foreach (string f in files) { - ExportedCreatureControl ecc = new ExportedCreatureControl(ImportExported.importExportedCreature(f)); + ExportedCreatureControl ecc = new ExportedCreatureControl(f); ecc.Dock = DockStyle.Top; ecc.CopyValuesToExtractor += CopyValuesToExtractor; ecc.CheckGuidInLibrary += CheckGuidInLibrary; diff --git a/ARKBreedingStats/Extraction.cs b/ARKBreedingStats/Extraction.cs index 5fafc451..21612a1c 100644 --- a/ARKBreedingStats/Extraction.cs +++ b/ARKBreedingStats/Extraction.cs @@ -124,7 +124,7 @@ public void extractLevels(int speciesI, int level, List statIOs, double // double precision makes it necessary to give a bit more tolerance (hence 0.050001 instead of just 0.05 etc.) MinMaxDouble inputValue = new MinMaxDouble(statIOs[s].Input - (Utils.precision(s) == 3 ? 0.00050001 : 0.050001), statIOs[s].Input + (Utils.precision(s) == 3 ? 0.00050001 : 0.050001)); double statBaseValue = stats[s].BaseValue; - if (postTamed) statBaseValue *= (s == 0 ? (double)Values.V.species[speciesI].TamedBaseHealthMultiplier : 1); + if (postTamed && s == 0) statBaseValue *= (double)Values.V.species[speciesI].TamedBaseHealthMultiplier;// + 0.00000000001; // todo double-precision handling bool withTEff = (postTamed && stats[s].MultAffinity > 0); if (withTEff) { statsWithTE.Add(s); } diff --git a/ARKBreedingStats/Form1.Designer.cs b/ARKBreedingStats/Form1.Designer.cs index cd3efa6c..c7bc64c6 100644 --- a/ARKBreedingStats/Form1.Designer.cs +++ b/ARKBreedingStats/Form1.Designer.cs @@ -1336,7 +1336,7 @@ private void InitializeComponent() this.tabControlMain.Location = new System.Drawing.Point(0, 103); this.tabControlMain.Name = "tabControlMain"; this.tabControlMain.SelectedIndex = 1; - this.tabControlMain.Size = new System.Drawing.Size(1232, 710); + this.tabControlMain.Size = new System.Drawing.Size(1232, 688); this.tabControlMain.TabIndex = 3; this.tabControlMain.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); // @@ -1353,7 +1353,7 @@ private void InitializeComponent() this.tabPageStatTesting.Location = new System.Drawing.Point(4, 22); this.tabPageStatTesting.Name = "tabPageStatTesting"; this.tabPageStatTesting.Padding = new System.Windows.Forms.Padding(3); - this.tabPageStatTesting.Size = new System.Drawing.Size(1224, 684); + this.tabPageStatTesting.Size = new System.Drawing.Size(1224, 662); this.tabPageStatTesting.TabIndex = 1; this.tabPageStatTesting.Text = "Stat Testing"; this.tabPageStatTesting.UseVisualStyleBackColor = true; @@ -1666,7 +1666,7 @@ private void InitializeComponent() // // creatureInfoInputTester // - this.creatureInfoInputTester.Cooldown = new System.DateTime(2018, 5, 13, 17, 43, 44, 219); + this.creatureInfoInputTester.Cooldown = new System.DateTime(2018, 5, 24, 23, 18, 24, 116); this.creatureInfoInputTester.CreatureName = ""; this.creatureInfoInputTester.CreatureNote = ""; this.creatureInfoInputTester.CreatureOwner = ""; @@ -1676,9 +1676,11 @@ private void InitializeComponent() this.creatureInfoInputTester.CreatureTribe = ""; this.creatureInfoInputTester.domesticatedAt = new System.DateTime(2016, 7, 5, 13, 11, 41, 997); this.creatureInfoInputTester.father = null; - this.creatureInfoInputTester.Grown = new System.DateTime(2018, 5, 13, 17, 43, 44, 220); + this.creatureInfoInputTester.fatherId = new System.Guid("00000000-0000-0000-0000-000000000000"); + this.creatureInfoInputTester.Grown = new System.DateTime(2018, 5, 24, 23, 18, 24, 118); this.creatureInfoInputTester.Location = new System.Drawing.Point(321, 184); this.creatureInfoInputTester.mother = null; + this.creatureInfoInputTester.motherId = new System.Guid("00000000-0000-0000-0000-000000000000"); this.creatureInfoInputTester.MutationCounterFather = 0; this.creatureInfoInputTester.MutationCounterMother = 0; this.creatureInfoInputTester.Name = "creatureInfoInputTester"; @@ -2009,7 +2011,7 @@ private void InitializeComponent() // // creatureInfoInputExtractor // - this.creatureInfoInputExtractor.Cooldown = new System.DateTime(2018, 5, 13, 17, 43, 44, 264); + this.creatureInfoInputExtractor.Cooldown = new System.DateTime(2018, 5, 24, 23, 18, 24, 150); this.creatureInfoInputExtractor.CreatureName = ""; this.creatureInfoInputExtractor.CreatureNote = ""; this.creatureInfoInputExtractor.CreatureOwner = ""; @@ -2019,9 +2021,11 @@ private void InitializeComponent() this.creatureInfoInputExtractor.CreatureTribe = ""; this.creatureInfoInputExtractor.domesticatedAt = new System.DateTime(2016, 7, 5, 13, 12, 15, 968); this.creatureInfoInputExtractor.father = null; - this.creatureInfoInputExtractor.Grown = new System.DateTime(2018, 5, 13, 17, 43, 44, 265); + this.creatureInfoInputExtractor.fatherId = new System.Guid("00000000-0000-0000-0000-000000000000"); + this.creatureInfoInputExtractor.Grown = new System.DateTime(2018, 5, 24, 23, 18, 24, 150); this.creatureInfoInputExtractor.Location = new System.Drawing.Point(321, 184); this.creatureInfoInputExtractor.mother = null; + this.creatureInfoInputExtractor.motherId = new System.Guid("00000000-0000-0000-0000-000000000000"); this.creatureInfoInputExtractor.MutationCounterFather = 0; this.creatureInfoInputExtractor.MutationCounterMother = 0; this.creatureInfoInputExtractor.Name = "creatureInfoInputExtractor"; @@ -3364,7 +3368,7 @@ private void InitializeComponent() this.speciesSelector1.LastSpecies = new string[0]; this.speciesSelector1.Location = new System.Drawing.Point(0, 103); this.speciesSelector1.Name = "speciesSelector1"; - this.speciesSelector1.Size = new System.Drawing.Size(1232, 710); + this.speciesSelector1.Size = new System.Drawing.Size(1232, 688); this.speciesSelector1.TabIndex = 0; // // Form1 @@ -3373,12 +3377,12 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1232, 813); - this.Controls.Add(this.statusStrip1); this.Controls.Add(this.tabControlMain); this.Controls.Add(this.speciesSelector1); this.Controls.Add(this.panelToolBar); this.Controls.Add(this.toolStrip2); this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.statusStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.Name = "Form1"; diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index dcbef2f4..a0152fc8 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -1206,6 +1206,9 @@ private void add2Lib(bool fromExtractor = true) creature.guid = input.CreatureGuid; else creature.guid = Guid.NewGuid(); + // if parent creatures don't exist in the library but they have a known id, save these for if they are imported later + if (creature.Mother == null && input.motherId != Guid.Empty) creature.motherGuid = input.motherId; + if (creature.Father == null && input.fatherId != Guid.Empty) creature.fatherGuid = input.fatherId; creature.recalculateCreatureValues(levelStep); creature.recalculateAncestorGenerations(); @@ -1916,7 +1919,7 @@ private ListViewItem createCreatureLVItem(Creature cr, ListViewGroup g) cr.topStatsCount.ToString(), cr.generation.ToString(), cr.levelFound.ToString(), - (cr.mutationsMaternal+cr.mutationsPaternal).ToString(), + cr.Mutations.ToString(), (DateTime.Now.CompareTo(cldGr) < 0 ? cldGr.ToString() : "-") }) .Concat(cr.levelsWild.Select(x => x.ToString()).ToArray()) .ToArray(); @@ -1995,8 +1998,13 @@ private ListViewItem createCreatureLVItem(Creature cr, ListViewGroup g) lvi.SubItems[9].ForeColor = Color.LightGray; // color for mutation - if (cr.mutationsMaternal + cr.mutationsPaternal > 0) - lvi.SubItems[10].BackColor = Color.FromArgb(225, 192, 255); + if (cr.Mutations > 0) + { + if (cr.Mutations > 19) + lvi.SubItems[10].BackColor = Utils.MutationColorOverLimit; + else + lvi.SubItems[10].BackColor = Utils.MutationColor; + } else lvi.SubItems[10].ForeColor = Color.LightGray; @@ -2721,7 +2729,7 @@ private IEnumerable applyLibraryFilterSettings(IEnumerable c // show also creatures with mutations? if (!libraryViews["Mutated"]) - creatures = creatures.Where(c => c.mutationsMaternal + c.mutationsPaternal <= 0); + creatures = creatures.Where(c => c.Mutations <= 0); // show also different sexes? if (!libraryViews["Females"]) @@ -5100,9 +5108,11 @@ private void importLastExportedCreature() var files = Directory.GetFiles(folder); if (files.Length > 0) { - setCreatureValuesToExtractor(ImportExported.importExportedCreature(files.OrderByDescending(f => File.GetLastWriteTime(f)).First())); + var cv = ImportExported.importExportedCreature(files.OrderByDescending(f => File.GetLastWriteTime(f)).First()); + setCreatureValuesToExtractor(cv); tabControlMain.SelectedTab = tabPageExtractor; extractLevels(true); + creatureInfoInputExtractor.CreatureGuid = cv.guid; } else MessageBox.Show("No exported creature-file found in the set folder\n" + folder + "\nYou have to export a creature first ingame.\n\nYou may also want to check the set folder in the settings. Usually the folder is\n" + @"…\Steam\steamapps\common\ARK\ShooterGame\Saved\DinoExports\", "No files found", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/ARKBreedingStats/ParentComboBox.cs b/ARKBreedingStats/ParentComboBox.cs index c451981f..699b5305 100644 --- a/ARKBreedingStats/ParentComboBox.cs +++ b/ARKBreedingStats/ParentComboBox.cs @@ -29,12 +29,19 @@ public Creature SelectedParent { get { - if (parentList != null && SelectedIndex > 0 && parentList.Count > SelectedIndex - 1) + // at index 0 is the n/a + if (parentList != null && SelectedIndex > 0 && SelectedIndex - 1 < parentList.Count) return parentList[SelectedIndex - 1]; return null; } } + public void Clear() + { + preselectedCreatureGuid = Guid.Empty; + SelectedIndex = 0; + } + public List ParentList { set diff --git a/ARKBreedingStats/Pedigree.Designer.cs b/ARKBreedingStats/Pedigree.Designer.cs index 10a4d1d1..41640401 100644 --- a/ARKBreedingStats/Pedigree.Designer.cs +++ b/ARKBreedingStats/Pedigree.Designer.cs @@ -35,12 +35,17 @@ private void InitializeComponent() this.listViewCreatures = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // // pictureBox // - this.pictureBox.Location = new System.Drawing.Point(525, 180); + this.pictureBox.Location = new System.Drawing.Point(375, 180); this.pictureBox.Name = "pictureBox"; this.pictureBox.Size = new System.Drawing.Size(256, 256); this.pictureBox.TabIndex = 0; @@ -52,7 +57,7 @@ private void InitializeComponent() this.lbPedigreeEmpty.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbPedigreeEmpty.Location = new System.Drawing.Point(0, 0); this.lbPedigreeEmpty.Name = "lbPedigreeEmpty"; - this.lbPedigreeEmpty.Size = new System.Drawing.Size(1043, 520); + this.lbPedigreeEmpty.Size = new System.Drawing.Size(881, 520); this.lbPedigreeEmpty.TabIndex = 1; this.lbPedigreeEmpty.Text = "Select a creature in the Library to see its pedigree here."; this.lbPedigreeEmpty.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -61,7 +66,7 @@ private void InitializeComponent() // this.pedigreeCreature1.Creature = null; this.pedigreeCreature1.IsVirtual = false; - this.pedigreeCreature1.Location = new System.Drawing.Point(525, 10); + this.pedigreeCreature1.Location = new System.Drawing.Point(375, 19); this.pedigreeCreature1.Name = "pedigreeCreature1"; this.pedigreeCreature1.Size = new System.Drawing.Size(296, 35); this.pedigreeCreature1.TabIndex = 2; @@ -71,13 +76,13 @@ private void InitializeComponent() this.listViewCreatures.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader2}); - this.listViewCreatures.Dock = System.Windows.Forms.DockStyle.Left; + this.listViewCreatures.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewCreatures.FullRowSelect = true; this.listViewCreatures.HideSelection = false; this.listViewCreatures.Location = new System.Drawing.Point(0, 0); this.listViewCreatures.MultiSelect = false; this.listViewCreatures.Name = "listViewCreatures"; - this.listViewCreatures.Size = new System.Drawing.Size(153, 520); + this.listViewCreatures.Size = new System.Drawing.Size(158, 520); this.listViewCreatures.TabIndex = 3; this.listViewCreatures.UseCompatibleStateImageBehavior = false; this.listViewCreatures.View = System.Windows.Forms.View.Details; @@ -94,18 +99,39 @@ private void InitializeComponent() this.columnHeader2.Text = "Lvl"; this.columnHeader2.Width = 31; // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.listViewCreatures); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.AutoScroll = true; + this.splitContainer1.Panel2.Controls.Add(this.pedigreeCreature1); + this.splitContainer1.Panel2.Controls.Add(this.pictureBox); + this.splitContainer1.Panel2.Controls.Add(this.lbPedigreeEmpty); + this.splitContainer1.Size = new System.Drawing.Size(1043, 520); + this.splitContainer1.SplitterDistance = 158; + this.splitContainer1.TabIndex = 4; + // // Pedigree // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScroll = true; - this.Controls.Add(this.listViewCreatures); - this.Controls.Add(this.pedigreeCreature1); - this.Controls.Add(this.lbPedigreeEmpty); - this.Controls.Add(this.pictureBox); + this.Controls.Add(this.splitContainer1); this.Name = "Pedigree"; this.Size = new System.Drawing.Size(1043, 520); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); } @@ -118,5 +144,6 @@ private void InitializeComponent() private System.Windows.Forms.ListView listViewCreatures; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.SplitContainer splitContainer1; } } diff --git a/ARKBreedingStats/Pedigree.cs b/ARKBreedingStats/Pedigree.cs index a4814730..fedb3e18 100644 --- a/ARKBreedingStats/Pedigree.cs +++ b/ARKBreedingStats/Pedigree.cs @@ -31,50 +31,59 @@ public Pedigree() lines.Add(new List()); noCreatureSelected(); listViewCreatures.ListViewItemSorter = new ListViewColumnSorter(); + splitContainer1.Panel2.Paint += Panel2_Paint; } - protected override void OnPaint(PaintEventArgs e) + private void Panel2_Paint(object sender, PaintEventArgs e) { - // paintBase - base.OnPaint(e); - - e.Graphics.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y); + e.Graphics.TranslateTransform(splitContainer1.Panel2.AutoScrollPosition.X, splitContainer1.Panel2.AutoScrollPosition.Y); if (creature != null) drawLines(e.Graphics); } + //protected override void OnPaint(PaintEventArgs e) + //{ + // // paintBase + // base.OnPaint(e); + + // e.Graphics.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y); + // if (creature != null) + // drawLines(e.Graphics); + //} + public void drawLines(Graphics g) { // lines contains all the coordinates the arrows should be drawn: x1,y1,x2,y2,red/green,mutated/equal - System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Green, 3); - myPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; - - g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - foreach (int[] line in lines[0]) + using (Pen myPen = new Pen(Color.Green, 3)) { - if (line[4] == 1) - myPen.Color = Color.DarkRed; - else if (line[4] == 2) - myPen.Color = Color.Green; - else - myPen.Color = Color.LightGray; - if (line[5] > 0) + myPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; + + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + foreach (int[] line in lines[0]) { - // if stat is mutated - int mutationBoxWidth = 14; - g.FillEllipse(Brushes.LightGreen, (line[0] + line[2] - mutationBoxWidth) / 2, (line[1] + line[3] - mutationBoxWidth) / 2, mutationBoxWidth, mutationBoxWidth); + if (line[4] == 1) + myPen.Color = Color.DarkRed; + else if (line[4] == 2) + myPen.Color = Color.Green; + else + myPen.Color = Color.LightGray; + if (line[5] > 0) + { + // if stat is mutated + int mutationBoxWidth = 14; + g.FillEllipse(Brushes.LightGreen, (line[0] + line[2] - mutationBoxWidth) / 2, (line[1] + line[3] - mutationBoxWidth) / 2, mutationBoxWidth, mutationBoxWidth); + } + g.DrawLine(myPen, line[0], line[1], line[2], line[3]); } - g.DrawLine(myPen, line[0], line[1], line[2], line[3]); - } - myPen.Color = Color.DarkGray; - myPen.Width = 1; - foreach (int[] line in lines[1]) - { - g.DrawLine(myPen, line[0], line[1], line[2], line[3]); + myPen.Color = Color.DarkGray; + myPen.Width = 1; + foreach (int[] line in lines[1]) + { + g.DrawLine(myPen, line[0], line[1], line[2], line[3]); + } + if (children.Count > 0) + g.DrawString("Descendants", new System.Drawing.Font("Arial", 14), new System.Drawing.SolidBrush(System.Drawing.Color.Black), 210, 170); } - if (children.Count > 0) - g.DrawString("Descendants", new System.Drawing.Font("Arial", 14), new System.Drawing.SolidBrush(System.Drawing.Color.Black), 210, 170); - myPen.Dispose(); } public void Clear() @@ -87,14 +96,14 @@ public void Clear() public void ClearControls() { // clear pedigree - this.SuspendLayout(); + SuspendLayout(); foreach (PedigreeCreature pc in pcs) pc.Dispose(); lines.Clear(); lines.Add(new List()); lines.Add(new List()); pictureBox.Image = null; - this.ResumeLayout(); + ResumeLayout(); } /// @@ -106,9 +115,9 @@ public void createPedigree() ClearControls(); if (creature != null) { - this.SuspendLayout(); + SuspendLayout(); - int leftBorder = 200; + int leftBorder = 50; lbPedigreeEmpty.Visible = false; @@ -143,15 +152,15 @@ public void createPedigree() pc.CreatureEdit += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit); pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners); pc.exportToClipboard += new PedigreeCreature.ExportToClipboardEventHandler(exportToClipboard); - Controls.Add(pc); + splitContainer1.Panel2.Controls.Add(pc); pcs.Add(pc); row++; } pictureBox.Image = CreatureColored.getColoredCreature(creature.colors, creature.species, enabledColorRegions, 256); - this.Invalidate(); - this.ResumeLayout(); + Invalidate(); + ResumeLayout(); } else { @@ -171,7 +180,7 @@ private bool createParentsChild(Creature creature, int x, int y, bool drawWithNo if (highlightCreature) pc.highlight = true; pc.Location = new Point(x + xS, y + yS + 40); - Controls.Add(pc); + splitContainer1.Panel2.Controls.Add(pc); pc.CreatureClicked += new PedigreeCreature.CreatureChangedEventHandler(CreatureClicked); pc.CreatureEdit += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit); pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners); @@ -182,7 +191,7 @@ private bool createParentsChild(Creature creature, int x, int y, bool drawWithNo { pc = new PedigreeCreature(creature.Mother, enabledColorRegions); pc.Location = new Point(x + xS, y + yS); - Controls.Add(pc); + splitContainer1.Panel2.Controls.Add(pc); pc.CreatureClicked += new PedigreeCreature.CreatureChangedEventHandler(CreatureClicked); pc.CreatureEdit += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit); pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners); @@ -194,7 +203,7 @@ private bool createParentsChild(Creature creature, int x, int y, bool drawWithNo { pc = new PedigreeCreature(creature.Father, enabledColorRegions); pc.Location = new Point(x + xS, y + yS + 80); - Controls.Add(pc); + splitContainer1.Panel2.Controls.Add(pc); pc.CreatureClicked += new PedigreeCreature.CreatureChangedEventHandler(CreatureClicked); pc.CreatureEdit += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit); pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners); diff --git a/ARKBreedingStats/PedigreeCreature.cs b/ARKBreedingStats/PedigreeCreature.cs index 811fd422..a9095793 100644 --- a/ARKBreedingStats/PedigreeCreature.cs +++ b/ARKBreedingStats/PedigreeCreature.cs @@ -129,14 +129,23 @@ public Creature Creature labelSex.BackColor = creature.neutered ? SystemColors.GrayText : Utils.sexColor(creature.sex); // creature Colors pictureBox1.Image = CreatureColored.getColoredCreature(creature.colors, "", enabledColorRegions, 24, 22, true); + tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(creature.species, creature.colors)); labelSex.Visible = true; pictureBox1.Visible = true; plainTextcurrentValuesToolStripMenuItem.Visible = true; aRKChatcurrentValuesToolStripMenuItem.Visible = true; } - labelMutations.BackColor = Color.FromArgb(225, 192, 255); - labelMutations.Text = (creature.mutationsMaternal + creature.mutationsPaternal).ToString(); - labelMutations.Visible = (creature.mutationsMaternal + creature.mutationsPaternal) > 0; + int totalMutations = creature.Mutations; + if (totalMutations > 0) + { + if (totalMutations > 19) + labelMutations.BackColor = Utils.MutationColorOverLimit; + else + labelMutations.BackColor = Utils.MutationColor; + labelMutations.Text = totalMutations.ToString(); + tt.SetToolTip(labelMutations, "Mutation-Counter\nMaternal: " + creature.mutationsMaternal + "\nPaternal: " + creature.mutationsPaternal); + } + labelMutations.Visible = totalMutations > 0; contextMenuAvailable = true; } } diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index 8d43eead..700406d9 100644 --- a/ARKBreedingStats/Properties/AssemblyInfo.cs +++ b/ARKBreedingStats/Properties/AssemblyInfo.cs @@ -34,6 +34,6 @@ // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.28.2")] +[assembly: AssemblyFileVersion("0.28.3")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/Stats.cs b/ARKBreedingStats/Stats.cs index a144506f..af391c7a 100644 --- a/ARKBreedingStats/Stats.cs +++ b/ARKBreedingStats/Stats.cs @@ -4,7 +4,7 @@ namespace ARKBreedingStats { public static class Stats { - private const double roundupDelta = 0.00001; + private const double roundupDelta = 0.0001; public static double calculateValue(int speciesIndex, int stat, int levelWild, int levelDom, bool dom, double tamingEff, double imprintingBonus) { @@ -31,8 +31,8 @@ public static double calculateValue(int speciesIndex, int stat, int levelWild, i //double result = Math.Round((Values.V.species[speciesIndex].stats[stat].BaseValue * tamedBaseHP * (1 + Values.V.species[speciesIndex].stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, Utils.precision(stat), MidpointRounding.AwayFromZero); // double is too precise and results in wrong values due to rounding. float results in better values, probably ARK uses float as well. // or rounding first to a precision of 7, then use the rounding of the precision - //double result = Math.Round((Values.V.species[speciesIndex].stats[stat].BaseValue * tamedBaseHP * (1 + Values.V.species[speciesIndex].stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, 7); - //result = Math.Round(result, Utils.precision(stat), MidpointRounding.AwayFromZero); + //double resultt = Math.Round((Values.V.species[speciesIndex].stats[stat].BaseValue * tamedBaseHP * (1 + Values.V.species[speciesIndex].stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult, 7); + //resultt = Math.Round(resultt, Utils.precision(stat), MidpointRounding.AwayFromZero); // adding an epsilon to handle rounding-errors double result = Math.Round((Values.V.species[speciesIndex].stats[stat].BaseValue * tamedBaseHP * (1 + Values.V.species[speciesIndex].stats[stat].IncPerWildLevel * levelWild) * imprintingM + add) * domMult + roundupDelta, Utils.precision(stat), MidpointRounding.AwayFromZero); diff --git a/ARKBreedingStats/Utils.cs b/ARKBreedingStats/Utils.cs index 70642461..ca502de3 100644 --- a/ARKBreedingStats/Utils.cs +++ b/ARKBreedingStats/Utils.cs @@ -60,6 +60,9 @@ private static void getRGBFromPercent(out int r, out int g, out int b, int perce } } + public static Color MutationColor { get { return Color.FromArgb(225, 192, 255); } } + public static Color MutationColorOverLimit { get { return Color.FromArgb(255, 200, 200); } } + public static string sexSymbol(Sex g) { switch (g) diff --git a/ARKBreedingStats/Values.cs b/ARKBreedingStats/Values.cs index 3d1abb5c..5739b452 100644 --- a/ARKBreedingStats/Values.cs +++ b/ARKBreedingStats/Values.cs @@ -284,22 +284,22 @@ public void applyMultipliers(CreatureCollection cc, bool eventMultipliers = fals // stat-multiplier for (int s = 0; s < 8; s++) { - species[sp].stats[s].BaseValue = (double)species[sp].statsRaw[s][0]; + species[sp].stats[s].BaseValue = (float)species[sp].statsRaw[s][0]; // don't apply the multiplier if AddWhenTamed is negative (e.g. Giganotosaurus, Griffin) - species[sp].stats[s].AddWhenTamed = (double)species[sp].statsRaw[s][3] * (species[sp].statsRaw[s][3] > 0 ? cc.multipliers[s][0] : 1); + species[sp].stats[s].AddWhenTamed = (float)species[sp].statsRaw[s][3] * (species[sp].statsRaw[s][3] > 0 ? (float)cc.multipliers[s][0] : 1); // don't apply the multiplier if MultAffinity is negative (e.g. Aberration variants) - species[sp].stats[s].MultAffinity = (double)species[sp].statsRaw[s][4] * (species[sp].statsRaw[s][4] > 0 ? cc.multipliers[s][1] : 1); - species[sp].stats[s].IncPerTamedLevel = (double)species[sp].statsRaw[s][2] * cc.multipliers[s][2]; - species[sp].stats[s].IncPerWildLevel = (double)species[sp].statsRaw[s][1] * cc.multipliers[s][3]; + species[sp].stats[s].MultAffinity = (float)species[sp].statsRaw[s][4] * (species[sp].statsRaw[s][4] > 0 ? (float)cc.multipliers[s][1] : 1); + species[sp].stats[s].IncPerTamedLevel = (float)species[sp].statsRaw[s][2] * (float)cc.multipliers[s][2]; + species[sp].stats[s].IncPerWildLevel = (float)species[sp].statsRaw[s][1] * (float)cc.multipliers[s][3]; if (cc.singlePlayerSettings && statMultipliersSP[s] != null) { // don't apply the multiplier if AddWhenTamed is negative (e.g. Giganotosaurus, Griffin) - species[sp].stats[s].AddWhenTamed *= statMultipliersSP[s][0] != null && species[sp].stats[s].AddWhenTamed > 0 ? (double)statMultipliersSP[s][0] : 1; + species[sp].stats[s].AddWhenTamed *= statMultipliersSP[s][0] != null && species[sp].stats[s].AddWhenTamed > 0 ? (float)statMultipliersSP[s][0] : 1; // don't apply the multiplier if MultAffinity is negative (e.g. Aberration variants) - species[sp].stats[s].MultAffinity *= statMultipliersSP[s][1] != null && species[sp].stats[s].MultAffinity > 0 ? (double)statMultipliersSP[s][1] : 1; - species[sp].stats[s].IncPerTamedLevel *= statMultipliersSP[s][2] != null ? (double)statMultipliersSP[s][2] : 1; - species[sp].stats[s].IncPerWildLevel *= statMultipliersSP[s][3] != null ? (double)statMultipliersSP[s][3] : 1; + species[sp].stats[s].MultAffinity *= statMultipliersSP[s][1] != null && species[sp].stats[s].MultAffinity > 0 ? (float)statMultipliersSP[s][1] : 1; + species[sp].stats[s].IncPerTamedLevel *= statMultipliersSP[s][2] != null ? (float)statMultipliersSP[s][2] : 1; + species[sp].stats[s].IncPerWildLevel *= statMultipliersSP[s][3] != null ? (float)statMultipliersSP[s][3] : 1; } } } diff --git a/ARKBreedingStats/multiplierTesting/StatMultiplierTestingControl.cs b/ARKBreedingStats/multiplierTesting/StatMultiplierTestingControl.cs index a8990324..5083fc0b 100644 --- a/ARKBreedingStats/multiplierTesting/StatMultiplierTestingControl.cs +++ b/ARKBreedingStats/multiplierTesting/StatMultiplierTestingControl.cs @@ -191,7 +191,7 @@ private void nudStatValue_ValueChanged(object sender, EventArgs e) private void updateMatchingColor() { // if matching, color green - double statValue = (double)nudStatValue.Value; + double statValue = (double)Math.Round(nudStatValue.Value, 1); double VP = Math.Round(V * (_percent ? 100 : 1), 1, MidpointRounding.AwayFromZero); if (VP == statValue) nudStatValue.BackColor = Color.LightGreen; diff --git a/ARKBreedingStats/species/CreatureStat.cs b/ARKBreedingStats/species/CreatureStat.cs index 04581716..707664bc 100644 --- a/ARKBreedingStats/species/CreatureStat.cs +++ b/ARKBreedingStats/species/CreatureStat.cs @@ -6,11 +6,11 @@ namespace ARKBreedingStats public class CreatureStat { public StatName Stat; - public double BaseValue; - public double IncPerWildLevel; - public double IncPerTamedLevel; - public double AddWhenTamed; - public double MultAffinity; // used with taming effectiveness + public float BaseValue; + public float IncPerWildLevel; + public float IncPerTamedLevel; + public float AddWhenTamed; + public float MultAffinity; // used with taming effectiveness public CreatureStat(StatName s) { Stat = s; } diff --git a/ARKBreedingStats/uiControls/ExportedCreatureControl.Designer.cs b/ARKBreedingStats/uiControls/ExportedCreatureControl.Designer.cs index cda62eca..b9a04620 100644 --- a/ARKBreedingStats/uiControls/ExportedCreatureControl.Designer.cs +++ b/ARKBreedingStats/uiControls/ExportedCreatureControl.Designer.cs @@ -30,6 +30,7 @@ private void InitializeComponent() { this.lbStatus = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btRemoveFile = new System.Windows.Forms.Button(); this.btLoadValues = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); @@ -45,6 +46,7 @@ private void InitializeComponent() // // groupBox1 // + this.groupBox1.Controls.Add(this.btRemoveFile); this.groupBox1.Controls.Add(this.btLoadValues); this.groupBox1.Controls.Add(this.lbStatus); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -54,6 +56,18 @@ private void InitializeComponent() this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; // + // btRemoveFile + // + this.btRemoveFile.Dock = System.Windows.Forms.DockStyle.Right; + this.btRemoveFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btRemoveFile.Location = new System.Drawing.Point(430, 16); + this.btRemoveFile.Name = "btRemoveFile"; + this.btRemoveFile.Size = new System.Drawing.Size(30, 28); + this.btRemoveFile.TabIndex = 2; + this.btRemoveFile.Text = "×"; + this.btRemoveFile.UseVisualStyleBackColor = true; + this.btRemoveFile.Click += new System.EventHandler(this.btRemoveFile_Click); + // // btLoadValues // this.btLoadValues.Location = new System.Drawing.Point(6, 19); @@ -82,5 +96,6 @@ private void InitializeComponent() private System.Windows.Forms.Label lbStatus; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button btLoadValues; + private System.Windows.Forms.Button btRemoveFile; } } diff --git a/ARKBreedingStats/uiControls/ExportedCreatureControl.cs b/ARKBreedingStats/uiControls/ExportedCreatureControl.cs index 0849c20b..7cffc698 100644 --- a/ARKBreedingStats/uiControls/ExportedCreatureControl.cs +++ b/ARKBreedingStats/uiControls/ExportedCreatureControl.cs @@ -1,6 +1,7 @@ using ARKBreedingStats.species; using System; using System.Drawing; +using System.IO; using System.Windows.Forms; namespace ARKBreedingStats.uiControls @@ -14,17 +15,30 @@ public partial class ExportedCreatureControl : UserControl public CreatureValues creatureValues; public ImportStatus Status { get; internal set; } public DateTime AddedToLibrary; + private string exportedFile; + private ToolTip tt; public ExportedCreatureControl() { InitializeComponent(); } - public ExportedCreatureControl(CreatureValues creatureValues) + public ExportedCreatureControl(string filePath) { InitializeComponent(); + exportedFile = filePath; + CreatureValues creatureValues = ImportExported.importExportedCreature(filePath); this.creatureValues = creatureValues; - groupBox1.Text = creatureValues.name + " (" + creatureValues.species + ", Lv " + creatureValues.level + "), exported at " + Utils.shortTimeDate(creatureValues.domesticatedAt); + groupBox1.Text = creatureValues.name + " (" + creatureValues.species + ", Lv " + creatureValues.level + "), exported at " + Utils.shortTimeDate(creatureValues.domesticatedAt) + + ". Filename: " + Path.GetFileName(filePath); + Disposed += ExportedCreatureControl_Disposed; + tt = new ToolTip(); + tt.SetToolTip(btRemoveFile, "Delete the exported game-file"); + } + + private void ExportedCreatureControl_Disposed(object sender, EventArgs e) + { + tt.RemoveAll(); } private void btLoadValues_Click(object sender, EventArgs e) @@ -75,5 +89,26 @@ public enum ImportStatus JustImported, OldImported } + + private void btRemoveFile_Click(object sender, EventArgs e) + { + removeFile(); + } + + public void removeFile(bool getConfirmation = true) + { + if (File.Exists(exportedFile)) + { + if (!getConfirmation || MessageBox.Show("Are you sure to remove the exported file for this creature?\nThis cannot be undone.", "Remove file?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) + == DialogResult.Yes) + { + File.Delete(exportedFile); + } + } + else + { + MessageBox.Show("The file does not exist:\n" + exportedFile, "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } } diff --git a/ARKBreedingStats/uiControls/NamePatterns.cs b/ARKBreedingStats/uiControls/NamePatterns.cs index b8b5a7c1..1f711721 100644 --- a/ARKBreedingStats/uiControls/NamePatterns.cs +++ b/ARKBreedingStats/uiControls/NamePatterns.cs @@ -121,7 +121,7 @@ static public Dictionary createTokenDictionary(Creature creature dmg + effImp; - var mutasn = creature.mutationsMaternal + creature.mutationsPaternal; + var mutasn = creature.Mutations; string mutas; if (mutasn > 99) mutas = "99"; diff --git a/ARKBreedingStats/uiControls/RegionColorChooser.cs b/ARKBreedingStats/uiControls/RegionColorChooser.cs index 1ff6932a..2e0449aa 100644 --- a/ARKBreedingStats/uiControls/RegionColorChooser.cs +++ b/ARKBreedingStats/uiControls/RegionColorChooser.cs @@ -16,7 +16,7 @@ public partial class RegionColorChooser : UserControl public delegate void RegionColorChosenEventHandler(); public event RegionColorChosenEventHandler RegionColorChosen; private Button[] buttonColors; - private int[] colorIDs; + private int[] _colorIDs; public bool[] ColorRegionsUseds; private MyColorPicker colorPicker; private List colorRegions; @@ -26,16 +26,17 @@ public RegionColorChooser() { InitializeComponent(); buttonColors = new Button[] { buttonColor0, buttonColor1, buttonColor2, buttonColor3, buttonColor4, buttonColor5 }; - colorIDs = new int[6]; + _colorIDs = new int[6]; ColorRegionsUseds = new bool[6]; colorPicker = new MyColorPicker(); tt = new ToolTip(); + tt.AutoPopDelay = 7000; Disposed += RegionColorChooser_Disposed; } public void setCreature(string species, int[] colorIDs) { - this.colorIDs = colorIDs; + _colorIDs = colorIDs.ToArray(); int si = Values.V.speciesNames.IndexOf(species); if (si >= 0 && Values.V.species[si].colors != null) @@ -57,18 +58,22 @@ public void setCreature(string species, int[] colorIDs) if (buttonColors[r].Visible) { - setColorButton(buttonColors[r], CreatureColors.creatureColor(colorIDs[r])); - tt.SetToolTip(buttonColors[r], colorRegions[r].name); + setColorButton(buttonColors[r], r); } } } + public int[] colorIDs + { + get { return _colorIDs.ToArray(); } + } + public void Clear() { for (int r = 0; r < buttonColors.Length; r++) { - buttonColors[r].Hide(); - setColorButton(buttonColors[r], CreatureColors.creatureColor(0)); + _colorIDs[r] = 0; + setColorButton(buttonColors[r], r); } } @@ -106,20 +111,25 @@ private void chooseColor(int region, Button sender) { if (!colorPicker.isShown && colorRegions != null) { - colorPicker.SetColors(colorIDs, region, colorRegions[region].name, colorRegions[region].colorIds); + colorPicker.SetColors(_colorIDs, region, colorRegions[region].name, colorRegions[region].colorIds); if (colorPicker.ShowDialog() == DialogResult.OK) { // color was chosen - setColorButton(sender, species.CreatureColors.creatureColor(colorIDs[region])); + setColorButton(sender, region); RegionColorChosen?.Invoke(); } } } - private void setColorButton(Button bt, Color cl) + private void setColorButton(Button bt, int region) { + int colorId = _colorIDs[region]; + Color cl = CreatureColors.creatureColor(colorId); bt.BackColor = cl; bt.ForeColor = Utils.ForeColor(cl); + // tooltip + if (colorRegions != null) + tt.SetToolTip(bt, colorRegions[region].name + " (" + region.ToString() + "):\n" + CreatureColors.creatureColorName(colorId) + " (" + colorId.ToString() + ")"); } private void RegionColorChooser_Disposed(object sender, EventArgs e) diff --git a/ARKBreedingStats/ver.txt b/ARKBreedingStats/ver.txt index 2a11f783..f6e406de 100644 --- a/ARKBreedingStats/ver.txt +++ b/ARKBreedingStats/ver.txt @@ -1 +1 @@ -279.275.1,0.28.2 +279.275.1,0.28.3