Skip to content

Commit

Permalink
fix for out-of-range-error. fix for suspended layout resizing-error. …
Browse files Browse the repository at this point in the history
…performance-tweak in tester.
  • Loading branch information
cadaei committed Feb 5, 2017
1 parent e9c7cd3 commit ae7a6bd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 52 deletions.
5 changes: 3 additions & 2 deletions ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public partial class CreatureInfoInput : UserControl
public CreatureInfoInput()
{
InitializeComponent();
speciesIndex = -1;
parentComboBoxMother.naLabel = " - Mother n/a";
parentComboBoxMother.Items.Add(" - Mother n/a");
parentComboBoxFather.naLabel = " - Father n/a";
Expand Down Expand Up @@ -171,7 +172,7 @@ private void groupBox1_Enter(object sender, EventArgs e)

private void dhmInputGrown_TextChanged(object sender, EventArgs e)
{
if (updateMaturation)
if (updateMaturation && speciesIndex >= 0 && Values.V.species[speciesIndex] != null)
{
updateMaturation = false;
numericUpDownWeight.Value = Values.V.species[speciesIndex].breeding != null && Values.V.species[speciesIndex].breeding.maturationTimeAdjusted > 0 ?
Expand Down Expand Up @@ -263,7 +264,7 @@ public int SpeciesIndex
set
{
speciesIndex = value;
bool breedingPossible = Values.V.species[speciesIndex].breeding != null;
bool breedingPossible = Values.V.species.Count > value && Values.V.species[speciesIndex].breeding != null;

dhmInputCooldown.Visible = breedingPossible;
dhmInputGrown.Visible = breedingPossible;
Expand Down
68 changes: 35 additions & 33 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ private void Form1_Load(object sender, EventArgs e)
for (int i = 0; i < custWs.Length; i++)
{
if (i < custWd.Length)
{
custW.Add(custWs[i], custWd[i]);
}
}
}
statWeighting1.CustomWeightings = custW;
Expand Down Expand Up @@ -156,7 +154,7 @@ private void Form1_Load(object sender, EventArgs e)
if (Utils.precision(s) == 3) { statIOs[s].Percent = true; testingIOs[s].Percent = true; }
statIOs[s].statIndex = s;
testingIOs[s].statIndex = s;
testingIOs[s].LevelChanged += new LevelChangedEventHandler(this.statIOUpdateValue);
testingIOs[s].LevelChanged += new LevelChangedEventHandler(this.testingStatIOValueUpdate);
testingIOs[s].InputType = StatIOInputType.LevelsInputType;
statIOs[s].InputValueChanged += new InputValueChangedEventHandler(this.statIOQuickWildLevelCheck);
considerStatHighlight[s] = ((Properties.Settings.Default.consideredStats & (1 << s)) > 0);
Expand Down Expand Up @@ -372,6 +370,7 @@ private bool extractLevels()
this.checkBoxJustTamed.BackColor = Color.LightSalmon;
panelWildTamedBred.BackColor = Color.LightSalmon;
extractionFailed();
ResumeLayout();
return false;
}

Expand Down Expand Up @@ -426,6 +425,7 @@ private bool extractLevels()
if (!Extraction.E.validResults)
{
extractionFailed();
ResumeLayout();
return false;
}
if (nonUniqueStats)
Expand Down Expand Up @@ -1002,13 +1002,26 @@ private void assignCollectionClasses()
timerList1.TimerListEntries = creatureCollection.timerListEntries;
}

private void applyMultipliersToValues()
private void applySettingsToValues()
{
// apply multipliers
Values.V.applyMultipliersToStats(creatureCollection.multipliers);
Values.V.applyMultipliersToBreedingTimes(creatureCollection.breedingMultipliers);
Values.V.imprintingMultiplier = creatureCollection.imprintingMultiplier;
Values.V.tamingSpeedMultiplier = creatureCollection.tamingSpeedMultiplier;
Values.V.tamingFoodRateMultiplier = creatureCollection.tamingFoodRateMultiplier;

// apply level settings
creatureBoxListView.BarMaxLevel = creatureCollection.maxChartLevel;
for (int s = 0; s < 8; s++)
{
statIOs[s].barMaxLevel = creatureCollection.maxChartLevel;
testingIOs[s].barMaxLevel = creatureCollection.maxChartLevel;
}
breedingPlan1.maxWildLevels = creatureCollection.maxWildLevel;
radarChart1.initializeVariables(creatureCollection.maxChartLevel);
statPotentials1.levelDomMax = creatureCollection.maxDomLevel;
statPotentials1.levelGraphMax = creatureCollection.maxChartLevel;
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -1136,7 +1149,7 @@ private void loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
creatureCollection.multipliers = Values.V.getOfficialMultipliers();
}

applyMultipliersToValues();
applySettingsToValues();
assignCollectionClasses();

bool creatureWasAdded = false;
Expand All @@ -1158,8 +1171,6 @@ private void loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
setCollectionChanged(creatureWasAdded); // setCollectionChanged only if there really were creatures added from the old library to the just opened one
// creatures loaded.

applyLevelSettings();

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

// calculate creature values
Expand Down Expand Up @@ -1509,7 +1520,7 @@ private void checkForUpdates(bool silentCheck = false)
{
if (Values.V.loadValues())
{
applyMultipliersToValues();
applySettingsToValues();
updateSpeciesComboboxes();
MessageBox.Show("Download and update of new creature-stats successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
updateStatusBar();
Expand Down Expand Up @@ -1564,7 +1575,7 @@ private void newCollection()
creatureCollection.multipliers = oldMultipliers;
pedigree1.Clear();
breedingPlan1.Clear();
applyMultipliersToValues();
applySettingsToValues();
assignCollectionClasses();

updateCreatureListings();
Expand Down Expand Up @@ -1622,7 +1633,8 @@ private void Form1_FormClosed(object sender, FormClosedEventArgs e)
Properties.Settings.Default.customStatWeightNames = custWs.ToArray();

// save last selected species in combobox
Properties.Settings.Default.lastSpecies = comboBoxSpeciesExtractor.SelectedItem.ToString();
if (comboBoxSpeciesExtractor.SelectedIndex >= 0)
Properties.Settings.Default.lastSpecies = comboBoxSpeciesExtractor.SelectedItem.ToString();

// save settings for next session
Properties.Settings.Default.Save();
Expand Down Expand Up @@ -2202,9 +2214,9 @@ private void updateAllTesterValues()
{
if (s == 6)
updateTorporInTester = true;
statIOUpdateValue(testingIOs[s]);
testingStatIOsRecalculateValue(testingIOs[s]);
}
statIOUpdateValue(testingIOs[7]);
testingStatIOsRecalculateValue(testingIOs[7]);
}

private void NumericUpDownTestingTE_ValueChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -2255,10 +2267,9 @@ private void checkBoxQuickWildCheck_CheckedChanged(object sender, EventArgs e)
/// Updates the values in the testing-statIOs
/// </summary>
/// <param name="sIo"></param>
private void statIOUpdateValue(StatIO sIo)
private void testingStatIOValueUpdate(StatIO sIo)
{
sIo.BreedingValue = Stats.calculateValue(cbbStatTestingSpecies.SelectedIndex, sIo.statIndex, sIo.LevelWild, 0, true, 1, 0);
sIo.Input = Stats.calculateValue(cbbStatTestingSpecies.SelectedIndex, sIo.statIndex, sIo.LevelWild, sIo.LevelDom, (radioButtonTesterTamed.Checked || radioButtonTesterBred.Checked), (radioButtonTesterBred.Checked ? 1 : (double)NumericUpDownTestingTE.Value / 100), (radioButtonTesterBred.Checked ? (double)numericUpDownImprintingBonusTester.Value / 100 : 0));
testingStatIOsRecalculateValue(sIo);

// update Torpor-level if changed value is not from torpor-StatIO
if (updateTorporInTester && sIo != statTestingTorpor)
Expand Down Expand Up @@ -2289,6 +2300,12 @@ private void statIOUpdateValue(StatIO sIo)
statPotentials1.setLevels(levelsWild, false);
}

private void testingStatIOsRecalculateValue(StatIO sIo)
{
sIo.BreedingValue = Stats.calculateValue(cbbStatTestingSpecies.SelectedIndex, sIo.statIndex, sIo.LevelWild, 0, true, 1, 0);
sIo.Input = Stats.calculateValue(cbbStatTestingSpecies.SelectedIndex, sIo.statIndex, sIo.LevelWild, sIo.LevelDom, (radioButtonTesterTamed.Checked || radioButtonTesterBred.Checked), (radioButtonTesterBred.Checked ? 1 : (double)NumericUpDownTestingTE.Value / 100), (radioButtonTesterBred.Checked ? (double)numericUpDownImprintingBonusTester.Value / 100 : 0));
}

private void onlinehelpToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/cadon/ARKStatsExtractor/wiki/manual");
Expand Down Expand Up @@ -2781,32 +2798,17 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
Settings settingsfrm = new Settings(creatureCollection);
if (settingsfrm.ShowDialog() == DialogResult.OK)
{
applyMultipliersToValues();
applySettingsToValues();
autoSave = Properties.Settings.Default.autosave;
autoSaveMinutes = Properties.Settings.Default.autosaveMinutes;
creatureBoxListView.maxDomLevel = creatureCollection.maxDomLevel;
breedingPlan1.maxSuggestions = creatureCollection.maxBreedingSuggestions;
fileSync.changeFile(currentFileName); // only to trigger the update, filename is not changed
applyLevelSettings();

setCollectionChanged(true);
}
}

private void applyLevelSettings()
{
creatureBoxListView.BarMaxLevel = creatureCollection.maxChartLevel;
for (int s = 0; s < 8; s++)
{
statIOs[s].barMaxLevel = creatureCollection.maxChartLevel;
testingIOs[s].barMaxLevel = creatureCollection.maxChartLevel;
}
breedingPlan1.maxWildLevels = creatureCollection.maxWildLevel;
radarChart1.initializeVariables(creatureCollection.maxChartLevel);
statPotentials1.levelDomMax = creatureCollection.maxDomLevel;
statPotentials1.levelGraphMax = creatureCollection.maxChartLevel;
}

/// <summary>
/// Display the wild-levels, assuming it's a wild creature. Used for quick checking
/// </summary>
Expand Down Expand Up @@ -3136,7 +3138,7 @@ private void toolStripButtonCopy2Tester_Click_1(object sender, EventArgs e)
{
testingIOs[s].LevelWild = statIOs[s].LevelWild;
testingIOs[s].LevelDom = statIOs[s].LevelDom;
statIOUpdateValue(testingIOs[s]);
testingStatIOValueUpdate(testingIOs[s]);
}
tabControlMain.SelectedTab = tabPageStatTesting;
setTesterInfoInputCreature();
Expand Down Expand Up @@ -3334,7 +3336,7 @@ private bool loadAdditionalValues(string file, bool showResult = false)
{
if (Values.V.loadAdditionalValues(file, showResult))
{
applyMultipliersToValues();
applySettingsToValues();
updateSpeciesComboboxes();
creatureCollection.additionalValues = Path.GetFileName(file);
updateStatusBar();
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.21.0")]
[assembly: AssemblyFileVersion("0.21.1")]
33 changes: 18 additions & 15 deletions ARKBreedingStats/StatWeighting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,26 @@ public Dictionary<string, double[]> CustomWeightings
get { return customWeightings; }
set
{
customWeightings = value;
// clear custom presets
for (int i = contextMenuStrip1.Items.Count - 4; i > 1; i--)
if (value != null)
{
contextMenuStrip1.Items.RemoveAt(i);
}
deletePresetToolStripMenuItem.DropDownItems.Clear();
customWeightings = value;
// clear custom presets
for (int i = contextMenuStrip1.Items.Count - 4; i > 1; i--)
{
contextMenuStrip1.Items.RemoveAt(i);
}
deletePresetToolStripMenuItem.DropDownItems.Clear();

foreach (KeyValuePair<string, double[]> e in customWeightings)
{
ToolStripMenuItem ti = new ToolStripMenuItem(e.Key);
ti.Click += new System.EventHandler(this.ToolStripMenuItemCustom_Click);
contextMenuStrip1.Items.Insert(contextMenuStrip1.Items.Count - 3, ti);
// delete entry
ti = new ToolStripMenuItem(e.Key);
ti.Click += new System.EventHandler(this.ToolStripMenuItemDelete_Click);
deletePresetToolStripMenuItem.DropDownItems.Add(ti);
foreach (KeyValuePair<string, double[]> e in customWeightings)
{
ToolStripMenuItem ti = new ToolStripMenuItem(e.Key);
ti.Click += new System.EventHandler(this.ToolStripMenuItemCustom_Click);
contextMenuStrip1.Items.Insert(contextMenuStrip1.Items.Count - 3, ti);
// delete entry
ti = new ToolStripMenuItem(e.Key);
ti.Click += new System.EventHandler(this.ToolStripMenuItemDelete_Click);
deletePresetToolStripMenuItem.DropDownItems.Add(ti);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/ver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2540000,0.21.0
2540000,0.21.1

0 comments on commit ae7a6bd

Please sign in to comment.