This commit is contained in:
Hakoyu 2023-10-07 22:30:34 +08:00
parent 530f32e3f6
commit 4c311c2d70
5 changed files with 416 additions and 55 deletions

View File

@ -18,29 +18,95 @@ using VPet_Simulator.Windows.Interface;
namespace VPet.ModMaker.Models;
/// <summary>
/// 模组信息模型
/// </summary>
public class ModInfoModel : I18nModel<I18nModInfoModel>
{
/// <summary>
/// 作者Id
/// </summary>
public long AuthorID { get; }
/// <summary>
/// 项目Id
/// </summary>
public ulong ItemID { get; }
/// <summary>
/// 当前
/// </summary>
public static ModInfoModel Current { get; set; } = new();
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 描述Id
/// </summary>
public ObservableValue<string> DescriptionId { get; } = new();
/// <summary>
/// 作者
/// </summary>
public ObservableValue<string> Author { get; } = new();
/// <summary>
/// 支持的游戏版本
/// </summary>
public ObservableValue<string> GameVersion { get; } = new();
/// <summary>
/// 模组版本
/// </summary>
public ObservableValue<string> ModVersion { get; } = new();
/// <summary>
/// 封面
/// </summary>
public ObservableValue<BitmapImage> Image { get; } = new();
/// <summary>
/// 源路径
/// </summary>
public ObservableValue<string> SourcePath { get; } = new();
/// <summary>
/// 食物
/// </summary>
public ObservableCollection<FoodModel> Foods { get; } = new();
/// <summary>
/// 点击文本
/// </summary>
public ObservableCollection<ClickTextModel> ClickTexts { get; } = new();
/// <summary>
/// 低状态文本
/// </summary>
public ObservableCollection<LowTextModel> LowTexts { get; } = new();
/// <summary>
/// 选择文本
/// </summary>
public ObservableCollection<SelectTextModel> SelectTexts { get; } = new();
/// <summary>
/// 宠物
/// </summary>
public ObservableCollection<PetModel> Pets { get; } = new();
/// <summary>
/// 其它I18n数据
/// </summary>
public Dictionary<string, Dictionary<string, string>> OtherI18nDatas { get; } = new();
/// <summary>
/// 需要保存的I18n数据
/// </summary>
private readonly Dictionary<string, Dictionary<string, string>> _saveI18nDatas = new();
public ModInfoModel()
@ -93,6 +159,11 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
#region Load
/// <summary>
/// 加载宠物动画
/// </summary>
/// <param name="petModel">模型</param>
/// <param name="path">路径</param>
static void LoadAnime(PetModel petModel, string path)
{
foreach (var animeDir in Directory.EnumerateDirectories(path))
@ -170,6 +241,9 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
/// <summary>
/// 加载本地化数据
/// </summary>
private void LoadI18nData()
{
foreach (var lang in I18nDatas)
@ -231,12 +305,35 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
#endregion
#region Save
/// <summary>
/// 保存
/// </summary>
public void Save()
{
SaveTo(SourcePath.Value);
}
/// <summary>
/// 保存至路径
/// </summary>
/// <param name="path">路径</param>
public void SaveTo(string path)
{
// 保存模型信息
SaveModInfo(path);
// 保存模组数据
SavePets(path);
SaveFoods(path);
SaveText(path);
SaveI18nData(path);
SaveImage(path);
}
/// <summary>
/// 保存模型信息
/// </summary>
/// <param name="path">路径</param>
private void SaveModInfo(string path)
{
var modInfoFile = Path.Combine(path, ModMakerInfo.InfoFile);
if (File.Exists(modInfoFile) is false)
@ -246,7 +343,6 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
foreach (var cultureName in I18nHelper.Current.CultureNames)
_saveI18nDatas.Add(cultureName, new());
//var lps = new LpsDocument(File.ReadAllText(modInfoFile));
var lps = new LPS()
{
new Line("vupmod", Id.Value)
@ -272,13 +368,13 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
Image.Value?.SaveToPng(Path.Combine(path, "icon.png"));
File.WriteAllText(modInfoFile, lps.ToString());
SavePets(path);
SaveFoods(path);
SaveText(path);
SaveLang(path);
SaveImage(path);
}
#region SavePet
/// <summary>
/// 保存宠物
/// </summary>
/// <param name="path">路径</param>
private void SavePets(string path)
{
var petPath = Path.Combine(path, "pet");
@ -310,9 +406,9 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
if (File.Exists(petFile) is false)
File.Create(petFile).Close();
var lps = new LPS();
GetPetInfo(lps, pet);
GetWorksInfo(lps, pet);
GetMoveInfo(lps, pet);
SavePetInfo(lps, pet);
SaveWorksInfo(lps, pet);
SaveMoveInfo(lps, pet);
File.WriteAllText(petFile, lps.ToString());
var petAnimePath = Path.Combine(petPath, pet.Id.Value);
@ -321,7 +417,12 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
void GetMoveInfo(LPS lps, PetModel pet)
/// <summary>
/// 保存移动信息
/// </summary>
/// <param name="lps"></param>
/// <param name="pet"></param>
void SaveMoveInfo(LPS lps, PetModel pet)
{
foreach (var move in pet.Moves)
{
@ -329,7 +430,12 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
void GetWorksInfo(LPS lps, PetModel pet)
/// <summary>
/// 保存工作信息
/// </summary>
/// <param name="lps"></param>
/// <param name="pet"></param>
void SaveWorksInfo(LPS lps, PetModel pet)
{
foreach (var work in pet.Works)
{
@ -344,7 +450,12 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
private void GetPetInfo(LPS lps, PetModel pet)
/// <summary>
/// 保存宠物信息
/// </summary>
/// <param name="lps"></param>
/// <param name="pet"></param>
private void SavePetInfo(LPS lps, PetModel pet)
{
lps.Add(
new Line("pet", pet.Id.Value)
@ -410,7 +521,11 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
);
}
#endregion
/// <summary>
/// 保存食物
/// </summary>
/// <param name="path">路径</param>
private void SaveFoods(string path)
{
var foodPath = Path.Combine(path, "food");
@ -443,6 +558,11 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
File.WriteAllText(foodFile, lps.ToString());
}
#region SaveText
/// <summary>
/// 保存文本
/// </summary>
/// <param name="path">路径</param>
private void SaveText(string path)
{
var textPath = Path.Combine(path, "text");
@ -458,6 +578,10 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
SaveSelectText(textPath);
}
/// <summary>
/// 保存选择文本
/// </summary>
/// <param name="path">路径</param>
private void SaveSelectText(string textPath)
{
if (SelectTexts.Count == 0)
@ -483,6 +607,10 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
File.WriteAllText(textFile, lps.ToString());
}
/// <summary>
/// 保存低状态文本
/// </summary>
/// <param name="path">路径</param>
private void SaveLowText(string textPath)
{
if (LowTexts.Count == 0)
@ -504,6 +632,10 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
File.WriteAllText(textFile, lps.ToString());
}
/// <summary>
/// 保存点击文本
/// </summary>
/// <param name="path">路径</param>
private void SaveClickText(string textPath)
{
if (ClickTexts.Count == 0)
@ -524,8 +656,12 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
File.WriteAllText(textFile, lps.ToString());
}
private void SaveLang(string path)
#endregion
/// <summary>
/// 保存I18n数据
/// </summary>
/// <param name="path">路径</param>
private void SaveI18nData(string path)
{
var langPath = Path.Combine(path, "lang");
Directory.CreateDirectory(langPath);
@ -542,6 +678,10 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
/// <summary>
/// 保存突破
/// </summary>
/// <param name="path">路径</param>
private void SaveImage(string path)
{
var imagePath = Path.Combine(path, "image");
@ -562,8 +702,6 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
Image.Value.CloseStream();
foreach (var food in Foods)
food.Close();
//foreach (var pet in Pets)
// pet.Close();
}
}

View File

@ -9,38 +9,112 @@ using VPet_Simulator.Core;
namespace VPet.ModMaker.Models;
/// <summary>
/// 移动模型
/// </summary>
public class MoveModel
{
/// <summary>
/// 移动类型
/// </summary>
public static ObservableCollection<GraphHelper.Move.DirectionType> DirectionTypes { get; } =
new(
Enum.GetValues(typeof(GraphHelper.Move.DirectionType))
.Cast<GraphHelper.Move.DirectionType>()
);
/// <summary>
/// 模式类型
/// </summary>
public static ObservableCollection<GraphHelper.Move.ModeType> ModeTypes { get; } =
new(Enum.GetValues(typeof(GraphHelper.Move.ModeType)).Cast<GraphHelper.Move.ModeType>());
//public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 指定动画
/// </summary>
public ObservableValue<string> Graph { get; } = new();
/// <summary>
/// 移动距离
/// </summary>
public ObservableValue<int> Distance { get; } = new(5);
/// <summary>
/// 间隔
/// </summary>
public ObservableValue<int> Interval { get; } = new(125);
/// <summary>
/// 定位长度
/// </summary>
public ObservableValue<int> LocateLength { get; } = new();
/// <summary>
/// X速度
/// </summary>
public ObservableValue<int> SpeedX { get; } = new();
/// <summary>
/// Y速度
/// </summary>
public ObservableValue<int> SpeedY { get; } = new();
/// <summary>
/// 左侧检测距离
/// </summary>
public ObservableValue<int> CheckLeft { get; } = new(100);
/// <summary>
/// 右侧检测距离
/// </summary>
public ObservableValue<int> CheckRight { get; } = new(100);
/// <summary>
/// 上方检测距离
/// </summary>
public ObservableValue<int> CheckTop { get; } = new(100);
/// <summary>
/// 下方检测距离
/// </summary>
public ObservableValue<int> CheckBottom { get; } = new(100);
/// <summary>
/// 左侧触发距离
/// </summary>
public ObservableValue<int> TriggerLeft { get; } = new(100);
/// <summary>
/// 右侧触发距离
/// </summary>
public ObservableValue<int> TriggerRight { get; } = new(100);
/// <summary>
/// 上方触发距离
/// </summary>
public ObservableValue<int> TriggerTop { get; } = new(100);
/// <summary>
/// 下方触发距离
/// </summary>
public ObservableValue<int> TriggerBottom { get; } = new(100);
/// <summary>
/// 定位类型
/// </summary>
public ObservableEnumFlags<GraphHelper.Move.DirectionType> LocateType { get; } =
new(GraphHelper.Move.DirectionType.None);
/// <summary>
/// 触发类型
/// </summary>
public ObservableEnumFlags<GraphHelper.Move.DirectionType> TriggerType { get; } =
new(GraphHelper.Move.DirectionType.None);
/// <summary>
/// 模式
/// </summary>
public ObservableEnumFlags<GraphHelper.Move.ModeType> ModeType { get; } =
new(GraphHelper.Move.ModeType.Nomal);

View File

@ -12,13 +12,35 @@ using VPet_Simulator.Core;
namespace VPet.ModMaker.Models;
/// <summary>
/// 宠物模型
/// </summary>
public class PetModel : I18nModel<I18nPetInfoModel>
{
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 宠物名称Id
/// </summary>
public ObservableValue<string> PetNameId { get; } = new();
/// <summary>
/// 描述Id
/// </summary>
public ObservableValue<string> DescriptionId { get; } = new();
/// <summary>
/// 头部点击区域
/// </summary>
public ObservableValue<ObservableRect<double>> TouchHeadRect { get; } =
new(new(159, 16, 189, 178));
/// <summary>
/// 提起区域
/// </summary>
public ObservableValue<ObservableMultiStateRect> TouchRaisedRect { get; } =
new(
new(
@ -28,13 +50,26 @@ public class PetModel : I18nModel<I18nPetInfoModel>
new(0, 200, 500, 300)
)
);
/// <summary>
/// 提起定位
/// </summary>
public ObservableValue<ObservableMultiStatePoint> RaisePoint { get; } =
new(new(new(290, 128), new(290, 128), new(290, 128), new(225, 115)));
/// <summary>
/// 工作
/// </summary>
public ObservableCollection<WorkModel> Works { get; } = new();
/// <summary>
/// 移动
/// </summary>
public ObservableCollection<MoveModel> Moves { get; } = new();
/// <summary>
/// 动画
/// </summary>
public ObservableCollection<AnimeTypeModel> Animes { get; } = new();
public PetModel()

View File

@ -10,37 +10,79 @@ using VPet_Simulator.Windows.Interface;
namespace VPet.ModMaker.Models;
/// <summary>
/// 选择文本模型
/// </summary>
public class SelectTextModel : I18nModel<I18nSelectTextModel>
{
/// <summary>
/// 模式类型
/// </summary>
public static ObservableCollection<ClickText.ModeType> ModeTypes => ClickTextModel.ModeTypes;
//public ObservableValue<int> Exp { get; } = new();
//public ObservableValue<double> Money { get; } = new();
//public ObservableValue<double> Strength { get; } = new();
//public ObservableValue<double> StrengthFood { get; } = new();
//public ObservableValue<double> StrengthDrink { get; } = new();
//public ObservableValue<double> Feeling { get; } = new();
//public ObservableValue<double> Health { get; } = new();
//public ObservableValue<double> Likability { get; } = new();
/// <summary>
/// 标签
/// </summary>
public ObservableValue<string> Tags { get; } = new();
/// <summary>
/// 跳转标签
/// </summary>
public ObservableValue<string> ToTags { get; } = new();
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 选择Id
/// </summary>
public ObservableValue<string> ChooseId { get; } = new();
/// <summary>
/// 模式
/// </summary>
public ObservableEnumFlags<ClickText.ModeType> Mode { get; } = new();
//public ObservableValue<string> Working { get; } = new();
//public ObservableValue<VPet_Simulator.Core.Main.WorkingState> WorkingState { get; } = new();
//public ObservableValue<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 SelectTextModel()
@ -59,9 +101,6 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
Mode.EnumValue.Value = model.Mode.EnumValue.Value;
Tags.Value = model.Tags.Value;
ToTags.Value = model.ToTags.Value;
//Working.EnumValue = model.Working.EnumValue;
//WorkingState.EnumValue = model.WorkingState.EnumValue;
//DayTime.EnumValue = model.DayTime.EnumValue;
Like = model.Like.Copy();
Health = model.Health.Copy();
Level = model.Level.Copy();
@ -84,9 +123,6 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
Mode.EnumValue.Value = text.Mode;
Tags.Value = text.Tags is null ? string.Empty : string.Join(", ", text.Tags);
ToTags.Value = text.ToTags is null ? string.Empty : string.Join(", ", text.ToTags);
//Working.EnumValue = text.Working;
//WorkingState.EnumValue = text.State;
//DayTime.EnumValue = text.DaiTime;
Like.SetValue(text.LikeMin, text.LikeMax);
Health.SetValue(text.HealthMin, text.HealthMax);
Level.SetValue(text.LevelMin, text.LevelMax);
@ -108,9 +144,6 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
Mode = Mode.EnumValue.Value,
Tags = new(Tags.Value.Split(rs_splitChar, StringSplitOptions.RemoveEmptyEntries)),
ToTags = new(ToTags.Value.Split(rs_splitChar, StringSplitOptions.RemoveEmptyEntries)),
//Working = Working.EnumValue,
//State = WorkingState.EnumValue,
//DaiTime = DayTime.EnumValue,
LikeMax = Like.Max.Value,
LikeMin = Like.Min.Value,
HealthMin = Health.Min.Value,

View File

@ -9,43 +9,124 @@ using System.Windows.Media;
namespace VPet.ModMaker.Models;
/// <summary>
/// 工作模型
/// </summary>
public class WorkModel : I18nModel<I18nWorkModel>
{
/// <summary>
/// 工作类型
/// </summary>
public static ObservableCollection<VPet_Simulator.Core.GraphHelper.Work.WorkType> WorkTypes { get; } =
new(
Enum.GetValues(typeof(VPet_Simulator.Core.GraphHelper.Work.WorkType))
.Cast<VPet_Simulator.Core.GraphHelper.Work.WorkType>()
);
/// <summary>
/// Id
/// </summary>
public ObservableValue<string> Id { get; } = new();
/// <summary>
/// 指定动画
/// </summary>
public ObservableValue<string> Graph { get; } = new();
/// <summary>
/// 收获倍率
/// </summary>
public ObservableValue<double> MoneyLevel { get; } = new();
/// <summary>
/// 收获基础
/// </summary>
public ObservableValue<double> MoneyBase { 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<int> LevelLimit { get; } = new();
/// <summary>
/// 时间
/// </summary>
public ObservableValue<int> Time { get; } = new();
/// <summary>
/// 完成奖励倍率
/// </summary>
public ObservableValue<double> FinishBonus { get; } = new();
/// <summary>
/// 是否超模
/// </summary>
public ObservableValue<bool> IsOverLoad { get; } = new();
/// <summary>
/// 类型
/// </summary>
public ObservableValue<VPet_Simulator.Core.GraphHelper.Work.WorkType> WorkType { get; } =
new(VPet_Simulator.Core.GraphHelper.Work.WorkType.Work);
public ObservableValue<string> Id { get; } = new();
public ObservableValue<string> Graph { get; } = new();
public ObservableValue<double> MoneyLevel { get; } = new();
public ObservableValue<double> MoneyBase { get; } = new();
public ObservableValue<double> StrengthFood { get; } = new();
public ObservableValue<double> StrengthDrink { get; } = new();
public ObservableValue<double> Feeling { get; } = new();
public ObservableValue<int> LevelLimit { get; } = new();
public ObservableValue<int> Time { get; } = new();
public ObservableValue<double> FinishBonus { get; } = new();
public ObservableValue<bool> IsOverLoad { get; } = new();
/// <summary>
/// 边框颜色
/// </summary>
public ObservableValue<SolidColorBrush> BorderBrush { get; } =
new(new((Color)ColorConverter.ConvertFromString("#FF0290D5")));
/// <summary>
/// 背景色
/// </summary>
public ObservableValue<SolidColorBrush> Background { get; } =
new(new((Color)ColorConverter.ConvertFromString("#FF81d4fa")));
new(new((Color)ColorConverter.ConvertFromString("#FF81D4FA")));
/// <summary>
/// 前景色
/// </summary>
public ObservableValue<SolidColorBrush> Foreground { get; } =
new(new((Color)ColorConverter.ConvertFromString("#FF0286C6")));
/// <summary>
/// 按钮背景色
/// </summary>
public ObservableValue<SolidColorBrush> ButtonBackground { get; } =
new(new((Color)ColorConverter.ConvertFromString("#AA0286C6")));
public ObservableValue<SolidColorBrush> ButtonForeground { get; } =
new(new((Color)ColorConverter.ConvertFromString("#FFffffff")));
/// <summary>
/// 按钮前景色
/// </summary>
public ObservableValue<SolidColorBrush> ButtonForeground { get; } =
new(new((Color)ColorConverter.ConvertFromString("#FFFFFFFF")));
/// <summary>
/// X位置
/// </summary>
public ObservableValue<double> Left { get; } = new(100);
/// <summary>
/// Y位置
/// </summary>
public ObservableValue<double> Top { get; } = new(160);
/// <summary>
/// 宽度
/// </summary>
public ObservableValue<double> Width { get; } = new(300);
public WorkModel()