Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Jul 11, 2023
2 parents b81d633 + dfaf43f commit d1d509a
Show file tree
Hide file tree
Showing 18 changed files with 239 additions and 74 deletions.
67 changes: 59 additions & 8 deletions src/StatisticsAnalysisTool/Common/ItemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ public static bool IsTrash(int index)

public static async Task<bool> GetItemListFromJsonAsync()
{
var currentSettingsItemsJsonSourceUrl = SettingsController.CurrentSettings.ItemListSourceUrl;
var url = GetSourceUrlOrDefault(Settings.Default.DefaultItemListSourceUrl, currentSettingsItemsJsonSourceUrl, ref currentSettingsItemsJsonSourceUrl);
SettingsController.CurrentSettings.ItemListSourceUrl = currentSettingsItemsJsonSourceUrl;
var currentSettingsItemListSourceUrl = SettingsController.CurrentSettings.ItemListSourceUrl;
var url = GetSourceUrlOrDefault(Settings.Default.DefaultItemListSourceUrl, currentSettingsItemListSourceUrl, ref currentSettingsItemListSourceUrl);
SettingsController.CurrentSettings.ItemListSourceUrl = currentSettingsItemListSourceUrl;

var localFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Settings.Default.ItemListFileName}";

Expand Down Expand Up @@ -401,11 +401,38 @@ public static void SaveFavoriteItemsToLocalFile()
}
}

public static bool IsItemsLoaded()
public static bool IsItemListLoaded()
{
return Items?.Count > 0;
}

public static async Task DownloadItemListAsync()
{
var url = GetItemListSourceUrlOrDefault();
var localFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Settings.Default.ItemListFileName}";

if (string.IsNullOrEmpty(url))
{
return;
}

using var client = new HttpClient
{
Timeout = TimeSpan.FromSeconds(1200)
};

await client.DownloadFileAsync(url, localFilePath, LanguageController.Translation("GET_ITEM_LIST_JSON"));
}

private static string GetItemListSourceUrlOrDefault()
{
var currentSettingsItemListSourceUrl = SettingsController.CurrentSettings.ItemListSourceUrl;
var url = GetSourceUrlOrDefault(Settings.Default.DefaultItemListSourceUrl, currentSettingsItemListSourceUrl, ref currentSettingsItemListSourceUrl);
SettingsController.CurrentSettings.ItemListSourceUrl = currentSettingsItemListSourceUrl;

return url;
}

#endregion Item list

#region Item extra information
Expand Down Expand Up @@ -623,10 +650,7 @@ public static ItemType GetItemType(int index)

public static async Task<bool> GetItemsJsonAsync()
{
var currentSettingsItemsJsonSourceUrl = SettingsController.CurrentSettings.ItemsJsonSourceUrl;
var url = GetSourceUrlOrDefault(Settings.Default.DefaultItemsJsonSourceUrl, currentSettingsItemsJsonSourceUrl, ref currentSettingsItemsJsonSourceUrl);
SettingsController.CurrentSettings.ItemsJsonSourceUrl = currentSettingsItemsJsonSourceUrl;

var url = GetItemsJsonSourceUrlOrDefault();
var localFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Settings.Default.ItemsJsonFileName}";

if (string.IsNullOrEmpty(url))
Expand Down Expand Up @@ -746,6 +770,33 @@ public static string GetGeneralJournalName(string uniqueName)
return resultUniqueName;
}

public static async Task DownloadItemsJsonAsync()
{
var url = GetItemsJsonSourceUrlOrDefault();
var localFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Settings.Default.ItemListFileName}";

if (string.IsNullOrEmpty(url))
{
return;
}

using var client = new HttpClient
{
Timeout = TimeSpan.FromSeconds(1200)
};

await client.DownloadFileAsync(url, localFilePath, LanguageController.Translation("GET_ITEM_LIST_JSON"));
}

private static string GetItemsJsonSourceUrlOrDefault()
{
var currentSettingsItemsJsonSourceUrl = SettingsController.CurrentSettings.ItemsJsonSourceUrl;
var url = GetSourceUrlOrDefault(Settings.Default.DefaultItemsJsonSourceUrl, currentSettingsItemsJsonSourceUrl, ref currentSettingsItemsJsonSourceUrl);
SettingsController.CurrentSettings.ItemsJsonSourceUrl = currentSettingsItemsJsonSourceUrl;

return url;
}

#endregion

#region Estimated market value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task SaveInFileAfterExceedingLimit(int limit)
return;
}

if (_mainWindowViewModel?.TradeMonitoringBindings?.Trades == null)
if (_mainWindowViewModel?.GatheringBindings?.GatheredCollection == null)
{
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/StatisticsAnalysisTool/Languages/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,6 @@
<translation name="DELETE_AFTER_30_DAYS">Löschen nach 30 Tagen</translation>
<translation name="DELETE_AFTER_365_DAYS">Löschen nach 365 Tagen</translation>
<translation name="PLAYER_SELECTION_WITH_SAME_NAME_IN_DB">Spieler Auswahl bei gleichen Namen in der DB</translation>
<translation name="UPDATE_NOW">Jetzt aktualisieren</translation>
<translation name="DAMAGE_METER_DESCRIPTION_2">Wenn im Damage Meter nicht die richtigen Waffen angezeigt werden, liegt das meistens an den nicht aktuellen ItemList.json und Items.json Dateien. Lösche Die Dateien manuell aus dem Tool ordner und starte das Tool neu, dann wird die neuste Version der Dateien heruntergeladen und alles sollte wie gewohn funktionieren.</translation>
</translations>
2 changes: 2 additions & 0 deletions src/StatisticsAnalysisTool/Languages/en-US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,6 @@
<translation name="DELETE_AFTER_30_DAYS">Delete after 30 days</translation>
<translation name="DELETE_AFTER_365_DAYS">Delete after 365 days</translation>
<translation name="PLAYER_SELECTION_WITH_SAME_NAME_IN_DB">Player selection with the same name in the DB</translation>
<translation name="UPDATE_NOW">Update now</translation>
<translation name="DAMAGE_METER_DESCRIPTION_2">If the right weapons are not displayed in the Damage Meter, this is usually due to the outdated ItemList.json and Items.json files. Manually delete the files from the tool folder and restart the tool, then the latest version of the files will be downloaded and everything should work as usual.</translation>
</translations>
1 change: 1 addition & 0 deletions src/StatisticsAnalysisTool/Languages/pl-PL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -743,4 +743,5 @@
<translation name="DELETE_AFTER_14_DAYS">Usuń po 14 dniach</translation>
<translation name="DELETE_AFTER_30_DAYS">Usuń po 30 dniach</translation>
<translation name="DELETE_AFTER_365_DAYS">Usuń po 365 dniach</translation>
<translation name="PLAYER_SELECTION_WITH_SAME_NAME_IN_DB">Wybór gracza o takiej samej nazwie w bazie danych</translation>
</translations>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using StatisticsAnalysisTool.Models.NetworkModel;
using StatisticsAnalysisTool.Models.TranslationModel;
using StatisticsAnalysisTool.Properties;
using StatisticsAnalysisTool.Trade;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
Expand Down Expand Up @@ -38,7 +39,9 @@ public DungeonBindings()
if (DungeonsCollectionView != null)
{
DungeonsCollectionView.IsLiveSorting = true;
DungeonsCollectionView.IsLiveFiltering = true;
DungeonsCollectionView.CustomSort = new DungeonTrackingNumberComparer();
DungeonsCollectionView.Refresh();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PlayerGameObject : GameObject

public PlayerGameObject(long? objectId)
{
ObjectId = objectId;
ObjectId ??= objectId;
LastUpdate = DateTime.UtcNow.Ticks;
}

Expand All @@ -40,6 +40,7 @@ public Guid? InteractGuid
public string Name { get; set; } = "Unknown";
public string Guild { get; set; }
public string Alliance { get; set; }
public bool IsInParty { get; set; }
public CharacterEquipment CharacterEquipment
{
get => _characterEquipment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class MainWindowTranslation
public static string Total => LanguageController.Translation("TOTAL");
public static string DamageMeter => LanguageController.Translation("DAMAGE_METER");
public static string DamageMeterDescription1 => LanguageController.Translation("DAMAGE_METER_DESCRIPTION_1");
public static string DamageMeterDescription2 => LanguageController.Translation("DAMAGE_METER_DESCRIPTION_2");
public static string ResetDamageMeter => LanguageController.Translation("RESET_DAMAGE_METER");
public static string Settings => LanguageController.Translation("SETTINGS");
public static string Favorite => LanguageController.Translation("FAVORITE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ public class SettingsWindowTranslation
public static string PacketFilter => LanguageController.Translation("PACKET_FILTER");
public static string Reset => LanguageController.Translation("RESET");
public static string PlayerSelectionWithSameNameInDb => LanguageController.Translation("PLAYER_SELECTION_WITH_SAME_NAME_IN_DB");
public static string UpdateNow => LanguageController.Translation("UPDATE_NOW");
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using StatisticsAnalysisTool.Enumerations;
using StatisticsAnalysisTool.Network.Events;
using StatisticsAnalysisTool.Network.Manager;
using System;
using System.Threading.Tasks;

namespace StatisticsAnalysisTool.Network.Handler;
Expand All @@ -17,10 +16,7 @@ public PartyPlayerJoinedEventHandler(TrackingController trackingController) : ba

protected override async Task OnActionAsync(PartyPlayerJoinedEvent value)
{
if (value.UserGuid != Guid.Empty)
{
_trackingController.EntityController.AddEntity(null, value.UserGuid, null, value.Username, null, null, null, GameObjectType.Player, GameObjectSubType.Player);
await _trackingController.EntityController.AddToPartyAsync(value.UserGuid);
}
_trackingController?.EntityController?.AddEntity(null, value.UserGuid, null, value.Username, null, null, null, GameObjectType.Player, GameObjectSubType.Mob);
await _trackingController?.EntityController?.AddToPartyAsync(value.UserGuid)!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public Task AddDamage(long objectId, long causerId, double healthChange, double
var gameObject = _trackingController?.EntityController?.GetEntity(causerId);
var gameObjectValue = gameObject?.Value;

if (gameObject?.Value == null
|| gameObject.Value.Value?.ObjectType != GameObjectType.Player
|| !_trackingController.EntityController.IsEntityInParty(gameObject.Value.Key)
)
if (gameObject?.Value is not { ObjectType: GameObjectType.Player } || !_trackingController.EntityController.IsEntityInParty(gameObject.Value.Key))
{
return Task.CompletedTask;
}
Expand Down
Loading

0 comments on commit d1d509a

Please sign in to comment.