This commit is contained in:
Hakoyu 2023-10-07 21:59:37 +08:00
parent 5b602d864d
commit 530f32e3f6
7 changed files with 283 additions and 23 deletions

View File

@ -6,12 +6,24 @@ using VPet_Simulator.Core;
namespace VPet.ModMaker.Models.ModModel;
/// <summary>
/// 动画模型
/// </summary>
public class AnimeModel
{
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 动画类型
/// </summary>
public ObservableValue<GraphInfo.AnimatType> AnimeType { get; } = new();
/// <summary>
/// 图像列表
/// </summary>
public ObservableCollection<ImageModel> Images { get; } = new();
public AnimeModel() { }
@ -31,6 +43,10 @@ public class AnimeModel
}
}
/// <summary>
/// 复制
/// </summary>
/// <returns></returns>
public AnimeModel Copy()
{
var model = new AnimeModel();
@ -41,6 +57,9 @@ public class AnimeModel
return model;
}
/// <summary>
/// 关闭所有图像流
/// </summary>
public void Close()
{
foreach (var image in Images)

View File

@ -14,13 +14,27 @@ namespace VPet.ModMaker.Models.ModModel;
public class AnimeTypeModel
{
/// <summary>
/// 动作类型
/// </summary>
public static ObservableCollection<GraphInfo.GraphType> GraphTypes { get; } =
new(Enum.GetValues(typeof(GraphInfo.GraphType)).Cast<GraphInfo.GraphType>());
/// <summary>
/// 动画类型
/// </summary>
public static ObservableCollection<GraphInfo.AnimatType> AnimatTypes { get; } =
new(Enum.GetValues(typeof(GraphInfo.AnimatType)).Cast<GraphInfo.AnimatType>());
/// <summary>
/// 模式类型
/// </summary>
public static ObservableCollection<GameSave.ModeType> ModeTypes { get; } =
new(Enum.GetValues(typeof(GameSave.ModeType)).Cast<GameSave.ModeType>());
/// <summary>
/// 含有名称的动作列表
/// </summary>
public static HashSet<GraphInfo.GraphType> HasNameAnimes { get; } =
new()
{
@ -31,6 +45,9 @@ public class AnimeTypeModel
GraphInfo.GraphType.Say
};
/// <summary>
/// 含有不同动画类型的动作列表
/// </summary>
public static HashSet<GraphInfo.GraphType> HasMultiTypeAnimes { get; } =
new()
{
@ -47,14 +64,39 @@ public class AnimeTypeModel
GraphInfo.GraphType.Say
};
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 名称
/// </summary>
public ObservableValue<string> Name { get; } = new();
/// <summary>
/// 动作类型
/// </summary>
public ObservableValue<GraphInfo.GraphType> GraphType { get; } = new();
/// <summary>
/// 开心动画
/// </summary>
public ObservableCollection<AnimeModel> HappyAnimes { get; } = new();
/// <summary>
/// 普通动画 (默认)
/// </summary>
public ObservableCollection<AnimeModel> NomalAnimes { get; } = new();
/// <summary>
/// 低状态动画
/// </summary>
public ObservableCollection<AnimeModel> PoorConditionAnimes { get; } = new();
/// <summary>
/// 生病动画
/// </summary>
public ObservableCollection<AnimeModel> IllAnimes { get; } = new();
public AnimeTypeModel()
@ -81,6 +123,12 @@ public class AnimeTypeModel
IllAnimes.Add(anime.Copy());
}
/// <summary>
/// 创建动画类型模型
/// </summary>
/// <param name="graphType">动作类型</param>
/// <param name="path">路径</param>
/// <returns></returns>
public static AnimeTypeModel? Create(GraphInfo.GraphType graphType, string path)
{
try
@ -132,6 +180,10 @@ public class AnimeTypeModel
}
#region Load
/// <summary>
/// 默认载入方式 (只有一个动画类型 <see cref="GraphInfo.AnimatType.Single"/>)
/// </summary>
/// <param name="path">路径</param>
private void LoadDefault(string path)
{
foreach (var dir in Directory.EnumerateDirectories(path))
@ -180,6 +232,10 @@ public class AnimeTypeModel
}
}
/// <summary>
/// 有多个动画类型的载入方式
/// </summary>
/// <param name="path">路径</param>
private void LoadMultiType(string path)
{
foreach (var dir in Directory.EnumerateDirectories(path))
@ -242,6 +298,12 @@ public class AnimeTypeModel
}
}
/// <summary>
/// 添加动画到不同模式
/// </summary>
/// <param name="path">路径</param>
/// <param name="modeType">模式类型</param>
/// <param name="animeType">动画类型</param>
private void AddAnimeForModeType(
string path,
GameSave.ModeType modeType,
@ -277,6 +339,12 @@ public class AnimeTypeModel
};
}
/// <summary>
/// 添加动画至动画列表
/// </summary>
/// <param name="collection">动画列表</param>
/// <param name="path">路径</param>
/// <param name="animatType">动画类型</param>
private static void AddAnime(
ObservableCollection<AnimeModel> collection,
string path,
@ -285,12 +353,14 @@ public class AnimeTypeModel
{
if (Directory.EnumerateFiles(path).Any())
{
// 如果没有文件夹 则载入全部文件
var animeModel = new AnimeModel(path);
animeModel.AnimeType.Value = animatType;
collection.Add(animeModel);
}
else
{
// 否则遍历文件夹
foreach (var imagesDir in Directory.EnumerateDirectories(path))
{
var animeModel = new AnimeModel(imagesDir);
@ -301,6 +371,10 @@ public class AnimeTypeModel
}
#endregion
#region Save
/// <summary>
/// 保存至指定路径
/// </summary>
/// <param name="path">路径</param>
public void Save(string path)
{
if (
@ -330,7 +404,7 @@ public class AnimeTypeModel
is GraphInfo.GraphType.Raised_Dynamic
or GraphInfo.GraphType.Raised_Static
)
SaveRaise(path, this);
SaveRaised(path, this);
else if (GraphType.Value is GraphInfo.GraphType.StateONE or GraphInfo.GraphType.StateTWO)
SaveState(path, this);
else if (GraphType.Value is GraphInfo.GraphType.Common)
@ -339,6 +413,11 @@ public class AnimeTypeModel
SaveHasNameAnime(path, this);
}
/// <summary>
/// 保存为带有名称的动画样式
/// </summary>
/// <param name="path">路径</param>
/// <param name="animeTypeModel">动画模型</param>
void SaveHasNameAnime(string path, AnimeTypeModel animeTypeModel)
{
var animeTypePath = Path.Combine(path, animeTypeModel.GraphType.Value.ToString());
@ -348,6 +427,11 @@ public class AnimeTypeModel
SaveWithModeType(animePath, animeTypeModel);
}
/// <summary>
/// 保存为通用样式
/// </summary>
/// <param name="path">路径</param>
/// <param name="animeTypeModel">模型</param>
void SaveCommon(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, animeTypeModel.Name.Value);
@ -355,6 +439,11 @@ public class AnimeTypeModel
SaveWithModeType(animePath, animeTypeModel);
}
/// <summary>
/// 保存为 <see cref="GraphInfo.GraphType.StateONE"/> 或 <see cref="GraphInfo.GraphType.StateTWO"/> 样式
/// </summary>
/// <param name="path">路径</param>
/// <param name="animeTypeModel">模型</param>
void SaveState(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, "State");
@ -362,7 +451,12 @@ public class AnimeTypeModel
SaveMultiType(animePath, animeTypeModel);
}
void SaveRaise(string path, AnimeTypeModel animeTypeModel)
/// <summary>
/// 保存为 <see cref="GraphInfo.GraphType.Raised_Dynamic"/> 或 <see cref="GraphInfo.GraphType.Raised_Static"/> 样式
/// </summary>
/// <param name="path">路径</param>
/// <param name="animeTypeModel">模型</param>
void SaveRaised(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, "Raise");
Directory.CreateDirectory(animePath);
@ -372,6 +466,11 @@ public class AnimeTypeModel
SaveMultiType(animePath, animeTypeModel);
}
/// <summary>
/// 保存为 <see cref="GraphInfo.GraphType.Switch_Up"/> 或 <see cref="GraphInfo.GraphType.Switch_Down"/> 或 <see cref="GraphInfo.GraphType.Switch_Thirsty"/> 或 <see cref="GraphInfo.GraphType.Switch_Hunger"/>
/// </summary>
/// <param name="path">路径</param>
/// <param name="animeTypeModel">模型</param>
void SaveSwitch(string path, AnimeTypeModel animeTypeModel)
{
var animePath = Path.Combine(path, "Switch");
@ -405,17 +504,7 @@ public class AnimeTypeModel
}
/// <summary>
/// 保存为 ModeType 划分的样式
/// <para><![CDATA[
/// Happy/A/0
/// Happy/A/1
/// Happy/B/0
/// Happy/B/1
/// Nomal/A/0
/// Nomal/A/1
/// ...
/// ]]>
/// </para>
/// 保存为 Happy/A/0 的路径样式
/// </summary>
/// <param name="path"></param>
/// <param name="animeTypeModel"></param>
@ -476,15 +565,7 @@ public class AnimeTypeModel
}
/// <summary>
/// 保存为 AnimeType 划分的样式
/// <para><![CDATA[
/// Happy/0
/// Happy/1
/// Nomal/0
/// Nomal/1
/// ...
/// ]]>
/// </para>
/// 保存为 Happy/0 的路径样式
/// </summary>
/// <param name="animePath"></param>
/// <param name="animeType"></param>

View File

@ -10,31 +10,95 @@ using VPet_Simulator.Windows.Interface;
namespace VPet.ModMaker.Models;
/// <summary>
/// 点击文本模型
/// </summary>
public class ClickTextModel : I18nModel<I18nClickTextModel>
{
/// <summary>
/// 模式类型
/// </summary>
public static ObservableCollection<ClickText.ModeType> ModeTypes { get; } =
new(Enum.GetValues(typeof(ClickText.ModeType)).Cast<ClickText.ModeType>());
/// <summary>
/// 日期区间
/// </summary>
public static ObservableCollection<ClickText.DayTime> DayTimes { get; } =
new(Enum.GetValues(typeof(ClickText.DayTime)).Cast<ClickText.DayTime>());
/// <summary>
/// 工作状态
/// </summary>
public static ObservableCollection<VPet_Simulator.Core.Main.WorkingState> WorkingStates { get; } =
new(
Enum.GetValues(typeof(VPet_Simulator.Core.Main.WorkingState))
.Cast<VPet_Simulator.Core.Main.WorkingState>()
);
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 指定工作
/// </summary>
public ObservableValue<string> Working { get; } = new();
/// <summary>
/// 模式
/// </summary>
public ObservableEnumFlags<ClickText.ModeType> Mode { get; } = new();
/// <summary>
/// 工作状态
/// </summary>
public ObservableValue<VPet_Simulator.Core.Main.WorkingState> WorkingState { get; } = new();
/// <summary>
/// 日期区间
/// </summary>
public ObservableEnumFlags<ClickText.DayTime> DayTime { get; } = new();
/// <summary>
/// 好感度
/// </summary>
public ObservableRange<double> Like { get; } = new(0, int.MaxValue);
/// <summary>
/// 健康值
/// </summary>
public ObservableRange<double> Health { get; } = new(0, int.MaxValue);
/// <summary>
/// 等级
/// </summary>
public ObservableRange<double> Level { get; } = new(0, int.MaxValue);
/// <summary>
/// 金钱
/// </summary>
public ObservableRange<double> Money { get; } = new(int.MinValue, int.MaxValue);
/// <summary>
/// 饱食度
/// </summary>
public ObservableRange<double> Food { get; } = new(0, int.MaxValue);
/// <summary>
/// 口渴度
/// </summary>
public ObservableRange<double> Drink { get; } = new(0, int.MaxValue);
/// <summary>
/// 心情
/// </summary>
public ObservableRange<double> Feel { get; } = new(0, int.MaxValue);
/// <summary>
/// 体力
/// </summary>
public ObservableRange<double> Strength { get; } = new(0, int.MaxValue);
public ClickTextModel() { }

View File

@ -11,23 +11,80 @@ using VPet_Simulator.Windows.Interface;
namespace VPet.ModMaker.Models;
/// <summary>
/// 食物模型
/// </summary>
public class FoodModel : I18nModel<I18nFoodModel>
{
/// <summary>
/// 食物类型
/// </summary>
public static ObservableCollection<Food.FoodType> FoodTypes { get; } =
new(Enum.GetValues(typeof(Food.FoodType)).Cast<Food.FoodType>());
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 详情Id
/// </summary>
public ObservableValue<string> DescriptionId { get; } = new();
/// <summary>
/// 指定动画
/// </summary>
public ObservableValue<string> Graph { get; } = new("eat");
/// <summary>
/// 类型
/// </summary>
public ObservableValue<Food.FoodType> Type { get; } = new();
/// <summary>
/// 体力
/// </summary>
public ObservableValue<double> Strength { get; } = new();
/// <summary>
/// 饱食度
/// </summary>
public ObservableValue<double> StrengthFood { get; } = new();
/// <summary>
/// 口渴度
/// </summary>
public ObservableValue<double> StrengthDrink { get; } = new();
/// <summary>
/// 心情
/// </summary>
public ObservableValue<double> Feeling { get; } = new();
/// <summary>
/// 健康度
/// </summary>
public ObservableValue<double> Health { get; } = new();
/// <summary>
/// 好感度
/// </summary>
public ObservableValue<double> Likability { get; } = new();
/// <summary>
/// 价格
/// </summary>
public ObservableValue<double> Price { get; } = new();
/// <summary>
/// 经验
/// </summary>
public ObservableValue<int> Exp { get; } = new();
/// <summary>
/// 图片
/// </summary>
public ObservableValue<BitmapImage> Image { get; } = new();
public FoodModel()

View File

@ -8,9 +8,19 @@ using System.Windows.Media.Imaging;
namespace VPet.ModMaker.Models.ModModel;
/// <summary>
/// 图像模型
/// </summary>
public class ImageModel
{
/// <summary>
/// 图像
/// </summary>
public ObservableValue<BitmapImage> Image { get; } = new();
/// <summary>
/// 持续时间
/// </summary>
public ObservableValue<int> Duration { get; } = new(100);
public ImageModel(BitmapImage image, int duration = 100)

View File

@ -10,18 +10,47 @@ using VPet_Simulator.Windows.Interface;
namespace VPet.ModMaker.Models;
/// <summary>
/// 低状态文本
/// </summary>
public class LowTextModel : I18nModel<I18nLowTextModel>
{
/// <summary>
/// 状态类型
/// </summary>
public static ObservableCollection<LowText.ModeType> ModeTypes { get; } =
new(Enum.GetValues(typeof(LowText.ModeType)).Cast<LowText.ModeType>());
/// <summary>
/// 好感度类型
/// </summary>
public static ObservableCollection<LowText.LikeType> LikeTypes { get; } =
new(Enum.GetValues(typeof(LowText.LikeType)).Cast<LowText.LikeType>());
/// <summary>
/// 体力类型
/// </summary>
public static ObservableCollection<LowText.StrengthType> StrengthTypes { get; } =
new(Enum.GetValues(typeof(LowText.StrengthType)).Cast<LowText.StrengthType>());
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 状态
/// </summary>
public ObservableValue<LowText.ModeType> Mode { get; } = new();
/// <summary>
/// 体力
/// </summary>
public ObservableValue<LowText.StrengthType> Strength { get; } = new();
/// <summary>
/// 好感度
/// </summary>
public ObservableValue<LowText.LikeType> Like { get; } = new();
public LowTextModel() { }

View File

@ -20,7 +20,7 @@ public static class Utils
public const int DecodePixelWidth = 250;
/// <summary>
/// 码像素高度
/// 码像素高度
/// </summary>
public const int DecodePixelHeight = 250;
public static char[] Separator { get; } = new char[] { '_' };