Skip to content

Commit

Permalink
feat: Added Paimon, Gliders and some characters from Fontaine. (#13)
Browse files Browse the repository at this point in the history
feat: Added Paimon, Gliders and some characters from Fontaine.

fix: Better description of reorganize mods
feat: Qol, when selected character for moving mods the move button will recieve focus

fix: When navigating to a charcter detailed overview focus is set on grid and not the back button

fix: That some mod names had an underscore shown  with their name (_ModName) when enabled.

chore: Gliders character is now at the bottom

chore: Removed question mark from "Delete?" when deleting characters

fix: Closing JASM will now NOT close Migoto or Genshin if they were started trough it....

refactor: Refactored ProcessManager code, less bloat code
  • Loading branch information
Jorixon authored Sep 3, 2023
1 parent fc3851a commit b6ceb06
Show file tree
Hide file tree
Showing 23 changed files with 1,488 additions and 1,192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace GIMI_ModManager.Core.Contracts.Entities;
public interface ICharacterModList
{
public string AbsModsFolderPath { get; }
public string DisabledPrefix { get; }

/// <summary>
/// All mods for this character that have added to the mod list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ public interface ISkinManagerService
public void Initialize(string activeModsFolderPath, string? unloadedModsFolderPath);

/// <summary>
///
///
/// </summary>
public int ReorganizeMods();
/// <param name="characterFolderToReorganize">If null, reorganize all mods outside of characters mod folders</param>
/// <returns>Mods moved</returns>
public int ReorganizeMods(GenshinCharacter? characterFolderToReorganize = null);

/// <summary>
/// This looks for mods in characters mod folder that are not tracked by the mod manager and adds them to the mod manager.
Expand Down
12 changes: 8 additions & 4 deletions src/GIMI-ModManager.Core/Entities/CharacterModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public sealed class CharacterModList : ICharacterModList, IDisposable
public string AbsModsFolderPath { get; }
private readonly List<CharacterSkinEntry> _mods = new();
public const string DISABLED_PREFIX = "DISABLED_";
public string DisabledPrefix => DISABLED_PREFIX;
private readonly FileSystemWatcher _watcher;
public GenshinCharacter Character { get; }

Expand Down Expand Up @@ -48,7 +49,7 @@ private void OnWatcherError(object sender, ErrorEventArgs e)

private void OnModDeleted(object sender, FileSystemEventArgs e)
{
_logger?.Information("Mod {ModName} deleted", e.FullPath);
_logger?.Information("Mod {ModName} in {characterFolder} folder was deleted", e.Name, Character.DisplayName);
if (_mods.Any(mod => mod.Mod.FullPath == e.FullPath))
{
var mod = _mods.First(mod => mod.Mod.FullPath == e.FullPath);
Expand All @@ -62,10 +63,11 @@ private void OnModDeleted(object sender, FileSystemEventArgs e)

private void OnModCreated(object sender, FileSystemEventArgs e)
{
_logger?.Information("Mod {ModName} created", e.FullPath);
_logger?.Information("Mod {ModName} was created in {characterFolder} created", e.Name, Character.DisplayName);
var mod = new Mod(new DirectoryInfo(e.FullPath));
if (ModAlreadyAdded(mod))
_logger?.Warning("Created folder {Folder} was already tracked in mod list", e.FullPath);
_logger?.Warning("Created folder {Folder} was already tracked in {characterFolder} mod list", e.Name,
Character.DisplayName);
else
TrackMod(mod);
ModFolderChanged();
Expand Down Expand Up @@ -101,7 +103,7 @@ public void TrackMod(IMod mod)
_mods.Add(mod.Name.StartsWith(DISABLED_PREFIX)
? new CharacterSkinEntry(mod, this, false)
: new CharacterSkinEntry(mod, this, true));
_logger?.Debug("Tracking {ModName} in {CharacterName} modList", mod.FullPath, Character.DisplayName);
_logger?.Debug("Tracking {ModName} in {CharacterName} modList", mod.Name, Character.DisplayName);
}

// Untrack
Expand All @@ -115,6 +117,8 @@ public void UnTrackMod(IMod mod)
}

_mods.Remove(_mods.First(m => m.Mod == mod));
_logger?.Debug("Stopped tracking {ModName} in {CharacterName} modList", mod.Name, Character.DisplayName);

}

public void EnableMod(Guid modId)
Expand Down
22 changes: 21 additions & 1 deletion src/GIMI-ModManager.Core/Services/GenshinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public async Task InitializeAsync(string assetsUriPath)
}

_characters.AddRange(characters);
_characters.Add(getGlidersCharacter(assetsUriPath));
_characters.Add(getOthersCharacter(assetsUriPath));
}

Expand Down Expand Up @@ -97,7 +98,6 @@ public Dictionary<GenshinCharacter, int> GetCharacters(string keywords,

foreach (var character in restrictToGenshinCharacters ?? _characters)
{

Debug.Assert(searchResult.Count(x => x.Value == 100) <= 1,
"searchResult.Count(x => x.Value == 100) <= 1, Multiple 100 results");

Expand All @@ -110,6 +110,7 @@ public Dictionary<GenshinCharacter, int> GetCharacters(string keywords,
searchResult.Add(character, 100);
continue;
}

if (keywords.ToLower().Split().Any(modKeyWord =>
character.Keys.Any(characterKeyWord => characterKeyWord.ToLower() == modKeyWord)))
{
Expand Down Expand Up @@ -148,6 +149,24 @@ private static GenshinCharacter getOthersCharacter(string assetsUriPath)
return character;
}

private const int _glidersCharacterId = -1235;
public int GlidersCharacterId => _glidersCharacterId;

private static GenshinCharacter getGlidersCharacter(string assetsUriPath)
{
var character = new GenshinCharacter
{
Id = _glidersCharacterId,
DisplayName = "Gliders",
ReleaseDate = DateTime.MinValue,
Rarity = -1,
Keys = new[] { "gliders", "glider", "wings" },
ImageUri = "Character_Gliders_Thumb.webp"
};
SetImageUriForCharacter(assetsUriPath, character);
return character;
}

public GenshinCharacter? GetCharacter(int id)
=> _characters.FirstOrDefault(c => c.Id == id);
}
Expand All @@ -165,6 +184,7 @@ public Dictionary<GenshinCharacter, int> GetCharacters(string keywords,

public GenshinCharacter? GetCharacter(int id);
public int OtherCharacterId { get; }
public int GlidersCharacterId { get; }
}

internal static class GenshinCharacters
Expand Down
23 changes: 16 additions & 7 deletions src/GIMI-ModManager.Core/Services/SkinManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void InitializeFolderStructure()
}
}

public int ReorganizeMods()
public int ReorganizeMods(GenshinCharacter? characterFolderToReorganize = null)
{
if (_activeModsFolder is null) throw new InvalidOperationException("ModManagerService is not initialized");

Expand All @@ -179,7 +179,11 @@ public int ReorganizeMods()

var movedMods = 0;

foreach (var folder in _activeModsFolder.EnumerateDirectories())
var folderToReorganize = characterFolderToReorganize is null
? _activeModsFolder
: new DirectoryInfo(GetCharacterModFolderPath(characterFolderToReorganize));

foreach (var folder in folderToReorganize.EnumerateDirectories())
{
// Is a character folder continue
var character = characters.FirstOrDefault(x => x.DisplayName == folder.Name);
Expand All @@ -188,14 +192,19 @@ public int ReorganizeMods()

// Is a mod folder, determine which character it belongs to
var closestMatchCharacter = _genshinService.GetCharacter(folder.Name);
if (closestMatchCharacter is null)
switch (closestMatchCharacter)
{
_logger.Information(
"Mod folder {ModFolder} does not seem to belong to a character. Moving to 'Others' folder",
folder.Name);
closestMatchCharacter = othersCharacter;
case null when characterFolderToReorganize is null:
_logger.Information(
"Mod folder {ModFolder} does not seem to belong to a character. Moving to 'Others' folder",
folder.Name);
closestMatchCharacter = othersCharacter;
break;
case null:
continue; // Mod folder does not belong to this character, but we cant determine which character it belongs to. Move on
}


var modList = GetCharacterModList(closestMatchCharacter);
var mod = new Mod(folder, folder.Name);
try
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b6ceb06

Please sign in to comment.