Skip to content

Commit 8c2f3db

Browse files
committed
Merge branch 'dev'
2 parents 1d4f924 + 2e92a11 commit 8c2f3db

33 files changed

+653
-129
lines changed

ARKBreedingStats/ARKBreedingStats.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="NamePatterns\JavaScriptNamePattern.cs" />
110110
<Compile Include="NamePatterns\TokenModel.cs" />
111111
<Compile Include="species\CanHaveWildLevelExceptions.cs" />
112+
<Compile Include="species\ColorPattern.cs" />
112113
<Compile Include="StatsOptions\StatsOptionsControl.cs">
113114
<SubType>Component</SubType>
114115
</Compile>

ARKBreedingStats/AboutBox1.cs

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
119119
* Lunat1q: improved OCR
120120
* ThatGamerBlue: species dividers in virtual listView
121121
* Jaymei: ATLAS species data
122+
* Shen: many ASA color region images
122123
123124
Translations:
124125
* French by Vykan and Yanuut

ARKBreedingStats/App.config

+3
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@
535535
<setting name="ColorSelectorShowAllColors" serializeAs="String">
536536
<value>False</value>
537537
</setting>
538+
<setting name="BeginServerListeningOnLaunch" serializeAs="String">
539+
<value>False</value>
540+
</setting>
538541
</ARKBreedingStats.Properties.Settings>
539542
</userSettings>
540543
</configuration>

ARKBreedingStats/CreatureBox.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void SetParentLabel(Label l, string lbText = null, bool clickable = false)
151151
labelNotes.Text = _creature.note;
152152
_tt.SetToolTip(labelNotes, _creature.note);
153153
labelSpecies.Text = _creature.SpeciesName;
154-
pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex));
154+
pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex, game: _cc.Game));
155155
_tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(_creature.Species, _creature.colors)
156156
+ "\n\nClick to copy creature infos as image to the clipboard");
157157
pictureBox1.Visible = true;
@@ -251,7 +251,7 @@ private void RegionColorChooser1_RegionColorChosen()
251251
if (_creature == null) return;
252252

253253
_creature.colors = regionColorChooser1.ColorIds;
254-
pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex));
254+
pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex, game: _cc.Game));
255255
Changed?.Invoke(_creature, false, false);
256256
}
257257

ARKBreedingStats/CreatureInfoInput.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ private void UpdateRegionColorImage()
123123
{
124124
ParentInheritance?.UpdateColors(RegionColors);
125125
ColorsChanged?.Invoke(this);
126-
PbColorRegion?.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies, regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex));
126+
PbColorRegion?.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies,
127+
regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex
128+
, game: CreatureCollection.CurrentCreatureCollection?.Game));
127129
}
128130

129131
/// <summary>

ARKBreedingStats/Form1.Designer.cs

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ARKBreedingStats/Form1.collection.cs

+56-23
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
384384

385385
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
386386
{
387-
MessageBoxes.ShowMessageBox($"Save file with name \"{filePath}\" does not exist!", $"File not found");
387+
MessageBoxes.ShowMessageBox($"Couldn't load file with name\n{filePath}\nit does not exist!", "File not found");
388388
return false;
389389
}
390390

@@ -404,6 +404,7 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
404404
Thread.Sleep(delayOnRetry);
405405
continue;
406406
}
407+
407408
try
408409
{
409410
if (Path.GetExtension(filePath).ToLower() == ".xml")
@@ -413,7 +414,8 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
413414
{
414415
// use xml-serializer for old library-format
415416
XmlSerializer reader = new XmlSerializer(typeof(oldLibraryFormat.CreatureCollectionOld));
416-
var creatureCollectionOld = (oldLibraryFormat.CreatureCollectionOld)reader.Deserialize(fileStream);
417+
var creatureCollectionOld =
418+
(oldLibraryFormat.CreatureCollectionOld)reader.Deserialize(fileStream);
417419

418420
List<Mod> mods = null;
419421
// first check if additional values are used, and if the according values-file is already available.
@@ -422,40 +424,49 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
422424
{
423425
// usually the old filename is equal to the mod-tag
424426
bool modFound = false;
425-
string modTag = Path.GetFileNameWithoutExtension(creatureCollectionOld.additionalValues).Replace(" ", "").ToLower().Replace("gaiamod", "gaia");
427+
string modTag = Path.GetFileNameWithoutExtension(creatureCollectionOld.additionalValues)
428+
.Replace(" ", "").ToLower().Replace("gaiamod", "gaia");
426429
foreach (KeyValuePair<string, ModInfo> tmi in Values.V.modsManifest.modsByTag)
427430
{
428431
if (tmi.Key.ToLower() == modTag)
429432
{
430433
modFound = true;
431434

432-
MessageBox.Show("The library contains creatures of modded species. For a correct file-conversion the correct mod-values file is needed.\n\n"
435+
MessageBox.Show(
436+
"The library contains creatures of modded species. For a correct file-conversion the correct mod-values file is needed.\n\n"
433437
+ "If the mod-value file is not loaded, the conversion may assign wrong species to your creatures.\n"
434438
+ "If the mod-value file is not available locally, it will be tried to download it.",
435-
$"Mod values needed - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK, MessageBoxIcon.Information);
439+
$"Mod values needed - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK,
440+
MessageBoxIcon.Information);
436441

437442
if (Values.V.loadedModsHash != Values.NoModsHash)
438443
LoadStatAndKibbleValues(false); // reset values to default
439-
LoadModValueFiles(new List<string> { tmi.Value.mod.FileName }, true, true, out mods);
444+
LoadModValueFiles(new List<string> { tmi.Value.mod.FileName }, true, true,
445+
out mods);
440446
break;
441447
}
442448
}
449+
443450
if (!modFound
444-
&& MessageBox.Show("The additional-values file in the library you're loading is unknown. You should first get a values-file in the new format for that mod.\n"
451+
&& MessageBox.Show(
452+
"The additional-values file in the library you're loading is unknown. You should first get a values-file in the new format for that mod.\n"
445453
+ "If you're loading the library the conversion of some modded species to the new format may fail and the according creatures have to be imported again later.\n\n"
446454
+ $"File:\n{filePath}\n"
447455
+ $"unknown mod-file: {modTag}\n\n"
448-
+ "Do you want to load the library and risk losing creatures?", $"Unknown mod-file - {Utils.ApplicationNameVersion}",
456+
+ "Do you want to load the library and risk losing creatures?",
457+
$"Unknown mod-file - {Utils.ApplicationNameVersion}",
449458
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
450459
return false;
451460
}
452461

453-
_creatureCollection = oldLibraryFormat.FormatConverter.ConvertXml2Asb(creatureCollectionOld, filePath);
462+
_creatureCollection =
463+
oldLibraryFormat.FormatConverter.ConvertXml2Asb(creatureCollectionOld, filePath);
454464
_creatureCollection.ModList = mods ?? new List<Mod>(0);
455465

456466
if (_creatureCollection == null) throw new Exception("Conversion failed");
457467

458-
string fileNameWOExt = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
468+
string fileNameWOExt = Path.Combine(Path.GetDirectoryName(filePath),
469+
Path.GetFileNameWithoutExtension(filePath));
459470
// check if new fileName is not yet existing
460471
filePath = fileNameWOExt + CollectionFileExtension;
461472
if (File.Exists(filePath))
@@ -472,19 +483,24 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
472483
else
473484
{
474485
// new json-format
475-
if (FileService.LoadJsonFile(filePath, out CreatureCollection readCollection, out string errorMessage))
486+
if (FileService.LoadJsonFile(filePath, out CreatureCollection readCollection,
487+
out string errorMessage))
476488
{
477489
if (!Version.TryParse(readCollection.FormatVersion, out Version ccVersion)
478-
|| !Version.TryParse(CreatureCollection.CurrentLibraryFormatVersion, out Version currentVersion)
479-
|| ccVersion > currentVersion)
490+
|| !Version.TryParse(CreatureCollection.CurrentLibraryFormatVersion,
491+
out Version currentVersion)
492+
|| ccVersion > currentVersion)
480493
{
481-
throw new FormatException($"Unsupported format version: {readCollection.FormatVersion ?? "null"}");
494+
throw new FormatException(
495+
$"Unsupported format version: {readCollection.FormatVersion ?? "null"}");
482496
}
497+
483498
_creatureCollection = readCollection;
484499
}
485500
else
486501
{
487-
MessageBoxes.ShowMessageBox($"Error while trying to read the library-file\n{filePath}\n\n{errorMessage}");
502+
MessageBoxes.ShowMessageBox(
503+
$"Error while trying to read the library-file\n{filePath}\n\n{errorMessage}");
488504
return false;
489505
}
490506
}
@@ -499,15 +515,23 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
499515
catch (FormatException ex)
500516
{
501517
// This FormatVersion is not understood, abort
502-
MessageBoxes.ShowMessageBox("This library format is unsupported in this version of ARK Smart Breeding." +
503-
$"\n\n{ex.Message}\n\nTry updating to a newer version.");
518+
MessageBoxes.ShowMessageBox(
519+
"This library format is unsupported in this version of ARK Smart Breeding." +
520+
$"\n\n{ex.Message}\n\nTry updating to a newer version.");
504521
if ((DateTime.Now - Properties.Settings.Default.lastUpdateCheck).TotalMinutes < 10)
505522
CheckForUpdates();
506523
return false;
507524
}
508525
catch (InvalidOperationException ex)
509526
{
510-
MessageBoxes.ExceptionMessageBox(ex, $"The library-file\n{filePath}\ncouldn't be opened, we thought you should know.");
527+
MessageBoxes.ExceptionMessageBox(ex,
528+
$"The library-file\n{filePath}\ncouldn't be opened, we thought you should know.");
529+
return false;
530+
}
531+
catch (Exception ex)
532+
{
533+
MessageBoxes.ExceptionMessageBox(ex,
534+
$"The library-file\n{filePath}\ncouldn't be opened, an unexpected exception occurred.");
511535
return false;
512536
}
513537
finally
@@ -1015,7 +1039,8 @@ private void DetermineLevelStatusAndSoundFeedback(Creature c, bool playImportSou
10151039
var species = c.Species;
10161040
_topLevels.TryGetValue(species, out var topLevels);
10171041
var statWeights = breedingPlan1.StatWeighting.GetWeightingForSpecies(species);
1018-
LevelStatusFlags.DetermineLevelStatus(species, topLevels, statWeights,
1042+
var considerAsTopStat = StatsOptionsConsiderTopStats.GetStatsOptions(species).StatOptions;
1043+
LevelStatusFlags.DetermineLevelStatus(species, topLevels, statWeights, considerAsTopStat,
10191044
c.levelsWild, c.levelsMutated, c.valuesBreeding, out _, out _);
10201045

10211046
if (playImportSound)
@@ -1043,11 +1068,19 @@ private void CopyTopCreatureStatsToClipboard(object sender, EventArgs e)
10431068
var si = Stats.DisplayOrder[s];
10441069
if (si == Stats.Torpidity) continue;
10451070
var level = sp.Key.UsesStat(si)
1046-
? (statWeights.Item1[si] < 0 ? sp.Value.WildLevelsLowest[si] : sp.Value.WildLevelsHighest[si]) : -1;
1047-
if (level < 0) continue;
1048-
maxLevel += level;
1049-
columns[s + 1].Add(level.ToString());
1071+
? (statWeights.Item1[si] < 0 ? sp.Value.WildLevelsLowest[si] : sp.Value.WildLevelsHighest[si])
1072+
: -1;
1073+
if (level >= 0)
1074+
{
1075+
maxLevel += level;
1076+
columns[s + 1].Add(level.ToString());
1077+
}
1078+
else
1079+
{
1080+
columns[s + 1].Add(string.Empty);
1081+
}
10501082
}
1083+
10511084
columns[Stats.StatsCount + 1].Add(maxLevel.ToString());
10521085
}
10531086

0 commit comments

Comments
 (0)