move towards auto-import
This commit is contained in:
@ -1,20 +1,41 @@
|
||||
using System;
|
||||
using CsvHelper.Configuration;
|
||||
using CsvHelper;
|
||||
using System.IO;
|
||||
using System.Reactive.Linq;
|
||||
using Splat;
|
||||
using StarsAssistant.Helpers;
|
||||
|
||||
namespace StarsAssistant.Services;
|
||||
|
||||
|
||||
public class CSVDataLoader
|
||||
public class CSVDataLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the game metadata, retrieved by DI
|
||||
/// </summary>
|
||||
protected Model.Game game;
|
||||
protected Services.Game Game = Locator.Current.GetService<Services.Game>()!;
|
||||
|
||||
public CSVDataLoader()
|
||||
public void CSVDataLoader()
|
||||
{
|
||||
game = Locator.Current.GetService<Model.Game>()!;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void StartPlanetCSVWatcher()
|
||||
{
|
||||
// TODO: which scheduler for Throttle?
|
||||
var watcher = FsWatcher
|
||||
.ObserveFileSystem(Game.GamePath, new string[] { Game.PlanetFileSearchPattern });
|
||||
.ThrottleAndDistinct(2);
|
||||
|
||||
/*
|
||||
watcher.Subscribe(x =>
|
||||
{
|
||||
Console.WriteLine($"{DateTime.Now.ToLongTimeString()} got {x.Count()} events:");
|
||||
|
||||
foreach (var fsEvent in x)
|
||||
{
|
||||
Console.WriteLine($"{DateTime.Now.ToLongTimeString()} {i++} {fsEvent.FullPath} - {fsEvent.ChangeType}");
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
33
Stars Assistant/Services/Game.cs
Normal file
33
Stars Assistant/Services/Game.cs
Normal file
@ -0,0 +1,33 @@
|
||||
namespace StarsAssistant.Services;
|
||||
|
||||
public class Game
|
||||
{
|
||||
/// <summary>
|
||||
/// The base path in which all game files reside.
|
||||
/// </summary>
|
||||
public required string GamePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The base name without extensions of your game, inside the GamePath folder.
|
||||
/// All dependant files are resolved using this name.
|
||||
/// </summary>
|
||||
public required string BaseName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Combine into the DatabaseName
|
||||
/// </summary>
|
||||
public string DatabaseFileName => Path.Combine(GamePath, $"{BaseName}.sqlite");
|
||||
|
||||
/// <summary>
|
||||
/// Search for Planet files using this pattern, will give you all pxx files.
|
||||
/// </summary>
|
||||
public string PlanetFileSearchPattern => $"{BaseName}.p*";
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of a planet file for a given race.
|
||||
/// </summary>
|
||||
/// <param name="r">The race to load.</param>
|
||||
/// <returns>Fully qualified file path.</returns>
|
||||
public string PlanetFileForRace (Model.Race r) => Path.Combine(GamePath, $"{BaseName}.p{r.PlayerFileId}");
|
||||
|
||||
}
|
Reference in New Issue
Block a user