Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Nov 13, 2023
2 parents a393a91 + 8c44ddf commit bc7a969
Show file tree
Hide file tree
Showing 19 changed files with 3,334 additions and 3,203 deletions.
1 change: 1 addition & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@
</EmbeddedResource>
<EmbeddedResource Include="settings\Settings.resx">
<DependentUpon>Settings.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="uiControls\StatDisplay.resx">
<DependentUpon>StatDisplay.cs</DependentUpon>
Expand Down
6 changes: 6 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@
<setting name="OverlayRelativeFontSize" serializeAs="String">
<value>1</value>
</setting>
<setting name="DisplayLibraryCreatureIndex" serializeAs="String">
<value>False</value>
</setting>
<setting name="AskSaveSettingsOnClose" serializeAs="String">
<value>True</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
32 changes: 15 additions & 17 deletions ARKBreedingStats/Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,25 +549,23 @@ private List<MinMaxDouble> CalculateImprintingBonus(Species species, double impr

public void RemoveImpossibleTEsAccordingToMaxWildLevel(int maxWildLevel)
{
if (!_bred
&& maxWildLevel > 0
&& LevelWildSum + 1 > maxWildLevel)
{
double minTECheck = 2d * (LevelWildSum + 1 - maxWildLevel) / maxWildLevel;
if (_bred
|| maxWildLevel <= 0
|| LevelWildSum + 1 <= maxWildLevel) return;

var minTeCheck = 2d * (LevelWildSum + 1 - maxWildLevel) / maxWildLevel;

// if min TE is equal or greater than 1, that indicates it can't possibly be anything but bred, and there cannot be any results that should be sorted out
if (minTECheck < 1)
// if min TE is equal or greater than 1, that indicates it can't possibly be anything but bred, and there cannot be any results that should be sorted out
if (!(minTeCheck < 1)) return;

for (int s = 0; s < Stats.StatsCount; s++)
{
if (Results[s].Count == 0 || Results[s][0].TE.Max < 0)
continue;
for (int r = 0; r < Results[s].Count; r++)
{
for (int s = 0; s < Stats.StatsCount; s++)
{
if (Results[s].Count == 0 || Results[s][0].TE.Max < 0)
continue;
for (int r = 0; r < Results[s].Count; r++)
{
if (Results[s][r].TE.Max < minTECheck)
Results[s].RemoveAt(r--);
}
}
if (Results[s][r].TE.Max < minTeCheck)
Results[s].RemoveAt(r--);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,7 @@ private void OpenSettingsDialog(SettingsTabPages page = SettingsTabPages.Unknown
bool libraryTopCreatureColorHighlight = Properties.Settings.Default.LibraryHighlightTopCreatures;
bool considerWastedStatsForTopCreatures = Properties.Settings.Default.ConsiderWastedStatsForTopCreatures;
var gameSettingBefore = _creatureCollection.Game;
var displayLibraryCreatureIndexBefore = Properties.Settings.Default.DisplayLibraryCreatureIndex;

using (Settings settingsForm = new Settings(_creatureCollection, page))
{
Expand Down Expand Up @@ -2022,6 +2023,9 @@ private void OpenSettingsDialog(SettingsTabPages page = SettingsTabPages.Unknown

SetOverlayLocation();

if (displayLibraryCreatureIndexBefore != Properties.Settings.Default.DisplayLibraryCreatureIndex)
FilterLib();

SetCollectionChanged(true);
}

Expand Down Expand Up @@ -2397,6 +2401,7 @@ private void chkbToggleOverlay_CheckedChanged(object sender, EventArgs e)
};
_overlay.InitLabelPositions();
_overlay.CreatureTimers = _creatureCollection.creatures.Where(c => c.ShowInOverlay).ToList();
_overlay.timers = _creatureCollection.timerListEntries.Where(t => t.showInOverlay).OrderBy(t => t.time).ToArray();
}

if (enableOverlay && !SetOverlayLocation()) return;
Expand Down
38 changes: 22 additions & 16 deletions ARKBreedingStats/Form1.library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ private void UpdateIncubationParents(CreatureCollection cc)
private void ShowCreaturesInListView(IEnumerable<Creature> creatures)
{
listViewLibrary.BeginUpdate();
IEnumerable<Creature> sorted = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray();
var sorted = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted;
listViewLibrary.VirtualListSize = _creaturesDisplayed.Length;
_libraryListViewItemCache = null;
listViewLibrary.EndUpdate();
Expand All @@ -723,16 +723,15 @@ private void ShowCreaturesInListView(IEnumerable<Creature> creatures)
}
}

private Creature[] InsertDividers(IEnumerable<Creature> creatures)
private Creature[] InsertDividers(IList<Creature> creatures)
{
var enumerable = creatures.ToList();
if (!enumerable.Any())
if (!creatures.Any())
{
return Array.Empty<Creature>();
}
List<Creature> result = new List<Creature>();
Species lastSpecies = null;
foreach (Creature c in enumerable)
foreach (Creature c in creatures)
{
if (lastSpecies == null || c.Species != lastSpecies)
{
Expand Down Expand Up @@ -765,7 +764,7 @@ private void ListViewLibrary_RetrieveVirtualItem(object sender, RetrieveVirtualI
else if (_creaturesDisplayed?.Length > e.ItemIndex)
{
// create item not available in the cache
e.Item = CreateCreatureLvItem(_creaturesDisplayed[e.ItemIndex]);
e.Item = CreateCreatureLvItem(_creaturesDisplayed[e.ItemIndex], Properties.Settings.Default.DisplayLibraryCreatureIndex);
}
}

Expand All @@ -785,10 +784,11 @@ private void ListViewLibrary_CacheVirtualItems(object sender, CacheVirtualItemsE
var length = indexEnd - indexStart + 1;
_libraryListViewItemCache = new ListViewItem[length];

var displayIndex = Properties.Settings.Default.DisplayLibraryCreatureIndex;
//Fill the cache with the appropriate ListViewItems.
for (int i = 0; i < length; i++)
{
_libraryListViewItemCache[i] = CreateCreatureLvItem(_creaturesDisplayed[i + _libraryItemCacheFirstIndex]);
_libraryListViewItemCache[i] = CreateCreatureLvItem(_creaturesDisplayed[i + _libraryItemCacheFirstIndex], displayIndex);
}
}

Expand All @@ -805,11 +805,16 @@ private void ListViewLibrary_DrawItem(object sender, DrawListViewItemEventArgs e
{
e.DrawDefault = false;
var rect = e.Bounds;
var count = 0;
if (creature.Species.blueprintPath != null)
_creatureCollection.GetCreatureCountBySpecies()
.TryGetValue(creature.Species.blueprintPath, out count);
var displayedText = creature.Species.DescriptiveNameAndMod + " (" + count + ")";
float middle = (rect.Top + rect.Bottom) / 2f;
e.Graphics.FillRectangle(Brushes.Blue, rect.Left, middle, rect.Width - 3, 1);
SizeF strSize = e.Graphics.MeasureString(creature.Species.DescriptiveNameAndMod, e.Item.Font);
SizeF strSize = e.Graphics.MeasureString(displayedText, e.Item.Font);
e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), rect.Left, rect.Top, strSize.Width + 15, rect.Height);
e.Graphics.DrawString(creature.Species.DescriptiveNameAndMod, e.Item.Font, Brushes.Black, rect.Left + 10, rect.Top + ((rect.Height - strSize.Height) / 2f));
e.Graphics.DrawString(displayedText, e.Item.Font, Brushes.Black, rect.Left + 10, rect.Top + ((rect.Height - strSize.Height) / 2f));
}
}

Expand Down Expand Up @@ -943,7 +948,7 @@ private void UpdateCreatureListViewItem(Creature creature)
var cacheIndex = index - _libraryItemCacheFirstIndex;
if (cacheIndex >= 0 && cacheIndex < _libraryListViewItemCache.Length)
{
_libraryListViewItemCache[cacheIndex] = CreateCreatureLvItem(creature);
_libraryListViewItemCache[cacheIndex] = CreateCreatureLvItem(creature, Properties.Settings.Default.DisplayLibraryCreatureIndex);
}
}

Expand All @@ -961,7 +966,7 @@ private void UpdateCreatureListViewItem(Creature creature)
private const int ColumnIndexPostColor = 30;
private const int ColumnIndexMutagenApplied = 34;

private ListViewItem CreateCreatureLvItem(Creature cr)
private ListViewItem CreateCreatureLvItem(Creature cr, bool displayIndex = false)
{
if (cr.flags.HasFlag(CreatureFlags.Divider))
{
Expand All @@ -974,6 +979,7 @@ private ListViewItem CreateCreatureLvItem(Creature cr)
double colorFactor = 100d / _creatureCollection.maxChartLevel;

string[] subItems = new[] {
(displayIndex ? cr.ListIndex + " - " : string.Empty) +
cr.name,
cr.owner,
cr.note,
Expand Down Expand Up @@ -1209,8 +1215,8 @@ private void SortLibrary(int columnIndex = -1)
foreach (int i in listViewLibrary.SelectedIndices)
selectedCreatures.Add(_creaturesDisplayed[i]);

IEnumerable<Creature> sorted = _creatureListSorter.DoSort(_creaturesDisplayed.Where(c => !c.flags.HasFlag(CreatureFlags.Divider)), columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray();
var sorted = _creatureListSorter.DoSort(_creaturesDisplayed.Where(c => !c.flags.HasFlag(CreatureFlags.Divider)), columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted;
_libraryListViewItemCache = null;
listViewLibrary.EndUpdate();
SelectCreaturesInLibrary(selectedCreatures);
Expand Down Expand Up @@ -1636,11 +1642,11 @@ private void ShowMultiSetter()
}
}

private Debouncer filterLibraryDebouncer = new Debouncer();
private readonly Debouncer _filterLibraryDebouncer = new Debouncer();

private void ToolStripTextBoxLibraryFilter_TextChanged(object sender, EventArgs e)
{
filterLibraryDebouncer.Debounce(ToolStripTextBoxLibraryFilter.Text == string.Empty ? 0 : 500, FilterLib, Dispatcher.CurrentDispatcher, false);
_filterLibraryDebouncer.Debounce(ToolStripTextBoxLibraryFilter.Text == string.Empty ? 0 : 500, FilterLib, Dispatcher.CurrentDispatcher, false);
}

private void ToolStripButtonLibraryFilterClear_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.57.1.0")]
[assembly: AssemblyFileVersion("0.57.2.0")]
[assembly: NeutralResourcesLanguage("en")]

24 changes: 24 additions & 0 deletions ARKBreedingStats/Properties/Settings.Designer.cs

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

6 changes: 6 additions & 0 deletions ARKBreedingStats/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -557,5 +557,11 @@
<Setting Name="OverlayRelativeFontSize" Type="System.Single" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="DisplayLibraryCreatureIndex" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AskSaveSettingsOnClose" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
2 changes: 1 addition & 1 deletion ARKBreedingStats/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ARK Smart Breeding": {
"Id": "ARK Smart Breeding",
"Category": "main",
"version": "0.57.1.0"
"version": "0.57.2.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
6 changes: 5 additions & 1 deletion ARKBreedingStats/json/values/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@
"version": "356.5.1654594229",
"mod": { "id": "2247209652", "tag": "MonstersandMore", "title": "Monsters and More" }
},
"2269289965-RRMod_StarPegasus.json": {
"version": "358.17.1650033587",
"mod": { "id": "2269289965", "tag": "RRMod_StarPegasus", "title": "RR-StarPegasus" }
},
"2337840412-RRMod_StarFarmAnimals.json": {
"version": "356.5.1650033456",
"mod": { "id": "2337840412", "tag": "RRMod_StarFarmAnimals", "title": "RRMod StarFarmAnimals" }
Expand Down Expand Up @@ -394,7 +398,7 @@
"mod": { "id": "919470289", "tag": "SSFlyer", "title": "SSFlyer" }
},
"ASA-values.json": {
"version": "25.53.449745",
"version": "25.53.449746",
"format": "1.15-asa",
"mod": { "id": "ASA", "tag": "", "title": "Ark: Survival Ascended", "shortTitle": "ASA", "official": true }
},
Expand Down
5 changes: 5 additions & 0 deletions ARKBreedingStats/library/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ public DateTime? growingUntil
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<string> tags = new List<string>();

/// <summary>
/// Used to display the creature's position in a list.
/// </summary>
public int ListIndex;

public Creature() { }

public Creature(Species species, string name, string owner = null, string tribe = null, Sex sex = Sex.Unknown,
Expand Down
30 changes: 23 additions & 7 deletions ARKBreedingStats/library/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public CreatureCollection()
[JsonProperty]
public Dictionary<string, double?[][]> CustomSpeciesStats;

public Dictionary<string, int> _creatureCountBySpecies;

/// <summary>
/// Calculates a hashcode for a list of mods and their order. Can be used to check for changes.
/// </summary>
Expand Down Expand Up @@ -344,7 +346,10 @@ void UpdateString(ref string oldCreatureValue, ref string newCreatureValue)
}

if (creaturesWereAddedOrUpdated)
{
ResetExistingColors(onlyOneSpeciesAdded ? onlyThisSpeciesAdded : null);
_creatureCountBySpecies = null;
}

return creaturesWereAddedOrUpdated;
}
Expand All @@ -355,13 +360,13 @@ void UpdateString(ref string oldCreatureValue, ref string newCreatureValue)
/// <param name="c"></param>
internal void DeleteCreature(Creature c)
{
if (creatures.Remove(c))
{
if (DeletedCreatureGuids == null)
DeletedCreatureGuids = new List<Guid>();
DeletedCreatureGuids.Add(c.guid);
ResetExistingColors(c.Species);
}
if (!creatures.Remove(c)) return;

if (DeletedCreatureGuids == null)
DeletedCreatureGuids = new List<Guid>();
DeletedCreatureGuids.Add(c.guid);
ResetExistingColors(c.Species);
_creatureCountBySpecies = null;
}

public int? getWildLevelStep()
Expand Down Expand Up @@ -611,5 +616,16 @@ public string Game
}
}
}

public Dictionary<string, int> GetCreatureCountBySpecies(bool recalculate = false)
{
if (_creatureCountBySpecies == null || recalculate)
{
_creatureCountBySpecies = creatures.Where(c => !c.flags.HasFlag(CreatureFlags.Placeholder)).GroupBy(c => c.speciesBlueprint)
.ToDictionary(g => g.Key, g => g.Count());
}

return _creatureCountBySpecies;
}
}
}
Loading

0 comments on commit bc7a969

Please sign in to comment.