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