diff --git a/src/StatisticsAnalysisTool/Assets/preparation_folder.png b/src/StatisticsAnalysisTool/Assets/preparation_folder.png index a44f61528..5c548746d 100644 Binary files a/src/StatisticsAnalysisTool/Assets/preparation_folder.png and b/src/StatisticsAnalysisTool/Assets/preparation_folder.png differ diff --git a/src/StatisticsAnalysisTool/Assets/preparation_folder_steam.png b/src/StatisticsAnalysisTool/Assets/preparation_folder_steam.png new file mode 100644 index 000000000..a541eac62 Binary files /dev/null and b/src/StatisticsAnalysisTool/Assets/preparation_folder_steam.png differ diff --git a/src/StatisticsAnalysisTool/Cluster/ClusterController.cs b/src/StatisticsAnalysisTool/Cluster/ClusterController.cs index f94c1b8fb..8af04d62a 100644 --- a/src/StatisticsAnalysisTool/Cluster/ClusterController.cs +++ b/src/StatisticsAnalysisTool/Cluster/ClusterController.cs @@ -72,8 +72,8 @@ public void SetAndResetValues(ClusterInfo currentCluster) _trackingController.CombatController.ResetDamageMeterByClusterChange(); _trackingController.StatisticController.SetKillsDeathsValues(); _trackingController.VaultController.ResetDiscoveredItems(); - _trackingController.VaultController.ResetVaultContainer(); - _trackingController.VaultController.ResetCurrentVaultInfo(); + _trackingController.VaultController.ResetInternalVaultContainer(); + _trackingController.VaultController.ResetCurrentInternalVault(); _trackingController.TreasureController.RemoveTemporaryTreasures(); _trackingController.TreasureController.UpdateLootedChestsDashboardUi(); _trackingController.LootController.ResetLocalPlayerDiscoveredLoot(); diff --git a/src/StatisticsAnalysisTool/Localization/localization.json b/src/StatisticsAnalysisTool/Localization/localization.json index ae39d73c0..9e829b490 100644 --- a/src/StatisticsAnalysisTool/Localization/localization.json +++ b/src/StatisticsAnalysisTool/Localization/localization.json @@ -37274,6 +37274,58 @@ "seg": "Average est. Market value" } ] + }, + { + "tuid": "STANDALONE_LAUNCHER", + "tuv": [ + { + "lang": "de-DE", + "seg": "Eigenständiger Launcher" + }, + { + "lang": "en-US", + "seg": "Standalone Launcher" + } + ] + }, + { + "tuid": "STANDALONE_LAUNCHER_MESSAGE", + "tuv": [ + { + "lang": "de-DE", + "seg": "Wähle den AlbionOnline Ordner aus, wo du ihn installiert hast. Zum Beispiel unter 'C:\\AlbionOnline'" + }, + { + "lang": "en-US", + "seg": "Select the AlbionOnline folder where you installed it. For example, under 'C:\\AlbionOnline'" + } + ] + }, + { + "tuid": "STEAM_LAUNCHER", + "tuv": [ + { + "lang": "de-DE", + "seg": "Steam Launcher" + }, + { + "lang": "en-US", + "seg": "Steam Launcher" + } + ] + }, + { + "tuid": "STEAM_LAUNCHER_MESSAGE", + "tuv": [ + { + "lang": "de-DE", + "seg": "Wähle den AlbionOnline Ordner in den steamapps aus. Meistens zu finden unter 'C:\\Program Files\\Steam\\steamapps\\common'" + }, + { + "lang": "en-US", + "seg": "Select the AlbionOnline folder in the steamapps. Usually found under 'C:\\Program Files\\Steam\\steamapps\\common'" + } + ] } ] } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/ContainerItem.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/ContainerItem.cs deleted file mode 100644 index a5e5e798f..000000000 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/ContainerItem.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.Json.Serialization; -using StatisticsAnalysisTool.Common; - -namespace StatisticsAnalysisTool.Models.NetworkModel; - -public class ContainerItem -{ - [JsonPropertyName("I")] - public int ItemIndex { get; set; } - [JsonIgnore] - public Item Item => ItemController.GetItemByIndex(ItemIndex); - [JsonPropertyName("Q")] - public int Quantity { get; set; } -} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs index 72a2c985c..5aaa288bf 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs @@ -20,4 +20,5 @@ public ItemContainerObject(long? objectId, Guid privateContainerGuid, Guid conta public Guid PrivateContainerGuid { get; set; } public Guid ContainerGuid { get; set; } public List SlotItemIds { get; set; } + public double RepairCosts { get; set; } } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/Vault.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/Vault.cs deleted file mode 100644 index 3b9b7e702..000000000 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/Vault.cs +++ /dev/null @@ -1,36 +0,0 @@ -using StatisticsAnalysisTool.Cluster; -using StatisticsAnalysisTool.GameFileData; -using StatisticsAnalysisTool.Localization; -using System.Collections.Generic; -using System.Text.Json.Serialization; - -namespace StatisticsAnalysisTool.Models.NetworkModel; - -public class Vault -{ - public string Location { get; set; } - public string MainLocationIndex { get; set; } - public MapType MapType { get; set; } - public List VaultContainer { get; set; } = new(); - - [JsonIgnore] - public string MainLocation => WorldData.GetUniqueNameOrDefault(MainLocationIndex); - [JsonIgnore] - public string LocationDisplayString - { - get - { - if (MapType is MapType.Hideout) - { - return $"{Location} ({LocalizationController.Translation("HIDEOUT")}) - {MainLocation}"; - } - - if (MapType is MapType.Island) - { - return $"{Location} ({LocalizationController.Translation("ISLAND")})"; - } - - return Location; - } - } -} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/BankVaultInfoEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/BankVaultInfoEventHandler.cs index 5089b52c5..94f4de9af 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/BankVaultInfoEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/BankVaultInfoEventHandler.cs @@ -1,7 +1,7 @@ using StatisticsAnalysisTool.Network.Events; using StatisticsAnalysisTool.Network.Manager; +using StatisticsAnalysisTool.StorageHistory; using System.Threading.Tasks; -using StatisticsAnalysisTool.Models.NetworkModel; namespace StatisticsAnalysisTool.Network.Handler; @@ -18,7 +18,7 @@ protected override async Task OnActionAsync(BankVaultInfoEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.SetCurrentVault(new VaultInfo(value.ObjectId, value.LocationGuidString, value.VaultGuidList, value.VaultNames, value.IconTags)); + _trackingController.VaultController.SetCurrentVault(new InternalVault(value.ObjectId, value.LocationGuidString, value.VaultGuidList, value.VaultNames, value.IconTags)); } await Task.CompletedTask; diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs index fce5cc8b6..2ec0901b6 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs @@ -19,7 +19,7 @@ protected override async Task OnActionAsync(NewEquipmentItemEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.Add(value.Item); + _trackingController.VaultController.AddDiscoveredItem(value.Item); } _trackingController.EntityController.AddEquipmentItem(new EquipmentItemInternal diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs index a90646fe7..960454b1c 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs @@ -18,7 +18,7 @@ protected override async Task OnActionAsync(NewFurnitureItemEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.Add(value.Item); + _trackingController.VaultController.AddDiscoveredItem(value.Item); } EstimatedMarketValueController.Add(value.Item.ItemIndex, value.Item.EstimatedMarketValueInternal, value.Item.Quality); diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs index 4e4628f88..9900e878e 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs @@ -19,7 +19,7 @@ protected override async Task OnActionAsync(NewJournalItemEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.Add(value.Item); + _trackingController.VaultController.AddDiscoveredItem(value.Item); } EstimatedMarketValueController.Add(value.Item.ItemIndex, value.Item.EstimatedMarketValueInternal, value.Item.Quality); diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewKillTrophyItemHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewKillTrophyItemHandler.cs index 0f960b9a9..50692e2f4 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewKillTrophyItemHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewKillTrophyItemHandler.cs @@ -18,7 +18,7 @@ protected override async Task OnActionAsync(NewKillTrophyItemEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.Add(value.Item); + _trackingController.VaultController.AddDiscoveredItem(value.Item); } EstimatedMarketValueController.Add(value.Item.ItemIndex, value.Item.EstimatedMarketValueInternal, value.Item.Quality); diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs index b52e22d51..7a5b28ac1 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs @@ -18,7 +18,7 @@ protected override async Task OnActionAsync(NewLaborerItemEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.Add(value.Item); + _trackingController.VaultController.AddDiscoveredItem(value.Item); } EstimatedMarketValueController.Add(value.Item.ItemIndex, value.Item.EstimatedMarketValueInternal, value.Item.Quality); diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs index 1493c46b0..36a87cd49 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs @@ -18,7 +18,7 @@ protected override async Task OnActionAsync(NewSimpleItemEvent value) { if (_trackingController.IsTrackingAllowedByMainCharacter()) { - _trackingController.VaultController.Add(value.Item); + _trackingController.VaultController.AddDiscoveredItem(value.Item); } EstimatedMarketValueController.Add(value.Item.ItemIndex, value.Item.EstimatedMarketValueInternal, value.Item.Quality); diff --git a/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs b/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs index cd65a4157..e509b04ed 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs @@ -13,6 +13,7 @@ using StatisticsAnalysisTool.Localization; using StatisticsAnalysisTool.Network.PacketProviders; using StatisticsAnalysisTool.Party; +using StatisticsAnalysisTool.StorageHistory; using StatisticsAnalysisTool.Trade; using StatisticsAnalysisTool.Trade.Mails; using StatisticsAnalysisTool.Trade.Market; diff --git a/src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs b/src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs index b35e75068..8f5d1cc6d 100644 --- a/src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs +++ b/src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("7.7.1.*")] -[assembly: AssemblyFileVersion("7.7.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("7.7.2.*")] +[assembly: AssemblyFileVersion("7.7.2.0")] \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj b/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj index d2fb89784..c5acdfa6f 100644 --- a/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj +++ b/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj @@ -293,6 +293,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -690,6 +693,7 @@ + diff --git a/src/StatisticsAnalysisTool/StorageHistory/ContainerItem.cs b/src/StatisticsAnalysisTool/StorageHistory/ContainerItem.cs new file mode 100644 index 000000000..a760a2baf --- /dev/null +++ b/src/StatisticsAnalysisTool/StorageHistory/ContainerItem.cs @@ -0,0 +1,32 @@ +using StatisticsAnalysisTool.Common; +using StatisticsAnalysisTool.Models; +using StatisticsAnalysisTool.ViewModels; + +namespace StatisticsAnalysisTool.StorageHistory; + +public class ContainerItem : BaseViewModel +{ + private int _itemIndex; + private int _quantity; + + public int ItemIndex + { + get => _itemIndex; + set + { + _itemIndex = value; + OnPropertyChanged(); + } + } + + public int Quantity + { + get => _quantity; + set + { + _quantity = value; + OnPropertyChanged(); + } + } + public Item Item => ItemController.GetItemByIndex(ItemIndex); +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/StorageHistory/ContainerItemDto.cs b/src/StatisticsAnalysisTool/StorageHistory/ContainerItemDto.cs new file mode 100644 index 000000000..1b00629d5 --- /dev/null +++ b/src/StatisticsAnalysisTool/StorageHistory/ContainerItemDto.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace StatisticsAnalysisTool.StorageHistory; + +public class ContainerItemDto +{ + [JsonPropertyName("I")] + public int ItemIndex { get; set; } + [JsonPropertyName("Q")] + public int Quantity { get; set; } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultInfo.cs b/src/StatisticsAnalysisTool/StorageHistory/InternalVault.cs similarity index 73% rename from src/StatisticsAnalysisTool/Models/NetworkModel/VaultInfo.cs rename to src/StatisticsAnalysisTool/StorageHistory/InternalVault.cs index 807ab9e5a..02b5184b3 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultInfo.cs +++ b/src/StatisticsAnalysisTool/StorageHistory/InternalVault.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Generic; -namespace StatisticsAnalysisTool.Models.NetworkModel; +namespace StatisticsAnalysisTool.StorageHistory; -public class VaultInfo +public class InternalVault { - public VaultInfo(long? objectId, string locationGuidString, List containerGuidList, List containerNames, List containerIconTags) + public InternalVault(long? objectId, string locationGuidString, List containerGuidList, List containerNames, List containerIconTags) { ObjectId = objectId; LocationGuidString = locationGuidString; @@ -24,4 +24,5 @@ public VaultInfo(long? objectId, string locationGuidString, List container public MapType MapType => WorldData.GetMapType(LocationGuidString); public string MainLocationIndex { get; set; } public string UniqueClusterName { get; set; } + public double RepairCosts { get; set; } } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/StorageHistory/StorageHistoryMapping.cs b/src/StatisticsAnalysisTool/StorageHistory/StorageHistoryMapping.cs new file mode 100644 index 000000000..7c35d2c2d --- /dev/null +++ b/src/StatisticsAnalysisTool/StorageHistory/StorageHistoryMapping.cs @@ -0,0 +1,71 @@ +using System.Collections.ObjectModel; +using System.Linq; + +namespace StatisticsAnalysisTool.StorageHistory; + +public static class StorageHistoryMapping +{ + public static VaultDto Mapping(Vault vault) + { + return new VaultDto() + { + Location = vault.Location, + MainLocationIndex = vault.MainLocationIndex, + MapType = vault.MapType, + VaultContainer = vault.VaultContainer.Select(Mapping).ToList() + }; + } + + public static Vault Mapping(VaultDto vaultDto) + { + return new Vault() + { + Location = vaultDto.Location, + MainLocationIndex = vaultDto.MainLocationIndex, + MapType = vaultDto.MapType, + VaultContainer = vaultDto.VaultContainer.Select(Mapping).ToList() + }; + } + + public static VaultContainerDto Mapping(VaultContainer vaultContainer) + { + return new VaultContainerDto() + { + LastUpdate = vaultContainer.LastUpdate, + Guid = vaultContainer.Guid, + Name = vaultContainer.Name, + Icon = vaultContainer.Icon, + Items = vaultContainer.Items.Select(Mapping).ToList() + }; + } + + public static VaultContainer Mapping(VaultContainerDto vaultContainerDto) + { + return new VaultContainer() + { + LastUpdate = vaultContainerDto.LastUpdate, + Guid = vaultContainerDto.Guid, + Name = vaultContainerDto.Name, + Icon = vaultContainerDto.Icon, + Items = new ObservableCollection(vaultContainerDto.Items.Select(Mapping)) + }; + } + + public static ContainerItemDto Mapping(ContainerItem containerItem) + { + return new ContainerItemDto() + { + ItemIndex = containerItem.ItemIndex, + Quantity = containerItem.Quantity + }; + } + + public static ContainerItem Mapping(ContainerItemDto containerItemDto) + { + return new ContainerItem() + { + ItemIndex = containerItemDto.ItemIndex, + Quantity = containerItemDto.Quantity + }; + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/StorageHistory/Vault.cs b/src/StatisticsAnalysisTool/StorageHistory/Vault.cs new file mode 100644 index 000000000..c46d7c87a --- /dev/null +++ b/src/StatisticsAnalysisTool/StorageHistory/Vault.cs @@ -0,0 +1,75 @@ +using StatisticsAnalysisTool.Cluster; +using StatisticsAnalysisTool.GameFileData; +using StatisticsAnalysisTool.Localization; +using StatisticsAnalysisTool.ViewModels; +using System.Collections.Generic; + +namespace StatisticsAnalysisTool.StorageHistory; + +public class Vault : BaseViewModel +{ + private string _location; + private string _mainLocationIndex; + private MapType _mapType; + private List _vaultContainer = new(); + + public string Location + { + get => _location; + set + { + _location = value; + OnPropertyChanged(); + } + } + + public string MainLocationIndex + { + get => _mainLocationIndex; + set + { + _mainLocationIndex = value; + OnPropertyChanged(); + } + } + + public MapType MapType + { + get => _mapType; + set + { + _mapType = value; + OnPropertyChanged(); + } + } + + public List VaultContainer + { + get => _vaultContainer; + set + { + _vaultContainer = value; + OnPropertyChanged(); + } + } + + public string MainLocation => WorldData.GetUniqueNameOrDefault(MainLocationIndex); + + public string LocationDisplayString + { + get + { + if (MapType is MapType.Hideout) + { + return $"{Location} ({LocalizationController.Translation("HIDEOUT")}) - {MainLocation}"; + } + + if (MapType is MapType.Island) + { + return $"{Location} ({LocalizationController.Translation("ISLAND")})"; + } + + return Location; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs b/src/StatisticsAnalysisTool/StorageHistory/VaultBindings.cs similarity index 79% rename from src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs rename to src/StatisticsAnalysisTool/StorageHistory/VaultBindings.cs index 2fc33948f..851635713 100644 --- a/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs +++ b/src/StatisticsAnalysisTool/StorageHistory/VaultBindings.cs @@ -1,20 +1,21 @@ -using StatisticsAnalysisTool.Common.UserSettings; -using StatisticsAnalysisTool.Models.NetworkModel; +using StatisticsAnalysisTool.Common.UserSettings; +using StatisticsAnalysisTool.Models; using StatisticsAnalysisTool.ViewModels; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Windows; using System.Windows.Data; -namespace StatisticsAnalysisTool.Models.BindingModel; +namespace StatisticsAnalysisTool.StorageHistory; public class VaultBindings : BaseViewModel { - private List _vaultContainerContent; - private List _vaults; + private ObservableCollection _vaultContainerContent; + private ObservableCollection _vaults; private Vault _vaultSelected; - private List _vaultContainer; + private ObservableCollection _vaultContainer; private VaultContainer _vaultContainerSelected; private Visibility _lastUpdateVisibility = Visibility.Hidden; private DateTime _lastUpdate; @@ -36,7 +37,7 @@ public VaultBindings() } } - public List Vaults + public ObservableCollection Vaults { get => _vaults; set @@ -52,17 +53,25 @@ public Vault VaultSelected set { _vaultSelected = value; - VaultContainer = _vaultSelected?.VaultContainer?.FindAll(x => x?.LastUpdate.Ticks > 0).OrderBy(y => y.Name).ToList(); + VaultContainer = new ObservableCollection( + _vaultSelected?.VaultContainer?.FindAll(x => x?.LastUpdate.Ticks > 0).OrderBy(y => y.Name).ToList() ?? + new List() + ); OnPropertyChanged(); } } - public List VaultContainer + public ObservableCollection VaultContainer { get => _vaultContainer; set { + var vaultContainerSelectedGuid = VaultContainerSelected?.Guid; _vaultContainer = value; + if (VaultContainerSelected is not null) + { + VaultContainerSelected = VaultContainer.FirstOrDefault(x => x?.Guid == vaultContainerSelectedGuid); + } OnPropertyChanged(); } } @@ -73,14 +82,14 @@ public VaultContainer VaultContainerSelected set { _vaultContainerSelected = value; - VaultContainerContent = _vaultContainer?.FirstOrDefault(x => x.Guid == _vaultContainerSelected.Guid)?.Items ?? new List(); + VaultContainerContent = _vaultContainer?.FirstOrDefault(x => x.Guid == _vaultContainerSelected?.Guid)?.Items ?? new ObservableCollection(); LastUpdate = _vaultContainerSelected?.LastUpdate ?? new DateTime(0); LastUpdateVisibility = _vaultContainerSelected?.LastUpdate.Ticks <= 1 ? Visibility.Hidden : Visibility.Visible; OnPropertyChanged(); } } - public List VaultContainerContent + public ObservableCollection VaultContainerContent { get => _vaultContainerContent; set @@ -161,7 +170,7 @@ public GridLength GridSplitterPosition OnPropertyChanged(); } } - + #region Filter private bool Filter(object obj) diff --git a/src/StatisticsAnalysisTool/StorageHistory/VaultContainer.cs b/src/StatisticsAnalysisTool/StorageHistory/VaultContainer.cs new file mode 100644 index 000000000..f5298e0a0 --- /dev/null +++ b/src/StatisticsAnalysisTool/StorageHistory/VaultContainer.cs @@ -0,0 +1,75 @@ +using StatisticsAnalysisTool.ViewModels; +using System; +using System.Collections.ObjectModel; + +namespace StatisticsAnalysisTool.StorageHistory; + +public class VaultContainer : BaseViewModel +{ + private DateTime _lastUpdate; + private Guid _guid; + private string _name; + private string _icon; + private ObservableCollection _items = new(); + private double _repairCosts; + + public DateTime LastUpdate + { + get => _lastUpdate; + set + { + _lastUpdate = value; + OnPropertyChanged(); + } + } + + public Guid Guid + { + get => _guid; + set + { + _guid = value; + OnPropertyChanged(); + } + } + + public string Name + { + get => _name; + set + { + _name = value; + OnPropertyChanged(); + } + } + + public string Icon + { + get => _icon; + set + { + _icon = value; + OnPropertyChanged(); + } + } + + public ObservableCollection Items + { + get => _items; + set + { + _items = value; + OnPropertyChanged(); + } + } + + public double RepairCosts + { + get => _repairCosts; + set + { + _repairCosts = value; + OnPropertyChanged(); + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs b/src/StatisticsAnalysisTool/StorageHistory/VaultContainerDto.cs similarity index 59% rename from src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs rename to src/StatisticsAnalysisTool/StorageHistory/VaultContainerDto.cs index cb3709b23..e3aeb871b 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs +++ b/src/StatisticsAnalysisTool/StorageHistory/VaultContainerDto.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; -namespace StatisticsAnalysisTool.Models.NetworkModel; +namespace StatisticsAnalysisTool.StorageHistory; -public class VaultContainer +public class VaultContainerDto { public DateTime LastUpdate { get; set; } public Guid Guid { get; set; } public string Name { get; set; } public string Icon { get; set; } - public List Items { get; set; } = new (); + public List Items { get; set; } = new(); } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs b/src/StatisticsAnalysisTool/StorageHistory/VaultController.cs similarity index 51% rename from src/StatisticsAnalysisTool/Network/Manager/VaultController.cs rename to src/StatisticsAnalysisTool/StorageHistory/VaultController.cs index b3ae93099..a248711f8 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs +++ b/src/StatisticsAnalysisTool/StorageHistory/VaultController.cs @@ -1,4 +1,4 @@ -using StatisticsAnalysisTool.Cluster; +using StatisticsAnalysisTool.Cluster; using StatisticsAnalysisTool.Common; using StatisticsAnalysisTool.Localization; using StatisticsAnalysisTool.Models; @@ -15,31 +15,21 @@ using System.Threading.Tasks; using System.Windows; -namespace StatisticsAnalysisTool.Network.Manager; +namespace StatisticsAnalysisTool.StorageHistory; public class VaultController { private readonly MainWindowViewModel _mainWindowViewModel; - private VaultInfo _currentVaultInfo; + private InternalVault _currentInternalVault; private readonly List _discoveredItems = new(); - private readonly List _vaultContainer = new(); - private ObservableCollection _vault = new(); - - private ObservableCollection Vaults - { - get => _vault; - set - { - _vault = value; - OnVaultsChange?.Invoke(); - } - } + private readonly List _internalItemContainers = new(); + private readonly VaultBindings _vaultBindings; public VaultController(MainWindowViewModel mainWindowViewModel) { _mainWindowViewModel = mainWindowViewModel; + _vaultBindings = _mainWindowViewModel.VaultBindings; - OnVaultsChange += UpdateUi; OnVaultsChange += UpdateSearchListUiAsync; OnVaultsRemove += UpdateSearchListUiAsync; } @@ -47,24 +37,24 @@ public VaultController(MainWindowViewModel mainWindowViewModel) public event Action OnVaultsChange; public event Action OnVaultsRemove; - public void SetCurrentVault(VaultInfo vaultInfo) + public void SetCurrentVault(InternalVault internalVault) { - if (vaultInfo == null) + if (internalVault == null) { - _currentVaultInfo = null; + _currentInternalVault = null; return; } - vaultInfo.UniqueClusterName = ClusterController.CurrentCluster.UniqueClusterName; - vaultInfo.MainLocationIndex = ClusterController.CurrentCluster.MainClusterIndex; + internalVault.UniqueClusterName = ClusterController.CurrentCluster.UniqueClusterName; + internalVault.MainLocationIndex = ClusterController.CurrentCluster.MainClusterIndex; - if (string.IsNullOrEmpty(vaultInfo.UniqueClusterName)) + if (string.IsNullOrEmpty(internalVault.UniqueClusterName)) { - _currentVaultInfo = null; + _currentInternalVault = null; return; } - _currentVaultInfo = vaultInfo; + _currentInternalVault = internalVault; } public void AddContainer(ItemContainerObject newContainerObject) @@ -74,18 +64,19 @@ public void AddContainer(ItemContainerObject newContainerObject) return; } - var container = _vaultContainer.FirstOrDefault(x => x.PrivateContainerGuid == newContainerObject.PrivateContainerGuid); + var container = _internalItemContainers.FirstOrDefault(x => x.PrivateContainerGuid == newContainerObject.PrivateContainerGuid); if (container != null) { - _vaultContainer.Remove(container); + _internalItemContainers.Remove(container); } - _vaultContainer.Add(newContainerObject); - ParseVault(); - GetRepairCostsOfContainer(newContainerObject); + SetRepairCostsOfContainer(newContainerObject); + + _internalItemContainers.Add(newContainerObject); + UpdateUi(); } - public void Add(DiscoveredItem item) + public void AddDiscoveredItem(DiscoveredItem item) { if (_discoveredItems.Exists(x => x.ObjectId == item.ObjectId)) { @@ -95,9 +86,9 @@ public void Add(DiscoveredItem item) _discoveredItems.Add(item); } - public void ResetVaultContainer() + public void ResetInternalVaultContainer() { - _vaultContainer.Clear(); + _internalItemContainers.Clear(); } public void ResetDiscoveredItems() @@ -105,9 +96,9 @@ public void ResetDiscoveredItems() _discoveredItems.Clear(); } - public void ResetCurrentVaultInfo() + public void ResetCurrentInternalVault() { - _currentVaultInfo = null; + _currentInternalVault = null; } public void RemoveVault(Vault vault) @@ -117,69 +108,114 @@ public void RemoveVault(Vault vault) return; } - foreach (var removableContainer in vault.VaultContainer.Select(container => _vaultContainer?.FirstOrDefault(x => x?.PrivateContainerGuid == container?.Guid))) + foreach (var removableContainer in vault.VaultContainer.Select(container => _internalItemContainers?.FirstOrDefault(x => x?.PrivateContainerGuid == container?.Guid))) { - _vaultContainer?.Remove(removableContainer); + _internalItemContainers?.Remove(removableContainer); } - _vault.Remove(vault); - OnVaultsRemove?.Invoke(); + Application.Current.Dispatcher.Invoke(() => + { + _vaultBindings.Vaults.Remove(vault); + }); - UpdateUi(); + OnVaultsRemove?.Invoke(); } - private void ParseVault() + #region Ui + + private void UpdateUi() { - if (_currentVaultInfo == null) + if (_currentInternalVault == null) { return; } - var removableVaultInfo = Vaults.FirstOrDefault(x => x.Location == _currentVaultInfo.UniqueClusterName); + var vaultSelected = _vaultBindings.VaultSelected; + var vaultContainerSelectedGuid = _vaultBindings.VaultContainerSelected?.Guid; - if (removableVaultInfo != null) + var currentVault = _vaultBindings.Vaults.FirstOrDefault(x => x.Location == _currentInternalVault.UniqueClusterName); + if (currentVault is not null) { - Vaults.Remove(removableVaultInfo); - } + var vaultContainers = PreparationVaultContainerForUi(_internalItemContainers); - var vault = new Vault() + Application.Current.Dispatcher.Invoke(() => + { + currentVault.VaultContainer.Clear(); + currentVault.VaultContainer.AddRange(vaultContainers); + }); + } + else { - Location = _currentVaultInfo.UniqueClusterName, - MainLocationIndex = _currentVaultInfo.MainLocationIndex, - MapType = _currentVaultInfo.MapType - }; + var vault = new Vault() + { + Location = _currentInternalVault.UniqueClusterName, + MainLocationIndex = _currentInternalVault.MainLocationIndex, + MapType = _currentInternalVault.MapType + }; - try - { - for (var i = 0; i < _currentVaultInfo.ContainerGuidList.Count; i++) + try { - var vaultContainer = new VaultContainer() - { - Guid = _currentVaultInfo.ContainerGuidList[i], - Icon = _currentVaultInfo.ContainerIconTags[i], - Name = (_currentVaultInfo.ContainerNames[i] == "@BUILDINGS_T1_BANK") ? LocalizationController.Translation("BANK") : _currentVaultInfo.ContainerNames[i] - }; + var vaultContainers = PreparationVaultContainerForUi(_internalItemContainers); + vault.VaultContainer.AddRange(vaultContainers); - var itemContainer = _vaultContainer.FirstOrDefault(x => x.PrivateContainerGuid == vaultContainer.Guid); - if (itemContainer != null) + Application.Current.Dispatcher.Invoke(() => { - vaultContainer.LastUpdate = itemContainer.LastUpdate; - SetItemsToVaultContainer(itemContainer, vaultContainer, _discoveredItems); - } + int insertIndex = 0; + for (int i = 0; i < _vaultBindings.Vaults.Count; i++) + { + if (string.Compare(_vaultBindings.Vaults[i].LocationDisplayString, vault.LocationDisplayString, StringComparison.Ordinal) > 0) + { + insertIndex = i; + break; + } + insertIndex = i + 1; + } - vault.VaultContainer.Add(vaultContainer); + _vaultBindings.Vaults.Insert(insertIndex, vault); + }); + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); } - - Vaults.Add(vault); - OnVaultsChange?.Invoke(); } - catch (Exception e) + + _vaultBindings.VaultSelected = _vaultBindings.Vaults.Contains(vaultSelected) ? vaultSelected : default; + _vaultBindings.VaultContainerSelected = _vaultBindings.VaultContainer.FirstOrDefault(x => x?.Guid == vaultContainerSelectedGuid); + + OnVaultsChange?.Invoke(); + } + + private IEnumerable PreparationVaultContainerForUi(IReadOnlyCollection itemContainers) + { + var vaultContainers = new List(); + + for (var i = 0; i < _currentInternalVault.ContainerGuidList.Count; i++) { - ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + var vaultContainer = new VaultContainer() + { + Guid = _currentInternalVault.ContainerGuidList[i], + Icon = _currentInternalVault.ContainerIconTags[i], + Name = _currentInternalVault.ContainerNames[i] == "@BUILDINGS_T1_BANK" + ? LocalizationController.Translation("BANK") + : _currentInternalVault.ContainerNames[i] + }; + + var itemContainer = itemContainers.FirstOrDefault(x => x.PrivateContainerGuid == vaultContainer.Guid); + if (itemContainer != null) + { + vaultContainer.LastUpdate = itemContainer.LastUpdate; + SetItemsToVaultContainerForUi(itemContainer, vaultContainer, _discoveredItems); + vaultContainer.RepairCosts = itemContainer.RepairCosts; + } + + vaultContainers.Add(vaultContainer); } + + return vaultContainers; } - private void SetItemsToVaultContainer(ItemContainerObject containerObject, VaultContainer vaultContainer, List discoveredItems) + private void SetItemsToVaultContainerForUi(ItemContainerObject containerObject, VaultContainer vaultContainer, IReadOnlyCollection discoveredItems) { foreach (var slotItemId in containerObject?.SlotItemIds ?? new List()) { @@ -204,21 +240,11 @@ private void SetItemsToVaultContainer(ItemContainerObject containerObject, Vault } } - #region Ui - - private void UpdateUi() - { - Application.Current.Dispatcher.Invoke(() => - { - _mainWindowViewModel.VaultBindings.Vaults = Vaults.ToList(); - }); - } - private async void UpdateSearchListUiAsync() { var vaultSearchItem = new List(); - await foreach (var vault in Vaults.ToList().ToAsyncEnumerable()) + await foreach (var vault in _vaultBindings.Vaults.ToList().ToAsyncEnumerable()) { var tempItems = new List(); @@ -250,8 +276,8 @@ private async void UpdateSearchListUiAsync() Application.Current.Dispatcher.Invoke(() => { - _mainWindowViewModel.VaultBindings.VaultSearchList.Clear(); - _mainWindowViewModel.VaultBindings.VaultSearchList.AddRange(vaultSearchItem); + _vaultBindings.VaultSearchList.Clear(); + _vaultBindings.VaultSearchList.AddRange(vaultSearchItem); _mainWindowViewModel?.VaultBindings?.VaultSearchCollectionView?.Refresh(); }); } @@ -262,7 +288,7 @@ private async void UpdateSearchListUiAsync() private const double RepairCostModifier = 6.0606d; - private void GetRepairCostsOfContainer(ItemContainerObject newContainerObject) + private void SetRepairCostsOfContainer(ItemContainerObject newContainerObject) { var discoveredItems = new List(); foreach (var slotItemId in newContainerObject.SlotItemIds) @@ -304,18 +330,18 @@ private void GetRepairCostsOfContainer(ItemContainerObject newContainerObject) continue; } - var repairCosts = Math.Round((itemValue / RepairCostModifier * lostDurability), MidpointRounding.ToPositiveInfinity); + var repairCosts = Math.Round(itemValue / RepairCostModifier * lostDurability, MidpointRounding.ToPositiveInfinity); totalCosts += repairCosts * discoveredItem.Quantity; } try { - _mainWindowViewModel.DashboardBindings.RepairCostsChest = Convert.ToInt32(totalCosts); + newContainerObject.RepairCosts = totalCosts; } - catch + catch (Exception e) { - // ignore + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); } } @@ -326,14 +352,21 @@ private void GetRepairCostsOfContainer(ItemContainerObject newContainerObject) public async Task LoadFromFileAsync() { FileController.TransferFileIfExistFromOldPathToUserDataDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.VaultsFileName)); - Vaults = await FileController.LoadAsync>( - Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName, Settings.Default.VaultsFileName)); + + var vaultDtos = await FileController.LoadAsync>(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName, Settings.Default.VaultsFileName)); + _vaultBindings.Vaults = new ObservableCollection(vaultDtos.Select(StorageHistoryMapping.Mapping)); } public async Task SaveInFileAsync() { DirectoryController.CreateDirectoryWhenNotExists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName)); - await FileController.SaveAsync(Vaults, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName, Settings.Default.VaultsFileName)); + + var vaultDtosToSave = _vaultBindings.Vaults + .ToList() + .Select(StorageHistoryMapping.Mapping); + + await FileController.SaveAsync(vaultDtosToSave, + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName, Settings.Default.VaultsFileName)); Debug.Print("Vault saved"); } diff --git a/src/StatisticsAnalysisTool/StorageHistory/VaultDto.cs b/src/StatisticsAnalysisTool/StorageHistory/VaultDto.cs new file mode 100644 index 000000000..a94086d30 --- /dev/null +++ b/src/StatisticsAnalysisTool/StorageHistory/VaultDto.cs @@ -0,0 +1,12 @@ +using StatisticsAnalysisTool.Cluster; +using System.Collections.Generic; + +namespace StatisticsAnalysisTool.StorageHistory; + +public class VaultDto +{ + public string Location { get; set; } + public string MainLocationIndex { get; set; } + public MapType MapType { get; set; } + public List VaultContainer { get; set; } = new(); +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Styles/DashboardStyles.xaml b/src/StatisticsAnalysisTool/Styles/DashboardStyles.xaml index ba46cc3f8..c1b75709a 100644 --- a/src/StatisticsAnalysisTool/Styles/DashboardStyles.xaml +++ b/src/StatisticsAnalysisTool/Styles/DashboardStyles.xaml @@ -469,10 +469,6 @@ Foreground="{StaticResource SolidColorBrush.Accent.Red.3}" VerticalAlignment="Center" Margin="0,0,10,0" /> - - diff --git a/src/StatisticsAnalysisTool/Styles/GuildStyles.xaml b/src/StatisticsAnalysisTool/Styles/GuildStyles.xaml index 16690a99c..31e9e500c 100644 --- a/src/StatisticsAnalysisTool/Styles/GuildStyles.xaml +++ b/src/StatisticsAnalysisTool/Styles/GuildStyles.xaml @@ -2,9 +2,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:networkModel="clr-namespace:StatisticsAnalysisTool.Models.NetworkModel" xmlns:guild="clr-namespace:StatisticsAnalysisTool.Guild" - xmlns:common="clr-namespace:StatisticsAnalysisTool.Common"> + xmlns:common="clr-namespace:StatisticsAnalysisTool.Common" + xmlns:storageHistory="clr-namespace:StatisticsAnalysisTool.StorageHistory"> - + diff --git a/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml b/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml index e96c0e274..44e41c78c 100644 --- a/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml +++ b/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml @@ -1,9 +1,10 @@  + xmlns:networkModel="clr-namespace:StatisticsAnalysisTool.Models.NetworkModel" + xmlns:storageHistory="clr-namespace:StatisticsAnalysisTool.StorageHistory"> - + diff --git a/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml index c54a315ad..0f4eb7742 100644 --- a/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml +++ b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml @@ -21,11 +21,11 @@ - + - +