Skip to content

Commit 2761650

Browse files
committedJan 10, 2025
Organic Checklist now shows discovered when bio is codex scanned
1 parent 4ae5cf7 commit 2761650

File tree

4 files changed

+72
-7
lines changed

4 files changed

+72
-7
lines changed
 

‎ODExplorer/App.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public partial class App : Application
2121
{
2222
public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2323

24-
public static readonly Version AppVersion = new(2, 0, 7);
24+
public static readonly Version AppVersion = new(2, 0, 8);
2525
#if INSTALL
2626
public readonly static string BaseDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OD Explorer");
2727
#else

‎ODExplorer/Stores/OrganicCheckListDataStore.cs

+41-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Collections.Generic;
1010
using System.Linq;
1111
using System.Threading.Tasks;
12+
using static System.Windows.Forms.AxHost;
1213

1314
namespace ODExplorer.Stores
1415
{
@@ -103,7 +104,7 @@ private void AddBioScan(ScanOrganicEvent.ScanOrganicEventArgs scanOrganic)
103104
return;
104105

105106
item.AddRegion(currentRegion, state);
106-
if (string.IsNullOrEmpty(scanOrganic.Variant_Localised) == false)
107+
if (string.IsNullOrEmpty(scanOrganic.Variant) == false)
107108
{
108109
var names = ExoData.GetNames(scanOrganic.Variant);
109110

@@ -117,7 +118,6 @@ private void AddBioScan(ScanOrganicEvent.ScanOrganicEventArgs scanOrganic)
117118
}
118119
}
119120

120-
121121
if (parserStore.IsLive)
122122
OnSpeciesUpdated?.Invoke(this, scanOrganic.Genus);
123123

@@ -277,8 +277,45 @@ public void ParseJournalEvent(JournalEntry e)
277277
case CodexEntryEvent.CodexEntryEventArgs codex:
278278
{
279279
currentRegion = codex.Region;
280-
if (string.IsNullOrEmpty(codex.Name) == false)
281-
AddCodex(codex.Name);
280+
281+
if (codex.Category != "$Codex_Category_Biology;")
282+
break;
283+
284+
if (string.IsNullOrEmpty(codex.Name))
285+
break;
286+
287+
AddCodex(codex.Name);
288+
289+
var bioNames = ExoData.GetNames(codex.Name);
290+
291+
if (bioNames == null)
292+
break;
293+
294+
if (OrganicScanItems.TryGetValue(bioNames.GenusCodex, out var items))
295+
{
296+
var item = items.FirstOrDefault(x => x.SpeciesCodex == bioNames.SpeciesCodex);
297+
298+
if (item is null)
299+
return;
300+
301+
item.AddRegion(currentRegion, OrganicScanState.Discovered);
302+
303+
if (item.Variants.TryGetValue(currentRegion, out var variants))
304+
{
305+
var knownVariant = variants.FirstOrDefault(x => x.VaritantCodex == codex.Name);
306+
307+
if(knownVariant == null)
308+
{
309+
knownVariant = new(codex.Name, codex.Name_Localised, currentRegion, OrganicScanState.Discovered);
310+
variants.Add(knownVariant);
311+
}
312+
313+
knownVariant.State = OrganicScanState.Discovered;
314+
315+
if (parserStore.IsLive)
316+
OnSpeciesUpdated?.Invoke(this, bioNames.GenusCodex);
317+
}
318+
}
282319
}
283320
break;
284321
case ScanOrganicEvent.ScanOrganicEventArgs scanOrganic:

‎ODExplorer/ViewModels/ModelVMs/OrganicCheckListItemViewModel.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public string VariantCount
6060
{
6161
get
6262
{
63-
var count = Variants.Where(x => x.StageValue >= OrganicScanState.Analysed).DistinctBy(x => x.CodexValue).Count();
64-
var variantCount = Variants.Count;
63+
var count = Variants.Where(x => x.StageValue >= OrganicScanState.Discovered).DistinctBy(x => x.CodexValue).Count();
6564
return $"{count}";
6665
}
6766
}
@@ -74,5 +73,11 @@ public string TotalVariants
7473
return $"{variantCount}";
7574
}
7675
}
76+
77+
public void UpdateCounts()
78+
{
79+
OnPropertyChanged(nameof(VariantCount));
80+
OnPropertyChanged(nameof(TotalVariants));
81+
}
7782
}
7883
}

‎ODExplorer/ViewModels/ViewVMs/OrganicViewModel.cs

+23
Original file line numberDiff line numberDiff line change
@@ -323,58 +323,81 @@ private void FireUpdatePropertyChanged(string key)
323323
switch (key)
324324
{
325325
case "$Codex_Ent_Aleoids_Genus_Name;":
326+
UpdateSpeciesCounts(Aleoida);
326327
OnPropertyChanged(nameof(Aleoida));
327328
break;
328329
case "$Codex_Ent_Bacterial_Genus_Name;":
330+
UpdateSpeciesCounts(Bacterium);
329331
OnPropertyChanged(nameof(Bacterium));
330332
break;
331333
case "$Codex_Ent_Cactoid_Genus_Name;":
334+
UpdateSpeciesCounts(Cactoida);
332335
OnPropertyChanged(nameof(Cactoida));
333336
break;
334337
case "$Codex_Ent_Clypeus_Genus_Name;":
338+
UpdateSpeciesCounts(Clypeus);
335339
OnPropertyChanged(nameof(Clypeus));
336340
break;
337341
case "$Codex_Ent_Conchas_Genus_Name;":
342+
UpdateSpeciesCounts(Concha);
338343
OnPropertyChanged(nameof(Concha));
339344
break;
340345
case "$Codex_Ent_Electricae_Genus_Name":
346+
UpdateSpeciesCounts(Electricae);
341347
OnPropertyChanged(nameof(Electricae));
342348
break;
343349
case "$Codex_Ent_Fonticulus_Genus_Name":
350+
UpdateSpeciesCounts(Fonticulua);
344351
OnPropertyChanged(nameof(Fonticulua));
345352
break;
346353
case "$Codex_Ent_Fumerolas_Genus_Name;":
354+
UpdateSpeciesCounts(Fumerola);
347355
OnPropertyChanged(nameof(Fumerola));
348356
break;
349357
case "$Codex_Ent_Fungoids_Genus_Name;":
358+
UpdateSpeciesCounts(Fungoida);
350359
OnPropertyChanged(nameof(Fungoida));
351360
break;
352361
case "$Codex_Ent_Osseus_Genus_Name;":
362+
UpdateSpeciesCounts(Osseus);
353363
OnPropertyChanged(nameof(Osseus));
354364
break;
355365
case "$Codex_Ent_Recepta_Genus_Name;":
366+
UpdateSpeciesCounts(Recepta);
356367
OnPropertyChanged(nameof(Recepta));
357368
break;
358369
case "$Codex_Ent_Shrubs_Genus_Name;":
370+
UpdateSpeciesCounts(Frutexa);
359371
OnPropertyChanged(nameof(Frutexa));
360372
break;
361373
case "$Codex_Ent_Stratum_Genus_Name;":
374+
UpdateSpeciesCounts(Stratum);
362375
OnPropertyChanged(nameof(Stratum));
363376
break;
364377
case "$Codex_Ent_Tubus_Genus_Name;":
378+
UpdateSpeciesCounts(Tubus);
365379
OnPropertyChanged(nameof(Tubus));
366380
break;
367381
case "$Codex_Ent_Tussocks_Genus_Name;":
382+
UpdateSpeciesCounts(Tussock);
368383
OnPropertyChanged(nameof(Tussock));
369384
break;
370385
case "Other":
386+
UpdateSpeciesCounts(Other);
371387
OnPropertyChanged(nameof(Other));
372388
break;
373389
}
374390

375391
CountBios();
376392
}
377393

394+
private static void UpdateSpeciesCounts(IReadOnlyList<OrganicCheckListItemViewModel> list)
395+
{
396+
foreach(var item in list)
397+
{
398+
item.UpdateCounts();
399+
}
400+
}
378401
private void ExplorationDataStore_OnBioDataLost(object? sender, EventArgs e)
379402
{
380403
BuildLostList();

0 commit comments

Comments
 (0)
Please sign in to comment.