diff --git a/src/StatisticsAnalysisTool/Languages/de-DE.xml b/src/StatisticsAnalysisTool/Languages/de-DE.xml index 93bbdc6c5..e3e492035 100644 --- a/src/StatisticsAnalysisTool/Languages/de-DE.xml +++ b/src/StatisticsAnalysisTool/Languages/de-DE.xml @@ -560,4 +560,6 @@ Verkauf abgelaufen Kauf abgelaufen bis + Lager Historie + Bank \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Languages/en-US.xml b/src/StatisticsAnalysisTool/Languages/en-US.xml index 3689cf00b..081f70d0b 100644 --- a/src/StatisticsAnalysisTool/Languages/en-US.xml +++ b/src/StatisticsAnalysisTool/Languages/en-US.xml @@ -560,4 +560,6 @@ Sell expired Buy expired to + Storage History + Bank \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs b/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs index ae0e01dc7..f8167975f 100644 --- a/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs +++ b/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs @@ -1,9 +1,11 @@ -using StatisticsAnalysisTool.Models.NetworkModel; +using System; +using StatisticsAnalysisTool.Models.NetworkModel; using StatisticsAnalysisTool.Properties; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; +using System.Windows; namespace StatisticsAnalysisTool.Models.BindingModel; @@ -14,6 +16,8 @@ public class VaultBindings : INotifyPropertyChanged private Vault _vaultSelected; private List _vaultContainer; private VaultContainer _vaultContainerSelected; + private Visibility _lastUpdateVisibility = Visibility.Hidden; + private DateTime _lastUpdate; public List Vaults { @@ -31,7 +35,7 @@ public Vault VaultSelected set { _vaultSelected = value; - VaultContainer = _vaultSelected.VaultContainer; + VaultContainer = _vaultSelected.VaultContainer.FindAll(x => x.LastUpdate.Ticks > 0).OrderBy(y => y.Name).ToList(); OnPropertyChanged(); } } @@ -53,6 +57,8 @@ public VaultContainer VaultContainerSelected { _vaultContainerSelected = value; VaultContainerContent = _vaultContainer?.FirstOrDefault(x => x.Guid == _vaultContainerSelected.Guid)?.Items ?? new List(); + LastUpdate = _vaultContainerSelected?.LastUpdate ?? new DateTime(0); + LastUpdateVisibility = _vaultContainerSelected?.LastUpdate.Ticks <= 1 ? Visibility.Hidden : Visibility.Visible; OnPropertyChanged(); } } @@ -67,6 +73,26 @@ public List VaultContainerContent } } + public Visibility LastUpdateVisibility + { + get => _lastUpdateVisibility; + set + { + _lastUpdateVisibility = value; + OnPropertyChanged(); + } + } + + public DateTime LastUpdate + { + get => _lastUpdate; + set + { + _lastUpdate = value; + OnPropertyChanged(); + } + } + public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] diff --git a/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs b/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs index f3cba473e..bd559770d 100644 --- a/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs +++ b/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs @@ -71,6 +71,7 @@ public class MainWindowTranslation public static string Dungeons => LanguageController.Translation("DUNGEONS"); public static string PlayerInformation => LanguageController.Translation("PLAYER_INFORMATION"); public static string MailMonitoring => LanguageController.Translation("MAIL_MONITORING"); + public static string StorageHistory => LanguageController.Translation("STORAGE_HISTORY"); public static string Logging => LanguageController.Translation("LOGGING"); public static string TrackingIsActive => LanguageController.Translation("TRACKING_IS_ACTIVE"); public static string TrackingIsPartiallyActive => LanguageController.Translation("TRACKING_IS_PARTIALLY_ACTIVE"); diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs index 1e551d47e..fd7329d73 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs @@ -10,8 +10,11 @@ public ItemContainerObject(long? objectId, Guid containerGuid, List slotIte ObjectId = objectId; ContainerGuid = containerGuid; SlotItemId = slotItemId; + + LastUpdate = DateTime.UtcNow; } + public DateTime LastUpdate { get; } public long? ObjectId { get; set; } public Guid ContainerGuid { get; set; } public List SlotItemId { get; set; } diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs index 41ff9f608..cb3709b23 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs @@ -5,6 +5,7 @@ namespace StatisticsAnalysisTool.Models.NetworkModel; public class VaultContainer { + public DateTime LastUpdate { get; set; } public Guid Guid { get; set; } public string Name { get; set; } public string Icon { get; set; } diff --git a/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs b/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs index ce3c4c55a..c37d3d572 100644 --- a/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs +++ b/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs @@ -36,7 +36,16 @@ public AttachItemContainerEvent(Dictionary parameters) if (parameters.ContainsKey(3) && parameters[3] != null) { var valueType = parameters[3].GetType(); - if (valueType.IsArray && typeof(short[]) == valueType) + if (valueType.IsArray && typeof(int[]) == valueType) + { + var intArray = ((int[])parameters[3]).ToDictionary(); + + foreach (var slot in intArray) + { + _containerSlots.Add(slot.Value); + } + } + else if (valueType.IsArray && typeof(short[]) == valueType) { var intArray = ((short[])parameters[3]).ToDictionary(); diff --git a/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs b/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs index 7b9bac4fe..509ed484d 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs @@ -46,7 +46,7 @@ public TrackingController(MainWindowViewModel mainWindowViewModel, MainWindow ma LootController = new LootController(this, mainWindowViewModel); StatisticController = new StatisticController(this, mainWindowViewModel); MailController = new MailController(mainWindowViewModel); - VaultController = new VaultController(this, mainWindowViewModel); + VaultController = new VaultController(mainWindowViewModel); CountUpTimer = new CountUpTimer(this, mainWindowViewModel); } @@ -102,6 +102,7 @@ public void SetNewCluster(MapType mapType, Guid? mapGuid, string clusterIndex, s StatisticController.SetKillsDeathsValues(); VaultController.ResetDiscoveredItems(); VaultController.ResetVaultContainer(); + VaultController.ResetCurrentVaultInfo(); } private bool TryChangeCluster(string index, string mapName) diff --git a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs b/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs index 1e4bceadd..989099be9 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs @@ -7,22 +7,19 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Collections.Specialized; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Text.Json; using System.Windows; -using StatisticsAnalysisTool.Models.BindingModel; namespace StatisticsAnalysisTool.Network.Manager; public class VaultController { private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType); - - private readonly TrackingController _trackingController; + private readonly MainWindowViewModel _mainWindowViewModel; private VaultInfo _currentVaultInfo; private readonly List _discoveredItems = new(); @@ -39,9 +36,8 @@ private ObservableCollection Vaults } } - public VaultController(TrackingController trackingController, MainWindowViewModel mainWindowViewModel) + public VaultController(MainWindowViewModel mainWindowViewModel) { - _trackingController = trackingController; _mainWindowViewModel = mainWindowViewModel; OnVaultsChange += UpdateUi; @@ -53,6 +49,7 @@ public void SetCurrentVault(VaultInfo vaultInfo) { if (vaultInfo == null || vaultInfo.VaultLocation == VaultLocation.Unknown) { + _currentVaultInfo = null; return; } @@ -69,11 +66,6 @@ public void Add(DiscoveredItem item) _discoveredItems.Add(item); } - public void ResetDiscoveredItems() - { - _discoveredItems.Clear(); - } - public void AddContainer(ItemContainerObject newContainerObject) { if (newContainerObject?.ContainerGuid == default) @@ -97,6 +89,16 @@ public void ResetVaultContainer() _vaultContainer.Clear(); } + public void ResetDiscoveredItems() + { + _discoveredItems.Clear(); + } + + public void ResetCurrentVaultInfo() + { + _currentVaultInfo = null; + } + private void ParseVault() { if (_currentVaultInfo == null || GetVaultLocation(_currentVaultInfo?.Location) == VaultLocation.Unknown) @@ -124,12 +126,15 @@ private void ParseVault() { Guid = _currentVaultInfo.ContainerGuidList[i], Icon = _currentVaultInfo.ContainerIconTags[i], - Name = _currentVaultInfo.ContainerNames[i] + Name = (_currentVaultInfo.ContainerNames[i] == "@BUILDINGS_T1_BANK") ? LanguageController.Translation("BANK") : _currentVaultInfo.ContainerNames[i] }; var itemContainer = _vaultContainer.FirstOrDefault(x => x.ContainerGuid == vaultContainer.Guid); - - SetItemsToVaultContainer(itemContainer, vaultContainer, _discoveredItems); + if (itemContainer != null) + { + vaultContainer.LastUpdate = itemContainer.LastUpdate; + SetItemsToVaultContainer(itemContainer, vaultContainer, _discoveredItems); + } vault.VaultContainer.Add(vaultContainer); } @@ -186,12 +191,7 @@ private void UpdateUi() { Application.Current.Dispatcher.Invoke(() => { - var unknownVaultSelection = new Vault() { Location = "UNKNOWN" }; - var list = Vaults.ToList(); - list.Insert(0, unknownVaultSelection); - - _mainWindowViewModel.VaultBindings.Vaults = list; - _mainWindowViewModel.VaultBindings.VaultSelected = unknownVaultSelection; + _mainWindowViewModel.VaultBindings.Vaults = Vaults.ToList(); }); } diff --git a/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml index f90073816..a6a576e0c 100644 --- a/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml +++ b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:viewModels="clr-namespace:StatisticsAnalysisTool.ViewModels" + xmlns:gl="clr-namespace:System.Globalization;assembly=System.Runtime" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"> @@ -14,6 +15,12 @@ + + + +