Skip to content

Commit 32733a7

Browse files
committed
Merge branch 'dev'
2 parents c841bd1 + 39d8dd6 commit 32733a7

15 files changed

+232
-109
lines changed

ARKBreedingStats/ARKBreedingStats.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@
961961
<PrivateAssets>all</PrivateAssets>
962962
</PackageReference>
963963
<PackageReference Include="Newtonsoft.Json">
964-
<Version>13.0.1</Version>
964+
<Version>13.0.2</Version>
965965
</PackageReference>
966966
</ItemGroup>
967967
<ItemGroup>

ARKBreedingStats/AboutBox1.cs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
108108
* dunger (fixes)
109109
* Myrmecoleon (extra species images)
110110
* Lunat1q (improved OCR)
111+
* ThatGamerBlue (species dividers in virtual listview)
111112
112113
Translations:
113114
* French by Vykan and Yanuut

ARKBreedingStats/CreatureInfoInput.Designer.cs

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

ARKBreedingStats/CreatureInfoInput.cs

+34-33
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public CreatureInfoInput()
8080
parentComboBoxFather.SelectedIndex = 0;
8181
_updateMaturation = true;
8282
_regionColorIDs = new byte[Ark.ColorRegionCount];
83-
CooldownUntil = new DateTime(2000, 1, 1);
84-
GrowingUntil = new DateTime(2000, 1, 1);
8583
NamesOfAllCreatures = new List<string>();
8684

8785
var namingPatternButtons = ButtonsNamingPattern;
@@ -291,38 +289,39 @@ private void groupBox1_Enter(object sender, EventArgs e)
291289
ParentListRequested?.Invoke(this);
292290
}
293291

294-
//private void dhmsInputGrown_ValueChanged(object sender, TimeSpan ts)
295-
//{
296-
// if (_updateMaturation && _selectedSpecies != null)
297-
// {
298-
// _updateMaturation = false;
299-
// double maturation = 0;
300-
// if (_selectedSpecies.breeding != null && _selectedSpecies.breeding.maturationTimeAdjusted > 0)
301-
// {
302-
// maturation = 1 - dhmsInputGrown.Timespan.TotalSeconds / _selectedSpecies.breeding.maturationTimeAdjusted;
303-
// if (maturation < 0) maturation = 0;
304-
// if (maturation > 1) maturation = 1;
305-
// }
306-
// nudMaturation.Value = (decimal)maturation * 100;
307-
308-
// _updateMaturation = true;
309-
// }
310-
//}
292+
private void dhmsInputGrown_ValueChanged(object sender, TimeSpan ts)
293+
{
294+
if (!_updateMaturation || _selectedSpecies?.breeding == null) return;
295+
dhmsInputGrown.changed = true;
296+
SetMaturationAccordingToGrownUpIn();
297+
}
298+
299+
private void SetMaturationAccordingToGrownUpIn()
300+
{
301+
double maturation = 1;
302+
if (_selectedSpecies.breeding != null && _selectedSpecies.breeding.maturationTimeAdjusted > 0)
303+
{
304+
maturation = 1 - dhmsInputGrown.Timespan.TotalSeconds / _selectedSpecies.breeding.maturationTimeAdjusted;
305+
if (maturation < 0) maturation = 0;
306+
if (maturation > 1) maturation = 1;
307+
}
308+
_updateMaturation = false;
309+
nudMaturation.Value = (decimal)maturation * 100;
310+
_updateMaturation = true;
311+
}
311312

312313
private void nudMaturation_ValueChanged(object sender, EventArgs e)
313314
{
314-
if (_updateMaturation)
315+
if (!_updateMaturation) return;
316+
317+
_updateMaturation = false;
318+
if (_selectedSpecies.breeding != null)
315319
{
316-
_updateMaturation = false;
317-
if (_selectedSpecies.breeding != null)
318-
{
319-
dhmsInputGrown.Timespan = new TimeSpan(0, 0, (int)(_selectedSpecies.breeding.maturationTimeAdjusted *
320-
(1 - (double)nudMaturation.Value / 100)));
321-
dhmsInputGrown.changed = true;
322-
}
323-
else dhmsInputGrown.Timespan = TimeSpan.Zero;
324-
_updateMaturation = true;
320+
dhmsInputGrown.Timespan = TimeSpan.FromSeconds(_selectedSpecies.breeding.maturationTimeAdjusted * (1 - (double)nudMaturation.Value / 100));
321+
dhmsInputGrown.changed = true;
325322
}
323+
else dhmsInputGrown.Timespan = TimeSpan.Zero;
324+
_updateMaturation = true;
326325
}
327326

328327
/// <summary>
@@ -348,8 +347,9 @@ public DateTime? GrowingUntil
348347
get => dhmsInputGrown.changed ? DateTime.Now.Add(dhmsInputGrown.Timespan) : default(DateTime?);
349348
set
350349
{
351-
if (value.HasValue)
352-
dhmsInputGrown.Timespan = value.Value - DateTime.Now;
350+
if (!value.HasValue) return;
351+
dhmsInputGrown.Timespan = value.Value - DateTime.Now;
352+
SetMaturationAccordingToGrownUpIn();
353353
}
354354
}
355355

@@ -540,7 +540,7 @@ public Species SelectedSpecies
540540
lbMaturationPerc.Visible = breedingPossible;
541541
if (!breedingPossible)
542542
{
543-
nudMaturation.Value = 0;
543+
nudMaturation.Value = 1;
544544
dhmsInputGrown.Timespan = TimeSpan.Zero;
545545
dhmsInputCooldown.Timespan = TimeSpan.Zero;
546546
}
@@ -632,7 +632,8 @@ public void SetCreatureData(Creature cr)
632632
cr.colors = RegionColors;
633633
cr.ColorIdsAlsoPossible = ColorIdsAlsoPossible;
634634
cr.cooldownUntil = CooldownUntil;
635-
cr.growingUntil = GrowingUntil;
635+
if (GrowingUntil != null) // if growing was not changed, don't change that value, growing could be paused
636+
cr.growingUntil = GrowingUntil;
636637
cr.domesticatedAt = DomesticatedAt;
637638
cr.ArkId = ArkId;
638639
cr.InitializeArkInGame();

ARKBreedingStats/Form1.cs

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ public Form1()
172172
listViewLibrary.VirtualMode = true;
173173
listViewLibrary.RetrieveVirtualItem += ListViewLibrary_RetrieveVirtualItem;
174174
listViewLibrary.CacheVirtualItems += ListViewLibrary_CacheVirtualItems;
175+
listViewLibrary.OwnerDraw = true;
176+
listViewLibrary.DrawItem += ListViewLibrary_DrawItem;
177+
listViewLibrary.DrawColumnHeader += (sender, args) => args.DrawDefault = true;
178+
listViewLibrary.DrawSubItem += ListViewLibrary_DrawSubItem;
175179

176180
speciesSelector1.SetTextBox(tbSpeciesGlobal);
177181

ARKBreedingStats/Form1.library.cs

+71-2
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,8 @@ private void UpdateIncubationParents(CreatureCollection cc)
758758
private void ShowCreaturesInListView(IEnumerable<Creature> creatures)
759759
{
760760
listViewLibrary.BeginUpdate();
761-
_creaturesDisplayed = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
761+
IEnumerable<Creature> sorted = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
762+
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray();
762763
listViewLibrary.VirtualListSize = _creaturesDisplayed.Length;
763764
_libraryListViewItemCache = null;
764765
listViewLibrary.EndUpdate();
@@ -777,6 +778,31 @@ private void ShowCreaturesInListView(IEnumerable<Creature> creatures)
777778
}
778779
}
779780

781+
private Creature[] InsertDividers(IEnumerable<Creature> creatures)
782+
{
783+
var enumerable = creatures.ToList();
784+
if (!enumerable.Any())
785+
{
786+
return Array.Empty<Creature>();
787+
}
788+
List<Creature> result = new List<Creature>();
789+
Species lastSpecies = null;
790+
foreach (Creature c in enumerable)
791+
{
792+
if (lastSpecies == null || c.Species != lastSpecies)
793+
{
794+
result.Add(new Creature(c.Species)
795+
{
796+
flags = CreatureFlags.Placeholder | CreatureFlags.Divider,
797+
Status = CreatureStatus.Unavailable
798+
});
799+
}
800+
result.Add(c);
801+
lastSpecies = c.Species;
802+
}
803+
return result.ToArray();
804+
}
805+
780806
#region ListViewLibrary virtual
781807

782808
private Creature[] _creaturesDisplayed;
@@ -821,6 +847,33 @@ private void ListViewLibrary_CacheVirtualItems(object sender, CacheVirtualItemsE
821847
}
822848
}
823849

850+
private void ListViewLibrary_DrawItem(object sender, DrawListViewItemEventArgs e)
851+
{
852+
e.DrawDefault = true;
853+
854+
if (!(e.Item.Tag is Creature creature))
855+
{
856+
return;
857+
}
858+
859+
if (creature.flags.HasFlag(CreatureFlags.Divider))
860+
{
861+
e.DrawDefault = false;
862+
var rect = e.Bounds;
863+
float middle = (rect.Top + rect.Bottom) / 2f;
864+
e.Graphics.FillRectangle(Brushes.Blue, rect.Left, middle, rect.Width - 3, 1);
865+
SizeF strSize = e.Graphics.MeasureString(creature.Species.DescriptiveNameAndMod, e.Item.Font);
866+
e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), rect.Left, rect.Top, strSize.Width + 15, rect.Height);
867+
e.Graphics.DrawString(creature.Species.DescriptiveNameAndMod, e.Item.Font, Brushes.Black, rect.Left + 10, rect.Top + ((rect.Height - strSize.Height) / 2f));
868+
}
869+
}
870+
871+
private void ListViewLibrary_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
872+
{
873+
var isDivider = e.Item.Tag is Creature creature && creature.flags.HasFlag(CreatureFlags.Divider);
874+
e.DrawDefault = !isDivider;
875+
}
876+
824877
#endregion
825878

826879
/// <summary>
@@ -951,6 +1004,14 @@ private void UpdateCreatureListViewItem(Creature creature)
9511004

9521005
private ListViewItem CreateCreatureLvItem(Creature cr)
9531006
{
1007+
if (cr.flags.HasFlag(CreatureFlags.Divider))
1008+
{
1009+
return new ListViewItem(Enumerable.Repeat(string.Empty, listViewLibrary.Columns.Count).ToArray())
1010+
{
1011+
Tag = cr
1012+
};
1013+
}
1014+
9541015
double colorFactor = 100d / _creatureCollection.maxChartLevel;
9551016

9561017
string[] subItems = new[]
@@ -1187,7 +1248,8 @@ private void SortLibrary(int columnIndex = -1)
11871248
foreach (int i in listViewLibrary.SelectedIndices)
11881249
selectedCreatures.Add(_creaturesDisplayed[i]);
11891250

1190-
_creaturesDisplayed = _creatureListSorter.DoSort(_creaturesDisplayed, columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
1251+
IEnumerable<Creature> sorted = _creatureListSorter.DoSort(_creaturesDisplayed.Where(c => !c.flags.HasFlag(CreatureFlags.Divider)), columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
1252+
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray();
11911253
_libraryListViewItemCache = null;
11921254
listViewLibrary.EndUpdate();
11931255
SelectCreaturesInLibrary(selectedCreatures);
@@ -1207,6 +1269,13 @@ private void listViewLibrary_SelectedIndexChanged(object sender, EventArgs e)
12071269
/// </summary>
12081270
private void LibrarySelectedIndexChanged()
12091271
{
1272+
// remove dividers from selection
1273+
foreach (int i in listViewLibrary.SelectedIndices)
1274+
{
1275+
if (_creaturesDisplayed[i].flags.HasFlag(CreatureFlags.Divider))
1276+
listViewLibrary.SelectedIndices.Remove(i);
1277+
}
1278+
12101279
int cnt = listViewLibrary.SelectedIndices.Count;
12111280
if (cnt == 0)
12121281
{

ARKBreedingStats/Form1.tester.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ private void creatureInfoInputTester_Save2Library_Clicked(CreatureInfoInput send
215215
_creatureTesterEdit.RecalculateNewMutations();
216216

217217
// if maturation was changed, update raising-timers
218-
if (_creatureTesterEdit.growingUntil != creatureInfoInputTester.GrowingUntil)
218+
var newGrownUpAt = creatureInfoInputTester.GrowingUntil;
219+
if (newGrownUpAt != null && _creatureTesterEdit.growingUntil != newGrownUpAt)
219220
{
220221
raisingControl1.RecreateList();
221-
_creatureTesterEdit.StartStopMatureTimer(true);
222222
}
223223

224224
SetTesterInfoInputCreature();

ARKBreedingStats/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
// Revision
3131
//
3232
[assembly: AssemblyVersion("1.0.0.0")]
33-
[assembly: AssemblyFileVersion("0.50.7.0")]
33+
[assembly: AssemblyFileVersion("0.50.8.0")]
3434
[assembly: NeutralResourcesLanguage("en")]
3535

ARKBreedingStats/_manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"ARK Smart Breeding": {
55
"Id": "ARK Smart Breeding",
66
"Category": "main",
7-
"version": "0.50.7.0"
7+
"version": "0.50.8.0"
88
},
99
"SpeciesColorImages": {
1010
"Id": "SpeciesColorImages",

ARKBreedingStats/json/values/_manifest.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"mod": { "id": "1139775728", "tag": "Confuciusornis", "title": "Confuciusornis" }
3636
},
3737
"1169020368-Trex.json": {
38-
"version": "354.4.1669539497",
38+
"version": "354.6.1670659701",
3939
"mod": { "id": "1169020368", "tag": "Trex", "title": "Ark Creature Rebalance (AG Reborn)" }
4040
},
4141
"1178308359-ShadDragon.json": {
@@ -235,7 +235,7 @@
235235
"mod": { "id": "2000326197", "tag": "ExtraResources", "title": "Event Assets" }
236236
},
237237
"2003934830-Beasts.json": {
238-
"version": "354.4.1669867458",
238+
"version": "354.4.1670199617",
239239
"mod": { "id": "2003934830", "tag": "Beasts", "title": "Prehistoric Beasts" }
240240
},
241241
"2019846325-ApexMod.json": {
@@ -263,7 +263,7 @@
263263
"mod": { "id": "2135314513", "tag": "CI_Dinos", "title": "Crystal Isles Dino Addition" }
264264
},
265265
"2447186973-ArkOmega.json": {
266-
"version": "351.6.1667016777",
266+
"version": "354.6.1670707999",
267267
"mod": { "id": "2447186973", "tag": "ArkOmega", "title": "Ark Omega" }
268268
},
269269
"2869411055-SDinoVariants.json": {

0 commit comments

Comments
 (0)