mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
更新
This commit is contained in:
parent
d4349147d6
commit
72a5843875
@ -21,7 +21,7 @@ public static class Extensions
|
|||||||
return ((FileStream)image.StreamSource).Name;
|
return ((FileStream)image.StreamSource).Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CloseString(this ImageSource source)
|
public static void CloseStream(this ImageSource source)
|
||||||
{
|
{
|
||||||
if (source is BitmapImage image)
|
if (source is BitmapImage image)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ public class ModLoader
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong ItemID { get; }
|
public ulong ItemID { get; }
|
||||||
public string Intro { get; }
|
public string Intro { get; }
|
||||||
public DirectoryInfo Path { get; }
|
public DirectoryInfo ModPath { get; }
|
||||||
public int GameVer { get; }
|
public int GameVer { get; }
|
||||||
public int Ver { get; }
|
public int Ver { get; }
|
||||||
public HashSet<string> Tag { get; } = new();
|
public HashSet<string> Tag { get; } = new();
|
||||||
@ -38,19 +38,18 @@ public class ModLoader
|
|||||||
public List<LowText> LowTexts { get; } = new();
|
public List<LowText> LowTexts { get; } = new();
|
||||||
public List<ClickText> ClickTexts { get; } = new();
|
public List<ClickText> ClickTexts { get; } = new();
|
||||||
public List<SelectText> SelectTexts { get; } = new();
|
public List<SelectText> SelectTexts { get; } = new();
|
||||||
|
public Dictionary<string, GraphCore> MultiGraphs { get; } = new();
|
||||||
|
|
||||||
public Dictionary<string, I18nModInfoModel> I18nDatas { get; } = new();
|
public Dictionary<string, I18nModInfoModel> I18nDatas { get; } = new();
|
||||||
|
|
||||||
public Dictionary<string, Dictionary<string, string>> OtherI18nDatas { get; } = new();
|
public Dictionary<string, Dictionary<string, string>> OtherI18nDatas { get; } = new();
|
||||||
|
|
||||||
public ModLoader(DirectoryInfo directory)
|
public ModLoader(DirectoryInfo path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Path = directory;
|
ModPath = path;
|
||||||
LpsDocument modlps = new LpsDocument(
|
LpsDocument modlps = new LpsDocument(File.ReadAllText(path.FullName + @"\info.lps"));
|
||||||
File.ReadAllText(directory.FullName + @"\info.lps")
|
|
||||||
);
|
|
||||||
Name = modlps.FindLine("vupmod").Info;
|
Name = modlps.FindLine("vupmod").Info;
|
||||||
Intro = modlps.FindLine("intro").Info;
|
Intro = modlps.FindLine("intro").Info;
|
||||||
GameVer = modlps.FindSub("gamever").InfoToInt;
|
GameVer = modlps.FindSub("gamever").InfoToInt;
|
||||||
@ -80,7 +79,7 @@ public class ModLoader
|
|||||||
I18nDatas.Add(line.Info, i18nData);
|
I18nDatas.Add(line.Info, i18nData);
|
||||||
}
|
}
|
||||||
DirectoryInfo? langDirectory = null;
|
DirectoryInfo? langDirectory = null;
|
||||||
foreach (DirectoryInfo di in Path.EnumerateDirectories())
|
foreach (DirectoryInfo di in path.EnumerateDirectories())
|
||||||
{
|
{
|
||||||
switch (di.Name.ToLower())
|
switch (di.Name.ToLower())
|
||||||
{
|
{
|
||||||
@ -93,7 +92,16 @@ public class ModLoader
|
|||||||
if (lps.First().Name.ToLower() == "pet")
|
if (lps.First().Name.ToLower() == "pet")
|
||||||
{
|
{
|
||||||
var name = lps.First().Info;
|
var name = lps.First().Info;
|
||||||
Pets.Add(new PetLoader(lps, di));
|
var pet = new PetLoader(lps, di);
|
||||||
|
Pets.Add(pet);
|
||||||
|
// 此方法会导致 LoadImageToStream 无法使用
|
||||||
|
//var graphCore = new GraphCore(0);
|
||||||
|
//foreach (var p in pet.path)
|
||||||
|
// PetLoader.LoadGraph(graphCore, di, p);
|
||||||
|
//MultiGraphs.Add(pet.Name, graphCore);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var p = mw.Pets.FirstOrDefault(x => x.Id == name);
|
//var p = mw.Pets.FirstOrDefault(x => x.Id == name);
|
||||||
//if (p == null)
|
//if (p == null)
|
||||||
// mw.Pets.Add(new PetLoader(lps, di));
|
// mw.Pets.Add(new PetLoader(lps, di));
|
||||||
@ -113,7 +121,7 @@ public class ModLoader
|
|||||||
foreach (ILine li in tmp)
|
foreach (ILine li in tmp)
|
||||||
{
|
{
|
||||||
var food = LPSConvert.DeserializeObject<Food>(li);
|
var food = LPSConvert.DeserializeObject<Food>(li);
|
||||||
var imagePath = $"{Path.FullName}\\image\\food\\{food.Name}.png";
|
var imagePath = $"{path.FullName}\\image\\food\\{food.Name}.png";
|
||||||
if (File.Exists(imagePath))
|
if (File.Exists(imagePath))
|
||||||
food.Image = imagePath;
|
food.Image = imagePath;
|
||||||
Foods.Add(food);
|
Foods.Add(food);
|
||||||
@ -208,7 +216,7 @@ public class ModLoader
|
|||||||
|
|
||||||
public void WriteFile()
|
public void WriteFile()
|
||||||
{
|
{
|
||||||
var lps = new LpsDocument(File.ReadAllText(Path.FullName + @"\info.lps"));
|
var lps = new LpsDocument(File.ReadAllText(ModPath.FullName + @"\info.lps"));
|
||||||
lps.FindLine("vupmod").Info = Name;
|
lps.FindLine("vupmod").Info = Name;
|
||||||
lps.FindLine("intro").Info = Intro;
|
lps.FindLine("intro").Info = Intro;
|
||||||
lps.FindSub("gamever").InfoToInt = GameVer;
|
lps.FindSub("gamever").InfoToInt = GameVer;
|
||||||
@ -216,6 +224,6 @@ public class ModLoader
|
|||||||
lps.FindSub("author").Info = Author;
|
lps.FindSub("author").Info = Author;
|
||||||
lps.FindorAddLine("authorid").InfoToInt64 = AuthorID;
|
lps.FindorAddLine("authorid").InfoToInt64 = AuthorID;
|
||||||
lps.FindorAddLine("itemid").info = ItemID.ToString();
|
lps.FindorAddLine("itemid").info = ItemID.ToString();
|
||||||
File.WriteAllText(Path.FullName + @"\info.lps", lps.ToString());
|
File.WriteAllText(ModPath.FullName + @"\info.lps", lps.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,5 @@ public static class ModMakerInfo
|
|||||||
{
|
{
|
||||||
public const string BaseDirectory = nameof(ModMaker);
|
public const string BaseDirectory = nameof(ModMaker);
|
||||||
public const string HistoryFile = $"{BaseDirectory}\\history.lps";
|
public const string HistoryFile = $"{BaseDirectory}\\history.lps";
|
||||||
|
public const string InfoFile = "info.lps";
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,36 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using VPet_Simulator.Core;
|
||||||
|
using static VPet_Simulator.Core.GraphInfo;
|
||||||
|
|
||||||
namespace VPet.ModMaker.Models.ModModel;
|
namespace VPet.ModMaker.Models.ModModel;
|
||||||
|
|
||||||
public class AnimeModel
|
public class AnimeModel
|
||||||
{
|
{
|
||||||
public ObservableValue<ImageModel> CurrentImageModel { get; } = new();
|
public ObservableValue<string> Id { get; } = new();
|
||||||
public ObservableCollection<ImageModel> ImageModels { get; } = new();
|
public ObservableValue<GraphInfo.AnimatType> AnimeType { get; } = new();
|
||||||
|
|
||||||
|
public ObservableCollection<ObservableCollection<ImageModel>> MultiHappyImageModels = new();
|
||||||
|
public ObservableCollection<ObservableCollection<ImageModel>> MultiNomalImageModels = new();
|
||||||
|
public ObservableCollection<ObservableCollection<ImageModel>> MultiPoorConditionImageModels =
|
||||||
|
new();
|
||||||
|
public ObservableCollection<ObservableCollection<ImageModel>> MultiIllImageModels = new();
|
||||||
|
|
||||||
|
public AnimeModel() { }
|
||||||
|
|
||||||
|
public AnimeModel(string name, AnimatType animatType, IList<IGraph> graphList)
|
||||||
|
{
|
||||||
|
Id.Value = name;
|
||||||
|
AnimeType.Value = animatType;
|
||||||
|
foreach (IGraph graph in graphList)
|
||||||
|
{
|
||||||
|
//if(graph.)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System.Collections.Specialized;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using VPet_Simulator.Windows.Interface;
|
using VPet_Simulator.Windows.Interface;
|
||||||
@ -50,13 +51,15 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
|||||||
public ModInfoModel(ModLoader loader)
|
public ModInfoModel(ModLoader loader)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
SourcePath.Value = loader.Path.FullName;
|
SourcePath.Value = loader.ModPath.FullName;
|
||||||
Id.Value = loader.Name;
|
Id.Value = loader.Name;
|
||||||
DescriptionId.Value = loader.Intro;
|
DescriptionId.Value = loader.Intro;
|
||||||
Author.Value = loader.Author;
|
Author.Value = loader.Author;
|
||||||
GameVersion.Value = loader.GameVer.ToString();
|
GameVersion.Value = loader.GameVer.ToString();
|
||||||
ModVersion.Value = loader.Ver.ToString();
|
ModVersion.Value = loader.Ver.ToString();
|
||||||
var imagePath = Path.Combine(loader.Path.FullName, "icon.png");
|
var imagePath = Path.Combine(loader.ModPath.FullName, "icon.png");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
GC.Collect();
|
||||||
if (File.Exists(imagePath))
|
if (File.Exists(imagePath))
|
||||||
Image.Value = Utils.LoadImageToStream(imagePath);
|
Image.Value = Utils.LoadImageToStream(imagePath);
|
||||||
foreach (var food in loader.Foods)
|
foreach (var food in loader.Foods)
|
||||||
@ -243,7 +246,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
|||||||
new Line("pet", pet.Id.Value)
|
new Line("pet", pet.Id.Value)
|
||||||
{
|
{
|
||||||
new Sub("intor", pet.DescriptionId.Value),
|
new Sub("intor", pet.DescriptionId.Value),
|
||||||
new Sub("path", pet.Id.Value),
|
new Sub("ModPath", pet.Id.Value),
|
||||||
new Sub("petname", pet.PetNameId.Value)
|
new Sub("petname", pet.PetNameId.Value)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -7,6 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using VPet.ModMaker.Models.ModModel;
|
||||||
using VPet_Simulator.Core;
|
using VPet_Simulator.Core;
|
||||||
|
|
||||||
namespace VPet.ModMaker.Models;
|
namespace VPet.ModMaker.Models;
|
||||||
@ -24,6 +25,10 @@ public class PetModel : I18nModel<I18nPetInfoModel>
|
|||||||
|
|
||||||
public ObservableCollection<MoveModel> Moves { get; } = new();
|
public ObservableCollection<MoveModel> Moves { get; } = new();
|
||||||
|
|
||||||
|
public ObservableValue<AnimeModel> CurrentAnime { get; } = new();
|
||||||
|
public Dictionary<GraphInfo.GraphType, ObservableCollection<AnimeModel>> Animes { get; } =
|
||||||
|
new();
|
||||||
|
|
||||||
public PetModel()
|
public PetModel()
|
||||||
{
|
{
|
||||||
PetNameId.Value = $"{Id.Value}_{nameof(PetNameId)}";
|
PetNameId.Value = $"{Id.Value}_{nameof(PetNameId)}";
|
||||||
@ -112,6 +117,20 @@ public class PetModel : I18nModel<I18nPetInfoModel>
|
|||||||
Moves.Add(new(move));
|
Moves.Add(new(move));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadAnime(GraphCore core)
|
||||||
|
{
|
||||||
|
foreach (var info in core.GraphsName)
|
||||||
|
{
|
||||||
|
var list = new ObservableCollection<AnimeModel>();
|
||||||
|
foreach (var name in info.Value)
|
||||||
|
{
|
||||||
|
foreach (var graph in core.GraphsList[name])
|
||||||
|
list.Add(new AnimeModel(name, graph.Key, graph.Value));
|
||||||
|
}
|
||||||
|
Animes.Add(info.Key, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Close() { }
|
public void Close() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,14 @@ public static class Utils
|
|||||||
{
|
{
|
||||||
BitmapImage bitmapImage = new();
|
BitmapImage bitmapImage = new();
|
||||||
bitmapImage.BeginInit();
|
bitmapImage.BeginInit();
|
||||||
|
try
|
||||||
|
{
|
||||||
bitmapImage.StreamSource = new StreamReader(imagePath).BaseStream;
|
bitmapImage.StreamSource = new StreamReader(imagePath).BaseStream;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
bitmapImage.EndInit();
|
bitmapImage.EndInit();
|
||||||
|
}
|
||||||
return bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,11 +35,17 @@ public static class Utils
|
|||||||
{
|
{
|
||||||
BitmapImage bitmapImage = new();
|
BitmapImage bitmapImage = new();
|
||||||
bitmapImage.BeginInit();
|
bitmapImage.BeginInit();
|
||||||
|
try
|
||||||
|
{
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
using var sr = new StreamReader(imagePath);
|
using var sr = new StreamReader(imagePath);
|
||||||
sr.BaseStream.CopyTo(ms);
|
sr.BaseStream.CopyTo(ms);
|
||||||
bitmapImage.StreamSource = ms;
|
bitmapImage.StreamSource = ms;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
bitmapImage.EndInit();
|
bitmapImage.EndInit();
|
||||||
|
}
|
||||||
return bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ public class AnimeEditWindowVM
|
|||||||
{
|
{
|
||||||
public AnimeModel OldAnime { get; set; }
|
public AnimeModel OldAnime { get; set; }
|
||||||
public ObservableValue<AnimeModel> Anime { get; } = new(new());
|
public ObservableValue<AnimeModel> Anime { get; } = new(new());
|
||||||
|
|
||||||
|
public ObservableValue<ImageModel> CurrentImageModel { get; } = new();
|
||||||
#region Command
|
#region Command
|
||||||
public ObservableCommand PlayCommand { get; } = new();
|
public ObservableCommand PlayCommand { get; } = new();
|
||||||
public ObservableCommand PauseCommand { get; } = new();
|
public ObservableCommand PauseCommand { get; } = new();
|
||||||
@ -24,14 +26,14 @@ public class AnimeEditWindowVM
|
|||||||
|
|
||||||
public AnimeEditWindowVM()
|
public AnimeEditWindowVM()
|
||||||
{
|
{
|
||||||
foreach (
|
//foreach (
|
||||||
var file in Directory.EnumerateFiles(
|
// var file in Directory.EnumerateFiles(
|
||||||
@"C:\Users\HKW\Desktop\TestPicture\0000_core\pet\vup\Default\Happy\1"
|
// @"C:\Users\HKW\Desktop\TestPicture\0000_core\pet\vup\Default\Happy\1"
|
||||||
)
|
// )
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
Anime.Value.ImageModels.Add(new(Utils.LoadImageToMemoryStream(file)));
|
// Anime.Value.MultiImageModels.Add(new(Utils.LoadImageToMemoryStream(file)));
|
||||||
}
|
//}
|
||||||
_playerTask = new(Play);
|
_playerTask = new(Play);
|
||||||
PlayCommand.ExecuteEvent += PlayCommand_ExecuteEvent;
|
PlayCommand.ExecuteEvent += PlayCommand_ExecuteEvent;
|
||||||
PauseCommand.ExecuteEvent += PauseCommand_ExecuteEvent;
|
PauseCommand.ExecuteEvent += PauseCommand_ExecuteEvent;
|
||||||
@ -49,13 +51,13 @@ public class AnimeEditWindowVM
|
|||||||
|
|
||||||
private void Play()
|
private void Play()
|
||||||
{
|
{
|
||||||
while (_pause is false)
|
//while (_pause is false)
|
||||||
{
|
//{
|
||||||
foreach (var model in Anime.Value.ImageModels)
|
// foreach (var model in Anime.Value.ImageModels)
|
||||||
{
|
// {
|
||||||
Anime.Value.CurrentImageModel.Value = model;
|
// Anime.Value.CurrentImageModel.Value = model;
|
||||||
Task.Delay(model.Duration.Value).Wait();
|
// Task.Delay(model.Duration.Value).Wait();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public partial class ModMakerWindow : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new ModMakerWindowVM(this);
|
DataContext = new ModMakerWindowVM(this);
|
||||||
new AnimeEditWindow().Show();
|
//new AnimeEditWindow().Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListBoxItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void ListBoxItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user