fix: fix build issue and tas seq refactor issue
This commit is contained in:
@@ -27,7 +27,7 @@ namespace BallanceTasEditor.Backend {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="index">要访问的单元的索引。</param>
|
/// <param name="index">要访问的单元的索引。</param>
|
||||||
/// <returns>被访问的单元。</returns>
|
/// <returns>被访问的单元。</returns>
|
||||||
/// <exception cref="ArgumentOutOfRangeException">给定的索引无效。</exception>
|
/// <exception cref="IndexOutOfRangeException">给定的索引无效。</exception>
|
||||||
TasFrame Visit(int index);
|
TasFrame Visit(int index);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在给定的帧索引<b>之前</b>插入给定的项目。
|
/// 在给定的帧索引<b>之前</b>插入给定的项目。
|
||||||
@@ -43,7 +43,7 @@ namespace BallanceTasEditor.Backend {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="index">要在前方插入数据的元素的索引。</param>
|
/// <param name="index">要在前方插入数据的元素的索引。</param>
|
||||||
/// <param name="items">要插入的元素的迭代器。</param>
|
/// <param name="items">要插入的元素的迭代器。</param>
|
||||||
/// <exception cref="ArgumentOutOfRangeException">给定的索引无效。</exception>
|
/// <exception cref="IndexOutOfRangeException">给定的索引无效。</exception>
|
||||||
void Insert(int index, IExactSizeEnumerable<TasFrame> items);
|
void Insert(int index, IExactSizeEnumerable<TasFrame> items);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从序列中移出给定帧区间的元素。
|
/// 从序列中移出给定帧区间的元素。
|
||||||
@@ -55,7 +55,7 @@ namespace BallanceTasEditor.Backend {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="startIndex">要移除的帧区间的起始索引(包含)。</param>
|
/// <param name="startIndex">要移除的帧区间的起始索引(包含)。</param>
|
||||||
/// <param name="endIndex">要移除的帧区间的终止索引(包含)</param>
|
/// <param name="endIndex">要移除的帧区间的终止索引(包含)</param>
|
||||||
/// <exception cref="ArgumentOutOfRangeException">给定的索引无效。</exception>
|
/// <exception cref="IndexOutOfRangeException">给定的索引无效。</exception>
|
||||||
void Remove(int startIndex, int endIndex);
|
void Remove(int startIndex, int endIndex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -159,7 +159,7 @@ namespace BallanceTasEditor.Backend {
|
|||||||
if (endIndex < startIndex || startIndex < 0 || endIndex >= m_Container.Count) {
|
if (endIndex < startIndex || startIndex < 0 || endIndex >= m_Container.Count) {
|
||||||
throw new IndexOutOfRangeException("Invalid index for frame.");
|
throw new IndexOutOfRangeException("Invalid index for frame.");
|
||||||
} else {
|
} else {
|
||||||
m_Container.RemoveRange(startIndex, endIndex - startIndex);
|
m_Container.RemoveRange(startIndex, endIndex - startIndex + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,9 +277,8 @@ namespace BallanceTasEditor.Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(int index, IExactSizeEnumerable<TasFrame> items) {
|
public void Insert(int index, IExactSizeEnumerable<TasFrame> items) {
|
||||||
if (index >= m_Container.Count || index < 0) {
|
// YYC MARK:
|
||||||
throw new IndexOutOfRangeException("Invalid index for frame.");
|
// We must test the equal first, to handle back appending properly.
|
||||||
} else {
|
|
||||||
if (index == m_Container.Count) {
|
if (index == m_Container.Count) {
|
||||||
foreach (TasFrame item in items) {
|
foreach (TasFrame item in items) {
|
||||||
m_Container.AddLast(item);
|
m_Container.AddLast(item);
|
||||||
@@ -291,6 +290,9 @@ namespace BallanceTasEditor.Backend {
|
|||||||
} else {
|
} else {
|
||||||
m_Cursor = new LinkedListCursor<TasFrame>(pendingCursor, 0);
|
m_Cursor = new LinkedListCursor<TasFrame>(pendingCursor, 0);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (index >= m_Container.Count || index < 0) {
|
||||||
|
throw new IndexOutOfRangeException("Invalid index for frame.");
|
||||||
} else {
|
} else {
|
||||||
MoveToIndex(index);
|
MoveToIndex(index);
|
||||||
|
|
||||||
@@ -308,7 +310,7 @@ namespace BallanceTasEditor.Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute count and move to index.
|
// Compute count and move to index.
|
||||||
var count = endIndex - startIndex;
|
var count = endIndex - startIndex + 1;
|
||||||
MoveToIndex(startIndex);
|
MoveToIndex(startIndex);
|
||||||
|
|
||||||
// 我们总是获取要删除的项目的前一项来作为参照。
|
// 我们总是获取要删除的项目的前一项来作为参照。
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<ApplicationIcon>Assets\App.ico</ApplicationIcon>
|
<ApplicationIcon>Frontend\Assets\App.ico</ApplicationIcon>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@@ -13,6 +13,10 @@
|
|||||||
<Resource Include="Frontend\Assets\*.ico" />
|
<Resource Include="Frontend\Assets\*.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Frontend\Assets\App.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
|
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
|
||||||
|
|||||||
@@ -44,21 +44,21 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
// 就直接把string绑定到TextBox.Text上,然后再辅以我自己定义的一套可复用验证逻辑。
|
// 就直接把string绑定到TextBox.Text上,然后再辅以我自己定义的一套可复用验证逻辑。
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[CustomValidation(typeof(NewFileDialog), nameof(ValidateCount))]
|
//[CustomValidation(typeof(NewFileDialog), nameof(ValidateCount))]
|
||||||
[NotifyCanExecuteChangedFor(nameof(OkCommand))]
|
[NotifyCanExecuteChangedFor(nameof(OkCommand))]
|
||||||
private string count;
|
private string count;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[CustomValidation(typeof(NewFileDialog), nameof(ValidateFps))]
|
//[CustomValidation(typeof(NewFileDialog), nameof(ValidateFps))]
|
||||||
[NotifyCanExecuteChangedFor(nameof(OkCommand))]
|
[NotifyCanExecuteChangedFor(nameof(OkCommand))]
|
||||||
private string fps;
|
private string fps;
|
||||||
|
|
||||||
public static ValidationResult ValidateCount(string count, ValidationContext context) {
|
//public static ValidationResult ValidateCount(string count, ValidationContext context) {
|
||||||
return CountValidator.Instance.Validate(count);
|
// return CountValidator.Instance.Validate(count);
|
||||||
}
|
//}
|
||||||
public static ValidationResult ValidateFps(string fps, ValidationContext context) {
|
//public static ValidationResult ValidateFps(string fps, ValidationContext context) {
|
||||||
return FpsValidator.Instance.Validate(fps);
|
// return FpsValidator.Instance.Validate(fps);
|
||||||
}
|
//}
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(CanOk))]
|
[RelayCommand(CanExecute = nameof(CanOk))]
|
||||||
private void Ok() {
|
private void Ok() {
|
||||||
@@ -73,12 +73,12 @@ namespace BallanceTasEditor.Frontend.ViewModels {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewFileDialogResult ToResult() {
|
//public NewFileDialogResult ToResult() {
|
||||||
return new NewFileDialogResult {
|
// return new NewFileDialogResult {
|
||||||
Count = CountValidator.Instance.Fetch(Count),
|
// Count = CountValidator.Instance.Fetch(Count),
|
||||||
DeltaTime = FpsConverter.ToDelta(FpsValidator.Instance.Fetch(Fps)),
|
// DeltaTime = FpsConverter.ToDelta(FpsValidator.Instance.Fetch(Fps)),
|
||||||
};
|
// };
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,18 +44,18 @@ namespace BallanceTasEditorTests.Backend {
|
|||||||
[DynamicData(nameof(TasSequenceInstanceProvider))]
|
[DynamicData(nameof(TasSequenceInstanceProvider))]
|
||||||
public void VisitTest(ITasSequence sequence) {
|
public void VisitTest(ITasSequence sequence) {
|
||||||
// 空时访问
|
// 空时访问
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(-1));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(-1));
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(0));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(0));
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(1));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(1));
|
||||||
|
|
||||||
// 设置数据
|
// 设置数据
|
||||||
sequence.Insert(0, GetExactSizeProbe());
|
sequence.Insert(0, GetExactSizeProbe());
|
||||||
// 访问数据
|
// 访问数据
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(-1));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(-1));
|
||||||
for (int i = 0; i < PROBE.Length; i++) {
|
for (int i = 0; i < PROBE.Length; i++) {
|
||||||
Assert.AreEqual(sequence.Visit(i), PROBE[i]);
|
Assert.AreEqual(sequence.Visit(i), PROBE[i]);
|
||||||
}
|
}
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(PROBE.Length));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(PROBE.Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -68,8 +68,8 @@ namespace BallanceTasEditorTests.Backend {
|
|||||||
// 和在非空时的头,中,尾分别插入的结果。
|
// 和在非空时的头,中,尾分别插入的结果。
|
||||||
|
|
||||||
// 先检测空插入
|
// 先检测空插入
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Insert(-1, GetExactSizeProbe()));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Insert(-1, GetExactSizeProbe()));
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Insert(1, GetExactSizeProbe()));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Insert(1, GetExactSizeProbe()));
|
||||||
sequence.Insert(0, GetExactSizeProbe());
|
sequence.Insert(0, GetExactSizeProbe());
|
||||||
for (int i = 0; i < PROBE.Length; i++) {
|
for (int i = 0; i < PROBE.Length; i++) {
|
||||||
Assert.AreEqual(sequence.Visit(i), PROBE[i]);
|
Assert.AreEqual(sequence.Visit(i), PROBE[i]);
|
||||||
@@ -103,16 +103,13 @@ namespace BallanceTasEditorTests.Backend {
|
|||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DynamicData(nameof(TasSequenceInstanceProvider))]
|
[DynamicData(nameof(TasSequenceInstanceProvider))]
|
||||||
public void RemoveTest(ITasSequence sequence) {
|
public void RemoveTest(ITasSequence sequence) {
|
||||||
// 在空的时候删除0项
|
|
||||||
sequence.Remove(0, 0);
|
|
||||||
|
|
||||||
// 插入项目后尝试在头中尾分别删除
|
// 插入项目后尝试在头中尾分别删除
|
||||||
var indices = new int[] { 0, PROBE.Length / 2, PROBE.Length - 1 };
|
var indices = new int[] { 0, PROBE.Length / 2, PROBE.Length - 1 };
|
||||||
foreach (var index in indices) {
|
foreach (var index in indices) {
|
||||||
// 清空,插入,删除
|
// 清空,插入,删除
|
||||||
sequence.Clear();
|
sequence.Clear();
|
||||||
sequence.Insert(0, GetExactSizeProbe());
|
sequence.Insert(0, GetExactSizeProbe());
|
||||||
sequence.Remove(index, 1);
|
sequence.Remove(index, index);
|
||||||
|
|
||||||
// 用List做正确模拟
|
// 用List做正确模拟
|
||||||
var expected = new List<TasFrame>();
|
var expected = new List<TasFrame>();
|
||||||
@@ -201,9 +198,9 @@ namespace BallanceTasEditorTests.Backend {
|
|||||||
// 清空后插入0项,然后确认
|
// 清空后插入0项,然后确认
|
||||||
sequence.Clear();
|
sequence.Clear();
|
||||||
sequence.Insert(0, GetExactSizeBlank());
|
sequence.Insert(0, GetExactSizeBlank());
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(-1));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(-1));
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(0));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(0));
|
||||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => sequence.Visit(1));
|
AssertExtension.ThrowsDerivedException<IndexOutOfRangeException>(() => sequence.Visit(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user