Skip to content

Commit

Permalink
fixed input-range for ocr-calibrate from font-input. fixed not appear…
Browse files Browse the repository at this point in the history
…ing image when calibrating for a not yet existing resolution. added name of creature to the message if in the breeding-planner a creature with all topstats exists. added function to save creature-values if extraction failed, these values can be reloaded, nothing else can be done with this. increased decimal-places for stat-multipliers to 3. added new default-stat-multipliers for SP.
  • Loading branch information
cadaei committed Jun 27, 2017
1 parent 32a97b6 commit c505178
Show file tree
Hide file tree
Showing 20 changed files with 619 additions and 276 deletions.
1 change: 1 addition & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<DependentUpon>CreatureInfoInput.cs</DependentUpon>
</Compile>
<Compile Include="species\CreatureStat.cs" />
<Compile Include="species\CreatureValues.cs" />
<Compile Include="species\Species.cs" />
<Compile Include="SpeechRecognition.cs" />
<Compile Include="settings\customSoundChooser.cs">
Expand Down
9 changes: 7 additions & 2 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ public void drawBestParents(BreedingMode breedingMode, bool updateBreedingData =
if (breedingMode == BreedingMode.TopStatsConservative)
{
bool bestCreatureAlreadyAvailable = true;
Creature bestCreature = null;
List<Creature> femalesAndMales = females.Concat(males).ToList();
foreach (Creature cr in femalesAndMales)
{
Expand All @@ -348,12 +349,16 @@ public void drawBestParents(BreedingMode breedingMode, bool updateBreedingData =
}
}
if (bestCreatureAlreadyAvailable)
{
bestCreature = cr;
break;
}
}

if (bestCreatureAlreadyAvailable)
MessageBox.Show("There is already a creature in your library that has all the available top-stats.\n"
+ "The currently selected conservative-breeding-mode might show some suggestions that may seem non-optimal.\n\n"
MessageBox.Show("There is already a creature in your library that has all the available top-stats ("
+ bestCreature.name + " " + Utils.sexSymbol(bestCreature.gender) + ")."
+ "\nThe currently selected conservative-breeding-mode might show some suggestions that may seem non-optimal.\n\n"
+ "Change the breeding-mode to \"High Stats\" for better suggestions.",
"Top-creature already available", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Creature : IEquatable<Creature>
public bool topBreedingCreature; // true if it has some topBreedingStats and if it's male, no other male has more topBreedingStats
[XmlIgnore]
public Int16 topness; // permille of mean of wildlevels compared to toplevels
public string owner;
public string owner = "";
public string tribe = "";
public string note; // user defined note about that creature
public Guid guid;
Expand Down
2 changes: 2 additions & 0 deletions ARKBreedingStats/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace ARKBreedingStats
[XmlArray]
public List<Creature> creatures = new List<Creature>();
[XmlArray]
public List<species.CreatureValues> creaturesValues = new List<species.CreatureValues>();
[XmlArray]
public double[][] multipliers; // multipliers[stat][m], m: 0:tamingadd, 1:tamingmult, 2:levelupdom, 3:levelupwild
[XmlArray]
public List<TimerListEntry> timerListEntries = new List<TimerListEntry>();
Expand Down
185 changes: 117 additions & 68 deletions ARKBreedingStats/Form1.Designer.cs

Large diffs are not rendered by default.

113 changes: 108 additions & 5 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ private void Form1_Load(object sender, EventArgs e)
// OCR
ocrControl1.setWhiteThreshold(Properties.Settings.Default.OCRWhiteThreshold);

// default ocr-file was renamed
if (Properties.Settings.Default.ocrFile == "json/ocr.json")
Properties.Settings.Default.ocrFile = "json/ocr_1920x1080_100.json";

ocr.OCRTemplate ocrConfig = ArkOCR.OCR.ocrConfig.loadFile(Properties.Settings.Default.ocrFile);
if (ocrConfig != null)
{
Expand Down Expand Up @@ -608,6 +612,7 @@ private void extractionFailed()
labelDoc.Visible = false;
if (radioButtonBred.Checked && numericUpDownImprintingBonusExtractor.Value > 0)
labelImprintingFailInfo.Visible = true;
toolStripButtonSaveCreatureValuesTemp.Visible = true;
}

private void setUniqueTE()
Expand Down Expand Up @@ -695,6 +700,7 @@ private void showSumOfChosenLevels()
{
creatureInfoInputExtractor.parentListValid = false;
radarChartExtractor.setLevels(statIOs.Select(s => s.LevelWild).ToArray());
toolStripButtonSaveCreatureValuesTemp.Visible = false;
}
creatureInfoInputExtractor.ButtonEnabled = allValid;
groupBoxRadarChartExtractor.Visible = allValid;
Expand Down Expand Up @@ -1289,7 +1295,7 @@ private bool loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
{
creatureCollection.multipliers = oldMultipliers;
if (creatureCollection.multipliers == null)
creatureCollection.multipliers = Values.V.getOfficialMultipliers();
creatureCollection.multipliers = Values.V.getOfficialMultipliers(true);
}

applySettingsToValues();
Expand Down Expand Up @@ -1318,7 +1324,8 @@ private bool loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
filterListAllowed = true;

setCollectionChanged(creatureWasAdded); // setCollectionChanged only if there really were creatures added from the old library to the just opened one
// creatures loaded.

///// creatures loaded.

lastAutoSaveBackup = DateTime.Now.AddMinutes(-10);

Expand All @@ -1340,6 +1347,8 @@ private bool loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
// apply last sorting
this.listViewLibrary.Sort();

updateTempCreatureDropDown();

Properties.Settings.Default.LastSaveFile = fileName;
return true;
}
Expand Down Expand Up @@ -1751,7 +1760,7 @@ private void newCollection()
if (creatureCollection.additionalValues.Length > 0) Values.V.loadValues(); // if old collection had additionalValues, load the original ones.

if (creatureCollection.multipliers == null)
creatureCollection.multipliers = Values.V.getOfficialMultipliers();
creatureCollection.multipliers = Values.V.getOfficialMultipliers(true);
// use previously used multipliers again in the new file
double[][] oldMultipliers = creatureCollection.multipliers;

Expand Down Expand Up @@ -2355,8 +2364,14 @@ private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
timerList1.updateTimer = (tabControlMain.SelectedTab == tabPageTimer);
toolStripButtonCopy2Extractor.Visible = (tabControlMain.SelectedTab == tabPageStatTesting);
toolStripButtonCopy2Tester.Visible = (tabControlMain.SelectedTab == tabPageExtractor);
toolStripButtonExtract.Visible = (tabControlMain.SelectedTab == tabPageExtractor);

bool extrTab = tabControlMain.SelectedTab == tabPageExtractor;
toolStripButtonCopy2Tester.Visible = extrTab;
toolStripButtonExtract.Visible = extrTab;
toolStripButtonDeleteTempCreature.Visible = extrTab;
toolStripButtonSaveCreatureValuesTemp.Visible = extrTab;
toolStripCBTempCreatures.Visible = extrTab;

toolStripButtonAddPlayer.Visible = (tabControlMain.SelectedTab == tabPagePlayerTribes);
toolStripButtonAddTribe.Visible = (tabControlMain.SelectedTab == tabPagePlayerTribes);
toolStripButtonClear.Visible = (tabControlMain.SelectedTab == tabPageExtractor || tabControlMain.SelectedTab == tabPageStatTesting);
Expand Down Expand Up @@ -2408,6 +2423,11 @@ private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
}
}

/// <summary>
/// Call if the collection has changed and needs to be saved.
/// </summary>
/// <param name="changed">is the collection changed?</param>
/// <param name="species">set to a specific species if only this species needs updates in the pedigree / breeding-planner. Set to "" if no species needs updates</param>
private void setCollectionChanged(bool changed, string species = null)
{
if (changed)
Expand Down Expand Up @@ -3732,6 +3752,89 @@ private void OcrupdateWhiteThreshold(int value)
ArkOCR.OCR.whiteThreshold = value;
}

private void toolStripCBTempCreatures_SelectedIndexChanged(object sender, EventArgs e)
{
if (toolStripCBTempCreatures.SelectedIndex >= 0)
{
species.CreatureValues cv = creatureCollection.creaturesValues[toolStripCBTempCreatures.SelectedIndex];
for (int s = 0; s < 8; s++)
statIOs[s].Input = cv.statValues[s];
comboBoxSpeciesGlobal.SelectedIndex = Values.V.speciesNames.IndexOf(cv.species);
creatureInfoInputExtractor.Name = cv.name;
creatureInfoInputExtractor.CreatureOwner = cv.owner;
creatureInfoInputExtractor.CreatureTribe = cv.tribe;
creatureInfoInputExtractor.CreatureSex = cv.gender;
creatureInfoInputExtractor.Neutered = cv.neutered;
creatureInfoInputExtractor.mother = cv.Mother;
creatureInfoInputExtractor.father = cv.Father;

numericUpDownLevel.Value = cv.level;
numericUpDownLowerTEffBound.Value = (decimal)cv.tamingEffMin;
numericUpDownUpperTEffBound.Value = (decimal)cv.tamingEffMax;

if (cv.isBred)
radioButtonBred.Checked = true;
else if (cv.isTamed)
radioButtonTamed.Checked = true;
else radioButtonWild.Checked = true;
numericUpDownImprintingBonusExtractor.Value = (decimal)cv.imprintingBonus;

toolStripButtonDeleteTempCreature.Visible = true;
}
else
toolStripButtonDeleteTempCreature.Visible = false;
}

private void toolStripButtonSaveCreatureValuesTemp_Click(object sender, EventArgs e)
{
species.CreatureValues cv = new species.CreatureValues();
for (int s = 0; s < 8; s++)
cv.statValues[s] = statIOs[s].Input;
cv.species = comboBoxSpeciesGlobal.SelectedItem.ToString();
cv.name = creatureInfoInputExtractor.CreatureName;
cv.owner = creatureInfoInputExtractor.CreatureOwner;
cv.tribe = creatureInfoInputExtractor.CreatureTribe;
cv.gender = creatureInfoInputExtractor.CreatureSex;
cv.neutered = creatureInfoInputExtractor.Neutered;
cv.Mother = creatureInfoInputExtractor.mother;
cv.Father = creatureInfoInputExtractor.father;

cv.level = (int)numericUpDownLevel.Value;
cv.tamingEffMin = (double)numericUpDownLowerTEffBound.Value;
cv.tamingEffMax = (double)numericUpDownUpperTEffBound.Value;

cv.isBred = false;
cv.isTamed = false;
if (radioButtonBred.Checked)
cv.isBred = true;
else if (radioButtonTamed.Checked)
cv.isTamed = true;
cv.imprintingBonus = (double)numericUpDownImprintingBonusExtractor.Value;

creatureCollection.creaturesValues.Add(cv);
setCollectionChanged(true, "");

updateTempCreatureDropDown();
}

private void toolStripButtonDeleteTempCreature_Click(object sender, EventArgs e)
{
if (toolStripCBTempCreatures.SelectedIndex >= 0
&& MessageBox.Show("Remove the data of this cached creature?", "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
creatureCollection.creaturesValues.RemoveAt(toolStripCBTempCreatures.SelectedIndex);
updateTempCreatureDropDown();
setCollectionChanged(true, "");
}
}

private void updateTempCreatureDropDown()
{
toolStripCBTempCreatures.Items.Clear();
foreach (species.CreatureValues cv in creatureCollection.creaturesValues)
toolStripCBTempCreatures.Items.Add(cv.name + " (" + cv.species + ")");
}

/// <summary>
/// fixes typos saved in earlier versions. is called right after loading a library
/// </summary>
Expand Down
Loading

0 comments on commit c505178

Please sign in to comment.