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 Mar 30, 2023
2 parents 73fdda8 + 4cbf723 commit d264aa2
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/StatisticsAnalysisTool/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DispatcherUnhandledException="Application_DispatcherUnhandledException"
ShutdownMode="OnMainWindowClose">
ShutdownMode="OnMainWindowClose"
SessionEnding="Application_SessionEnding"
Exit="Application_Exit">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
32 changes: 28 additions & 4 deletions src/StatisticsAnalysisTool/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media.Media3D;
using System.Windows.Threading;

namespace StatisticsAnalysisTool;

public partial class App
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType);
private MainWindowViewModel _mainWindowViewModel;

protected override void OnStartup(StartupEventArgs e)
{
Expand All @@ -28,12 +30,12 @@ protected override void OnStartup(StartupEventArgs e)
AutoUpdateController.RemoveUpdateFiles();
AutoUpdateController.AutoUpdate();

var mainWindowViewModel = new MainWindowViewModel();
ServiceLocator.Register<MainWindowViewModel>(mainWindowViewModel);
_mainWindowViewModel = new MainWindowViewModel();
ServiceLocator.Register<MainWindowViewModel>(_mainWindowViewModel);

var mainWindow = new MainWindow(mainWindowViewModel);
var mainWindow = new MainWindow(_mainWindowViewModel);
mainWindow.Show();
mainWindowViewModel.InitMainWindowData();
_mainWindowViewModel.InitMainWindowData();
}

private static void InitializeLanguage()
Expand Down Expand Up @@ -76,4 +78,26 @@ private void Application_DispatcherUnhandledException(object sender, DispatcherU
e.Handled = true;
}
}

private void Application_SessionEnding(object sender, SessionEndingCancelEventArgs e)
{
_mainWindowViewModel.SaveLootLogger();
SettingsController.SaveSettings();

if (_mainWindowViewModel.IsTrackingActive)
{
_ = _mainWindowViewModel.StopTrackingAsync();
}
}

private void Application_Exit(object sender, ExitEventArgs e)
{
_mainWindowViewModel.SaveLootLogger();
SettingsController.SaveSettings();

if (_mainWindowViewModel.IsTrackingActive)
{
_ = _mainWindowViewModel.StopTrackingAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class SettingsController
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType);
private static bool _haveSettingsAlreadyBeenLoaded;

public static void SaveSettings(WindowState windowState, double height, double width)
public static void SetWindowSettings(WindowState windowState, double height, double width)
{
if (windowState != WindowState.Maximized)
{
Expand All @@ -25,9 +25,11 @@ public static void SaveSettings(WindowState windowState, double height, double w
}

CurrentSettings.MainWindowMaximized = windowState == WindowState.Maximized;
}

public static void SaveSettings()
{
SaveToLocalFile();

ItemController.SaveFavoriteItemsToLocalFile();
}

Expand Down
6 changes: 3 additions & 3 deletions src/StatisticsAnalysisTool/DownloadItemJsonFilesManually.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
powershell -Command "if(!(Test-Path -Path 'Temp')) { New-Item -ItemType Directory -Path 'Temp' } ; Invoke-WebRequest https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/formatted/items.json -OutFile ItemList.json"
powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/items.json -OutFile Items.json"
powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/mobs.json -OutFile Temp\mobs.json"
powershell -Command "if(!(Test-Path -Path 'Temp')) { New-Item -ItemType Directory -Path 'Temp' } ; Invoke-WebRequest https://raw.githubusercontent.com/Triky313/ao-bin-dumps/main/formatted/items.json -OutFile ItemList.json"
powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/Triky313/ao-bin-dumps/main/items.json -OutFile Items.json"
powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/Triky313/ao-bin-dumps/main/mobs.json -OutFile Temp\mobs.json"
2 changes: 1 addition & 1 deletion src/StatisticsAnalysisTool/Enumerations/EventCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public enum EventCodes
ChangeMountSkin,
GameEvent,
KilledPlayer,
Died = 155,
Died = 156,
KnockedDown,
MatchPlayerJoinedEvent,
MatchPlayerStatsEvent,
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 @@ -706,4 +706,6 @@
<translation name="EAST_SERVER">Ost Server</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_WEST">Albion data project base url WEST</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_EAST">Albion data project base url OST</translation>
<translation name="DELETE_ALL_SNAPSHOTS">Alle Snapshots löschen</translation>
<translation name="SURE_YOU_WANT_TO_DELETE_ALL_SNAPSHOTS">Wirklich alle Snapshots löschen?</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 @@ -706,4 +706,6 @@
<translation name="EAST_SERVER">East Server</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_WEST">Albion data project base url WEST</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_EAST">Albion data project base url EAST</translation>
<translation name="DELETE_ALL_SNAPSHOTS">Delete all snapshots</translation>
<translation name="SURE_YOU_WANT_TO_DELETE_ALL_SNAPSHOTS">Are you sure you want to delete all snapshots?</translation>
</translations>
9 changes: 9 additions & 0 deletions src/StatisticsAnalysisTool/Languages/es-ES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,13 @@
<translation name="AMOUNT_OF_MINING_PROCESSES">Cantidad de picadas</translation>
<translation name="SURE_YOU_WANT_TO_DELETE_SELECTED_RESOURCES">¿Estás seguro de que quieres eliminar los recursos seleccionados?</translation>
<translation name="DELETE_SELECTED_RESOURCES">Eliminar los recursos seleccionados</translation>
<translation name="RESOURCE_VALUE">Valor del recurso</translation>
<translation name="TOTAL_MARKET_VALUE">Valor total de mercado</translation>
<translation name="NAVIGATION_TAB_VISIBILITY">Visibilidad de las pestaña de navegación</translation>
<translation name="SERVER">Servidor</translation>
<translation name="UNKNOWN_SERVER">Servidor desonocido</translation>
<translation name="WEST_SERVER">Servidor Oeste</translation>
<translation name="EAST_SERVER">Servidor Este</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_WEST">URL base de Albion Data Project OESTE</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_EAST">URL base de Albion Data Project ESTE</translation>
</translations>
6 changes: 6 additions & 0 deletions src/StatisticsAnalysisTool/Languages/zh-CN.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,10 @@
<translation name="RESOURCE_VALUE">资源价值</translation>
<translation name="TOTAL_MARKET_VALUE">市场价值总计</translation>
<translation name="NAVIGATION_TAB_VISIBILITY">设置显示的统计标签</translation>
<translation name="SERVER">服务器</translation>
<translation name="UNKNOWN_SERVER">未知服务器</translation>
<translation name="WEST_SERVER">西方服务器</translation>
<translation name="EAST_SERVER">东方服务器</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_WEST">Albion Data Project 源地址 (西方)</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_EAST">Albion Data Project 源地址 (东方)</translation>
</translations>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using FontAwesome5;
using StatisticsAnalysisTool.Common;
using StatisticsAnalysisTool.Common.UserSettings;
using StatisticsAnalysisTool.Enumerations;
using StatisticsAnalysisTool.Network.Notification;
using StatisticsAnalysisTool.Properties;
using StatisticsAnalysisTool.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -13,7 +15,6 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using StatisticsAnalysisTool.Common.UserSettings;

namespace StatisticsAnalysisTool.Models.BindingModel;

Expand Down Expand Up @@ -123,7 +124,7 @@ public EFontAwesomeIcon DamageMeterActivationToggleIcon

public Brush DamageMeterActivationToggleColor
{
get => _damageMeterActivationToggleColor ?? new SolidColorBrush((Color)Application.Current.Resources["Color.Text.1"]);
get => _damageMeterActivationToggleColor ?? new SolidColorBrush((Color) Application.Current.Resources["Color.Text.1"]);
set
{
_damageMeterActivationToggleColor = value;
Expand Down Expand Up @@ -296,7 +297,7 @@ public bool IsSnapshotAfterMapChangeActive
}
}

public void DeleteSnapshot()
public void DeleteSelectedSnapshot()
{
var damageMeterSnapshotSelection = DamageMeterSnapshotSelection;
if (damageMeterSnapshotSelection != null)
Expand All @@ -307,6 +308,22 @@ public void DeleteSnapshot()
DamageMeterSnapshots = DamageMeterSnapshots?.ToList();
}

public void DeleteAllSnapshots()
{
if (DamageMeterSnapshots?.Count <= 0)
{
return;
}

var dialog = new DialogWindow(LanguageController.Translation("DELETE_ALL_SNAPSHOTS"), LanguageController.Translation("SURE_YOU_WANT_TO_DELETE_ALL_SNAPSHOTS"));
var dialogResult = dialog.ShowDialog();

if (dialogResult is true)
{
DamageMeterSnapshots = new List<DamageMeterSnapshot>();
}
}

public void SetDamageMeterSnapshotSort()
{
switch (DamageMeterSnapshotSortSelection.DamageMeterSortType)
Expand Down Expand Up @@ -368,6 +385,7 @@ private static void SetIsDamageMeterSnapshotShowing(IEnumerable<DamageMeterSnaps
public static string TranslationSortByHps => LanguageController.Translation("SORT_BY_HPS");
public static string TranslationSnapshots => LanguageController.Translation("SNAPSHOTS");
public static string TranslationDeleteSelectedSnapshot => LanguageController.Translation("DELETE_SELECTED_SNAPSHOT");
public static string TranslationDeleteAllSnapshots => LanguageController.Translation("DELETE_ALL_SNAPSHOTS");
public static string TranslationTakeASnapshotOfDamageMeterDescription => LanguageController.Translation("TAKE_A_SNAPSHOT_OF_DAMAGE_METER_DESCRIPTION");

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using StatisticsAnalysisTool.Models.NetworkModel;
using StatisticsAnalysisTool.Network.Events;
using StatisticsAnalysisTool.Network.Manager;
using StatisticsAnalysisTool.Network.Notification;
using System;
using System.Threading.Tasks;

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(0, 0);
RunDamageMeterDebugAsync(10, 10);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@
<ComboBox Width="200" Height="26" ItemsSource="{Binding DamageMeterBindings.DamageMeterSnapshotSort}"
SelectedItem="{Binding DamageMeterBindings.DamageMeterSnapshotSortSelection}"
IsSynchronizedWithCurrentItem="True" DisplayMemberPath="Name" SelectedValuePath="DamageMeterSortType" />
<Button Content="{Binding DamageMeterBindings.TranslationDeleteSelectedSnapshot, FallbackValue=DELETE__SELECTED__SNAPSHOT}" Height="26" MaxWidth="500" MinWidth="200"
Margin="5,0,5,0" Click="BtnDeleteSelectedSnapshot_Click" />
<Button Content="{Binding DamageMeterBindings.TranslationDeleteSelectedSnapshot, FallbackValue=DELETE__SELECTED__SNAPSHOT}" Height="26"
MaxWidth="500" MinWidth="200" Margin="5,0,5,0" Click="BtnDeleteSelectedSnapshot_Click" />
<Grid Height="20" Width="20" Margin="5,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center"
ToolTip="{Binding DamageMeterBindings.TranslationDeleteAllSnapshots, FallbackValue=DELETE__ALL__SNAPSHOTS}" MouseUp="DeleteAllDamageMeterSnapshots_MouseUp">
<fa5:ImageAwesome Icon="Regular_TrashAlt" Foreground="{StaticResource SolidColorBrush.Accent.Red.5}" />
</Grid>
<Grid Height="20" Width="20" Margin="5,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center"
ToolTip="{Binding Translation.CopyToClipboard, FallbackValue=COPY__TO__CLIPBOARD}" MouseUp="CopyDamageMeterSnapshotToClipboard_MouseUp">
<fa5:ImageAwesome Icon="Regular_Copy" Foreground="{StaticResource SolidColorBrush.Text.1}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ private void CopyDamageMeterSnapshotToClipboard_MouseUp(object sender, MouseButt
CopyDamageMeterToClipboard(true);
}

private void DeleteAllDamageMeterSnapshots_MouseUp(object sender, MouseButtonEventArgs e)
{
var vm = (MainWindowViewModel) DataContext;
vm?.DamageMeterBindings?.DeleteAllSnapshots();
}

private void TakeASnapShot_MouseUp(object sender, MouseButtonEventArgs e)
{
var vm = (MainWindowViewModel)DataContext;
Expand All @@ -185,7 +191,7 @@ private void TakeASnapShot_MouseUp(object sender, MouseButtonEventArgs e)
private void BtnDeleteSelectedSnapshot_Click(object sender, RoutedEventArgs e)
{
var vm = (MainWindowViewModel)DataContext;
vm?.DamageMeterBindings?.DeleteSnapshot();
vm?.DamageMeterBindings?.DeleteSelectedSnapshot();
}

#endregion
Expand Down
8 changes: 1 addition & 7 deletions src/StatisticsAnalysisTool/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ private void CopyPartyToClipboard_PreviewMouseDown(object sender, MouseButtonEve

private void MainWindow_OnClosed(object sender, EventArgs eventArgs)
{
_mainWindowViewModel.SaveLootLogger();
SettingsController.SaveSettings(WindowState, Height, Width);

if (_mainWindowViewModel.IsTrackingActive)
{
_ = _mainWindowViewModel.StopTrackingAsync();
}
SettingsController.SetWindowSettings(WindowState, Height, Width);
}

private void Grid_MouseMove(object sender, MouseEventArgs e)
Expand Down

0 comments on commit d264aa2

Please sign in to comment.