diff --git a/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs b/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs index ac22587..92237a9 100644 --- a/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs +++ b/Client/Application/ViewModels/HeroSummaryInfoViewModel.cs @@ -4,6 +4,7 @@ using Client.Domain.Entities; using Client.Domain.ValueObjects; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -89,10 +90,19 @@ namespace Client.Application.ViewModels return ai.IsEnabled ? ai.CurrentState.ToString() : "Disabled"; } } - public HeroSummaryInfoViewModel(Hero hero, AIInterface ai) + public int InventoryOccupiedSlots + { + get + { + return items.Count + questItems.Count; + } + } + public HeroSummaryInfoViewModel(Hero hero, AIInterface ai, ObservableCollection items, ObservableCollection questItems) { this.hero = hero; this.ai = ai; + this.items = items; + this.questItems = questItems; hero.FullName.PropertyChanged += FullName_PropertyChanged; hero.Phenotype.PropertyChanged += Phenotype_PropertyChanged; hero.ExperienceInfo.PropertyChanged += ExperienceInfo_PropertyChanged; @@ -101,6 +111,18 @@ namespace Client.Application.ViewModels hero.InventoryInfo.PropertyChanged += InventoryInfo_PropertyChanged; hero.PropertyChanged += Hero_PropertyChanged; ai.PropertyChanged += Ai_PropertyChanged; + items.CollectionChanged += Items_CollectionChanged; + questItems.CollectionChanged += QuestItems_CollectionChanged; + } + + private void QuestItems_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + OnPropertyChanged("InventoryOccupiedSlots"); + } + + private void Items_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + OnPropertyChanged("InventoryOccupiedSlots"); } private void Ai_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -169,6 +191,8 @@ namespace Client.Application.ViewModels private readonly Hero hero; private readonly AIInterface ai; + private readonly ObservableCollection items; + private readonly ObservableCollection questItems; private TargetSummaryInfoViewModel? target; } } diff --git a/Client/Application/ViewModels/MainViewModel.cs b/Client/Application/ViewModels/MainViewModel.cs index 8bd0c73..1e03c0d 100644 --- a/Client/Application/ViewModels/MainViewModel.cs +++ b/Client/Application/ViewModels/MainViewModel.cs @@ -39,7 +39,7 @@ namespace Client.Application.ViewModels public void Handle(HeroCreatedEvent @event) { - Hero = new HeroSummaryInfoViewModel(@event.Hero, ai); + Hero = new HeroSummaryInfoViewModel(@event.Hero, ai, Items, QuestItems); hero = @event.Hero; Map.Hero = hero; Map.CombatZone = new AICombatZoneMapViewModel(aiConfig.Combat.Zone, hero); diff --git a/Client/Application/Views/MainWindow.xaml b/Client/Application/Views/MainWindow.xaml index 19b4401..5cda4f1 100644 --- a/Client/Application/Views/MainWindow.xaml +++ b/Client/Application/Views/MainWindow.xaml @@ -257,7 +257,7 @@ - +