mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
# 修复
- 启动时本体宠物无法载入的问题
This commit is contained in:
parent
4c48706d6b
commit
3daed8a022
@ -5,7 +5,7 @@
|
||||
<c:MarginMultiConverter x:Key="MarginConverter" />
|
||||
<c:MarginMultiConverter x:Key="RatioMarginConverter" HasRatio="True" />
|
||||
<c:CalculatorMultiConverter x:Key="CalculatorConverter" />
|
||||
<c:StringFormatMultiConverter x:Key="StringFormatConverter" />
|
||||
<c:StringFormatMultiConverter x:Key="StringFormatConverter" HiddenUnsetAndNull="True" />
|
||||
<c:SolidColorBrushToMediaColorConverter x:Key="BrushToMediaColorConverter" />
|
||||
<!--<c:MaxConverter x:Key="MaxConverter" />-->
|
||||
<c:BoolToVisibilityConverter x:Key="FalseToCollapsedConverter" />
|
||||
|
@ -40,7 +40,7 @@ public class ModMaker : MainPlugin
|
||||
Application.Current.Resources.MergedDictionaries.Add(ModMakerInfo.NativeStyles);
|
||||
}
|
||||
|
||||
public I18nResource<string, string> I18nResource { get; } =
|
||||
public static I18nResource<string, string> I18nResource { get; } =
|
||||
new() { FillDefaultValueForNewCulture = true, DefaultValue = string.Empty };
|
||||
|
||||
public override void Setting()
|
||||
|
@ -55,4 +55,19 @@ public static class ModMakerInfo
|
||||
{
|
||||
return AnimeTypeModel.HasNameAnimes.Contains(graphType);
|
||||
}
|
||||
|
||||
static ModMakerInfo()
|
||||
{
|
||||
//#if DEBUG
|
||||
// MainPets.TryAdd(
|
||||
// "TestMainPet",
|
||||
// new()
|
||||
// {
|
||||
// ID = "TestMainPet",
|
||||
// FromMain = true,
|
||||
// I18nResource = new()
|
||||
// }
|
||||
// );
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,12 @@ public class ModInfoModel : ObservableObjectX
|
||||
]
|
||||
)
|
||||
);
|
||||
foreach (var pet in ModMakerInfo.MainPets)
|
||||
{
|
||||
// 确保ID不重复
|
||||
if (Pets.All(i => i.ID != pet.Key))
|
||||
Pets.Add(pet.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public ModInfoModel(ModLoader loader)
|
||||
@ -118,14 +124,6 @@ public class ModInfoModel : ObservableObjectX
|
||||
foreach (var p in pet.path)
|
||||
LoadAnime(petModel, p);
|
||||
}
|
||||
|
||||
// 插入本体宠物
|
||||
foreach (var pet in ModMakerInfo.MainPets)
|
||||
{
|
||||
// 确保ID不重复
|
||||
if (Pets.All(i => i.ID != pet.Key))
|
||||
Pets.Insert(0, pet.Value);
|
||||
}
|
||||
if (loader.I18nDatas.HasValue() is false)
|
||||
return;
|
||||
LoadI18nDatas(loader);
|
||||
|
@ -112,12 +112,7 @@ public class PetModel : ObservableObjectX
|
||||
RaisePoint.Ill = new(loader.Config.RaisePoint[3].X, loader.Config.RaisePoint[3].Y);
|
||||
// 如果这个宠物数据来自本体, 则不载入 Work 和 Move
|
||||
if (FromMain = fromMain)
|
||||
{
|
||||
Name = ID.Translate();
|
||||
PetName = PetNameID.Translate();
|
||||
Description = DescriptionID.Translate();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var work in loader.Config.Works)
|
||||
Works.Add(new(work) { I18nResource = I18nResource! });
|
||||
@ -163,7 +158,7 @@ public class PetModel : ObservableObjectX
|
||||
private string _petNameID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 名称Id
|
||||
/// 名称ID
|
||||
/// </summary>
|
||||
public string PetNameID
|
||||
{
|
||||
@ -177,7 +172,7 @@ public class PetModel : ObservableObjectX
|
||||
private string _descriptionID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 描述Id
|
||||
/// 描述ID
|
||||
/// </summary>
|
||||
public string DescriptionID
|
||||
{
|
||||
@ -217,6 +212,32 @@ public class PetModel : ObservableObjectX
|
||||
]
|
||||
)
|
||||
);
|
||||
if (FromMain)
|
||||
{
|
||||
foreach (var cultureName in LocalizeCore.AvailableCultures)
|
||||
{
|
||||
if (LocalizeCore.Localizations.TryGetValue(cultureName, out var data) is false)
|
||||
continue;
|
||||
foreach (var line in data)
|
||||
{
|
||||
if (line?.Name == ID)
|
||||
{
|
||||
I18nResource.AddCultureData(cultureName, ID, line.Info);
|
||||
}
|
||||
else if (line?.Name == PetNameID)
|
||||
{
|
||||
I18nResource.AddCultureData(cultureName, PetNameID, line.Info);
|
||||
}
|
||||
else if (line?.Name == DescriptionID)
|
||||
{
|
||||
I18nResource.AddCultureData(cultureName, DescriptionID, line.Info);
|
||||
}
|
||||
}
|
||||
I18nResource.AddCultureData(cultureName, ID, ID);
|
||||
I18nResource.AddCultureData(cultureName, PetNameID, PetNameID);
|
||||
I18nResource.AddCultureData(cultureName, DescriptionID, DescriptionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AdaptIgnore]
|
||||
|
@ -14,34 +14,34 @@
|
||||
<Configurations>Debug;Release;Test</Configurations>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
<DebugType>embedded</DebugType>
|
||||
</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>
|
||||
<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.WPF" Version="1.0.7" />
|
||||
<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" />
|
||||
<PackageReference Include="VPet-Simulator.Core" Version="1.1.0.12" />
|
||||
<PackageReference Include="VPet-Simulator.Windows.Interface" Version="1.1.0.12" />
|
||||
<PackageReference Include="LinePutScript" Version="1.11.6" />
|
||||
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
|
||||
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.7" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
|
||||
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.2" />
|
||||
|
@ -48,6 +48,21 @@ public class AnimePageVM : ObservableObjectX
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteCommand;
|
||||
ModInfo.PropertyChangedX += ModInfo_PropertyChangedX;
|
||||
}
|
||||
|
||||
private void ModInfo_PropertyChangedX(object? sender, PropertyChangedXEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(ModInfoModel.ShowMainPet))
|
||||
{
|
||||
if (e.NewValue is false)
|
||||
{
|
||||
if (CurrentPet.FromMain)
|
||||
{
|
||||
CurrentPet = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AnimePageVM_PropertyChangedX(object? sender, PropertyChangedXEventArgs e)
|
||||
|
@ -21,7 +21,12 @@ public class PetPageVM : ObservableObjectX
|
||||
{
|
||||
Pets = new(ModInfoModel.Current.Pets)
|
||||
{
|
||||
Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase),
|
||||
Filter = (f) =>
|
||||
{
|
||||
if (ShowMainPet is false && f.FromMain)
|
||||
return false;
|
||||
return f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase);
|
||||
},
|
||||
FilteredList = new()
|
||||
};
|
||||
Pets.BindingList(ModInfoModel.Current.Pets);
|
||||
@ -59,6 +64,24 @@ public class PetPageVM : ObservableObjectX
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region ShowMainPet
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||
private bool _showMainPet;
|
||||
|
||||
public bool ShowMainPet
|
||||
{
|
||||
get => _showMainPet;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _showMainPet, value);
|
||||
ModInfo.ShowMainPet = value;
|
||||
Pets.Refresh();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Command
|
||||
public ObservableCommand AddCommand { get; } = new();
|
||||
|
@ -34,6 +34,21 @@ public class WorkPageVM : ObservableObjectX
|
||||
AddCommand.ExecuteCommand += AddCommand_ExecuteCommand;
|
||||
EditCommand.ExecuteCommand += EditCommand_ExecuteCommand;
|
||||
RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteCommand;
|
||||
ModInfo.PropertyChangedX += ModInfo_PropertyChangedX;
|
||||
}
|
||||
|
||||
private void ModInfo_PropertyChangedX(object? sender, PropertyChangedXEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(ModInfoModel.ShowMainPet))
|
||||
{
|
||||
if (e.NewValue is false)
|
||||
{
|
||||
if (CurrentPet.FromMain)
|
||||
{
|
||||
CurrentPet = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ModInfoModel ModInfo => ModInfoModel.Current;
|
||||
|
@ -30,7 +30,7 @@
|
||||
<pu:Switch
|
||||
Grid.Column="1"
|
||||
Content="{ll:Str 显示本体宠物}"
|
||||
IsChecked="{Binding ModInfo.ShowMainPet}" />
|
||||
IsChecked="{Binding ShowMainPet}" />
|
||||
</Grid>
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
||||
|
Loading…
Reference in New Issue
Block a user