mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
更新
This commit is contained in:
parent
3a349aa0b4
commit
c307d50674
@ -1,4 +1,3 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33213.308
|
||||
@ -9,12 +8,15 @@ Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Test|Any CPU = Test|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8F804A27-A57E-4799-801C-4DE96BA153BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8F804A27-A57E-4799-801C-4DE96BA153BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8F804A27-A57E-4799-801C-4DE96BA153BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8F804A27-A57E-4799-801C-4DE96BA153BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8F804A27-A57E-4799-801C-4DE96BA153BC}.Test|Any CPU.ActiveCfg = Test|Any CPU
|
||||
{8F804A27-A57E-4799-801C-4DE96BA153BC}.Test|Any CPU.Build.0 = Test|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -50,7 +50,10 @@ public class ModMaker : MainPlugin
|
||||
ModMakerInfo.GameVersion = MW.version;
|
||||
// 载入本体宠物
|
||||
foreach (var pet in MW.Pets)
|
||||
ModMakerInfo.MainPets.TryAdd(pet.Name, new(pet, true));
|
||||
ModMakerInfo.MainPets.TryAdd(
|
||||
pet.Name,
|
||||
new(pet, true) { I18nResource = ModInfoModel.Current.I18nResource }
|
||||
);
|
||||
//Maker.ModMaker = this;
|
||||
Maker.Show();
|
||||
Maker.Closed += Maker_Closed;
|
||||
|
@ -36,7 +36,7 @@ public static class ModMakerInfo
|
||||
/// <summary>
|
||||
/// 本体的宠物
|
||||
/// <para>
|
||||
/// (PetId, PetModel)
|
||||
/// (PetID, PetModel)
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static Dictionary<string, PetModel> MainPets { get; } = new();
|
||||
|
@ -19,12 +19,7 @@ namespace VPet.ModMaker.Models;
|
||||
/// </summary>
|
||||
public class ClickTextModel : ObservableObjectX
|
||||
{
|
||||
public ClickTextModel()
|
||||
{
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Add(
|
||||
new(this, OnPropertyChanged, [(nameof(ID), ID, nameof(Text), true)])
|
||||
);
|
||||
}
|
||||
public ClickTextModel() { }
|
||||
|
||||
public ClickTextModel(ClickTextModel clickText)
|
||||
: this()
|
||||
@ -124,11 +119,35 @@ public class ClickTextModel : ObservableObjectX
|
||||
#endregion
|
||||
|
||||
#region I18nData
|
||||
[AdaptIgnore]
|
||||
private I18nResource<string, string> _i18nResource = null!;
|
||||
|
||||
[AdaptIgnore]
|
||||
public required I18nResource<string, string> I18nResource
|
||||
{
|
||||
get => _i18nResource;
|
||||
set
|
||||
{
|
||||
if (_i18nResource is not null)
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
_i18nResource = value;
|
||||
InitializeI18nResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(this, OnPropertyChanged, [(nameof(ID), ID, nameof(Text), true),])
|
||||
);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Text
|
||||
{
|
||||
get => ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => I18nResource.SetCurrentCultureData(ID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -224,25 +243,9 @@ public class ClickTextModel : ObservableObjectX
|
||||
/// 体力
|
||||
/// </summary>
|
||||
public ObservableRange<double> Strength { get; } = new(0, int.MaxValue);
|
||||
}
|
||||
|
||||
public class I18nClickTextModel : ObservableObjectX, ICloneable<I18nClickTextModel>
|
||||
{
|
||||
#region Text
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private string _text = string.Empty;
|
||||
|
||||
public string Text
|
||||
public void Close()
|
||||
{
|
||||
get => _text;
|
||||
set => SetProperty(ref _text, value);
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public I18nClickTextModel Clone()
|
||||
{
|
||||
return this.Adapt<I18nClickTextModel>();
|
||||
}
|
||||
|
||||
object ICloneable.Clone() => Clone();
|
||||
}
|
||||
|
@ -26,19 +26,9 @@ public class FoodModel : ObservableObjectX
|
||||
public FoodModel()
|
||||
{
|
||||
PropertyChangedX += FoodModel_PropertyChangedX;
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Add(
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Name), true),
|
||||
(nameof(DescriptionID), DescriptionID, nameof(Description), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static FrozenSet<string> _notifyReferencePrice = FrozenSet.ToFrozenSet(
|
||||
private static readonly FrozenSet<string> _notifyReferencePrice = FrozenSet.ToFrozenSet(
|
||||
[
|
||||
nameof(Strength),
|
||||
nameof(StrengthFood),
|
||||
@ -116,22 +106,50 @@ public class FoodModel : ObservableObjectX
|
||||
#endregion
|
||||
|
||||
#region I18nData
|
||||
|
||||
[AdaptIgnore]
|
||||
private I18nResource<string, string> _i18nResource = null!;
|
||||
|
||||
[AdaptIgnore]
|
||||
public required I18nResource<string, string> I18nResource
|
||||
{
|
||||
get => _i18nResource;
|
||||
set
|
||||
{
|
||||
if (_i18nResource is not null)
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
_i18nResource = value;
|
||||
InitializeI18nResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Name), true),
|
||||
(nameof(DescriptionID), DescriptionID, nameof(Description), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Name
|
||||
{
|
||||
get => ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => I18nResource.SetCurrentCultureData(ID, value);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Description
|
||||
{
|
||||
get =>
|
||||
ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(
|
||||
DescriptionID,
|
||||
string.Empty
|
||||
);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(DescriptionID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(DescriptionID, string.Empty);
|
||||
set => I18nResource.SetCurrentCultureData(DescriptionID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -345,10 +363,6 @@ public class FoodModel : ObservableObjectX
|
||||
public void Close()
|
||||
{
|
||||
Image?.CloseStream();
|
||||
var item = ModInfoModel.Current.I18nResource.I18nObjectInfos.FirstOrDefault(i =>
|
||||
i.Source == this
|
||||
);
|
||||
if (item is not null)
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Remove(item);
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,7 @@ namespace VPet.ModMaker.Models;
|
||||
/// </summary>
|
||||
public class LowTextModel : ObservableObjectX
|
||||
{
|
||||
public LowTextModel()
|
||||
{
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Add(
|
||||
new(this, OnPropertyChanged, [(nameof(ID), ID, nameof(Text), true)])
|
||||
);
|
||||
}
|
||||
public LowTextModel() { }
|
||||
|
||||
public LowTextModel(LowTextModel lowText)
|
||||
: this()
|
||||
@ -56,6 +51,7 @@ public class LowTextModel : ObservableObjectX
|
||||
Enum.GetValues<LowText.StrengthType>().ToFrozenSet();
|
||||
|
||||
#region ID
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private string _id = string.Empty;
|
||||
|
||||
@ -71,11 +67,35 @@ public class LowTextModel : ObservableObjectX
|
||||
#endregion
|
||||
|
||||
#region I18nData
|
||||
[AdaptIgnore]
|
||||
private I18nResource<string, string> _i18nResource = null!;
|
||||
|
||||
[AdaptIgnore]
|
||||
public required I18nResource<string, string> I18nResource
|
||||
{
|
||||
get => _i18nResource;
|
||||
set
|
||||
{
|
||||
if (_i18nResource is not null)
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
_i18nResource = value;
|
||||
InitializeI18nResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(this, OnPropertyChanged, [(nameof(ID), ID, nameof(Text), true)])
|
||||
);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Text
|
||||
{
|
||||
get => ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => I18nResource.SetCurrentCultureData(ID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -128,4 +148,9 @@ public class LowTextModel : ObservableObjectX
|
||||
{
|
||||
return this.Adapt<LowText>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,19 @@ public class ModInfoModel : ObservableObjectX
|
||||
Current = this;
|
||||
PropertyChanged += ModInfoModel_PropertyChanged;
|
||||
Pets.CollectionChanged += Pets_CollectionChanged;
|
||||
I18nResource.PropertyChanged += I18nResource_PropertyChanged;
|
||||
I18nResource.Cultures.SetChanged += Cultures_SetChanged;
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Name), true),
|
||||
(nameof(DescriptionID), DescriptionID, nameof(Description), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public ModInfoModel(ModLoader loader)
|
||||
@ -51,28 +64,28 @@ public class ModInfoModel : ObservableObjectX
|
||||
if (File.Exists(imagePath))
|
||||
Image = NativeUtils.LoadImageToMemoryStream(imagePath);
|
||||
foreach (var food in loader.Foods.Where(m => string.IsNullOrWhiteSpace(m.Name) is false))
|
||||
Foods.Add(new(food));
|
||||
Foods.Add(new(food) { I18nResource = I18nResource });
|
||||
foreach (
|
||||
var clickText in loader.ClickTexts.Where(m =>
|
||||
string.IsNullOrWhiteSpace(m.Text) is false
|
||||
)
|
||||
)
|
||||
ClickTexts.Add(new(clickText));
|
||||
ClickTexts.Add(new(clickText) { I18nResource = I18nResource });
|
||||
foreach (
|
||||
var lowText in loader.LowTexts.Where(m => string.IsNullOrWhiteSpace(m.Text) is false)
|
||||
)
|
||||
LowTexts.Add(new(lowText));
|
||||
LowTexts.Add(new(lowText) { I18nResource = I18nResource });
|
||||
foreach (
|
||||
var selectText in loader.SelectTexts.Where(m =>
|
||||
string.IsNullOrWhiteSpace(m.Text) is false
|
||||
)
|
||||
)
|
||||
SelectTexts.Add(new(selectText));
|
||||
SelectTexts.Add(new(selectText) { I18nResource = I18nResource });
|
||||
|
||||
// 载入模组宠物
|
||||
foreach (var pet in loader.Pets)
|
||||
{
|
||||
var petModel = new PetModel(pet);
|
||||
var petModel = new PetModel(pet) { I18nResource = I18nResource };
|
||||
// 如果检测到本体存在同名宠物
|
||||
if (ModMakerInfo.MainPets.TryGetValue(petModel.ID, out var mainPet))
|
||||
{
|
||||
@ -113,12 +126,8 @@ public class ModInfoModel : ObservableObjectX
|
||||
if (Pets.All(i => i.ID != pet.Key))
|
||||
Pets.Insert(0, pet.Value);
|
||||
}
|
||||
|
||||
// 载入本地化模组信息
|
||||
//foreach (var lang in loader.I18nDatas)
|
||||
// I18nDatas.Add(lang.Key, lang.Value);
|
||||
//OtherI18nDatas = loader.I18nDatas;
|
||||
|
||||
if (loader.I18nDatas.HasValue() is false)
|
||||
return;
|
||||
LoadI18nDatas(loader);
|
||||
RefreshAllID();
|
||||
if (I18nResource.CultureDatas.HasValue())
|
||||
@ -143,9 +152,18 @@ public class ModInfoModel : ObservableObjectX
|
||||
/// </summary>
|
||||
public static ModInfoModel Current { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// I18n资源
|
||||
/// </summary>
|
||||
public I18nResource<string, string> I18nResource { get; } =
|
||||
new() { FillDefaultValueForNewCulture = true, DefaultValue = string.Empty };
|
||||
|
||||
/// <summary>
|
||||
/// 临时I18n资源, 用于新建的项目
|
||||
/// </summary>
|
||||
public I18nResource<string, string> TempI18nResource { get; } =
|
||||
new() { FillDefaultValueForNewCulture = true, DefaultValue = string.Empty };
|
||||
|
||||
#region I18nData
|
||||
public string Name
|
||||
{
|
||||
@ -339,6 +357,41 @@ public class ModInfoModel : ObservableObjectX
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
private void I18nResource_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(I18nResource.CurrentCulture))
|
||||
{
|
||||
TempI18nResource.CurrentCulture = I18nResource.CurrentCulture;
|
||||
}
|
||||
}
|
||||
|
||||
private void Cultures_SetChanged(
|
||||
IObservableSet<CultureInfo> sender,
|
||||
NotifySetChangeEventArgs<CultureInfo> e
|
||||
)
|
||||
{
|
||||
if (e.Action is SetChangeAction.Clear)
|
||||
{
|
||||
TempI18nResource.ClearCulture();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.OldItems is not null)
|
||||
{
|
||||
foreach (var item in e.OldItems)
|
||||
{
|
||||
TempI18nResource.RemoveCulture(item);
|
||||
}
|
||||
}
|
||||
if (e.NewItems is not null)
|
||||
{
|
||||
foreach (var item in e.NewItems)
|
||||
{
|
||||
TempI18nResource.AddCulture(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Pets_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
@ -448,9 +501,6 @@ public class ModInfoModel : ObservableObjectX
|
||||
/// </summary>
|
||||
private void LoadI18nDatas(ModLoader modLoader)
|
||||
{
|
||||
if (modLoader.I18nDatas.HasValue() is false)
|
||||
return;
|
||||
|
||||
foreach (var cultureDatas in modLoader.I18nDatas)
|
||||
{
|
||||
var culture = CultureInfo.GetCultureInfo(cultureDatas.Key);
|
||||
@ -460,106 +510,11 @@ public class ModInfoModel : ObservableObjectX
|
||||
}
|
||||
if (I18nResource.SetCurrentCulture(CultureInfo.CurrentCulture) is false)
|
||||
I18nResource.SetCurrentCulture(I18nResource.Cultures.First());
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Name), true),
|
||||
(nameof(DescriptionID), DescriptionID, nameof(Description), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
//foreach (var lang in I18nDatas.Keys.Union(OtherI18nDatas.Keys))
|
||||
//{
|
||||
// if (I18nHelper.Current.CultureNames.Contains(lang) is false)
|
||||
// I18nHelper.Current.CultureNames.Add(lang);
|
||||
//}
|
||||
//if (I18nHelper.Current.CultureNames.Count == 0)
|
||||
// return;
|
||||
//I18nHelper.Current.CultureName = I18nHelper.Current.CultureNames.First();
|
||||
//foreach (var i18nData in OtherI18nDatas)
|
||||
//{
|
||||
// LoadFoodI18nData(i18nData.Key, i18nData.Value);
|
||||
// LoadLowTextI18nData(i18nData.Key, i18nData.Value);
|
||||
// LoadClickTextI18nData(i18nData.Key, i18nData.Value);
|
||||
// LoadSelectTextI18nData(i18nData.Key, i18nData.Value);
|
||||
// LoadPetI18nData(i18nData.Key, i18nData.Value);
|
||||
//}
|
||||
}
|
||||
|
||||
//private void LoadFoodI18nData(string key, Dictionary<string, string> i18nData)
|
||||
//{
|
||||
// foreach (var food in Foods)
|
||||
// {
|
||||
// if (food.I18nDatas.TryGetValue(key, out var data) is false)
|
||||
// continue;
|
||||
// if (i18nData.TryGetValue(food.ID, out var name))
|
||||
// data.Name = name;
|
||||
// if (i18nData.TryGetValue(food.DescriptionID, out var description))
|
||||
// data.Description = description;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void LoadLowTextI18nData(string key, Dictionary<string, string> i18nData)
|
||||
//{
|
||||
// foreach (var lowText in LowTexts)
|
||||
// {
|
||||
// if (lowText.I18nDatas.TryGetValue(key, out var data) is false)
|
||||
// continue;
|
||||
// if (i18nData.TryGetValue(lowText.ID, out var text))
|
||||
// data.Text = text;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void LoadClickTextI18nData(string key, Dictionary<string, string> i18nData)
|
||||
//{
|
||||
// foreach (var clickText in ClickTexts)
|
||||
// {
|
||||
// if (clickText.I18nDatas.TryGetValue(key, out var data) is false)
|
||||
// continue;
|
||||
// if (i18nData.TryGetValue(clickText.ID, out var text))
|
||||
// data.Text = text;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void LoadSelectTextI18nData(string key, Dictionary<string, string> i18nData)
|
||||
//{
|
||||
// foreach (var selectText in SelectTexts)
|
||||
// {
|
||||
// if (selectText.I18nDatas.TryGetValue(key, out var data) is false)
|
||||
// continue;
|
||||
// if (i18nData.TryGetValue(selectText.ID, out var text))
|
||||
// data.Text = text;
|
||||
// if (i18nData.TryGetValue(selectText.ChooseID, out var choose))
|
||||
// data.Choose = choose;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void LoadPetI18nData(string key, Dictionary<string, string> i18nData)
|
||||
//{
|
||||
// foreach (var pet in Pets)
|
||||
// {
|
||||
// if (pet.I18nDatas.TryGetValue(key, out var data) is false)
|
||||
// continue;
|
||||
// if (i18nData.TryGetValue(pet.ID, out var name))
|
||||
// data.Name = name;
|
||||
// if (i18nData.TryGetValue(pet.PetNameID, out var petName))
|
||||
// data.PetName = petName;
|
||||
// if (i18nData.TryGetValue(pet.DescriptionID, out var description))
|
||||
// data.Description = description;
|
||||
// foreach (var work in pet.Works)
|
||||
// {
|
||||
// if (work.I18nDatas.TryGetValue(key, out var workData) is false)
|
||||
// continue;
|
||||
// if (i18nData.TryGetValue(work.ID, out var workName))
|
||||
// workData.Name = workName;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
private void RefreshAllID()
|
||||
public void RefreshAllID()
|
||||
{
|
||||
RefreshID();
|
||||
foreach (var food in Foods)
|
||||
food.RefreshID();
|
||||
foreach (var selectText in SelectTexts)
|
||||
|
@ -27,7 +27,7 @@ public static class ModUpdataHelper
|
||||
/// <returns>可以升级为 <see langword="true"/> 不可以为 <see langword="false"/></returns>
|
||||
public static bool CanUpdata(ModInfoModel mod)
|
||||
{
|
||||
if (mod.ModVersion >= LastVersion)
|
||||
if (mod.GameVersion >= LastVersion)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -44,7 +44,7 @@ public static class ModUpdataHelper
|
||||
return false;
|
||||
foreach (var action in UpdataAction)
|
||||
{
|
||||
if (mod.ModVersion >= action.Key)
|
||||
if (mod.GameVersion >= action.Key)
|
||||
continue;
|
||||
try
|
||||
{
|
||||
|
@ -30,17 +30,6 @@ public class PetModel : ObservableObjectX
|
||||
PropertyChanged += PetModel_PropertyChanged;
|
||||
Animes.PropertyChanged += Animes_PropertyChanged;
|
||||
FoodAnimes.PropertyChanged += FoodAnimes_PropertyChanged;
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Add(
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Name), true),
|
||||
(nameof(PetNameID), PetNameID, nameof(Name), true),
|
||||
(nameof(DescriptionID), DescriptionID, nameof(Description), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private void PetModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
@ -126,12 +115,12 @@ public class PetModel : ObservableObjectX
|
||||
return;
|
||||
|
||||
foreach (var work in loader.Config.Works)
|
||||
Works.Add(new(work));
|
||||
Works.Add(new(work) { I18nResource = ModInfoModel.Current.I18nResource });
|
||||
foreach (var move in loader.Config.Moves)
|
||||
Moves.Add(new(move));
|
||||
}
|
||||
|
||||
public static PetModel Current { get; } = new();
|
||||
public static PetModel Current { get; } = null!;
|
||||
|
||||
#region FromMain
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
@ -164,7 +153,7 @@ public class PetModel : ObservableObjectX
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region PetNameId
|
||||
#region PetNameID
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private string _petNameID = string.Empty;
|
||||
|
||||
@ -178,7 +167,7 @@ public class PetModel : ObservableObjectX
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DescriptionId
|
||||
#region DescriptionID
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private string _descriptionID = string.Empty;
|
||||
|
||||
@ -193,33 +182,57 @@ public class PetModel : ObservableObjectX
|
||||
#endregion
|
||||
|
||||
#region I18nData
|
||||
[AdaptIgnore]
|
||||
private I18nResource<string, string> _i18nResource = null!;
|
||||
|
||||
[AdaptIgnore]
|
||||
public required I18nResource<string, string> I18nResource
|
||||
{
|
||||
get => _i18nResource;
|
||||
set
|
||||
{
|
||||
if (_i18nResource is not null)
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
_i18nResource = value;
|
||||
InitializeI18nResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Name), true),
|
||||
(nameof(PetNameID), PetNameID, nameof(PetName), true),
|
||||
(nameof(DescriptionID), DescriptionID, nameof(Description), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Name
|
||||
{
|
||||
get => ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => I18nResource.SetCurrentCultureData(ID, value);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string PetName
|
||||
{
|
||||
get =>
|
||||
ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(
|
||||
PetNameID,
|
||||
string.Empty
|
||||
);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(PetNameID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(PetNameID);
|
||||
set => I18nResource.SetCurrentCultureData(PetNameID, value);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Description
|
||||
{
|
||||
get =>
|
||||
ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(
|
||||
DescriptionID,
|
||||
string.Empty
|
||||
);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(DescriptionID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(DescriptionID);
|
||||
set => I18nResource.SetCurrentCultureData(DescriptionID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -357,6 +370,11 @@ public class PetModel : ObservableObjectX
|
||||
anime.Close();
|
||||
}
|
||||
|
||||
public void CloseI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
}
|
||||
|
||||
#region Save
|
||||
|
||||
/// <summary>
|
||||
@ -382,17 +400,6 @@ public class PetModel : ObservableObjectX
|
||||
/// <param name="path">路径</param>
|
||||
public void Save(string path)
|
||||
{
|
||||
// TODO
|
||||
//foreach (var cultureName in I18nHelper.Current.CultureNames)
|
||||
//{
|
||||
// ModInfoModel.SaveI18nDatas[cultureName].TryAdd(ID, I18nDatas[cultureName].Name);
|
||||
// ModInfoModel
|
||||
// .SaveI18nDatas[cultureName]
|
||||
// .TryAdd(PetNameID, I18nDatas[cultureName].PetName);
|
||||
// ModInfoModel
|
||||
// .SaveI18nDatas[cultureName]
|
||||
// .TryAdd(DescriptionID, I18nDatas[cultureName].Description);
|
||||
//}
|
||||
var petFile = Path.Combine(path, $"{ID}.lps");
|
||||
if (File.Exists(petFile) is false)
|
||||
File.Create(petFile).Close();
|
||||
@ -439,14 +446,7 @@ public class PetModel : ObservableObjectX
|
||||
{
|
||||
foreach (var work in Works)
|
||||
{
|
||||
//TODO
|
||||
//lps.Add(LPSConvert.SerializeObjectToLine<Line>(work.ToWork(), "work"));
|
||||
//foreach (var cultureName in I18nHelper.Current.CultureNames)
|
||||
//{
|
||||
// ModInfoModel
|
||||
// .SaveI18nDatas[cultureName]
|
||||
// .TryAdd(work.ID, work.I18nDatas[cultureName].Name);
|
||||
//}
|
||||
lps.Add(LPSConvert.SerializeObjectToLine<Line>(work.ToWork(), "work"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,7 +505,8 @@ public class PetModel : ObservableObjectX
|
||||
new Sub("petname", PetNameID)
|
||||
}
|
||||
);
|
||||
lps.Add(new Line("tag", Tags));
|
||||
if (string.IsNullOrWhiteSpace(Tags) is false)
|
||||
lps.Add(new Line("tag", Tags));
|
||||
}
|
||||
|
||||
private void SavePetTouchHeadInfo(LPS lps)
|
||||
|
@ -18,19 +18,7 @@ namespace VPet.ModMaker.Models;
|
||||
/// </summary>
|
||||
public class SelectTextModel : ObservableObjectX
|
||||
{
|
||||
public SelectTextModel()
|
||||
{
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Add(
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Text), true),
|
||||
(nameof(ChooseID), ChooseID, nameof(Choose), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
public SelectTextModel() { }
|
||||
|
||||
public SelectTextModel(SelectTextModel model)
|
||||
: this()
|
||||
@ -120,37 +108,64 @@ public class SelectTextModel : ObservableObjectX
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ChooseId
|
||||
#region ChooseID
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private string _chooseId = string.Empty;
|
||||
private string _chooseID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 选择Id
|
||||
/// </summary>
|
||||
public string ChooseID
|
||||
{
|
||||
get => _chooseId;
|
||||
set => SetProperty(ref _chooseId, value);
|
||||
get => _chooseID;
|
||||
set => SetProperty(ref _chooseID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region I18nData
|
||||
[AdaptIgnore]
|
||||
private I18nResource<string, string> _i18nResource = null!;
|
||||
|
||||
[AdaptIgnore]
|
||||
public required I18nResource<string, string> I18nResource
|
||||
{
|
||||
get => _i18nResource;
|
||||
set
|
||||
{
|
||||
if (_i18nResource is not null)
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
_i18nResource = value;
|
||||
InitializeI18nResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(
|
||||
this,
|
||||
OnPropertyChanged,
|
||||
[
|
||||
(nameof(ID), ID, nameof(Text), true),
|
||||
(nameof(ChooseID), ChooseID, nameof(Choose), true)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Text
|
||||
{
|
||||
get => ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => I18nResource.SetCurrentCultureData(ID, value);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Choose
|
||||
{
|
||||
get =>
|
||||
ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(
|
||||
ChooseID,
|
||||
string.Empty
|
||||
);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ChooseID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ChooseID, string.Empty);
|
||||
set => I18nResource.SetCurrentCultureData(ChooseID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -239,4 +254,9 @@ public class SelectTextModel : ObservableObjectX
|
||||
StrengthMax = Strength.Max,
|
||||
};
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,6 @@ public class WorkModel : ObservableObjectX
|
||||
public WorkModel()
|
||||
{
|
||||
PropertyChanged += WorkModel_PropertyChanged;
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Add(
|
||||
new(this, OnPropertyChanged, [(nameof(ID), ID, nameof(Name), true)])
|
||||
);
|
||||
}
|
||||
|
||||
private static readonly FrozenSet<string> _notifyIsOverLoad = FrozenSet.ToFrozenSet(
|
||||
@ -126,11 +123,35 @@ public class WorkModel : ObservableObjectX
|
||||
#endregion
|
||||
|
||||
#region I18nData
|
||||
[AdaptIgnore]
|
||||
private I18nResource<string, string> _i18nResource = null!;
|
||||
|
||||
[AdaptIgnore]
|
||||
public required I18nResource<string, string> I18nResource
|
||||
{
|
||||
get => _i18nResource;
|
||||
set
|
||||
{
|
||||
if (_i18nResource is not null)
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
_i18nResource = value;
|
||||
InitializeI18nResource();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeI18nResource()
|
||||
{
|
||||
I18nResource.I18nObjectInfos.Add(
|
||||
this,
|
||||
new(this, OnPropertyChanged, [(nameof(ID), ID, nameof(Name), true),])
|
||||
);
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
public string Name
|
||||
{
|
||||
get => ModInfoModel.Current.I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => ModInfoModel.Current.I18nResource.SetCurrentCultureData(ID, value);
|
||||
get => I18nResource.GetCurrentCultureDataOrDefault(ID);
|
||||
set => I18nResource.SetCurrentCultureData(ID, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -459,10 +480,6 @@ public class WorkModel : ObservableObjectX
|
||||
public void Close()
|
||||
{
|
||||
//Image?.CloseStream();
|
||||
var item = ModInfoModel.Current.I18nResource.I18nObjectInfos.FirstOrDefault(i =>
|
||||
i.Source == this
|
||||
);
|
||||
if (item is not null)
|
||||
ModInfoModel.Current.I18nResource.I18nObjectInfos.Remove(item);
|
||||
I18nResource.I18nObjectInfos.Remove(this);
|
||||
}
|
||||
}
|
||||
|
@ -11,11 +11,23 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Configurations>Debug;Release;Test</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\food.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)'=='Test'">
|
||||
<Reference Include="HKW.Utils">
|
||||
<HintPath>..\..\HKW.Utils\HKW.Utils\bin\Debug\net8.0\HKW.Utils.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HKW.WPF">
|
||||
<HintPath>..\..\HKW.WPF\HKW.WPF\bin\Debug\net8.0-windows\HKW.WPF.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)'!='Test'">
|
||||
<PackageReference Include="HKW.WPF" Version="1.0.6" />
|
||||
<PackageReference Include="HKW.Utils" Version="1.2.21" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="VPet-Simulator.Core" Version="1.1.0.4" />
|
||||
<PackageReference Include="VPet-Simulator.Windows.Interface" Version="1.1.0.5" />
|
||||
@ -28,8 +40,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="HKW.Utils" Version="1.2.19" />
|
||||
<PackageReference Include="HKW.WPF" Version="1.0.5" />
|
||||
<PackageReference Include="Mapster" Version="7.4.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -142,6 +142,8 @@ public class AnimePageVM : ObservableObjectX
|
||||
private void InitializeAllAnimes()
|
||||
{
|
||||
AllAnimes.Clear();
|
||||
if (CurrentPet is null)
|
||||
return;
|
||||
foreach (var item in Animes)
|
||||
AllAnimes.Add(item);
|
||||
foreach (var item in FoodAnimes)
|
||||
|
@ -26,7 +26,7 @@ public class ClickTextEditWindowVM : ObservableObjectX
|
||||
|
||||
#region ClickText
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private ClickTextModel _clickText = new();
|
||||
private ClickTextModel _clickText = new() { I18nResource = ModInfoModel.Current.I18nResource };
|
||||
|
||||
/// <summary>
|
||||
/// 点击文本
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using HKW.HKWUtils.Extensions;
|
||||
using HKW.HKWUtils.Observable;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using VPet.ModMaker.Models;
|
||||
@ -22,6 +23,7 @@ public class ClickTextPageVM : ObservableObjectX
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
ClickTexts.BindingList(ModInfoModel.Current.ClickTexts);
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteCommand;
|
||||
@ -100,11 +102,22 @@ public class ClickTextPageVM : ObservableObjectX
|
||||
var window = new ClickTextEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.OldClickText = model;
|
||||
var newLowTest = vm.ClickText = new(model);
|
||||
var newModel = vm.ClickText = new(model)
|
||||
{
|
||||
I18nResource = ModInfoModel.Current.TempI18nResource
|
||||
};
|
||||
model.I18nResource.CopyDataTo(newModel.I18nResource, model.ID, true);
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
{
|
||||
newModel.I18nResource.ClearCultureData();
|
||||
newModel.Close();
|
||||
return;
|
||||
ClickTexts[ClickTexts.IndexOf(model)] = newLowTest;
|
||||
}
|
||||
newModel.I18nResource.CopyDataTo(ModInfoModel.Current.I18nResource, true);
|
||||
newModel.I18nResource = ModInfoModel.Current.I18nResource;
|
||||
ClickTexts[ClickTexts.IndexOf(model)] = newModel;
|
||||
model.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -116,5 +129,6 @@ public class ClickTextPageVM : ObservableObjectX
|
||||
if (MessageBox.Show("确定删除吗".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||
return;
|
||||
ClickTexts.Remove(model);
|
||||
model.Close();
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class FoodEditWindowVM : ObservableObjectX
|
||||
|
||||
#region Food
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private FoodModel _food = new();
|
||||
private FoodModel _food = new() { I18nResource = ModInfoModel.Current.I18nResource };
|
||||
|
||||
public FoodModel Food
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using HKW.HKWUtils.Extensions;
|
||||
using HKW.HKWUtils.Observable;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using VPet.ModMaker.Models;
|
||||
@ -24,6 +25,7 @@ public class FoodPageVM : ObservableObjectX
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
Foods.BindingList(ModInfoModel.Current.Foods);
|
||||
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
@ -76,23 +78,34 @@ public class FoodPageVM : ObservableObjectX
|
||||
Foods.Add(vm.Food);
|
||||
}
|
||||
|
||||
public void EditCommand_ExecuteCommand(FoodModel food)
|
||||
public void EditCommand_ExecuteCommand(FoodModel model)
|
||||
{
|
||||
var window = new FoodEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.OldFood = food;
|
||||
var newFood = vm.Food = new(food);
|
||||
vm.OldFood = model;
|
||||
var newModel = vm.Food = new(model)
|
||||
{
|
||||
I18nResource = ModInfoModel.Current.TempI18nResource
|
||||
};
|
||||
model.I18nResource.CopyDataTo(newModel.I18nResource, [model.ID, model.DescriptionID], true);
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
{
|
||||
newModel.I18nResource.ClearCultureData();
|
||||
newModel.Close();
|
||||
return;
|
||||
Foods[Foods.IndexOf(food)] = newFood;
|
||||
food.Close();
|
||||
}
|
||||
newModel.I18nResource.CopyDataTo(ModInfoModel.Current.I18nResource, true);
|
||||
newModel.I18nResource = ModInfoModel.Current.I18nResource;
|
||||
Foods[Foods.IndexOf(model)] = newModel;
|
||||
model.Close();
|
||||
}
|
||||
|
||||
private void RemoveCommand_ExecuteCommand(FoodModel food)
|
||||
private void RemoveCommand_ExecuteCommand(FoodModel model)
|
||||
{
|
||||
if (MessageBox.Show("确定删除吗".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||
return;
|
||||
Foods.Remove(food);
|
||||
Foods.Remove(model);
|
||||
model.Close();
|
||||
}
|
||||
}
|
||||
|
@ -23,16 +23,27 @@ public class I18nEditWindowVM : ObservableObjectX
|
||||
SearchTarget = SearchTargets.First();
|
||||
PropertyChanged += I18nEditWindowVM_PropertyChanged;
|
||||
|
||||
ModInfoModel.Current.I18nResource.Cultures.SetChanged -= Cultures_SetChanged;
|
||||
ModInfoModel.Current.I18nResource.Cultures.SetChanged += Cultures_SetChanged;
|
||||
I18nResource.Cultures.SetChanged -= Cultures_SetChanged;
|
||||
I18nResource.Cultures.SetChanged += Cultures_SetChanged;
|
||||
|
||||
I18nResource.CultureDatas.DictionaryChanged -= CultureDatas_DictionaryChanged;
|
||||
I18nResource.CultureDatas.DictionaryChanged += CultureDatas_DictionaryChanged;
|
||||
|
||||
I18nDatas = new() { Filter = DataFilter, FilteredList = [] };
|
||||
foreach (var data in ModInfoModel.Current.I18nResource.CultureDatas.Values)
|
||||
foreach (var data in I18nResource.CultureDatas.Values)
|
||||
{
|
||||
I18nDatas.Add(data);
|
||||
foreach (var culture in ModInfoModel.Current.I18nResource.Cultures)
|
||||
data.DictionaryChanged += Data_DictionaryChanged;
|
||||
}
|
||||
foreach (var culture in I18nResource.Cultures)
|
||||
SearchTargets.Add(culture.Name);
|
||||
}
|
||||
|
||||
public I18nResource<string, string> I18nResource { get; set; } =
|
||||
ModInfoModel.Current.I18nResource;
|
||||
|
||||
public bool CellEdit { get; set; } = false;
|
||||
|
||||
#region Search
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private string _search = string.Empty;
|
||||
@ -97,7 +108,7 @@ public class I18nEditWindowVM : ObservableObjectX
|
||||
|
||||
private void Cultures_SetChanged(
|
||||
IObservableSet<CultureInfo> sender,
|
||||
NotifySetChangedEventArgs<CultureInfo> e
|
||||
NotifySetChangeEventArgs<CultureInfo> e
|
||||
)
|
||||
{
|
||||
if (e.Action is SetChangeAction.Add)
|
||||
@ -122,6 +133,46 @@ public class I18nEditWindowVM : ObservableObjectX
|
||||
}
|
||||
}
|
||||
|
||||
private void CultureDatas_DictionaryChanged(
|
||||
IObservableDictionary<string, ObservableCultureDataDictionary<string, string>> sender,
|
||||
NotifyDictionaryChangeEventArgs<string, ObservableCultureDataDictionary<string, string>> e
|
||||
)
|
||||
{
|
||||
if (e.Action is DictionaryChangeAction.Add)
|
||||
{
|
||||
if (e.TryGetNewPair(out var newPair) is false)
|
||||
return;
|
||||
I18nDatas.Add(newPair.Value);
|
||||
newPair.Value.DictionaryChanged -= Data_DictionaryChanged;
|
||||
newPair.Value.DictionaryChanged += Data_DictionaryChanged;
|
||||
}
|
||||
else if (e.Action is DictionaryChangeAction.Remove)
|
||||
{
|
||||
if (e.TryGetOldPair(out var oldPair) is false)
|
||||
return;
|
||||
I18nDatas.Remove(oldPair.Value);
|
||||
oldPair.Value.DictionaryChanged -= Data_DictionaryChanged;
|
||||
}
|
||||
else if (e.Action is DictionaryChangeAction.Replace)
|
||||
{
|
||||
if (e.TryGetNewPair(out var newPair) is false)
|
||||
return;
|
||||
if (e.TryGetOldPair(out var oldPair) is false)
|
||||
return;
|
||||
if (I18nDatas.TryFind(0, i => i.Key == newPair.Key, out var itemInfo) is false)
|
||||
return;
|
||||
I18nDatas.RemoveAt(itemInfo.Index);
|
||||
I18nDatas.Insert(itemInfo.Index, newPair.Value);
|
||||
oldPair.Value.DictionaryChanged -= Data_DictionaryChanged;
|
||||
newPair.Value.DictionaryChanged -= Data_DictionaryChanged;
|
||||
newPair.Value.DictionaryChanged += Data_DictionaryChanged;
|
||||
}
|
||||
else if (e.Action is DictionaryChangeAction.Clear)
|
||||
{
|
||||
I18nDatas.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void I18nEditWindowVM_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(Search))
|
||||
@ -134,6 +185,29 @@ public class I18nEditWindowVM : ObservableObjectX
|
||||
}
|
||||
}
|
||||
|
||||
private void Data_DictionaryChanged(
|
||||
IObservableDictionary<CultureInfo, string> sender,
|
||||
NotifyDictionaryChangeEventArgs<CultureInfo, string> e
|
||||
)
|
||||
{
|
||||
if (sender is not ObservableCultureDataDictionary<string, string> cultureDatas)
|
||||
return;
|
||||
// 刷新修改后的数据
|
||||
if (e.Action is DictionaryChangeAction.Replace)
|
||||
{
|
||||
if (CellEdit)
|
||||
{
|
||||
// 防止在编辑单元格时重复响应
|
||||
CellEdit = false;
|
||||
return;
|
||||
}
|
||||
if (I18nDatas.TryFind(0, i => i.Key == cultureDatas.Key, out var itemInfo) is false)
|
||||
return;
|
||||
I18nDatas.RemoveAt(itemInfo.Index);
|
||||
I18nDatas.Insert(itemInfo.Index, cultureDatas);
|
||||
}
|
||||
}
|
||||
|
||||
#region Event
|
||||
private void AddCulture(string culture)
|
||||
{
|
||||
@ -145,10 +219,10 @@ public class I18nEditWindowVM : ObservableObjectX
|
||||
CultureChanged?.Invoke(culture, string.Empty);
|
||||
}
|
||||
|
||||
private void ReplaceCulture(string oldCulture, string newCulture)
|
||||
{
|
||||
CultureChanged?.Invoke(oldCulture, newCulture);
|
||||
}
|
||||
//private void ReplaceCulture(string oldCulture, string newCulture)
|
||||
//{
|
||||
// CultureChanged?.Invoke(oldCulture, newCulture);
|
||||
//}
|
||||
|
||||
public event CultureChangedEventHandler? CultureChanged;
|
||||
#endregion
|
||||
|
@ -22,7 +22,7 @@ public class LowTextEditWindowVM : ObservableObjectX
|
||||
|
||||
#region LowText
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private LowTextModel _lowText = new();
|
||||
private LowTextModel _lowText = new() { I18nResource = ModInfoModel.Current.I18nResource };
|
||||
|
||||
public LowTextModel LowText
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using HKW.HKWUtils.Extensions;
|
||||
using HKW.HKWUtils.Observable;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using VPet.ModMaker.Models;
|
||||
@ -24,6 +25,7 @@ public class LowTextPageVM : ObservableObjectX
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
LowTexts.BindingList(ModInfoModel.Current.LowTexts);
|
||||
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
@ -78,11 +80,22 @@ public class LowTextPageVM : ObservableObjectX
|
||||
var window = new LowTextEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.OldLowText = model;
|
||||
var newLowTest = vm.LowText = new(model);
|
||||
var newModel = vm.LowText = new(model)
|
||||
{
|
||||
I18nResource = ModInfoModel.Current.TempI18nResource
|
||||
};
|
||||
model.I18nResource.CopyDataTo(newModel.I18nResource, model.ID, true);
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
{
|
||||
newModel.I18nResource.ClearCultureData();
|
||||
newModel.Close();
|
||||
return;
|
||||
LowTexts[LowTexts.IndexOf(model)] = newLowTest;
|
||||
}
|
||||
newModel.I18nResource.CopyDataTo(ModInfoModel.Current.I18nResource, true);
|
||||
newModel.I18nResource = ModInfoModel.Current.I18nResource;
|
||||
LowTexts[LowTexts.IndexOf(model)] = newModel;
|
||||
model.Close();
|
||||
}
|
||||
|
||||
private void RemoveCommand_ExecuteCommand(LowTextModel model)
|
||||
@ -90,5 +103,6 @@ public class LowTextPageVM : ObservableObjectX
|
||||
if (MessageBox.Show("确定删除吗".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||
return;
|
||||
LowTexts.Remove(model);
|
||||
model.Close();
|
||||
}
|
||||
}
|
||||
|
@ -160,8 +160,8 @@ public class ModEditWindowVM : ObservableObjectX
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
return;
|
||||
ModInfoModel.Current.I18nResource.AddCulture(window.ViewModel.Culture);
|
||||
ModInfoModel.Current.I18nResource.SetCurrentCulture(window.ViewModel.Culture);
|
||||
I18nResource.AddCulture(window.ViewModel.Culture);
|
||||
I18nResource.SetCurrentCulture(window.ViewModel.Culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -175,7 +175,7 @@ public class ModEditWindowVM : ObservableObjectX
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
return;
|
||||
ModInfoModel.Current.I18nResource.ReplaceCulture(oldCulture, window.ViewModel.Culture);
|
||||
I18nResource.ReplaceCulture(oldCulture, window.ViewModel.Culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -192,7 +192,7 @@ public class ModEditWindowVM : ObservableObjectX
|
||||
) is MessageBoxResult.No
|
||||
)
|
||||
return;
|
||||
ModInfoModel.Current.I18nResource.RemoveCulture(oldCulture);
|
||||
I18nResource.RemoveCulture(oldCulture);
|
||||
}
|
||||
|
||||
public void SetMainCultureCommand_ExecuteCommand(string culture)
|
||||
@ -207,31 +207,11 @@ public class ModEditWindowVM : ObservableObjectX
|
||||
is not MessageBoxResult.Yes
|
||||
)
|
||||
return;
|
||||
// TODO
|
||||
//ModInfo.I18nDatas[culture].Name = ModInfo.ID;
|
||||
//ModInfo.I18nDatas[culture].Description = ModInfo.DescriptionID;
|
||||
//foreach (var food in ModInfo.Foods)
|
||||
//{
|
||||
// food.I18nDatas[culture].Name = food.ID;
|
||||
// food.I18nDatas[culture].Description = food.DescriptionID;
|
||||
//}
|
||||
//foreach (var text in ModInfo.LowTexts)
|
||||
// text.I18nDatas[culture].Text = text.ID;
|
||||
//foreach (var text in ModInfo.ClickTexts)
|
||||
// text.I18nDatas[culture].Text = text.ID;
|
||||
//foreach (var text in ModInfo.SelectTexts)
|
||||
//{
|
||||
// text.I18nDatas[culture].Text = text.ID;
|
||||
// text.I18nDatas[culture].Choose = text.ChooseID;
|
||||
//}
|
||||
//foreach (var pet in ModInfo.Pets)
|
||||
//{
|
||||
// pet.I18nDatas[culture].Name = pet.ID;
|
||||
// pet.I18nDatas[culture].PetName = pet.PetNameID;
|
||||
// pet.I18nDatas[culture].Description = pet.DescriptionID;
|
||||
// foreach (var work in pet.Works)
|
||||
// work.I18nDatas[culture].Name = work.ID;
|
||||
//}
|
||||
foreach (var datas in I18nResource.CultureDatas)
|
||||
{
|
||||
I18nResource.SetCurrentCultureData(datas.Key, datas.Key);
|
||||
}
|
||||
ModInfo.RefreshAllID();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -299,7 +279,7 @@ public class ModEditWindowVM : ObservableObjectX
|
||||
/// <returns>成功为 <see langword="true"/> 失败为 <see langword="false"/></returns>
|
||||
private bool ValidationData(ModInfoModel model)
|
||||
{
|
||||
if (ModInfoModel.Current.I18nResource.CultureDatas.HasValue() is false)
|
||||
if (I18nResource.CultureDatas.HasValue() is false)
|
||||
{
|
||||
MessageBox.Show(
|
||||
ModEditWindow,
|
||||
|
@ -24,7 +24,9 @@ public class MovePageVM : ObservableObjectX
|
||||
Filter = f => f.Graph.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
PropertyChanged += MovePageVM_PropertyChanged;
|
||||
|
||||
PropertyChangedX += MovePageVM_PropertyChangedX;
|
||||
;
|
||||
if (Pets.HasValue())
|
||||
CurrentPet = Pets.FirstOrDefault(
|
||||
m => m.FromMain is false && m.Moves.HasValue(),
|
||||
@ -78,12 +80,18 @@ public class MovePageVM : ObservableObjectX
|
||||
public ObservableCommand<MoveModel> EditCommand { get; } = new();
|
||||
public ObservableCommand<MoveModel> RemoveCommand { get; } = new();
|
||||
#endregion
|
||||
private void MovePageVM_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
|
||||
private void MovePageVM_PropertyChangedX(object? sender, PropertyChangedXEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(CurrentPet))
|
||||
{
|
||||
Moves.Clear();
|
||||
if (e.OldValue is PetModel pet)
|
||||
Moves.BindingList(pet.Moves, true);
|
||||
if (e.NewValue is null)
|
||||
return;
|
||||
Moves.AddRange(CurrentPet.Moves);
|
||||
Moves.BindingList(CurrentPet.Moves);
|
||||
}
|
||||
else if (e.PropertyName == nameof(Search))
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ public class PetEditWindowVM : ObservableObjectX
|
||||
|
||||
#region Pet
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private PetModel _pet = new();
|
||||
private PetModel _pet = new() { I18nResource = ModInfoModel.Current.I18nResource };
|
||||
|
||||
public PetModel Pet
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using HKW.HKWUtils.Extensions;
|
||||
using HKW.HKWUtils.Observable;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using VPet.ModMaker.Models;
|
||||
@ -23,6 +24,7 @@ public class PetPageVM : ObservableObjectX
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
Pets.BindingList(ModInfoModel.Current.Pets);
|
||||
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
@ -89,21 +91,32 @@ public class PetPageVM : ObservableObjectX
|
||||
var window = new PetEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.OldPet = model;
|
||||
var newPet = vm.Pet = new(model);
|
||||
var newModel = vm.Pet = new(model) { I18nResource = ModInfoModel.Current.TempI18nResource };
|
||||
model.I18nResource.CopyDataTo(
|
||||
newModel.I18nResource,
|
||||
[model.ID, model.PetNameID, model.DescriptionID],
|
||||
true
|
||||
);
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
{
|
||||
newModel.I18nResource.ClearCultureData();
|
||||
newModel.CloseI18nResource();
|
||||
return;
|
||||
}
|
||||
newModel.I18nResource.CopyDataTo(ModInfoModel.Current.I18nResource, true);
|
||||
newModel.I18nResource = ModInfoModel.Current.I18nResource;
|
||||
if (model.FromMain)
|
||||
{
|
||||
var index = Pets.IndexOf(model);
|
||||
Pets.Remove(model);
|
||||
Pets.Insert(index, newPet);
|
||||
Pets.Insert(index, newModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pets[Pets.IndexOf(model)] = newPet;
|
||||
Pets[Pets.IndexOf(model)] = newModel;
|
||||
}
|
||||
model.Close();
|
||||
model.CloseI18nResource();
|
||||
}
|
||||
|
||||
private void RemoveCommand_ExecuteCommand(PetModel model)
|
||||
@ -116,5 +129,6 @@ public class PetPageVM : ObservableObjectX
|
||||
if (MessageBox.Show("确定删除吗".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||
return;
|
||||
Pets.Remove(model);
|
||||
model.CloseI18nResource();
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ public class SelectTextEditWindowVM : ObservableObjectX
|
||||
|
||||
#region SelectText
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private SelectTextModel _selectText = new();
|
||||
private SelectTextModel _selectText =
|
||||
new() { I18nResource = ModInfoModel.Current.I18nResource };
|
||||
|
||||
public SelectTextModel SelectText
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using HKW.HKWUtils.Extensions;
|
||||
using HKW.HKWUtils.Observable;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using VPet.ModMaker.Models;
|
||||
@ -23,6 +24,8 @@ public class SelectTextPageVM : ObservableObjectX
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
SelectTexts.BindingList(ModInfoModel.Current.SelectTexts);
|
||||
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteCommand;
|
||||
@ -77,11 +80,22 @@ public class SelectTextPageVM : ObservableObjectX
|
||||
var window = new SelectTextEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.OldSelectText = model;
|
||||
var newSelectText = vm.SelectText = new(model);
|
||||
var newModel = vm.SelectText = new(model)
|
||||
{
|
||||
I18nResource = ModInfoModel.Current.I18nResource
|
||||
};
|
||||
model.I18nResource.CopyDataTo(newModel.I18nResource, [model.ID, model.ChooseID], true);
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
{
|
||||
newModel.I18nResource.ClearCultureData();
|
||||
newModel.Close();
|
||||
return;
|
||||
SelectTexts[SelectTexts.IndexOf(model)] = newSelectText;
|
||||
}
|
||||
newModel.I18nResource.CopyDataTo(ModInfoModel.Current.I18nResource, true);
|
||||
newModel.I18nResource = ModInfoModel.Current.I18nResource;
|
||||
SelectTexts[SelectTexts.IndexOf(model)] = newModel;
|
||||
model.Close();
|
||||
}
|
||||
|
||||
private void RemoveCommand_ExecuteCommand(SelectTextModel model)
|
||||
@ -89,5 +103,6 @@ public class SelectTextPageVM : ObservableObjectX
|
||||
if (MessageBox.Show("确定删除吗".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||
return;
|
||||
SelectTexts.Remove(model);
|
||||
model.Close();
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class WorkEditWindowVM : ObservableObjectX
|
||||
|
||||
#region Work
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private WorkModel _work = new();
|
||||
private WorkModel _work = new() { I18nResource = ModInfoModel.Current.I18nResource };
|
||||
|
||||
public WorkModel Work
|
||||
{
|
||||
|
@ -24,7 +24,8 @@ public class WorkPageVM : ObservableObjectX
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
FilteredList = new()
|
||||
};
|
||||
PropertyChanged += WorkPageVM_PropertyChanged;
|
||||
PropertyChangedX += WorkPageVM_PropertyChangedX;
|
||||
|
||||
if (Pets.HasValue())
|
||||
CurrentPet = Pets.FirstOrDefault(
|
||||
m => m.FromMain is false && m.Works.HasValue(),
|
||||
@ -40,7 +41,7 @@ public class WorkPageVM : ObservableObjectX
|
||||
#region Property
|
||||
#region Works
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private ObservableFilterList<WorkModel, ObservableList<WorkModel>> _works;
|
||||
private ObservableFilterList<WorkModel, ObservableList<WorkModel>> _works = null!;
|
||||
|
||||
public ObservableFilterList<WorkModel, ObservableList<WorkModel>> Works
|
||||
{
|
||||
@ -53,7 +54,7 @@ public class WorkPageVM : ObservableObjectX
|
||||
|
||||
#region CurrentPet
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private PetModel _currentPet;
|
||||
private PetModel _currentPet = null!;
|
||||
|
||||
public PetModel CurrentPet
|
||||
{
|
||||
@ -78,12 +79,18 @@ public class WorkPageVM : ObservableObjectX
|
||||
public ObservableCommand<WorkModel> EditCommand { get; } = new();
|
||||
public ObservableCommand<WorkModel> RemoveCommand { get; } = new();
|
||||
#endregion
|
||||
private void WorkPageVM_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
|
||||
private void WorkPageVM_PropertyChangedX(object? sender, PropertyChangedXEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(CurrentPet))
|
||||
{
|
||||
Works.Clear();
|
||||
if (e.OldValue is PetModel pet)
|
||||
Works.BindingList(pet.Works, true);
|
||||
if (e.NewValue is null)
|
||||
return;
|
||||
Works.AddRange(CurrentPet.Works);
|
||||
Works.BindingList(CurrentPet.Works);
|
||||
}
|
||||
else if (e.PropertyName == nameof(Search))
|
||||
{
|
||||
@ -108,11 +115,21 @@ public class WorkPageVM : ObservableObjectX
|
||||
var vm = window.ViewModel;
|
||||
vm.CurrentPet = CurrentPet;
|
||||
vm.OldWork = model;
|
||||
var newWork = vm.Work = new(model);
|
||||
var newModel = vm.Work = new(model)
|
||||
{
|
||||
I18nResource = ModInfoModel.Current.TempI18nResource
|
||||
};
|
||||
model.I18nResource.CopyDataTo(newModel.I18nResource, model.ID, true);
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
{
|
||||
newModel.I18nResource.ClearCultureData();
|
||||
newModel.Close();
|
||||
return;
|
||||
Works[Works.IndexOf(model)] = newWork;
|
||||
}
|
||||
newModel.I18nResource.CopyDataTo(ModInfoModel.Current.I18nResource, true);
|
||||
newModel.I18nResource = ModInfoModel.Current.I18nResource;
|
||||
Works[Works.IndexOf(model)] = newModel;
|
||||
model.Close();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public partial class AddCultureWindow : WindowX
|
||||
if (
|
||||
MessageBoxX.Show(
|
||||
this,
|
||||
"无法正确打开链接,需要复制自行访问吗",
|
||||
"无法打开链接,需要复制自行访问吗",
|
||||
"",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxIcon.Warning
|
||||
|
@ -27,8 +27,8 @@ public partial class AnimeEditWindow : Window
|
||||
{
|
||||
public AnimeEditWindow()
|
||||
{
|
||||
DataContext = new AnimeEditWindowVM();
|
||||
InitializeComponent();
|
||||
DataContext = new AnimeEditWindowVM();
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
try
|
||||
@ -77,12 +77,12 @@ public partial class AnimeEditWindow : Window
|
||||
RoutedEvent = MouseWheelEvent,
|
||||
Source = sender
|
||||
};
|
||||
var parent = ((Control)sender).Parent as UIElement;
|
||||
var parent = ((Control)sender!).Parent as UIElement;
|
||||
parent.RaiseEvent(eventArg);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private object _dropSender;
|
||||
private object _dropSender = null!;
|
||||
|
||||
private void ListBox_PreviewMouseMove(object? sender, MouseEventArgs e)
|
||||
{
|
||||
|
@ -28,8 +28,8 @@ public partial class FoodAnimeEditWindow : Window
|
||||
{
|
||||
public FoodAnimeEditWindow()
|
||||
{
|
||||
DataContext = new FoodAnimeEditWindowVM();
|
||||
InitializeComponent();
|
||||
DataContext = new FoodAnimeEditWindowVM();
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
try
|
||||
|
@ -43,6 +43,7 @@
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
CanUserReorderColumns="False"
|
||||
CellEditEnding="DataGrid_Datas_CellEditEnding"
|
||||
ItemsSource="{Binding I18nDatas.FilteredList}"
|
||||
ScrollViewer.IsDeferredScrollingEnabled="True"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling">
|
||||
|
@ -87,8 +87,6 @@ public partial class I18nEditWindow : WindowX
|
||||
/// <param name="newCultureName"></param>
|
||||
public void ReplaceCulture(string oldCultureName, string newCultureName)
|
||||
{
|
||||
//if (_dataGridI18nColumns.ContainsKey(newCultureName))
|
||||
// throw new();
|
||||
var column = _dataGridI18nColumns[oldCultureName];
|
||||
column.Header = newCultureName;
|
||||
_dataGridI18nColumns.Remove(oldCultureName);
|
||||
@ -111,4 +109,9 @@ public partial class I18nEditWindow : WindowX
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void DataGrid_Datas_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||
{
|
||||
ViewModel.CellEdit = true;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public partial class ModEditWindow : WindowX
|
||||
/// </summary>
|
||||
public void InitializeData()
|
||||
{
|
||||
if (ModInfoModel.Current.I18nResource.CultureDatas.HasValue() is false)
|
||||
if (ModInfoModel.Current.I18nResource.Cultures.HasValue() is false)
|
||||
{
|
||||
if (
|
||||
MessageBox.Show("未添加任何文化,确定要添加文化吗?".Translate(), "", MessageBoxButton.YesNo)
|
||||
@ -84,8 +84,10 @@ public partial class ModEditWindow : WindowX
|
||||
)
|
||||
return;
|
||||
ViewModel.AddCultureCommand_ExecuteCommand();
|
||||
if (string.IsNullOrWhiteSpace(ViewModel.ModInfo.ID))
|
||||
return;
|
||||
if (
|
||||
ModInfoModel.Current.I18nResource.CultureDatas.HasValue() is false
|
||||
ModInfoModel.Current.I18nResource.Cultures.HasValue() is false
|
||||
|| MessageBox.Show(
|
||||
"需要将文化 {0} 设为主要文化吗?".Translate(
|
||||
ModInfoModel.Current.I18nResource.Cultures.First().Name
|
||||
|
@ -27,8 +27,8 @@ public partial class PetEditWindow : Window
|
||||
|
||||
public PetEditWindow()
|
||||
{
|
||||
DataContext = new PetEditWindowVM();
|
||||
InitializeComponent();
|
||||
DataContext = new PetEditWindowVM();
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
ViewModel.Close();
|
||||
|
@ -28,10 +28,7 @@ public partial class WorkEditWindow : Window
|
||||
public WorkEditWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.SetDataContext<WorkEditWindowVM>(() => {
|
||||
//TODO
|
||||
//ViewModel.Close();
|
||||
});
|
||||
this.SetDataContext<WorkEditWindowVM>();
|
||||
}
|
||||
|
||||
private void Button_Cancel_Click(object? sender, RoutedEventArgs e)
|
||||
@ -41,15 +38,15 @@ public partial class WorkEditWindow : Window
|
||||
|
||||
private void Button_Yes_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ViewModel.Work.ID))
|
||||
if (string.IsNullOrWhiteSpace(ViewModel.Work.ID))
|
||||
{
|
||||
MessageBox.Show("Id不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
MessageBox.Show("ID不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(ViewModel.Work.Graph))
|
||||
if (string.IsNullOrWhiteSpace(ViewModel.Work.Graph))
|
||||
{
|
||||
MessageBox.Show(
|
||||
"指定动画Id不可为空".Translate(),
|
||||
"指定动画ID不可为空".Translate(),
|
||||
"",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning
|
||||
@ -61,7 +58,7 @@ public partial class WorkEditWindow : Window
|
||||
&& ViewModel.CurrentPet.Works.Any(i => i.ID == ViewModel.Work.ID)
|
||||
)
|
||||
{
|
||||
MessageBox.Show("此Id已存在".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
MessageBox.Show("此ID已存在".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
IsCancel = false;
|
||||
|
@ -84,7 +84,7 @@ public partial class ModMakerWindow : WindowX
|
||||
if (
|
||||
MessageBoxX.Show(
|
||||
this,
|
||||
"无法正确打开链接,需要复制自行访问吗".Translate(),
|
||||
"无法打开链接,需要复制自行访问吗".Translate(),
|
||||
"",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxIcon.Warning
|
||||
|
Loading…
Reference in New Issue
Block a user