mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-15 13:14:17 +01:00
API 4 updates
This commit is contained in:
parent
86417ed74f
commit
f10280d15d
31 changed files with 359 additions and 367 deletions
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Logging;
|
||||
using Glamourer.FileSystem;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
|
@ -16,9 +16,9 @@ namespace Glamourer.Designs
|
|||
public SortedList<string, CharacterSave> Designs = null!;
|
||||
public FileSystem.FileSystem FileSystem { get; } = new();
|
||||
|
||||
public DesignManager(DalamudPluginInterface pi)
|
||||
public DesignManager()
|
||||
{
|
||||
var saveFolder = new DirectoryInfo(pi.GetPluginConfigDirectory());
|
||||
var saveFolder = new DirectoryInfo(Dalamud.PluginInterface.GetPluginConfigDirectory());
|
||||
if (!saveFolder.Exists)
|
||||
Directory.CreateDirectory(saveFolder.FullName);
|
||||
|
||||
|
|
@ -31,24 +31,21 @@ namespace Glamourer.Designs
|
|||
{
|
||||
FileSystem.Clear();
|
||||
var anyChanges = false;
|
||||
foreach (var kvp in Designs.ToArray())
|
||||
foreach (var (path, save) in Designs.ToArray())
|
||||
{
|
||||
var path = kvp.Key;
|
||||
var save = kvp.Value;
|
||||
|
||||
try
|
||||
{
|
||||
var (folder, name) = FileSystem.CreateAllFolders(path);
|
||||
var design = new Design(folder, name) { Data = save };
|
||||
folder.FindOrAddChild(design);
|
||||
var fixedPath = design.FullName();
|
||||
if (!string.Equals(fixedPath, path, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Designs.Remove(path);
|
||||
Designs[fixedPath] = save;
|
||||
anyChanges = true;
|
||||
PluginLog.Debug($"Problem loading saved designs, {path} was renamed to {fixedPath}.");
|
||||
}
|
||||
if (string.Equals(fixedPath, path, StringComparison.InvariantCultureIgnoreCase))
|
||||
continue;
|
||||
|
||||
Designs.Remove(path);
|
||||
Designs[fixedPath] = save;
|
||||
anyChanges = true;
|
||||
PluginLog.Debug($"Problem loading saved designs, {path} was renamed to {fixedPath}.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue