mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
存档系统初始化
This commit is contained in:
parent
e7138c4516
commit
37b69b92a9
@ -48,7 +48,7 @@ public class FoodModel : I18nModel<I18nFoodModel>
|
||||
: this()
|
||||
{
|
||||
Name = food.Name;
|
||||
Description = food.Description;
|
||||
Description = food.Desc;
|
||||
Type.Value = food.Type;
|
||||
Strength.Value = food.Strength;
|
||||
StrengthDrink.Value = food.StrengthDrink;
|
||||
|
@ -1,4 +1,6 @@
|
||||
using HKW.HKWViewModels.SimpleObservable;
|
||||
using LinePutScript;
|
||||
using LinePutScript.Converter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -16,8 +18,8 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
||||
{
|
||||
public static ModInfoModel Current { get; set; }
|
||||
|
||||
public ObservableValue<string> Id { get; } = new();
|
||||
|
||||
public ObservableValue<string> Name { get; } = new();
|
||||
public ObservableValue<string> Description { get; } = new();
|
||||
public ObservableValue<string> Summary { get; } = new();
|
||||
public ObservableValue<string> Author { get; } = new();
|
||||
public ObservableValue<string> GameVersion { get; } = new();
|
||||
@ -35,13 +37,14 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
||||
public ModInfoModel(ModLoader loader)
|
||||
{
|
||||
SourcePath.Value = loader.Path.FullName;
|
||||
Id.Value = loader.Name;
|
||||
var imagePath = Path.Combine(loader.Path.FullName, "icon.png");
|
||||
if (File.Exists(imagePath))
|
||||
ModImage.Value = Utils.LoadImageToStream(imagePath);
|
||||
Name.Value = loader.Name;
|
||||
Description.Value = loader.Intro;
|
||||
Author.Value = loader.Author;
|
||||
GameVersion.Value = loader.GameVer.ToString();
|
||||
ModVersion.Value = loader.Ver.ToString();
|
||||
var imagePath = Path.Combine(loader.Path.FullName, "icon.png");
|
||||
if (File.Exists(imagePath))
|
||||
ModImage.Value = Utils.LoadImageToStream(imagePath);
|
||||
foreach (var food in loader.Foods)
|
||||
Foods.Add(new(food));
|
||||
foreach (var clickText in loader.ClickTexts)
|
||||
@ -61,6 +64,77 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
||||
点击文本: {ClickTexts.Count}
|
||||
低状态文本: {LowTexts.Count}";
|
||||
}
|
||||
|
||||
public const string ModInfoFile = "info.lps";
|
||||
|
||||
public void Save()
|
||||
{
|
||||
SaveTo(SourcePath.Value);
|
||||
}
|
||||
|
||||
public void SaveTo(string path)
|
||||
{
|
||||
var modInfoFile = Path.Combine(path, ModInfoFile);
|
||||
if (File.Exists(modInfoFile) is false)
|
||||
File.Create(modInfoFile).Close();
|
||||
//var lps = new LpsDocument(File.ReadAllText(modInfoFile));
|
||||
var lps = new LPS()
|
||||
{
|
||||
new Line("vupmod", Name.Value)
|
||||
{
|
||||
new Sub("author", Author.Value),
|
||||
new Sub("gamever", GameVersion.Value),
|
||||
new Sub("ver", ModVersion.Value)
|
||||
},
|
||||
new Line("authorid", "0"),
|
||||
new Line("itemid", "0"),
|
||||
new Line("cachedate", DateTime.Now.Date.ToString())
|
||||
};
|
||||
//lps.FindLine("vupmod").Info = Name.Value;
|
||||
//lps.FindLine("intro").Info = Description.Value;
|
||||
//lps.FindSub("gamever").Info = GameVersion.Value;
|
||||
//lps.FindSub("ver").Info = ModVersion.Value;
|
||||
//lps.FindSub("author").Info = Author.Value;
|
||||
//lps.FindorAddLine("authorid").InfoToInt64 = 0;
|
||||
//lps.FindorAddLine("itemid").info = "0";
|
||||
File.WriteAllText(modInfoFile, lps.ToString());
|
||||
SaveFoods(path);
|
||||
SaveLang(path);
|
||||
}
|
||||
|
||||
public void SaveFoods(string path)
|
||||
{
|
||||
if (Foods.Count == 0)
|
||||
return;
|
||||
var foodPath = Path.Combine(path, "food");
|
||||
Directory.CreateDirectory(foodPath);
|
||||
var foodFile = Path.Combine(foodPath, "food.lps");
|
||||
if (File.Exists(foodFile) is false)
|
||||
File.Create(foodFile).Close();
|
||||
var lps = new LPS();
|
||||
foreach (var food in Foods)
|
||||
lps.Add(LPSConvert.SerializeObjectToLine<Line>(food.ToFood(), "food"));
|
||||
File.WriteAllText(foodFile, lps.ToString());
|
||||
}
|
||||
|
||||
public void SaveLang(string path)
|
||||
{
|
||||
var langPath = Path.Combine(path, "lang");
|
||||
Directory.CreateDirectory(langPath);
|
||||
foreach (var cultureName in I18nHelper.Current.CultureNames)
|
||||
{
|
||||
var culturePath = Path.Combine(langPath, cultureName);
|
||||
Directory.CreateDirectory(culturePath);
|
||||
var cultureFile = Path.Combine(culturePath, $"{cultureName}.lps");
|
||||
File.Create(cultureFile).Close();
|
||||
var lps = new LPS();
|
||||
foreach (var food in Foods)
|
||||
{
|
||||
lps.Add(new Line(food.Name, food.I18nDatas[cultureName].Name.Value));
|
||||
lps.Add(new Line(food.Description, food.I18nDatas[cultureName].Description.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class I18nModInfoModel
|
||||
|
@ -12,6 +12,7 @@ using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using VPet.ModMaker.Views.ModEdit;
|
||||
using System.Windows;
|
||||
using System.IO;
|
||||
|
||||
namespace VPet.ModMaker.ViewModels.ModEdit;
|
||||
|
||||
@ -176,6 +177,17 @@ public class ModEditWindowVM
|
||||
|
||||
private void SaveTo()
|
||||
{
|
||||
SaveFileDialog saveFileDialog =
|
||||
new()
|
||||
{
|
||||
Title = "保存 模组信息文件,并在文件夹内保存模组数据",
|
||||
Filter = $"LPS文件|*.lps;",
|
||||
DefaultExt = "info.lps"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() is true)
|
||||
{
|
||||
ModInfo.Value.SaveTo(Path.GetDirectoryName(saveFileDialog.FileName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class ModMakerWindowVM
|
||||
if (string.IsNullOrEmpty(value))
|
||||
ShowMods = Mods;
|
||||
else
|
||||
ShowMods = new(Mods.Where(i => i.Id.Value.Contains(value)));
|
||||
ShowMods = new(Mods.Where(i => i.Name.Value.Contains(value)));
|
||||
}
|
||||
|
||||
public void CreateNewMod()
|
||||
|
@ -241,8 +241,14 @@
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
<StackPanel Grid.Row="2">
|
||||
<Button x:Name="Button_Save" Content="保存" />
|
||||
<Button x:Name="Button_SaveTo" Content="保存至" />
|
||||
<Button
|
||||
x:Name="Button_Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
Content="保存" />
|
||||
<Button
|
||||
x:Name="Button_SaveTo"
|
||||
Command="{Binding SaveToCommand}"
|
||||
Content="保存至" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
Loading…
Reference in New Issue
Block a user