Skip to content

Commit

Permalink
chore: Added presets overview (Jorixon#162)
Browse files Browse the repository at this point in the history
chore: Possible set preset as Read Only
  • Loading branch information
Jorixon authored Mar 28, 2024
1 parent 00e647d commit 442a164
Show file tree
Hide file tree
Showing 28 changed files with 1,581 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void ExportMods(ICollection<ICharacterModList> characterModLists, string
public event EventHandler<ExportProgress>? ModExportProgress;

public ISkinMod? GetModById(Guid id);
public CharacterSkinEntry? GetModEntryById(Guid id);

public Task EnableModListAsync(ICharacter moddableObject);

Expand Down
6 changes: 4 additions & 2 deletions src/GIMI-ModManager.Core/Helpers/AsyncLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ public sealed class AsyncLock : IDisposable
{
private readonly SemaphoreSlim _semaphore = new(1, 1);

public async Task<LockReleaser> LockAsync(int timeout = -1, CancellationToken cancellationToken = default)
public async Task<LockReleaser> LockAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)
{
await _semaphore.WaitAsync(timeout, cancellationToken).ConfigureAwait(false);
var timeoutValue = timeout.HasValue ? (int)Math.Round(timeout.Value.TotalMilliseconds) : -1;

await _semaphore.WaitAsync(timeoutValue, cancellationToken).ConfigureAwait(false);
return new LockReleaser(Release);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace GIMI_ModManager.Core.Services.ModPresetService.JsonModels;

internal class JsonModPreset
{
public bool IsReadOnly { get; set; }
public DateTime Created { get; set; } = DateTime.Now;
public int Index { get; set; }
public List<JsonModPresetEntry> Mods { get; set; } = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace GIMI_ModManager.Core.Services.ModPresetService.JsonModels;

[SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global", Justification = "This is a json model")]
internal class JsonModPresetEntry
{
public required Guid ModId { get; set; }
public required string FullPath { get; set; }
public bool IsMissing { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? CustomName { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? SourceUrl { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, string>? Preferences { get; set; }


[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? AddedAt { get; set; }
}
Loading

0 comments on commit 442a164

Please sign in to comment.