Skip to content

Commit

Permalink
added movable splitter between pedigree and creature-list. added butt…
Browse files Browse the repository at this point in the history
…on in exportedCreaturesList to remove exported creature-file. fixed parent-linking when importing creature whose parents were not yet imported. fix for mutation-input if creature has so many mutations the game considers it negative. fixed rounding-error in statmultiplierTester. importLastExported now sets the creature-id. fix regarding clearing the color-regions. added paternal and maternal mutations for tooltip in pedigree and breeding-plan. fixed mutation-limit in breeding-plan, so only pairs where both creature exceed the limit are filtered out. added tooltip infos about the color-names on the region-color-chooser (#695).
  • Loading branch information
cadaei committed May 27, 2018
1 parent 6f20172 commit 8e7b27c
Show file tree
Hide file tree
Showing 24 changed files with 384 additions and 214 deletions.
18 changes: 10 additions & 8 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion ARKBreedingStats/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class Creature : IEquatable<Creature>
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<string> tags = new List<string>();
Expand Down Expand Up @@ -211,8 +211,15 @@ public void recalculateCreatureValues(int? levelStep)
}
calculateLevelFound(levelStep);
}

[XmlIgnore]
public int Mutations
{
get { return mutationsMaternal + mutationsPaternal; }
}
}


public enum Sex
{
Unknown = 0,
Expand Down
1 change: 1 addition & 0 deletions ARKBreedingStats/CreatureBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
215 changes: 118 additions & 97 deletions ARKBreedingStats/CreatureColored.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}
}
}
Loading

0 comments on commit 8e7b27c

Please sign in to comment.