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 Aug 4, 2023
2 parents 962cfb2 + 67c37d5 commit b14b468
Show file tree
Hide file tree
Showing 23 changed files with 741 additions and 89 deletions.
3 changes: 2 additions & 1 deletion src/StatisticsAnalysisTool/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using StatisticsAnalysisTool.ViewModels;
using StatisticsAnalysisTool.Views;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
Expand Down Expand Up @@ -44,6 +43,8 @@ protected override async void OnStartup(StartupEventArgs e)
var mainWindow = new MainWindow(_mainWindowViewModel);
mainWindow.Show();
_mainWindowViewModel.InitMainWindowData();

Utilities.AnotherAppToStart(SettingsController.CurrentSettings.AnotherAppToStartPath);
}

private void RegisterServices()
Expand Down
2 changes: 1 addition & 1 deletion src/StatisticsAnalysisTool/Common/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public static class CategoryController
#region Tool

{ShopSubCategory.DemolitionHammer, LanguageController.Translation("DEMOLITION_HAMMER")},
{ShopSubCategory.Fishing, LanguageController.Translation("FISHING")},
{ShopSubCategory.Fishing, LanguageController.Translation("FISHING_ROD")},
{ShopSubCategory.Pickaxe, LanguageController.Translation("PICKAXE")},
{ShopSubCategory.Sickle, LanguageController.Translation("SICKLE")},
{ShopSubCategory.SkinningKnife, LanguageController.Translation("SKINNING_KNIFE")},
Expand Down
27 changes: 27 additions & 0 deletions src/StatisticsAnalysisTool/Common/LanguageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,33 @@ public static bool InitializeLanguage()
}
}

public static string Translation(string key, List<string> placeholders, List<string> replacements)
{
try
{
if (Translations.TryGetValue(key, out var value))
{
if (string.IsNullOrEmpty(value) || placeholders.Count != replacements.Count)
{
return key;
}

for (int i = 0; i < placeholders.Count; i++)
{
value = value.Replace("{" + placeholders[i] + "}", replacements[i]);
}

return value;
}
}
catch (ArgumentNullException)
{
return "TRANSLATION-ERROR";
}

return key;
}

public static string Translation(string key)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ public class SettingsObject
public double PartyBuilderMaximumItemPower { get; set; } = 900;
public double PartyBuilderMinimalBasicItemPower { get; set; } = 600;
public double PartyBuilderMaximumBasicItemPower { get; set; } = 900;
public string AnotherAppToStartPath { get; set; }
}
45 changes: 43 additions & 2 deletions src/StatisticsAnalysisTool/Common/Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using System;
using log4net;
using StatisticsAnalysisTool.Notification;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
Expand All @@ -9,6 +15,8 @@ namespace StatisticsAnalysisTool.Common;

public static class Utilities
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType);

public static long GetHighestLength(params Array[] arrays)
{
long highestLength = 0;
Expand All @@ -33,7 +41,7 @@ public static void CenterWindowOnScreen(Window window)
window.Left = (screenWidth / 2) - (windowWidth / 2);
window.Top = (screenHeight / 2) - (windowHeight / 2);
}

public static bool IsWindowOpen<T>(string name = "") where T : Window
{
return string.IsNullOrEmpty(name)
Expand Down Expand Up @@ -83,6 +91,39 @@ public static bool IsBlockingTimeExpired(DateTime dateTime, int waitingSeconds)
return difference.Seconds >= waitingSeconds;
}

public static void AnotherAppToStart(string path)
{
var notifyManager = ServiceLocator.Resolve<SatNotificationManager>();

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

try
{
if (!File.Exists(path))
{
notifyManager?.ShowErrorAsync(LanguageController.Translation("CANNOT_START_OTHER_APP"),
LanguageController.Translation("CAN_NOT_START_APP_WITH_PATH",
new List<string> { "path" },
new List<string> { path }));
return;
}

Process.Start(path);
}
catch (Exception e)
{
ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e);
Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e);
notifyManager?.ShowErrorAsync(LanguageController.Translation("CANNOT_START_OTHER_APP"),
LanguageController.Translation("CAN_NOT_START_APP_WITH_PATH",
new List<string> { "path" },
new List<string> { path }));
}
}

#region Window Flash

private const uint FlashwStop = 0; //Stop flashing. The system restores the window to its original state.
Expand Down
8 changes: 5 additions & 3 deletions src/StatisticsAnalysisTool/Languages/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
<translation name="ROYAL_SIGILS">Königliches Siegel</translation>

<translation name="DEMOLITION_HAMMER">Abbruchhammer</translation>
<translation name="FISHING">Angel</translation>
<translation name="FISHING">Angeln</translation>
<translation name="PICKAXE">Spitzhacke</translation>
<translation name="SICKLE">Sichel</translation>
<translation name="SKINNING_KNIFE">Abhäutemesser</translation>
Expand Down Expand Up @@ -775,8 +775,10 @@
<translation name="MAXIMUM_NUMBER_OF_BACKUPS">Anzahl maximaler Backups</translation>
<translation name="BACKUP">Backup</translation>
<translation name="ITEM_WINDOW">Item Fenster</translation>
<translation name="ITEM_SEARCH">Item Suche</translation>
<translation name="LOOT_LOGGER">Loot Protokollierung</translation>
<translation name="TOOLS">Werkzeuge</translation>
<translation name="FISHING">Angeln</translation>
<translation name="CAN_NOT_START_APP_WITH_PATH">Die App mit dem Pfad {path} kann nicht gestartet werden.</translation>
<translation name="ANOTHER_APP_TO_START_PATH">Eine weitere App zum Starten Pfad</translation>
<translation name="CANNOT_START_OTHER_APP">Kann andere App nicht starten</translation>
<translation name="FISHING_ROD">Angel</translation>
</translations>
6 changes: 4 additions & 2 deletions src/StatisticsAnalysisTool/Languages/en-US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,10 @@
<translation name="MAXIMUM_NUMBER_OF_BACKUPS">Maximum number of backups</translation>
<translation name="BACKUP">Backup</translation>
<translation name="ITEM_WINDOW">Item window</translation>
<translation name="ITEM_SEARCH">Item search</translation>
<translation name="LOOT_LOGGER">Loot logger</translation>
<translation name="TOOLS">Tools</translation>
<translation name="FISHING">Fishing</translation>
<translation name="CAN_NOT_START_APP_WITH_PATH">Can not start App with path: {path}</translation>
<translation name="ANOTHER_APP_TO_START_PATH">Another app to start path</translation>
<translation name="CANNOT_START_OTHER_APP">Cannot start other app</translation>
<translation name="FISHING_ROD">Fishing rod</translation>
</translations>
44 changes: 43 additions & 1 deletion src/StatisticsAnalysisTool/Languages/es-ES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
<translation name="ROYAL_SIGILS">Sellos reales</translation>

<translation name="DEMOLITION_HAMMER">Martillo de demolición</translation>
<translation name="FISHING">Caña de pescar</translation>
<translation name="FISHING">Pesca</translation>
<translation name="PICKAXE">Pico</translation>
<translation name="SICKLE">Hoz</translation>
<translation name="SKINNING_KNIFE">Cuchillo de despellejar</translation>
Expand Down Expand Up @@ -739,4 +739,46 @@
<translation name="DESCRIPTION">Descripción</translation>
<translation name="VALUE">Valor</translation>
<translation name="ADD_TRADE">Añadir intercambio</translation>
<translation name="MANUAL_SELL">Venta manual</translation>
<translation name="MANUAL_BUY">Compra manual</translation>
<translation name="NEVER_DELETE">Nunca eliminar</translation>
<translation name="DELETE_AFTER_7_DAYS">Eliminar después de 7 días</translation>
<translation name="DELETE_AFTER_14_DAYS">Eliminar después de 14 días</translation>
<translation name="DELETE_AFTER_30_DAYS">Eliminar después de 30 días</translation>
<translation name="DELETE_AFTER_365_DAYS">Eliminar después de 365 días</translation>
<translation name="PLAYER_SELECTION_WITH_SAME_NAME_IN_DB">Seleccionar jugador con mismo nombre en la base de datos</translation>
<translation name="UPDATE_NOW">Actualizar ahora</translation>
<translation name="DAMAGE_METER_DESCRIPTION_2">Si no se muestran las armas correctas en el Medidor de Daño, suele deberse a que los archivos ItemList.json e Items.json no están actualizados. Borra manualmente los archivos de la carpeta de la herramienta y reiníciala, entonces se descargará la última versión de los archivos y todo debería funcionar como de costumbre.</translation>
<translation name="PARTY_BUILDER">Organizador de Grupo</translation>
<translation name="GET_SPELLS_JSON">Obtener spells.json</translation>
<translation name="SPELLS_JSON_CAN_NOT_BE_LOADED">spells.json no ha podido ser cargado.</translation>
<translation name="GET_WORLD_JSON">Obtener world.json</translation>
<translation name="WORLD_JSON_CAN_NOT_BE_LOADED">world.json no ha podido ser cargado.</translation>
<translation name="UPDATE_WORLD_JSON_BY_DAYS">Actualizar world.json por días: </translation>
<translation name="WORLD_JSON_SOURCE_URL">world.json URL de origen</translation>
<translation name="CONDITIONS">Condiciones</translation>
<translation name="DESCRIPTIONS">Descripciones</translation>
<translation name="MINIMAL_ITEM_POWER">Poder de objeto mínimo</translation>
<translation name="MAXIMUM_ITEM_POWER">Poder de objeto máximo</translation>
<translation name="MINIMAL_BASIC_ITEM_POWER">Poder de objeto base mínimo</translation>
<translation name="MAXIMUM_BASIC_ITEM_POWER">Poder de objeto base máximo</translation>
<translation name="IP_OR_BIP_BETWEEN_MIN_AND_MAX_RANGE">Poder de objeto o poder de objeto base entre el rango mínimo y máximo</translation>
<translation name="IP_OR_BIP_OVER_MAX_RANGE">Poder de objeto o poder de objeto base mayor que el máximo</translation>
<translation name="IP_OR_BIP_UNDER_MIN_RANGE">Poder de objeto o poder de objeto base menor que el mínimo</translation>
<translation name="PLAYER_IS_NOT_INSPECTED">Jugador no inspeccionado</translation>
<translation name="PARTY_INFORMATION">Información de grupo</translation>
<translation name="AVERAGE_IP">IP media</translation>
<translation name="AVERAGE_BIP">IP base media</translation>
<translation name="SPELLS_JSON_SOURCE_URL">spells.json URL de origen</translation>
<translation name="UPDATE_SPELLS_JSON_BY_DAYS">Actualizar spells.json por días: </translation>
<translation name="BACKUP_CREATED">Copia de seguridad creada</translation>
<translation name="A_BACKUP_HAS_BEEN_CREATED">Una copia de seguridad ha sido creada</translation>
<translation name="BACKUP_INTERVAL">Frecuencia de copia de seguridad</translation>
<translation name="BACKUP_NOW">Hacer copia de seguridad ahora</translation>
<translation name="MAXIMUM_NUMBER_OF_BACKUPS">Número máximo de copias de seguridad</translation>
<translation name="BACKUP">Copia de seguridad</translation>
<translation name="ITEM_WINDOW">Ventana de objeto</translation>
<translation name="ITEM_SEARCH">Buscar objeto</translation>
<translation name="LOOT_LOGGER">Registro de botín</translation>
<translation name="TOOLS">Herramientas</translation>
</translations>
Loading

0 comments on commit b14b468

Please sign in to comment.