[Draft] Update 0.8 (#46)
* move stuff out into file transfer manager * obnoxious unsupported version text, adjustments to filetransfermanager * add back file upload transfer progress * restructure code * cleanup some more stuff I guess * downloadids by playername * individual anim/sound bs * fix migration stuff, finalize impl of individual sound/anim pause * fixes with logging stuff * move download manager to transient * rework dl ui first iteration * some refactoring and cleanup * more code cleanup * refactoring * switch to hostbuilder * some more rework I guess * more refactoring * clean up mediator calls and disposal * fun code cleanup * push error message when log level is set to anything but information in non-debug builds * remove notificationservice * move message to after login * add download bars to gameworld * fixes download progress bar * set gpose ui min and max size * remove unnecessary usings * adjustments to reconnection logic * add options to set visible/offline groups visibility * add impl of uploading display, transfer list in settings ui * attempt to fix issues with server selection * add back download status to compact ui * make dl bar fixed size based * some fixes for upload/download handling * adjust text from Syncing back to Uploading --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com> Co-authored-by: Stanley Dimant <stanley.dimant@varian.com>
This commit is contained in:
57
MareSynchronos/PlayerData/Data/CharacterData.cs
Normal file
57
MareSynchronos/PlayerData/Data/CharacterData.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Text;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.PlayerData.Data;
|
||||
|
||||
public class CharacterData
|
||||
{
|
||||
public string CustomizePlusScale { get; set; } = string.Empty;
|
||||
public Dictionary<ObjectKind, HashSet<FileReplacement>> FileReplacements { get; set; } = new();
|
||||
|
||||
public Dictionary<ObjectKind, string> GlamourerString { get; set; } = new();
|
||||
|
||||
public float HeelsOffset { get; set; } = 0f;
|
||||
public bool IsReady => FileReplacements.SelectMany(k => k.Value).All(f => f.Computed);
|
||||
|
||||
public string ManipulationString { get; set; } = string.Empty;
|
||||
public string PalettePlusPalette { get; set; } = string.Empty;
|
||||
|
||||
public API.Data.CharacterData ToAPI()
|
||||
{
|
||||
var fileReplacements = FileReplacements.ToDictionary(k => k.Key, k => k.Value.Where(f => f.HasFileReplacement && !f.IsFileSwap).GroupBy(f => f.Hash, StringComparer.OrdinalIgnoreCase).Select(g =>
|
||||
{
|
||||
return new FileReplacementData()
|
||||
{
|
||||
GamePaths = g.SelectMany(f => f.GamePaths).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(),
|
||||
Hash = g.First().Hash,
|
||||
};
|
||||
}).ToList());
|
||||
|
||||
foreach (var item in FileReplacements)
|
||||
{
|
||||
var fileSwapsToAdd = item.Value.Where(f => f.IsFileSwap).Select(f => f.ToFileReplacementDto());
|
||||
fileReplacements[item.Key].AddRange(fileSwapsToAdd);
|
||||
}
|
||||
|
||||
return new API.Data.CharacterData()
|
||||
{
|
||||
FileReplacements = fileReplacements,
|
||||
GlamourerData = GlamourerString.ToDictionary(d => d.Key, d => d.Value),
|
||||
ManipulationData = ManipulationString,
|
||||
HeelsOffset = HeelsOffset,
|
||||
CustomizePlusData = CustomizePlusScale,
|
||||
PalettePlusData = PalettePlusPalette,
|
||||
};
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new();
|
||||
foreach (var fileReplacement in FileReplacements.SelectMany(k => k.Value).OrderBy(a => a.GamePaths.First(), StringComparer.Ordinal))
|
||||
{
|
||||
stringBuilder.Append(fileReplacement).AppendLine();
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
45
MareSynchronos/PlayerData/Data/FileReplacement.cs
Normal file
45
MareSynchronos/PlayerData/Data/FileReplacement.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.PlayerData.Data;
|
||||
|
||||
public partial class FileReplacement
|
||||
{
|
||||
private readonly Lazy<string> _hashLazy;
|
||||
|
||||
public FileReplacement(List<string> gamePaths, string filePath, FileCacheManager fileDbManager)
|
||||
{
|
||||
GamePaths = gamePaths.Select(g => g.Replace('\\', '/')).ToHashSet(StringComparer.Ordinal);
|
||||
ResolvedPath = filePath.Replace('\\', '/');
|
||||
_hashLazy = new(() => !IsFileSwap ? fileDbManager.GetFileCacheByPath(ResolvedPath)?.Hash ?? string.Empty : string.Empty);
|
||||
}
|
||||
|
||||
public bool Computed => IsFileSwap || !HasFileReplacement || !string.IsNullOrEmpty(Hash);
|
||||
|
||||
public HashSet<string> GamePaths { get; init; }
|
||||
|
||||
public bool HasFileReplacement => GamePaths.Count >= 1 && GamePaths.Any(p => !string.Equals(p, ResolvedPath, StringComparison.Ordinal));
|
||||
|
||||
public string Hash => _hashLazy.Value;
|
||||
public bool IsFileSwap => !LocalPathRegex().IsMatch(ResolvedPath) && !string.Equals(GamePaths.First(), ResolvedPath, StringComparison.Ordinal);
|
||||
public string ResolvedPath { get; init; }
|
||||
|
||||
public FileReplacementData ToFileReplacementDto()
|
||||
{
|
||||
return new FileReplacementData
|
||||
{
|
||||
GamePaths = GamePaths.ToArray(),
|
||||
Hash = Hash,
|
||||
FileSwapPath = IsFileSwap ? ResolvedPath : string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Modded: {HasFileReplacement} - {string.Join(",", GamePaths)} => {ResolvedPath}";
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^[a-zA-Z]:(/|\\)", RegexOptions.ECMAScript)]
|
||||
private static partial Regex LocalPathRegex();
|
||||
}
|
||||
47
MareSynchronos/PlayerData/Data/FileReplacementComparer.cs
Normal file
47
MareSynchronos/PlayerData/Data/FileReplacementComparer.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace MareSynchronos.PlayerData.Data;
|
||||
|
||||
public class FileReplacementComparer : IEqualityComparer<FileReplacement>
|
||||
{
|
||||
private static readonly FileReplacementComparer _instance = new();
|
||||
|
||||
private FileReplacementComparer()
|
||||
{ }
|
||||
|
||||
public static FileReplacementComparer Instance => _instance;
|
||||
|
||||
public bool Equals(FileReplacement? x, FileReplacement? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.ResolvedPath.Equals(y.ResolvedPath) && CompareLists(x.GamePaths, y.GamePaths);
|
||||
}
|
||||
|
||||
public int GetHashCode(FileReplacement obj)
|
||||
{
|
||||
return HashCode.Combine(obj.ResolvedPath.GetHashCode(StringComparison.OrdinalIgnoreCase), GetOrderIndependentHashCode(obj.GamePaths));
|
||||
}
|
||||
|
||||
private static bool CompareLists(HashSet<string> list1, HashSet<string> list2)
|
||||
{
|
||||
if (list1.Count != list2.Count)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < list1.Count; i++)
|
||||
{
|
||||
if (!string.Equals(list1.ElementAt(i), list2.ElementAt(i), StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
|
||||
{
|
||||
int hash = 0;
|
||||
foreach (T element in source)
|
||||
{
|
||||
hash = unchecked(hash +
|
||||
EqualityComparer<T>.Default.GetHashCode(element));
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.PlayerData.Data;
|
||||
|
||||
public class FileReplacementDataComparer : IEqualityComparer<FileReplacementData>
|
||||
{
|
||||
private static readonly FileReplacementDataComparer _instance = new();
|
||||
|
||||
private FileReplacementDataComparer()
|
||||
{ }
|
||||
|
||||
public static FileReplacementDataComparer Instance => _instance;
|
||||
|
||||
public bool Equals(FileReplacementData? x, FileReplacementData? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.Hash.Equals(y.Hash) && CompareHashSets(x.GamePaths.ToHashSet(StringComparer.Ordinal), y.GamePaths.ToHashSet(StringComparer.Ordinal)) && string.Equals(x.FileSwapPath, y.FileSwapPath, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int GetHashCode(FileReplacementData obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Hash.GetHashCode(StringComparison.OrdinalIgnoreCase), GetOrderIndependentHashCode(obj.GamePaths), StringComparer.Ordinal.GetHashCode(obj.FileSwapPath));
|
||||
}
|
||||
|
||||
private static bool CompareHashSets(HashSet<string> list1, HashSet<string> list2)
|
||||
{
|
||||
if (list1.Count != list2.Count)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < list1.Count; i++)
|
||||
{
|
||||
if (!string.Equals(list1.ElementAt(i), list2.ElementAt(i), StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
|
||||
{
|
||||
int hash = 0;
|
||||
foreach (T element in source)
|
||||
{
|
||||
hash = unchecked(hash +
|
||||
EqualityComparer<T>.Default.GetHashCode(element));
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user