Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ We really like people helping us with the project. Nevertheless, take your time

## ChangeLog

<details open="open"><summary>v2.0.8</summary>

>- dotnet update to 8.0.15
>- Maui Replay Import improved
>- Maui Import 'Robust Import' - saving replays one by one

</details>

<details open="open"><summary>v2.0.7</summary>

>- s2protocol 5.0.14.93333.0 (s2protocol.NET v0.8.4)
Expand Down
4 changes: 1 addition & 3 deletions src/dsstats.db8services/IReplayRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ namespace dsstats.db8services;

public interface IReplayRepository
{
Task SaveReplay(ReplayDto replayDto,
HashSet<Unit> units,
HashSet<Upgrade> upgrades);
Task SaveReplay(ReplayDto replayDto);
Task<ReplayDto?> GetLatestReplay();
Task<ReplayDto?> GetPreviousReplay(DateTime gameTime);
Task<ReplayDto?> GetNextReplay(DateTime gameTime);
Expand Down
5 changes: 3 additions & 2 deletions src/dsstats.db8services/Import/ImportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public async Task Init()
await initSs.WaitAsync();
if (IsInit)
{
initSs.Release();
return;
}
try
Expand Down Expand Up @@ -181,7 +182,7 @@ private async Task<int> GetUnitIdAsync(string name)
}
}

private int GetUnitId(string name)
public int GetUnitId(string name)
{
if (!Units.TryGetValue(name, out var unitId))
{
Expand Down Expand Up @@ -236,7 +237,7 @@ private async Task<int> GetUpgradeIdAsync(string name)
}
}

private int GetUpgradeId(string name)
public int GetUpgradeId(string name)
{
if (!Upgrades.TryGetValue(name, out var upgradeId))
{
Expand Down
46 changes: 13 additions & 33 deletions src/dsstats.db8services/ReplayRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using dsstats.db8;
using dsstats.shared;
using dsstats.shared.Extensions;
using dsstats.shared.Interfaces;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Diagnostics;

namespace dsstats.db8services;
Expand All @@ -18,20 +18,24 @@ public class ReplayRepository : IReplayRepository
private readonly ReplayContext context;
private readonly IOptions<DbImportOptions> dbImportOptions;
private readonly IMapper mapper;
private readonly IImportService importService;

public ReplayRepository(ILogger<ReplayRepository> logger,
ReplayContext context,
IOptions<DbImportOptions> dbImportOptions,
IMapper mapper)
IMapper mapper,
IImportService importService)
{
this.logger = logger;
this.context = context;
this.dbImportOptions = dbImportOptions;
this.mapper = mapper;
this.importService = importService;
}

public async Task SaveReplay(ReplayDto replayDto, HashSet<Unit> units, HashSet<Upgrade> upgrades)
public async Task SaveReplay(ReplayDto replayDto)
{
await importService.Init();
replayDto.SetDefaultFilter();

var dbReplay = mapper.Map<Replay>(replayDto);
Expand Down Expand Up @@ -80,10 +84,10 @@ public async Task SaveReplay(ReplayDto replayDto, HashSet<Unit> units, HashSet<U

foreach (var spawn in replayPlayer.Spawns)
{
spawn.Units = await GetMapedSpawnUnits(spawn, replayPlayer.Race, units);
spawn.Units = GetMapedSpawnUnits(spawn, replayPlayer.Race);
}

replayPlayer.Upgrades = await GetMapedPlayerUpgrades(replayPlayer, upgrades);
replayPlayer.Upgrades = GetMapedPlayerUpgrades(replayPlayer);

}

Expand All @@ -106,55 +110,31 @@ public async Task SaveReplay(ReplayDto replayDto, HashSet<Unit> units, HashSet<U
}
}

private async Task<ICollection<SpawnUnit>> GetMapedSpawnUnits(Spawn spawn, Commander commander, HashSet<Unit> units)
private ICollection<SpawnUnit> GetMapedSpawnUnits(Spawn spawn, Commander commander)
{
List<SpawnUnit> spawnUnits = new();
foreach (var spawnUnit in spawn.Units)
{
var listUnit = units.FirstOrDefault(f => f.Name.Equals(spawnUnit.Unit.Name));
if (listUnit == null)
{
listUnit = new()
{
Name = spawnUnit.Unit.Name
};
context.Units.Add(listUnit);
await context.SaveChangesAsync();
units.Add(listUnit);
}

spawnUnits.Add(new()
{
Count = spawnUnit.Count,
Poss = spawnUnit.Poss,
UnitId = listUnit.UnitId,
UnitId = importService.GetUnitId(spawnUnit.Unit.Name),
SpawnId = spawn.SpawnId
});
}
return spawnUnits;
}

private async Task<ICollection<PlayerUpgrade>> GetMapedPlayerUpgrades(ReplayPlayer player, HashSet<Upgrade> upgrades)
private ICollection<PlayerUpgrade> GetMapedPlayerUpgrades(ReplayPlayer player)
{
List<PlayerUpgrade> playerUpgrades = new();
foreach (var playerUpgrade in player.Upgrades)
{
var listUpgrade = upgrades.FirstOrDefault(f => f.Name.Equals(playerUpgrade.Upgrade.Name));
if (listUpgrade == null)
{
listUpgrade = new()
{
Name = playerUpgrade.Upgrade.Name
};
context.Upgrades.Add(listUpgrade);
await context.SaveChangesAsync();
upgrades.Add(listUpgrade);
}

playerUpgrades.Add(new()
{
Gameloop = playerUpgrade.Gameloop,
UpgradeId = listUpgrade.UpgradeId,
UpgradeId = importService.GetUpgradeId(playerUpgrade.Upgrade.Name),
ReplayPlayerId = player.ReplayPlayerId
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Bitte überprüfen Sie, ob die Einstellungen wie erwartet sind.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Konservativer Wiederholungsimport (etwas langsamer, aber robuster)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Please check if the settings are as expected.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Conservative Replay Import (slightly slower, but more robust)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Por favor, compruebe si la configuración es la esperada.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Importación de repeticiones conservadora (ligeramente más lenta, pero más robusta)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Veuillez vérifier si les paramètres sont conformes aux attentes.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Importation de rediffusions conservatrice (légèrement plus lente, mais plus robuste)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Please check if the settings are as expected.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Conservative Replay Import (slightly slower, but more robust)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Пожалуйста, проверьте, соответствуют ли настройки ожидаемым.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Консервативный импорт повторов (немного медленнее, но более надежный)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/dsstats.maui/dsstats.localization/DsstatsLoc.uk.resx
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,7 @@
<data name="Please check if the settings are as expected." xml:space="preserve">
<value>Будь ласка, перевірте, чи налаштування відповідають очікуванням.</value>
</data>
<data name="NoBatchImport" xml:space="preserve">
<value>Консервативний імпорт повторів (трохи повільніше, але надійніше)</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ Should a backup be created at this location now?;Should a backup be created at t
Restore Database?;Restore Database?; Datenbank wiederherstellen?; ¿Restaurar base de datos?; Восстановить базу данных?; Restaurer la base de données ?; Відновити базу даних?
The current data will be overwritten.;The current data will be overwritten.; Die aktuellen Daten werden überschrieben.; Los datos actuales serán sobrescritos.; Текущие данные будут перезаписаны.; Les données actuelles seront écrasées.; Поточні дані будуть перезаписані.
Please check if the settings are as expected.;Please check if the settings are as expected.; Bitte überprüfen Sie, ob die Einstellungen wie erwartet sind.; Por favor, compruebe si la configuración es la esperada.; Пожалуйста, проверьте, соответствуют ли настройки ожидаемым.; Veuillez vérifier si les paramètres sont conformes aux attentes.; Будь ласка, перевірте, чи налаштування відповідають очікуванням.
NoBatchImport;Conservative Replay Import (slightly slower, but more robust);Konservativer Wiederholungsimport (etwas langsamer, aber robuster); Importación de repeticiones conservadora (ligeramente más lenta, pero más robusta); Консервативный импорт повторов (немного медленнее, но более надежный); Importation de rediffusions conservatrice (légèrement plus lente, mais plus robuste); Консервативний імпорт повторів (трохи повільніше, але надійніше)
4 changes: 2 additions & 2 deletions src/dsstats.maui/dsstats.maui8/AppOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using dsstats.db8;
using dsstats.shared;
using dsstats.shared;
using System.Text.Json.Serialization;

namespace dsstats.maui8;
Expand Down Expand Up @@ -27,6 +26,7 @@ public record AppOptions
public List<string> IgnoreReplays { get; set; } = new();
public string ReplayStartName { get; set; } = "Direct Strike";
public string Culture { get; set; } = "iv";
public bool NoBatchImport { get; set; }
}

public record Sc2Profile
Expand Down
26 changes: 17 additions & 9 deletions src/dsstats.maui/dsstats.maui8/Components/Pages/SettingsPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
<InputCheckbox class="form-check-input" @bind-Value="options.CheckForUpdates" />
</label>
</div>
<label class="col-form-label">
<InputNumber class="form-control" @bind-Value="options.CPUCores" style="max-width: 150px;"></InputNumber>
@Loc["CPU Cores - used for decoding new replays (available CPU-Cores: {0})", Environment.ProcessorCount]
</label>
<div>
<label class="col-form-label">
<InputNumber class="form-control" @bind-Value="options.CPUCores" style="max-width: 150px;"></InputNumber>
@Loc["CPU Cores - used for decoding new replays (available CPU-Cores: {0})", Environment.ProcessorCount]
</label>
</div>
<div class="form-check form-switch">
<label class="form-check-label">
<InputCheckbox class="form-check-input" @bind-Value="options.NoBatchImport" />
@Loc["NoBatchImport"]
</label>
</div>
</div>
</div>
<div>
Expand Down Expand Up @@ -74,7 +82,7 @@
<td>@profile.Folder</td>
<td>
<button type="button" class="@(ignore ? "btn btn-sm btn-success" : "btn btn-sm btn-outline-danger")"
@onclick:stopPropagation @onclick="e => DeOrActivateProfile(profile, ignore)">
@onclick:stopPropagation @onclick="e => DeOrActivateProfile(profile, ignore)">
@(ignore ? Loc["Activate"] : Loc["Deactivate"])
</button>
</td>
Expand Down Expand Up @@ -144,7 +152,7 @@
<td>@replayPath</td>
<td>
<button type="button" class="btn btn-sm btn-outline-warning"
@onclick="e => RemoveIgnoreReplay(replayPath)">
@onclick="e => RemoveIgnoreReplay(replayPath)">
@Loc["UnIgnore"]
</button>
</td>
Expand Down Expand Up @@ -349,9 +357,9 @@
public async Task Restore()
{
var pickResult = await filePicker.PickAsync(new PickOptions()
{
PickerTitle = "Select dsstats backup file",
});
{
PickerTitle = "Select dsstats backup file",
});
if (pickResult is not null)
{
var result = await backupService.Restore(pickResult.FullPath);
Expand Down
2 changes: 1 addition & 1 deletion src/dsstats.maui/dsstats.maui8/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static MauiApp CreateMauiApp()
builder.Services.AddSingleton<IRemoteToggleService, maui8.Services.RemoteToggleService>();
builder.Services.AddSingleton<ConfigService>();
builder.Services.AddSingleton<DsstatsService>();
builder.Services.AddSingleton<ImportService>();
builder.Services.AddSingleton<IImportService, ImportService>();
builder.Services.AddSingleton<IRatingService, RatingService>();
builder.Services.AddSingleton<IRatingsSaveService, Services.RatingsSaveService>();
builder.Services.AddSingleton<IUpdateService, StoreUpdateService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity Name="29898PhilippHetzner.141231D0ED353" Publisher="CN=592AF738-4E2A-4BF3-87A7-D07953D08DE9" Version="2.0.7.0" />
<Identity Name="29898PhilippHetzner.141231D0ED353" Publisher="CN=592AF738-4E2A-4BF3-87A7-D07953D08DE9" Version="2.0.8.0" />

<Properties>
<DisplayName>$placeholder$</DisplayName>
Expand Down
Loading