Skip to content

Commit

Permalink
changed default size of form. ShowBestBreedingPartners works now for …
Browse files Browse the repository at this point in the history
…all creatures, regardless if they're not available or neutered. fix for export to clipboard on systems that use a comma as decimal-separator. fix(?) for ping-pong syncing.
  • Loading branch information
cadaei committed Jan 19, 2017
1 parent 725dc88 commit 7f6bc85
Show file tree
Hide file tree
Showing 12 changed files with 524 additions and 509 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<value>51</value>
</setting>
<setting name="formSize" serializeAs="String">
<value>791, 627</value>
<value>900, 700</value>
</setting>
<setting name="formLocation" serializeAs="String">
<value>100, 100</value>
Expand Down
8 changes: 5 additions & 3 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ public void drawBestParents(BreedingMode breedingMode, bool updateBreedingData =

// chosen Creature (only consider this one for its gender)
bool considerChosenCreature = chosenCreature != null;
Sex chosenCG = (considerChosenCreature ? chosenCreature.gender : Sex.Unknown);
Sex chosenCS = (considerChosenCreature ? chosenCreature.gender : Sex.Unknown);

labelTitle.Text = currentSpecies + (considerChosenCreature ? " (only pairings with \"" + chosenCreature.name + "\")" : "");
if (considerChosenCreature && chosenCreature.neutered || chosenCreature.status != CreatureStatus.Available)
labelTitle.Text += "! Breeding not possible ! (" + (chosenCreature.neutered ? "neutered" : "not available") + ")";
if (females != null && males != null && females.Count > 0 && males.Count > 0)
{
combinedTops[0].Clear();
Expand All @@ -83,11 +85,11 @@ public void drawBestParents(BreedingMode breedingMode, bool updateBreedingData =

for (int f = 0; f < females.Count; f++)
{
if (considerChosenCreature && chosenCG == Sex.Female && females[f] != chosenCreature)
if (considerChosenCreature && chosenCS == Sex.Female && females[f] != chosenCreature)
continue;
for (int m = 0; m < males.Count; m++)
{
if (considerChosenCreature && chosenCG == Sex.Male && males[m] != chosenCreature)
if (considerChosenCreature && chosenCS == Sex.Male && males[m] != chosenCreature)
continue;

combinedTops[0].Add(f);
Expand Down
7 changes: 6 additions & 1 deletion ARKBreedingStats/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ namespace ARKBreedingStats
[XmlArray]
public List<Tribe> tribes = new List<Tribe>();

public void mergeCreatureList(List<Creature> creaturesToMerge)
public bool mergeCreatureList(List<Creature> creaturesToMerge)
{
bool creaturesWereAdded = false;
foreach (Creature creature in creaturesToMerge)
{
if (!creatures.Contains(creature))
{
creatures.Add(creature);
creaturesWereAdded = true;
}
}
return creaturesWereAdded;
}
}
}
12 changes: 9 additions & 3 deletions ARKBreedingStats/FileSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace ARKBreedingStats
{
class FileSync
{
String currentFile = "";
string currentFile = "";
FileSystemWatcher file_watcher;
DateTime lastUpdated;
Action callbackFunction;

public FileSync(String fileName, Action callback)
public FileSync(string fileName, Action callback)
{
currentFile = fileName;
callbackFunction = callback;
Expand All @@ -29,7 +29,7 @@ public FileSync(String fileName, Action callback)
updateProperties();
}

public void changeFile(String newFileName)
public void changeFile(string newFileName)
{
currentFile = newFileName;

Expand Down Expand Up @@ -68,6 +68,12 @@ private void onChanged(object source, FileSystemEventArgs e)
}
}

public void justSaving()
{
// call this function just before the tool saves the file, so the fileWatcher ignores the change
lastUpdated = DateTime.Now;
}

private void updateProperties()
{
if (currentFile != "" && Properties.Settings.Default.syncCollection)
Expand Down
976 changes: 488 additions & 488 deletions ARKBreedingStats/Form1.Designer.cs

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,12 @@ private void saveNewCollection()
}
}

private void saveCollectionToFileName(String fileName)
private void saveCollectionToFileName(string fileName)
{
XmlSerializer writer = new XmlSerializer(typeof(CreatureCollection));
try
{
fileSync.justSaving();
System.IO.FileStream file = System.IO.File.Create(fileName);
writer.Serialize(file, creatureCollection);
file.Close();
Expand Down Expand Up @@ -1091,8 +1092,10 @@ private void loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
applyMultipliersToValues();
assignCollectionClasses();

bool creatureWasAdded = false;

if (keepCurrentCreatures)
creatureCollection.mergeCreatureList(oldCreatures);
creatureWasAdded = creatureCollection.mergeCreatureList(oldCreatures);
else
{
currentFileName = fileName;
Expand All @@ -1105,7 +1108,7 @@ private void loadCollectionFile(string fileName, bool keepCurrentCreatures = fal
checkBoxShowNeuteredCreatures.Checked = creatureCollection.showNeutered;
filterListAllowed = true;

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

applyLevelSettings();
Expand Down Expand Up @@ -2498,7 +2501,7 @@ private void determineBestBreeding(Creature chosenCreature = null)
breedingPlanNeedsUpdate = true;
}
if (breedingPlanNeedsUpdate)
breedingPlan1.Creatures = creatureCollection.creatures.Where(c => c.species == selectedSpecies && c.status == CreatureStatus.Available && !c.neutered && c.cooldownUntil < DateTime.Now && c.growingUntil < DateTime.Now).ToList();
breedingPlan1.Creatures = creatureCollection.creatures.Where(c => (c == chosenCreature && c != null) || (c.species == selectedSpecies && c.status == CreatureStatus.Available && !c.neutered && c.cooldownUntil < DateTime.Now && c.growingUntil < DateTime.Now)).ToList();

breedingPlan1.statWeights = statWeighting1.Weightings;
BreedingPlan.BreedingMode bm = BreedingPlan.BreedingMode.TopStatsConservative;
Expand Down Expand Up @@ -2529,8 +2532,6 @@ private void showBestBreedingPartner(Creature c)
{
setStatus(new List<Creature>() { c }, CreatureStatus.Available);
}
else
return;
}
determineBestBreeding(c);
tabControlMain.SelectedTab = tabPageBreedingPlan;
Expand Down Expand Up @@ -2638,7 +2639,7 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
autoSaveMinutes = Properties.Settings.Default.autosaveMinutes;
creatureBoxListView.maxDomLevel = creatureCollection.maxDomLevel;
breedingPlan1.maxSuggestions = creatureCollection.maxBreedingSuggestions;
fileSync.changeFile(currentFileName);
fileSync.changeFile(currentFileName); // only to trigger the update, filename is not changed
applyLevelSettings();

setCollectionChanged(true);
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/PedigreeCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void setCreature(Creature creature)
{
labelSex.Visible = true;
labelSex.Text = Utils.sexSymbol(creature.gender);
labelSex.BackColor = Utils.sexColor(creature.gender);
labelSex.BackColor = creature.neutered ? SystemColors.GrayText : Utils.sexColor(creature.gender);
// creature Colors
pictureBox1.Image = CreatureColored.getColoredCreature(creature.colors, "", enabledColorRegions, 24, 22, true);
labelSex.Visible = true;
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.20.9.2")]
[assembly: AssemblyFileVersion("0.20.9.3")]
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Value Profile="(Default)">51</Value>
</Setting>
<Setting Name="formSize" Type="System.Drawing.Size" Scope="User">
<Value Profile="(Default)">791, 627</Value>
<Value Profile="(Default)">900, 700</Value>
</Setting>
<Setting Name="formLocation" Type="System.Drawing.Point" Scope="User">
<Value Profile="(Default)">100, 100</Value>
Expand Down
3 changes: 2 additions & 1 deletion ARKBreedingStats/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Globalization;

namespace ARKBreedingStats
{
Expand Down Expand Up @@ -31,7 +32,7 @@ public static string getARKmlFromPercent(string text, int percent, double light

public static string getARKml(string text, int r, int g, int b)
{
return "<RichColor Color=\"" + Math.Round(r / 255d, 2) + "," + Math.Round(g / 255d, 2) + "," + Math.Round(b / 255d, 2) + ",1\">" + text + "</>";
return "<RichColor Color=\"" + Math.Round(r / 255d, 2).ToString(CultureInfo.InvariantCulture) + "," + Math.Round(g / 255d, 2).ToString(CultureInfo.InvariantCulture) + "," + Math.Round(b / 255d, 2).ToString(CultureInfo.InvariantCulture) + ",1\">" + text + "</>";
}

private static void getRGBFromPercent(out int r, out int g, out int b, int percent, double light = 0)
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/ver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2530000,0.20.9.2
2530000,0.20.9.3

0 comments on commit 7f6bc85

Please sign in to comment.