Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Dec 11, 2022
2 parents c841bd1 + 39d8dd6 commit 32733a7
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 109 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
<Version>13.0.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions ARKBreedingStats/AboutBox1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
* dunger (fixes)
* Myrmecoleon (extra species images)
* Lunat1q (improved OCR)
* ThatGamerBlue (species dividers in virtual listview)
Translations:
* French by Vykan and Yanuut
Expand Down
12 changes: 10 additions & 2 deletions ARKBreedingStats/CreatureInfoInput.Designer.cs

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

67 changes: 34 additions & 33 deletions ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public CreatureInfoInput()
parentComboBoxFather.SelectedIndex = 0;
_updateMaturation = true;
_regionColorIDs = new byte[Ark.ColorRegionCount];
CooldownUntil = new DateTime(2000, 1, 1);
GrowingUntil = new DateTime(2000, 1, 1);
NamesOfAllCreatures = new List<string>();

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

//private void dhmsInputGrown_ValueChanged(object sender, TimeSpan ts)
//{
// if (_updateMaturation && _selectedSpecies != null)
// {
// _updateMaturation = false;
// double maturation = 0;
// if (_selectedSpecies.breeding != null && _selectedSpecies.breeding.maturationTimeAdjusted > 0)
// {
// maturation = 1 - dhmsInputGrown.Timespan.TotalSeconds / _selectedSpecies.breeding.maturationTimeAdjusted;
// if (maturation < 0) maturation = 0;
// if (maturation > 1) maturation = 1;
// }
// nudMaturation.Value = (decimal)maturation * 100;

// _updateMaturation = true;
// }
//}
private void dhmsInputGrown_ValueChanged(object sender, TimeSpan ts)
{
if (!_updateMaturation || _selectedSpecies?.breeding == null) return;
dhmsInputGrown.changed = true;
SetMaturationAccordingToGrownUpIn();
}

private void SetMaturationAccordingToGrownUpIn()
{
double maturation = 1;
if (_selectedSpecies.breeding != null && _selectedSpecies.breeding.maturationTimeAdjusted > 0)
{
maturation = 1 - dhmsInputGrown.Timespan.TotalSeconds / _selectedSpecies.breeding.maturationTimeAdjusted;
if (maturation < 0) maturation = 0;
if (maturation > 1) maturation = 1;
}
_updateMaturation = false;
nudMaturation.Value = (decimal)maturation * 100;
_updateMaturation = true;
}

private void nudMaturation_ValueChanged(object sender, EventArgs e)
{
if (_updateMaturation)
if (!_updateMaturation) return;

_updateMaturation = false;
if (_selectedSpecies.breeding != null)
{
_updateMaturation = false;
if (_selectedSpecies.breeding != null)
{
dhmsInputGrown.Timespan = new TimeSpan(0, 0, (int)(_selectedSpecies.breeding.maturationTimeAdjusted *
(1 - (double)nudMaturation.Value / 100)));
dhmsInputGrown.changed = true;
}
else dhmsInputGrown.Timespan = TimeSpan.Zero;
_updateMaturation = true;
dhmsInputGrown.Timespan = TimeSpan.FromSeconds(_selectedSpecies.breeding.maturationTimeAdjusted * (1 - (double)nudMaturation.Value / 100));
dhmsInputGrown.changed = true;
}
else dhmsInputGrown.Timespan = TimeSpan.Zero;
_updateMaturation = true;
}

/// <summary>
Expand All @@ -348,8 +347,9 @@ public DateTime? GrowingUntil
get => dhmsInputGrown.changed ? DateTime.Now.Add(dhmsInputGrown.Timespan) : default(DateTime?);
set
{
if (value.HasValue)
dhmsInputGrown.Timespan = value.Value - DateTime.Now;
if (!value.HasValue) return;
dhmsInputGrown.Timespan = value.Value - DateTime.Now;
SetMaturationAccordingToGrownUpIn();
}
}

Expand Down Expand Up @@ -540,7 +540,7 @@ public Species SelectedSpecies
lbMaturationPerc.Visible = breedingPossible;
if (!breedingPossible)
{
nudMaturation.Value = 0;
nudMaturation.Value = 1;
dhmsInputGrown.Timespan = TimeSpan.Zero;
dhmsInputCooldown.Timespan = TimeSpan.Zero;
}
Expand Down Expand Up @@ -632,7 +632,8 @@ public void SetCreatureData(Creature cr)
cr.colors = RegionColors;
cr.ColorIdsAlsoPossible = ColorIdsAlsoPossible;
cr.cooldownUntil = CooldownUntil;
cr.growingUntil = GrowingUntil;
if (GrowingUntil != null) // if growing was not changed, don't change that value, growing could be paused
cr.growingUntil = GrowingUntil;
cr.domesticatedAt = DomesticatedAt;
cr.ArkId = ArkId;
cr.InitializeArkInGame();
Expand Down
4 changes: 4 additions & 0 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public Form1()
listViewLibrary.VirtualMode = true;
listViewLibrary.RetrieveVirtualItem += ListViewLibrary_RetrieveVirtualItem;
listViewLibrary.CacheVirtualItems += ListViewLibrary_CacheVirtualItems;
listViewLibrary.OwnerDraw = true;
listViewLibrary.DrawItem += ListViewLibrary_DrawItem;
listViewLibrary.DrawColumnHeader += (sender, args) => args.DrawDefault = true;
listViewLibrary.DrawSubItem += ListViewLibrary_DrawSubItem;

speciesSelector1.SetTextBox(tbSpeciesGlobal);

Expand Down
73 changes: 71 additions & 2 deletions ARKBreedingStats/Form1.library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ private void UpdateIncubationParents(CreatureCollection cc)
private void ShowCreaturesInListView(IEnumerable<Creature> creatures)
{
listViewLibrary.BeginUpdate();
_creaturesDisplayed = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
IEnumerable<Creature> sorted = _creatureListSorter.DoSort(creatures, orderBySpecies: Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
_creaturesDisplayed = Properties.Settings.Default.LibraryGroupBySpecies ? InsertDividers(sorted) : sorted.ToArray();
listViewLibrary.VirtualListSize = _creaturesDisplayed.Length;
_libraryListViewItemCache = null;
listViewLibrary.EndUpdate();
Expand All @@ -777,6 +778,31 @@ private void ShowCreaturesInListView(IEnumerable<Creature> creatures)
}
}

private Creature[] InsertDividers(IEnumerable<Creature> creatures)
{
var enumerable = creatures.ToList();
if (!enumerable.Any())
{
return Array.Empty<Creature>();
}
List<Creature> result = new List<Creature>();
Species lastSpecies = null;
foreach (Creature c in enumerable)
{
if (lastSpecies == null || c.Species != lastSpecies)
{
result.Add(new Creature(c.Species)
{
flags = CreatureFlags.Placeholder | CreatureFlags.Divider,
Status = CreatureStatus.Unavailable
});
}
result.Add(c);
lastSpecies = c.Species;
}
return result.ToArray();
}

#region ListViewLibrary virtual

private Creature[] _creaturesDisplayed;
Expand Down Expand Up @@ -821,6 +847,33 @@ private void ListViewLibrary_CacheVirtualItems(object sender, CacheVirtualItemsE
}
}

private void ListViewLibrary_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = true;

if (!(e.Item.Tag is Creature creature))
{
return;
}

if (creature.flags.HasFlag(CreatureFlags.Divider))
{
e.DrawDefault = false;
var rect = e.Bounds;
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);
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));
}
}

private void ListViewLibrary_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
var isDivider = e.Item.Tag is Creature creature && creature.flags.HasFlag(CreatureFlags.Divider);
e.DrawDefault = !isDivider;
}

#endregion

/// <summary>
Expand Down Expand Up @@ -951,6 +1004,14 @@ private void UpdateCreatureListViewItem(Creature creature)

private ListViewItem CreateCreatureLvItem(Creature cr)
{
if (cr.flags.HasFlag(CreatureFlags.Divider))
{
return new ListViewItem(Enumerable.Repeat(string.Empty, listViewLibrary.Columns.Count).ToArray())
{
Tag = cr
};
}

double colorFactor = 100d / _creatureCollection.maxChartLevel;

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

_creaturesDisplayed = _creatureListSorter.DoSort(_creaturesDisplayed, columnIndex, Properties.Settings.Default.LibraryGroupBySpecies ? _speciesInLibraryOrdered : null);
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();
_libraryListViewItemCache = null;
listViewLibrary.EndUpdate();
SelectCreaturesInLibrary(selectedCreatures);
Expand All @@ -1207,6 +1269,13 @@ private void listViewLibrary_SelectedIndexChanged(object sender, EventArgs e)
/// </summary>
private void LibrarySelectedIndexChanged()
{
// remove dividers from selection
foreach (int i in listViewLibrary.SelectedIndices)
{
if (_creaturesDisplayed[i].flags.HasFlag(CreatureFlags.Divider))
listViewLibrary.SelectedIndices.Remove(i);
}

int cnt = listViewLibrary.SelectedIndices.Count;
if (cnt == 0)
{
Expand Down
4 changes: 2 additions & 2 deletions ARKBreedingStats/Form1.tester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ private void creatureInfoInputTester_Save2Library_Clicked(CreatureInfoInput send
_creatureTesterEdit.RecalculateNewMutations();

// if maturation was changed, update raising-timers
if (_creatureTesterEdit.growingUntil != creatureInfoInputTester.GrowingUntil)
var newGrownUpAt = creatureInfoInputTester.GrowingUntil;
if (newGrownUpAt != null && _creatureTesterEdit.growingUntil != newGrownUpAt)
{
raisingControl1.RecreateList();
_creatureTesterEdit.StartStopMatureTimer(true);
}

SetTesterInfoInputCreature();
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.50.7.0")]
[assembly: AssemblyFileVersion("0.50.8.0")]
[assembly: NeutralResourcesLanguage("en")]

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.50.7.0"
"version": "0.50.8.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/json/values/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"mod": { "id": "1139775728", "tag": "Confuciusornis", "title": "Confuciusornis" }
},
"1169020368-Trex.json": {
"version": "354.4.1669539497",
"version": "354.6.1670659701",
"mod": { "id": "1169020368", "tag": "Trex", "title": "Ark Creature Rebalance (AG Reborn)" }
},
"1178308359-ShadDragon.json": {
Expand Down Expand Up @@ -235,7 +235,7 @@
"mod": { "id": "2000326197", "tag": "ExtraResources", "title": "Event Assets" }
},
"2003934830-Beasts.json": {
"version": "354.4.1669867458",
"version": "354.4.1670199617",
"mod": { "id": "2003934830", "tag": "Beasts", "title": "Prehistoric Beasts" }
},
"2019846325-ApexMod.json": {
Expand Down Expand Up @@ -263,7 +263,7 @@
"mod": { "id": "2135314513", "tag": "CI_Dinos", "title": "Crystal Isles Dino Addition" }
},
"2447186973-ArkOmega.json": {
"version": "351.6.1667016777",
"version": "354.6.1670707999",
"mod": { "id": "2447186973", "tag": "ArkOmega", "title": "Ark Omega" }
},
"2869411055-SDinoVariants.json": {
Expand Down
Loading

0 comments on commit 32733a7

Please sign in to comment.