AnimeEdit 添加支持 Switch_Up Switch_Down Switch_Thirsty Switch_Hunger

This commit is contained in:
Hakoyu 2023-09-21 23:42:15 +08:00
parent 82904d1321
commit 2de90fe10c
2 changed files with 61 additions and 18 deletions

View File

@ -64,6 +64,10 @@ public class AnimeTypeModel
is GraphInfo.GraphType.Default
or GraphInfo.GraphType.Shutdown
or GraphInfo.GraphType.StartUP
or GraphInfo.GraphType.Switch_Up
or GraphInfo.GraphType.Switch_Down
or GraphInfo.GraphType.Switch_Thirsty
or GraphInfo.GraphType.Switch_Hunger
)
LoadDefault(path);
else if (
@ -88,6 +92,7 @@ public class AnimeTypeModel
// }
//}
private void LoadDefault(string path)
{
foreach (var dir in Directory.EnumerateDirectories(path))
@ -110,6 +115,10 @@ public class AnimeTypeModel
AddAnime(IllAnimes, dir);
}
}
if (Directory.EnumerateFiles(path).Any())
{
AddAnime(NomalAnimes, path);
}
}
private void LoadMultiType(string path)
@ -181,7 +190,7 @@ public class AnimeTypeModel
};
}
public static void AddAnime(
private static void AddAnime(
ObservableCollection<AnimeModel> collection,
string path,
GraphInfo.AnimatType animatType = AnimatType.Single
@ -220,31 +229,47 @@ public class AnimeTypeModel
or GraphInfo.GraphType.Sleep
)
SaveMultiType(path, this);
else if (
GraphType.Value
is GraphInfo.GraphType.Switch_Up
or GraphInfo.GraphType.Switch_Down
or GraphInfo.GraphType.Switch_Thirsty
or GraphInfo.GraphType.Switch_Hunger
)
SaveSwitch(path, this);
}
void SaveMultiType(string path, AnimeTypeModel animeType)
void SaveSwitch(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, animeType.GraphType.ToString());
var animePath = Path.Combine(path, "Switch");
Directory.CreateDirectory(animePath);
if (animeType.HappyAnimes.Count > 0)
var switchName = animeTypeModel.GraphType.ToString().Split(Utils.Separator).Last();
SaveWithAnimeType(Path.Combine(animePath, switchName), animeTypeModel);
}
void SaveMultiType(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, animeTypeModel.GraphType.ToString());
Directory.CreateDirectory(animePath);
if (animeTypeModel.HappyAnimes.Count > 0)
{
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Happy));
SaveAnimes(modePath, animeType.HappyAnimes);
SaveAnimes(modePath, animeTypeModel.HappyAnimes);
}
if (animeType.NomalAnimes.Count > 0)
if (animeTypeModel.NomalAnimes.Count > 0)
{
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Nomal));
SaveAnimes(modePath, animeType.NomalAnimes);
SaveAnimes(modePath, animeTypeModel.NomalAnimes);
}
if (animeType.PoorConditionAnimes.Count > 0)
if (animeTypeModel.PoorConditionAnimes.Count > 0)
{
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.PoorCondition));
SaveAnimes(modePath, animeType.PoorConditionAnimes);
SaveAnimes(modePath, animeTypeModel.PoorConditionAnimes);
}
if (animeType.IllAnimes.Count > 0)
if (animeTypeModel.IllAnimes.Count > 0)
{
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Ill));
SaveAnimes(modePath, animeType.IllAnimes);
SaveAnimes(modePath, animeTypeModel.IllAnimes);
}
static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes)
@ -280,10 +305,15 @@ public class AnimeTypeModel
}
}
static void SaveDefault(string path, AnimeTypeModel animeType)
static void SaveDefault(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, animeType.GraphType.ToString());
var animePath = Path.Combine(path, animeTypeModel.GraphType.ToString());
Directory.CreateDirectory(animePath);
SaveWithAnimeType(animePath, animeTypeModel);
}
static void SaveWithAnimeType(string animePath, AnimeTypeModel animeType)
{
if (animeType.HappyAnimes.Count > 0)
{
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Happy));

View File

@ -79,13 +79,26 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
{
foreach (var dir in Directory.EnumerateDirectories(p))
{
Enum.TryParse<GraphInfo.GraphType>(
Path.GetFileName(dir),
true,
out var animeType
);
var dirName = Path.GetFileName(dir);
Enum.TryParse<GraphInfo.GraphType>(dirName, true, out var animeType);
if (AnimeTypeModel.Create(animeType, dir) is AnimeTypeModel model)
petModel.Animes.Add(model);
else if (dirName.Equals("Switch", StringComparison.InvariantCultureIgnoreCase))
{
foreach (var switchDir in Directory.EnumerateDirectories(dir))
{
Enum.TryParse<GraphInfo.GraphType>(
$"{dirName}_{Path.GetFileName(switchDir)}",
true,
out var switchType
);
if (
AnimeTypeModel.Create(switchType, Path.Combine(dir, switchDir))
is AnimeTypeModel switchModel
)
petModel.Animes.Add(switchModel);
}
}
}
}
}