using HKW.HKWViewModels.SimpleObservable; using LinePutScript; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using VPet_Simulator.Core; namespace VPet.ModMaker.Models.ModModel; public class FoodAnimeModel { /// /// Id /// public ObservableValue Id { get; } = new(); public ObservableValue Mode { get; } /// /// 后图像列表 /// public ObservableCollection BackImages { get; set; } = new(); public ObservableValue BackImagesPath { get; } = new(); /// /// 前图像列表 /// public ObservableCollection FrontImages { get; set; } = new(); public ObservableValue FrontImagesPath { get; } = new(); /// /// 食物定位列表 /// public ObservableCollection FoodLocations { get; } = new(); public FoodAnimeModel() { } public FoodAnimeModel(ILine line) : this() { foreach (var item in line.Where(i => i.Name.StartsWith("a"))) { //var index = int.Parse(item.Name.Substring(1)); var infos = item.Info.Split(','); var foodLocationInfo = new FoodLocationModel(); foodLocationInfo.Duration.Value = int.Parse(infos[0]); if (infos.Length > 1) { foodLocationInfo.Rect.SetValue( double.Parse(infos[1]), double.Parse(infos[2]), double.Parse(infos[3]), double.Parse(infos[3]) ); } if (infos.Length > 4) foodLocationInfo.Rotate.Value = double.Parse(infos[4]); if (infos.Length > 5) foodLocationInfo.Opacity.Value = double.Parse(infos[5]); FoodLocations.Add(foodLocationInfo); } } /// /// 复制 /// /// public FoodAnimeModel Copy() { var model = new FoodAnimeModel(); model.Id.Value = Id.Value; foreach (var image in FrontImages) model.FrontImages.Add(image.Copy()); foreach (var image in BackImages) model.BackImages.Add(image.Copy()); foreach (var foodLocation in FoodLocations) model.FoodLocations.Add(foodLocation.Copy()); return model; } /// /// 关闭所有图像流 /// public void Close() { foreach (var image in FrontImages) image.Close(); foreach (var image in BackImages) image.Close(); } } public class FoodImagesPath { public ObservableValue Mode { get; } = new(); public ObservableValue Index { get; } = new(); }