Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Aug 22, 2024
2 parents 01f903f + 46a4045 commit 6f1ecb8
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 58 deletions.
9 changes: 8 additions & 1 deletion src/StatisticsAnalysisTool/Models/Spell.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using StatisticsAnalysisTool.GameFileData;
using StatisticsAnalysisTool.Common;
using StatisticsAnalysisTool.GameFileData;
using System.Windows;
using System.Windows.Media.Imaging;

namespace StatisticsAnalysisTool.Models;

public class Spell
{
private BitmapImage _icon;

public Spell(int index)
{
Index = index;
Expand All @@ -19,4 +24,6 @@ public Spell(int index)
public string UniqueName { get; init; }
public string Target { get; init; }
public string Category { get; init; }
public BitmapImage Icon => Application.Current.Dispatcher.Invoke(() => _icon ??= ImageController.GetSpellImage(UniqueName));
public string LocalizationName => SpellData.GetLocalizationName(UniqueName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ private void ProcessEquipment(IReadOnlyDictionary<byte, object> parameters)

private void ProcessSpells(IReadOnlyDictionary<byte, object> parameters)
{
if (parameters.TryGetValue(6, out object spellsObject))
if (parameters.TryGetValue(7, out object spellsObject))
{
var valueType = spellsObject.GetType();
if (valueType.IsArray && typeof(short[]).Name == valueType.Name)
{
var spell = ((short[]) parameters[6]).ToDictionary();
var spell = ((short[]) parameters[7]).ToDictionary();

AddSpell(SlotType.MainHand, spell[0]);
AddSpell(SlotType.MainHand, spell[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CombatController(TrackingController trackingController, MainWindowViewMod
OnDamageUpdate += UpdateDamageMeterUiAsync;

#if DEBUG
RunDamageMeterDebugAsync(10, 10);
RunDamageMeterDebugAsync(0, 0);
#endif
}

Expand Down
44 changes: 25 additions & 19 deletions src/StatisticsAnalysisTool/Network/Manager/StatisticController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;

using Serilog;
using SkiaSharp;
using StatisticsAnalysisTool.Common;
using StatisticsAnalysisTool.Models;
Expand All @@ -11,14 +11,12 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Serilog;
using ValueType = StatisticsAnalysisTool.Enumerations.ValueType;

namespace StatisticsAnalysisTool.Network.Manager;
Expand Down Expand Up @@ -242,22 +240,30 @@ public void UpdateRepairCostsUi()
{
var currentDate = DateTime.Now;

_mainWindowViewModel.DashboardBindings.RepairCostsToday = _dashboardStatistics?.DailyValues
?.Where(x => x.ValueType == ValueType.RepairCosts
&& x.Date.Year == currentDate.Year
&& x.Date.Month == currentDate.Month
&& x.Date.Day == currentDate.Day)
.Sum(x => FixPoint.FromFloatingPointValue(x.Value).IntegerValue) ?? 0;

_mainWindowViewModel.DashboardBindings.RepairCostsLast7Days = _dashboardStatistics?.DailyValues
?.Where(x => x.ValueType == ValueType.RepairCosts
&& x.Date.Ticks > currentDate.AddDays(-7).Ticks)
.Sum(x => FixPoint.FromFloatingPointValue(x.Value).IntegerValue) ?? 0;

_mainWindowViewModel.DashboardBindings.RepairCostsLast30Days = _dashboardStatistics?.DailyValues
?.Where(x => x.ValueType == ValueType.RepairCosts
&& x.Date.Ticks > currentDate.AddDays(-30).Ticks)
.Sum(x => FixPoint.FromFloatingPointValue(x.Value).IntegerValue) ?? 0;
if (_dashboardStatistics?.DailyValues == null)
{
_mainWindowViewModel.DashboardBindings.RepairCostsToday = 0;
_mainWindowViewModel.DashboardBindings.RepairCostsLast7Days = 0;
_mainWindowViewModel.DashboardBindings.RepairCostsLast30Days = 0;
return;
}

_mainWindowViewModel.DashboardBindings.RepairCostsToday = _dashboardStatistics.DailyValues
.Where(x => x is { ValueType: ValueType.RepairCosts }
&& x.Date.Year == currentDate.Year
&& x.Date.Month == currentDate.Month
&& x.Date.Day == currentDate.Day)
.Sum(x => FixPoint.FromFloatingPointValue(x.Value).IntegerValue);

_mainWindowViewModel.DashboardBindings.RepairCostsLast7Days = _dashboardStatistics.DailyValues
.Where(x => x is { ValueType: ValueType.RepairCosts }
&& x.Date.Ticks > currentDate.AddDays(-7).Ticks)
.Sum(x => FixPoint.FromFloatingPointValue(x.Value).IntegerValue);

_mainWindowViewModel.DashboardBindings.RepairCostsLast30Days = _dashboardStatistics.DailyValues
.Where(x => x is { ValueType: ValueType.RepairCosts }
&& x.Date.Ticks > currentDate.AddDays(-30).Ticks)
.Sum(x => FixPoint.FromFloatingPointValue(x.Value).IntegerValue);
}

#endregion
Expand Down
45 changes: 35 additions & 10 deletions src/StatisticsAnalysisTool/Party/PartyPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using StatisticsAnalysisTool.ViewModels;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;

namespace StatisticsAnalysisTool.Party;

Expand Down Expand Up @@ -36,6 +38,7 @@ public class PartyPlayer : BaseViewModel
private bool _isPlayerInspected;
private DateTime _lastUpdate;
private bool _isDeathAlertActive;
private Visibility _spellsContainerVisibility = Visibility.Collapsed;
public Guid Guid { get; init; }

public string Username
Expand Down Expand Up @@ -225,6 +228,28 @@ public Item BuffFood
}
}

public DateTime LastUpdate
{
get => _lastUpdate;
set
{
_lastUpdate = value;
OnPropertyChanged();
}
}

public bool IsDeathAlertActive
{
get => _isDeathAlertActive;
set
{
_isDeathAlertActive = value;
OnPropertyChanged();
}
}

#region Spells

public IEnumerable<Spell> MainHandSpells
{
get => _mainHandSpells;
Expand Down Expand Up @@ -305,26 +330,26 @@ public IEnumerable<Spell> FoodSpells
}
}

public DateTime LastUpdate
public Visibility SpellsContainerVisibility
{
get => _lastUpdate;
get => _spellsContainerVisibility;
set
{
_lastUpdate = value;
_spellsContainerVisibility = value;
OnPropertyChanged();
}
}

public bool IsDeathAlertActive
#endregion

private void PerformShowSpells(object value)
{
get => _isDeathAlertActive;
set
{
_isDeathAlertActive = value;
OnPropertyChanged();
}
SpellsContainerVisibility = SpellsContainerVisibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
}

private ICommand _showSpells;
public ICommand ShowSpells => _showSpells ??= new CommandHandler(PerformShowSpells, true);

public static string TranslationItemPower => LocalizationController.Translation("ITEM_POWER");
public static string TranslationLastUpdate => LocalizationController.Translation("LAST_UPDATE");
public static string TranslationSelectForDeathAlert => LocalizationController.Translation("SELECT_FOR_DEATH_ALERT");
Expand Down
4 changes: 2 additions & 2 deletions src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.*")]
[assembly: AssemblyFileVersion("7.7.2.0")]
[assembly: AssemblyVersion("7.7.3.*")]
[assembly: AssemblyFileVersion("7.7.3.0")]
4 changes: 2 additions & 2 deletions src/StatisticsAnalysisTool/StorageHistory/VaultController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ public async Task SaveInFileAsync()
DirectoryController.CreateDirectoryWhenNotExists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName));

var vaultDtosToSave = _vaultBindings.Vaults
.ToList()
.Select(StorageHistoryMapping.Mapping);
?.ToList()
.Select(StorageHistoryMapping.Mapping) ?? Enumerable.Empty<VaultDto>(); ;

await FileController.SaveAsync(vaultDtosToSave,
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName, Settings.Default.VaultsFileName));
Expand Down
27 changes: 15 additions & 12 deletions src/StatisticsAnalysisTool/Styles/PartyStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@
<DataTemplate x:Key="PartyBuilderPlayerTemplate" DataType="{x:Type party:PartyPlayer}">
<Grid>
<StackPanel Orientation="Vertical" Margin="0,0,0,5">
<StackPanel Orientation="Vertical" Background="{StaticResource SolidColorBrush.Accent.Blue.5}">
<Grid Background="{StaticResource SolidColorBrush.Accent.Blue.5}">
<Grid.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding ShowSpells}" />
</Grid.InputBindings>
<StackPanel Orientation="Horizontal">
<Grid Style="{StaticResource PartyBuilder.PlayerInspection.Grid}">
<fa5:ImageAwesome Margin="0" Icon="Solid_Eye" Foreground="{StaticResource SolidColorBrush.Accent.Yellow.1}" Style="{StaticResource PartyBuilder.Attention.Icon}" />
Expand All @@ -127,7 +130,7 @@
<Label Content="{Binding AverageBasicItemPower.ItemPower, IsAsync=True, Mode=OneWay, Converter={StaticResource RoundingConverter}, ConverterParameter=0}" Padding="5,5,10,0" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
<StackPanel Orientation="Horizontal" Background="{StaticResource SolidColorBrush.Accent.Blue.Transparent.4}">
<Image Source="{Binding MainHand.Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding OffHand.Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
Expand All @@ -139,12 +142,12 @@
<Image Source="{Binding BuffFood.Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Potion.Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
</StackPanel>
<!--<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Visibility="{Binding SpellsContainerVisibility}" Background="{StaticResource SolidColorBrush.Accent.Blue.Transparent.5}">
<ItemsControl ItemsSource="{Binding MainHandSpells}" Width="50">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -153,7 +156,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -162,7 +165,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -171,7 +174,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -180,7 +183,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -189,7 +192,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -198,7 +201,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand All @@ -207,12 +210,12 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" />
<Image Source="{Binding Icon, IsAsync=True, Mode=OneWay}" Style="{StaticResource PartyBuilder.Equipment.Icon}" ToolTip="{Binding LocalizationName}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>-->
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical">
<Label Content="{Binding LastUpdate}" ToolTip="{Binding TranslationLastUpdate}" HorizontalAlignment="Right" />
Expand Down
Loading

0 comments on commit 6f1ecb8

Please sign in to comment.