From 11ef727efe92c3d8f00d45d6e2c47e14a35f9466 Mon Sep 17 00:00:00 2001 From: 6d486f49 <76097bcc@gmail.com> Date: Thu, 11 Jun 2026 16:18:36 -0400 Subject: [PATCH] ... --- Pages/Pages/Database/CatalogPage.razor | 384 +++++++++++++++++++++++++ 1 file changed, 384 insertions(+) create mode 100644 Pages/Pages/Database/CatalogPage.razor diff --git a/Pages/Pages/Database/CatalogPage.razor b/Pages/Pages/Database/CatalogPage.razor new file mode 100644 index 0000000..5c8ad1a --- /dev/null +++ b/Pages/Pages/Database/CatalogPage.razor @@ -0,0 +1,384 @@ +@inherits BasePage +@page "/catalog" +@using Model +@using Model.Entity.Data +@using Model.Entity.Parts +@implements IDisposable + +@inject IEntityDisplayService EntityDisplayService +@inject NavigationManager NavigationManager + + + Catalog + + + + + Game Patch: @Variables.GamePatch + + + + + + + +
+ @searches.Count @(searches.Count == 1 ? "entity" : "entities") +
+ + @if (searches.Any()) + { +
+ @foreach (var entity in searches) + { + +
+
+ @entity.Info().Name + @entity.EntityType.Replace("_", " ") +
+ +
+ @{ + var faction = entity.Faction(); + } + @if (faction != null) + { + var factionName = EntityData.Get().TryGetValue(faction.Faction, out var fac) ? fac.Info().Name : ""; + @factionName + } + @{ + var vanguard = entity.VanguardAdded(); + } + @if (vanguard != null) + { + | + var immortalName = EntityData.Get().TryGetValue(vanguard.ImmortalId, out var imm) ? imm.Info().Name : ""; + @immortalName + } +
+ + @if (!string.IsNullOrEmpty(entity.Info().Description)) + { +
+ @(entity.Info().Description.Length > 160 + ? entity.Info().Description[..157] + "..." + : entity.Info().Description) +
+ } + +
+ @{ + var tier = entity.Tier(); + if (tier != null && tier.Tier > 0) + { + T@(tier.Tier) + } + } + @{ + var supply = entity.Supply(); + if (supply != null && (supply.Takes > 0 || supply.Grants > 0)) + { + @supply.Takes@(supply.Grants > 0 ? $"/{supply.Grants}" : "") + } + } + @{ + var prod = entity.Production(); + if (prod != null) + { + if (prod.Alloy > 0) { @prod.Alloy } + if (prod.Ether > 0) { @prod.Ether } + if (prod.Pyre > 0) { @prod.Pyre } + if (prod.Energy > 0) { @prod.Energy } + if (prod.BuildTime > 0) { @prod.BuildTime"s } + } + } + @{ + var vitality = entity.Vitality(); + if (vitality != null && vitality.Health > 0) + { + @vitality.Health + } + } +
+
+
+ } +
+ } + else + { +
No entities match the selected filters.
+ } +
+
+ + + +@code { + + [Inject] public IEntityFilterService EntityFilterService { get; set; } = default!; + + readonly List defaults = (from entity in EntityModel.GetList() + where !entity.IsSpeculative + select entity).ToList(); + + List factions = default!; + List immortals = default!; + List entities = default!; + List searches = default!; + + string selectedFactionType = DataType.Any; + string selectedImmortalType = DataType.Any; + string selectedEntityType = EntityType.Army; + string searchText = ""; + + protected override void OnInitialized() + { + base.OnInitialized(); + RefreshFactionSearch(); + + EntityFilterService.Subscribe(OnChange); + EntityDisplayService.Subscribe(StateHasChanged); + } + + void IDisposable.Dispose() + { + EntityFilterService.Unsubscribe(OnChange); + EntityDisplayService.Unsubscribe(StateHasChanged); + } + + void NavigateToEntity(EntityModel entity) + { + NavigationManager.NavigateTo($"/database/{Uri.EscapeDataString(entity.Info().Name)}"); + } + + void OnChange(EntityFilterEvent filterEntityEvent) + { + if (filterEntityEvent == EntityFilterEvent.OnRefreshFaction) + { + RefreshFactionSearch(); + } + + if (filterEntityEvent == EntityFilterEvent.OnRefreshImmortal) + { + RefreshImmortalSearch(); + } + + if (filterEntityEvent == EntityFilterEvent.OnRefreshEntity) + { + RefreshEntitySearch(); + } + + if (filterEntityEvent == EntityFilterEvent.OnRefreshSearch) + { + RefreshTextSearch(); + } + } + + void RefreshFactionSearch() + { + selectedFactionType = EntityFilterService.GetFactionType(); + + if (selectedFactionType == DataType.Any) + { + factions = defaults.ToList(); + } + else + { + factions = (from entity in defaults + where entity.Faction() != null && entity.Faction().Faction == selectedFactionType + select entity).ToList(); + } + + RefreshImmortalSearch(); + } + + void RefreshImmortalSearch() + { + selectedImmortalType = EntityFilterService.GetImmortalType(); + + if (selectedImmortalType == DataType.Any) + { + immortals = factions.ToList(); + } + else + { + immortals = (from entity in factions + let vanguardAdded = entity.VanguardAdded() + where vanguardAdded == null || vanguardAdded.ImmortalId == selectedImmortalType + select entity).ToList(); + } + + RefreshEntitySearch(); + } + + void RefreshEntitySearch() + { + selectedEntityType = EntityFilterService.GetEntityType(); + + if (selectedEntityType == EntityType.Any) + { + entities = immortals.ToList(); + } + else + { + entities = (from entity in immortals + where entity.EntityType == selectedEntityType + select entity).ToList(); + } + + RefreshTextSearch(); + } + + void RefreshTextSearch() + { + searchText = EntityFilterService.GetSearchText(); + + if (searchText.Trim() == "") + { + searches = entities.ToList(); + } + else + { + searches = (from entity in entities + where entity.Info().Name.ToLower().Contains(searchText.ToLower()) + select entity).ToList(); + } + + StateHasChanged(); + } + +}