mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
更新
This commit is contained in:
parent
9546fb604a
commit
479d995c84
@ -97,9 +97,9 @@ public class FoodModel : I18nModel<I18nFoodModel>
|
||||
public FoodModel()
|
||||
{
|
||||
DescriptionId.Value = $"{Id.Value}_{nameof(DescriptionId)}";
|
||||
Id.ValueChanged += (o, n) =>
|
||||
Id.ValueChanged += (s, e) =>
|
||||
{
|
||||
DescriptionId.Value = $"{n}_{nameof(DescriptionId)}";
|
||||
DescriptionId.Value = $"{e.NewValue}_{nameof(DescriptionId)}";
|
||||
};
|
||||
ReferencePrice.AddNotifySender(
|
||||
Strength,
|
||||
|
@ -149,10 +149,11 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
||||
{
|
||||
var petModel = new PetModel(pet);
|
||||
Pets.Add(petModel);
|
||||
ModMakerInfo.MainPets.Add(petModel.Id.Value, new(pet, true));
|
||||
foreach (var p in pet.path)
|
||||
LoadAnime(petModel, p);
|
||||
}
|
||||
|
||||
Pets.Clear();
|
||||
// 插入本体宠物
|
||||
foreach (var pet in ModMakerInfo.MainPets)
|
||||
{
|
||||
@ -392,7 +393,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
||||
private void SavePets(string path)
|
||||
{
|
||||
var petPath = Path.Combine(path, "pet");
|
||||
if (Pets.Count == 0)
|
||||
if (Pets.Count == 0 || Pets.All(m => m.CanSave() is false))
|
||||
{
|
||||
if (Directory.Exists(petPath))
|
||||
Directory.Delete(petPath, true);
|
||||
|
@ -25,7 +25,7 @@ public class PetModel : I18nModel<I18nPetInfoModel>
|
||||
/// <summary>
|
||||
/// 来自本体
|
||||
/// </summary>
|
||||
public ObservableValue<bool> FromMain { get; set; } = new(false);
|
||||
public ObservableValue<bool> FromMain { get; } = new(false);
|
||||
|
||||
/// <summary>
|
||||
/// Id
|
||||
@ -99,10 +99,10 @@ public class PetModel : I18nModel<I18nPetInfoModel>
|
||||
{
|
||||
PetNameId.Value = $"{Id.Value}_{nameof(PetNameId)}";
|
||||
DescriptionId.Value = $"{Id.Value}_{nameof(DescriptionId)}";
|
||||
Id.ValueChanged += (o, n) =>
|
||||
Id.ValueChanged += (s, e) =>
|
||||
{
|
||||
PetNameId.Value = $"{n}_{nameof(PetNameId)}";
|
||||
DescriptionId.Value = $"{n}_{nameof(DescriptionId)}";
|
||||
PetNameId.Value = $"{e.NewValue}_{nameof(PetNameId)}";
|
||||
DescriptionId.Value = $"{e.NewValue}_{nameof(DescriptionId)}";
|
||||
};
|
||||
AnimeCount.AddNotifySender(Animes);
|
||||
AnimeCount.AddNotifySender(FoodAnimes);
|
||||
@ -201,6 +201,18 @@ public class PetModel : I18nModel<I18nPetInfoModel>
|
||||
}
|
||||
|
||||
#region Save
|
||||
|
||||
/// <summary>
|
||||
/// 能被保存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CanSave()
|
||||
{
|
||||
if (FromMain.Value && Works.Count == 0 && Animes.Count == 0 && FoodAnimes.Count == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存宠物
|
||||
/// </summary>
|
||||
|
@ -95,9 +95,9 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
|
||||
public SelectTextModel()
|
||||
{
|
||||
ChooseId.Value = $"{Id.Value}_{nameof(ChooseId)}";
|
||||
Id.ValueChanged += (o, n) =>
|
||||
Id.ValueChanged += (s, e) =>
|
||||
{
|
||||
ChooseId.Value = $"{n}_{nameof(ChooseId)}";
|
||||
ChooseId.Value = $"{e.NewValue}_{nameof(ChooseId)}";
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class I18nEditWindowVM
|
||||
/// 载入宠物
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
private void LoadPets(ModInfoModel model)
|
||||
public void LoadPets(ModInfoModel model)
|
||||
{
|
||||
foreach (var pet in model.Pets)
|
||||
{
|
||||
@ -317,6 +317,8 @@ public class I18nEditWindowVM
|
||||
else if (e.Action is NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var oldModel = (PetModel)e.OldItems[0];
|
||||
if (oldModel.FromMain.Value)
|
||||
return;
|
||||
RemoveData(oldModel.Id, oldModel, (m) => m.Name);
|
||||
RemoveData(oldModel.DescriptionId, oldModel, (m) => m.Description);
|
||||
foreach (var work in oldModel.Works)
|
||||
|
@ -9,6 +9,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using VPet.ModMaker.Models;
|
||||
using VPet.ModMaker.ViewModels.ModEdit.I18nEdit;
|
||||
using VPet.ModMaker.Views.ModEdit.I18nEdit;
|
||||
using VPet.ModMaker.Views.ModEdit.PetEdit;
|
||||
|
||||
namespace VPet.ModMaker.ViewModels.ModEdit.PetEdit;
|
||||
@ -66,12 +68,14 @@ public class PetPageVM
|
||||
|
||||
public void Edit(PetModel model)
|
||||
{
|
||||
if (
|
||||
model.FromMain.Value
|
||||
&& MessageBox.Show("这是本体自带的宠物, 确定要编辑吗".Translate(), "", MessageBoxButton.YesNo)
|
||||
if (model.FromMain.Value)
|
||||
{
|
||||
if (
|
||||
MessageBox.Show("这是本体自带的宠物, 确定要编辑吗".Translate(), "", MessageBoxButton.YesNo)
|
||||
is not MessageBoxResult.Yes
|
||||
)
|
||||
return;
|
||||
)
|
||||
return;
|
||||
}
|
||||
var window = new PetEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.OldPet = model;
|
||||
@ -79,7 +83,16 @@ public class PetPageVM
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
return;
|
||||
Pets[Pets.IndexOf(model)] = newPet;
|
||||
if (model.FromMain.Value)
|
||||
{
|
||||
var index = Pets.IndexOf(model);
|
||||
Pets.Remove(model);
|
||||
Pets.Insert(index, newPet);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pets[Pets.IndexOf(model)] = newPet;
|
||||
}
|
||||
if (ShowPets.Value.Count != Pets.Count)
|
||||
ShowPets.Value[ShowPets.Value.IndexOf(model)] = newPet;
|
||||
model.Close();
|
||||
|
@ -51,7 +51,7 @@
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Id.Value}" />
|
||||
<TextBlock IsEnabled="{Binding FromMain, Converter={StaticResource FalseToCollapsedConverter}}" Text="{ll:Str {} (来自本体)}" />
|
||||
<TextBlock Text="{ll:Str {} (来自本体)}" Visibility="{Binding FromMain, Converter={StaticResource FalseToCollapsedConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
@ -51,7 +51,7 @@
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Id.Value}" />
|
||||
<TextBlock IsEnabled="{Binding FromMain.Value, Converter={StaticResource FalseToCollapsedConverter}}" Text="{ll:Str {} (来自本体)}" />
|
||||
<TextBlock Text="{ll:Str {} (来自本体)}" Visibility="{Binding FromMain.Value, Converter={StaticResource FalseToCollapsedConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
@ -43,13 +43,23 @@
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Id.Value}"
|
||||
<DataGridTemplateColumn
|
||||
CanUserSort="True"
|
||||
ElementStyle="{DynamicResource TextBlock_LeftCenter}"
|
||||
Header="Id"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Id.Value" />
|
||||
SortMemberPath="Id.Value">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{DynamicResource TextBlock_LeftCenter}" Text="{Binding Id.Value}" />
|
||||
<TextBlock
|
||||
Style="{DynamicResource TextBlock_LeftCenter}"
|
||||
Text="{ll:Str {} (来自本体)}"
|
||||
Visibility="{Binding FromMain.Value, Converter={StaticResource FalseToCollapsedConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding CurrentI18nData.Value.Name.Value}"
|
||||
CanUserSort="True"
|
||||
|
@ -55,7 +55,7 @@
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Id.Value}" />
|
||||
<TextBlock IsEnabled="{Binding FromMain.Value, Converter={StaticResource FalseToCollapsedConverter}}" Text="{ll:Str {} (来自本体)}" />
|
||||
<TextBlock Text="{ll:Str {} (来自本体)}" Visibility="{Binding FromMain.Value, Converter={StaticResource FalseToCollapsedConverter}}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
Loading…
Reference in New Issue
Block a user