Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #618

Merged
merged 84 commits into from
Jul 31, 2023
Merged

Dev #618

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
a0ac0f6
LogicalTreeをHierarchicalに変更
yuto-trd Mar 21, 2023
68fa7aa
ProjectをBeutl.Coreに移動、Workspace型名を削除
yuto-trd Mar 21, 2023
b5fc5cd
LayerのOperatorsをリストではなくオブジェクトにした
yuto-trd Mar 21, 2023
f689048
ProjectItem.FileNameの設定するタイミングを修正
yuto-trd Mar 22, 2023
750484d
SourceOperationのコードを単純にした
yuto-trd Mar 22, 2023
4cd4d50
StyleSetterを削除
yuto-trd Mar 22, 2023
919efda
ConfigureOperatorでStylingOperatorを継承するようにした
yuto-trd Mar 22, 2023
943ca6c
CorePropertyMetadataでの指定を最小限にした
yuto-trd Mar 22, 2023
e1856b1
数値型以外のSize, Pointなどの範囲バリデーションを使えるようにした
yuto-trd Mar 28, 2023
963b4ba
Setterでプロパティの値を強制するようにした
yuto-trd Mar 28, 2023
0b41d3f
IRenderer.InvalidateメソッドをRaiseInvalidatedにして、イベントを発生させるだけにした
yuto-trd Mar 28, 2023
9d95cd3
System.TypeのJsonに保存時のフォーマットを変更、ジェネリック引数が見づらくなるので
yuto-trd Mar 28, 2023
a625708
Jsonから型名を取得して復元する処理を関数にした
yuto-trd Mar 28, 2023
617d936
ShouldSerialize(false)をNotAutoSerializeに変更
yuto-trd Mar 28, 2023
e8d40fa
TransformParserでUnsafe.SkipInitを使えるようにした
yuto-trd Mar 29, 2023
1869060
- ノードのソケット間で型が一致しないとき、変換のためのボックス再利用するようにした。
yuto-trd Apr 1, 2023
05ff8b5
ImageSourceにJsonConverter属性を追加
yuto-trd Apr 1, 2023
161e819
ImageFileクラスを削除
yuto-trd Apr 1, 2023
1456fd8
MediaSourceの解放をDrawable側でしないようにした
yuto-trd Apr 1, 2023
81a87d1
HierarchyからStyledSourcePublisherがDetachされたときStyleInstanceをDisposeするよう…
yuto-trd Apr 1, 2023
f1e488c
CommandRecorderのStackにリングバッファを使うようにした
yuto-trd Apr 1, 2023
fd00603
プロジェクトを閉じてもシーンなどのインスタンスが破棄されないのを修正
yuto-trd Apr 2, 2023
bfa6ae3
メモリリークの可能性のあるコードを修正
yuto-trd Apr 2, 2023
7bf3612
調査用のコードを削除
yuto-trd Apr 2, 2023
1d5cc2f
Fix Styleable.cs
yuto-trd Apr 6, 2023
a4e9668
IHierarchicalRootをScene, ProjectからBeutlApplicationにした
yuto-trd Apr 6, 2023
a332ac7
アニメーションでレイヤー基準のフレームを使うかを選べるようにした
yuto-trd Apr 8, 2023
8069290
編集時にIAnimation.UseGlobalClockを考慮するようにした
yuto-trd Apr 8, 2023
c8cb580
IJsonSerializableの引数をJsonNodeからJsonObjectに変更
yuto-trd Apr 9, 2023
d60b6be
SourceOperation.EvaluateでClear, AddRangeしている場所をReplaceに変更した
yuto-trd Apr 11, 2023
f2c116a
TimelineLayerViewModelを修正
yuto-trd Apr 11, 2023
fc834c2
NodeTreeSpaceをnodeTreeModelに変更
yuto-trd Apr 11, 2023
d717f8a
Layerの名前をElementに変更
yuto-trd Apr 11, 2023
828e112
CoreObjectでIdを重複しないようにした
yuto-trd Apr 11, 2023
fba0460
NodeTreeBackgroundで拡大、移動したときに格子がずれるのを修正
yuto-trd Apr 11, 2023
139d85e
NodeTreeの表示の状態を保存するようにした
yuto-trd Apr 11, 2023
952f368
ファイルを移動
yuto-trd Apr 12, 2023
44d5258
Geometryクラスを追加
yuto-trd Apr 13, 2023
2142bd0
ShapeをGeometryベースのものにした
yuto-trd Apr 26, 2023
302be15
Geometryのノードを追加
yuto-trd Apr 30, 2023
699d4b2
ITransformを流すノード
yuto-trd Apr 30, 2023
c29a4d4
PenにStrokeAlignmentプロパティを追加
yuto-trd May 2, 2023
de7f39a
Beutl.Styling.SetterからCorePropertyMetadataを削除
yuto-trd May 3, 2023
2ced3b9
ComposedBitmapEffect, ComposedImageFilter, MultiTransformを追加
yuto-trd May 3, 2023
677b8c6
ComposedXXX, MultiTransformを使うようにした
yuto-trd May 3, 2023
0ab6c87
SourceOperatorのSetterの初期化をプロパティで指定することで省けるようにした
yuto-trd May 3, 2023
a0d1e32
UI側のPixelSizeConverterを修正
yuto-trd May 3, 2023
1a4d2bc
Shape.FillTypeを削除、計測を修正
yuto-trd May 6, 2023
c3680c7
テキストで縁取りを指定できるようにした
yuto-trd May 6, 2023
cb82c30
BrushEditorを使いやすくした
yuto-trd May 28, 2023
4c4b4bf
PenEditor
yuto-trd May 28, 2023
fd38d3b
IAbstractPropertyからCorePropertyにできるだけ直接依存しないようにした
yuto-trd Jun 3, 2023
0b3ef1d
ListEditor
yuto-trd Jun 10, 2023
e08597e
ListEditor
yuto-trd Jun 10, 2023
0649da9
ImageFilterEditor
yuto-trd Jun 17, 2023
d32791b
TransformEditor
yuto-trd Jun 17, 2023
d1e8a00
TransformOriginの仕様変更
yuto-trd Jun 19, 2023
8b39b70
PropertyEditor微調整
yuto-trd Jun 19, 2023
838ae72
chore
yuto-trd Jun 29, 2023
2f2363b
ImageFilterをNullableにした、引数にboundsを追加
yuto-trd Jun 29, 2023
b0311d9
試験的なフィルタ
yuto-trd Jun 29, 2023
16840f6
ViewModelの状態保存
yuto-trd Jun 29, 2023
d758dd1
StyleEditorを削除
yuto-trd Jun 30, 2023
ce03c8d
ComposedImageFilterを修正
yuto-trd Jun 30, 2023
82ffa0d
AlignmentEditorの表示がずれるのを修正
yuto-trd Jun 30, 2023
b7693a0
プロパティのグループ化を改善
yuto-trd Jun 30, 2023
f763060
Update DisplacementMap.cs
yuto-trd Jun 30, 2023
bed8975
Canvas変更
yuto-trd Jul 1, 2023
97d4868
nuget cpm
yuto-trd Jul 12, 2023
af2cff1
Fix DisposeWith imports.
yuto-trd Jul 12, 2023
e0b51dc
SceneGraph
yuto-trd Jul 14, 2023
4183278
Update Avalonia 11.0.0
yuto-trd Jul 14, 2023
28fa4f6
update packages
yuto-trd Jul 19, 2023
2adeae4
DispatcherをRenderThreadクラスに移動
yuto-trd Jul 22, 2023
c53dd31
ImageFilter, BitmapEffectを統合してFilterEffectを作った。
yuto-trd Jul 22, 2023
3818059
アニメーションでのバグを修正
yuto-trd Jul 22, 2023
61bdc39
Brush, PenにEqualsメソッドを追加
yuto-trd Jul 27, 2023
478870f
EqualityComparerを使うようにした
yuto-trd Jul 27, 2023
5f2de17
古いContainerNodeの子要素を再利用するようにした
yuto-trd Jul 27, 2023
b6ca599
描画キャッシュ
yuto-trd Jul 27, 2023
09bff4e
キャッシュ修正
yuto-trd Jul 29, 2023
cceb6b5
update
yuto-trd Jul 30, 2023
0af2a74
chore
yuto-trd Jul 30, 2023
5b0be01
Fix SharedGRContext.cs
yuto-trd Jul 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# License header
# file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
# file_header_template = {fileName}\r\n\r\nCopyright (C) b-editor\r\n\r\nThis software may be modified and distributed under the terms\r\nof the MIT license. See the LICENSE file for details.

# C++ Files
[*.{cpp,h,in}]
Expand Down
22 changes: 1 addition & 21 deletions Beutl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{BBF37951
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{74C34E00-E924-4463-A38B-F691AFBAE362}"
ProjectSection(SolutionItems) = preProject
build\props\AsyncImageLoader.Avalonia.props = build\props\AsyncImageLoader.Avalonia.props
build\props\Avalonia.props = build\props\Avalonia.props
build\props\Avalonia.Svg.Skia.props = build\props\Avalonia.Svg.Skia.props
build\props\Avalonia.Xaml.Interactivity.props = build\props\Avalonia.Xaml.Interactivity.props
build\props\CopyProjectReferencesToPackage.props = build\props\CopyProjectReferencesToPackage.props
build\props\CopyProjectReferencesToPackage.targets = build\props\CopyProjectReferencesToPackage.targets
build\props\CoreLibraries.props = build\props\CoreLibraries.props
build\props\FluentAvalonia.props = build\props\FluentAvalonia.props
build\props\FluentIcons.FluentAvalonia.props = build\props\FluentIcons.FluentAvalonia.props
build\props\Microsoft.CodeAnalysis.Analyzers.props = build\props\Microsoft.CodeAnalysis.Analyzers.props
build\props\Microsoft.CodeAnalysis.CSharp.Scripting.props = build\props\Microsoft.CodeAnalysis.CSharp.Scripting.props
build\props\Microsoft.Extensions.DependencyInjection.props = build\props\Microsoft.Extensions.DependencyInjection.props
build\props\Microsoft.Extensions.FileSystemGlobbing.props = build\props\Microsoft.Extensions.FileSystemGlobbing.props
build\props\Microsoft.Extensions.Http.props = build\props\Microsoft.Extensions.Http.props
build\props\Microsoft.Extensions.Logging.props = build\props\Microsoft.Extensions.Logging.props
build\props\Nito.AsyncEx.props = build\props\Nito.AsyncEx.props
build\props\OpenCvSharp4.props = build\props\OpenCvSharp4.props
build\props\ReactiveProperty.props = build\props\ReactiveProperty.props
build\props\Serilog.props = build\props\Serilog.props
build\props\SkiaSharp.props = build\props\SkiaSharp.props
build\props\System.Interactive.props = build\props\System.Interactive.props
build\props\System.Reactive.props = build\props\System.Reactive.props
build\props\UnitTest.props = build\props\UnitTest.props
build\props\XamlNameReferenceGenerator.props = build\props\XamlNameReferenceGenerator.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Beutl.Configuration", "src\Beutl.Configuration\Beutl.Configuration.csproj", "{985AFD44-4A83-43DE-A700-269F5175E8C5}"
Expand All @@ -67,6 +46,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Root", "Root", "{80264A90-C
.gitattributes = .gitattributes
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
LICENSE = LICENSE
README.md = README.md
EndProjectSection
Expand Down
60 changes: 60 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AsyncImageLoader.Avalonia" Version="3.0.0" />
<PackageVersion Include="Avalonia" Version="11.0.0" />
<PackageVersion Include="Avalonia.Controls.PanAndZoom" Version="11.0.0" />
<PackageVersion Include="Avalonia.Desktop" Version="11.0.0" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.0" />
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.0.0" />
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.0" />
<PackageVersion Include="Avalonia.Xaml.Behaviors" Version="11.0.0.1" />
<PackageVersion Include="Avalonia.Xaml.Interactivity" Version="11.0.0.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.6" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="DynamicData" Version="7.14.2" />
<PackageVersion Include="FFmpeg.AutoGen" Version="6.0.0.2" />
<PackageVersion Include="FluentAvalonia.BreadcrumbBar" Version="2.0.0" />
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.0" />
<PackageVersion Include="FluentIcons.FluentAvalonia" Version="1.1.207" />
<PackageVersion Include="FluentTextTable" Version="1.0.0" />
<PackageVersion Include="Kokuban" Version="0.2.0" />
<PackageVersion Include="Kurukuru" Version="1.4.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.6.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="Nito.AsyncEx" Version="5.1.2" />
<PackageVersion Include="NuGet.ProjectModel" Version="6.6.1" />
<PackageVersion Include="NuGet.Protocol" Version="6.6.1" />
<PackageVersion Include="NuGet.Resolver" Version="6.6.1" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="OpenCvSharp4" Version="4.8.0.20230708" />
<PackageVersion Include="OpenCvSharp4.runtime.centos7-x64" Version="4.0.0.20190129" />
<PackageVersion Include="OpenCvSharp4.runtime.osx.10.15-x64" Version="4.6.0.20230105" />
<PackageVersion Include="OpenCvSharp4.runtime.ubuntu.18.04-x64" Version="4.6.0.20220608" />
<PackageVersion Include="OpenCvSharp4.runtime.win" Version="4.8.0.20230708" />
<PackageVersion Include="OpenTK.OpenAL" Version="5.0.0-pre.8" />
<PackageVersion Include="OpenTK.Windowing.GraphicsLibraryFramework" Version="5.0.0-pre.8" />
<PackageVersion Include="PanelExtension" Version="1.0.0" />
<PackageVersion Include="ReactiveProperty" Version="9.2.0" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.3.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageVersion Include="Sharprompt" Version="2.4.5" />
<PackageVersion Include="SkiaSharp" Version="2.88.3" />
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Interactive" Version="6.0.1" />
<PackageVersion Include="System.Interactive.Async" Version="6.0.1" />
<PackageVersion Include="System.Reactive" Version="6.0.0" />
<PackageVersion Include="Vortice.XAudio2" Version="3.2.0" />
</ItemGroup>
</Project>
27 changes: 17 additions & 10 deletions packages/Beutl.Sdk/Beutl.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)/../../src/Beutl.Utilities/Beutl.Utilities.csproj" PrivateAssets="All" />
</ItemGroup>

<Import Project="$(RootDirectory)\build\props\Avalonia.props" />
<Import Project="$(RootDirectory)\build\props\Avalonia.Svg.Skia.props" />
<Import Project="$(RootDirectory)\build\props\Avalonia.Xaml.Interactivity.props" />
<Import Project="$(RootDirectory)\build\props\FluentAvalonia.props" />
<Import Project="$(RootDirectory)\build\props\FluentIcons.FluentAvalonia.props" />
<Import Project="$(RootDirectory)\build\props\OpenCvSharp4.props" />
<Import Project="$(RootDirectory)\build\props\ReactiveProperty.props" />
<Import Project="$(RootDirectory)\build\props\SkiaSharp.props" />
<Import Project="$(RootDirectory)\build\props\System.Interactive.props" />
<Import Project="$(RootDirectory)\build\props\System.Reactive.props" />
<ItemGroup>
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Desktop" />
<PackageReference Include="Avalonia.ReactiveUI" />
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="Avalonia.Svg.Skia" />
<PackageReference Include="Avalonia.Xaml.Behaviors" />
<PackageReference Include="Avalonia.Xaml.Interactivity" />
<PackageReference Include="FluentAvaloniaUI" />
<PackageReference Include="FluentIcons.FluentAvalonia" />
<PackageReference Include="ReactiveProperty" />
<PackageReference Include="System.Interactive" />
<PackageReference Include="System.Reactive" />

<PackageReference Include="OpenCvSharp4" />
<PackageReference Include="SkiaSharp" />
</ItemGroup>

<Import Project="$(RootDirectory)\build\props\CopyProjectReferencesToPackage.props" />
<Import Project="$(RootDirectory)\build\props\CopyProjectReferencesToPackage.targets" />
</Project>
20 changes: 9 additions & 11 deletions src/Beutl.Api/Beutl.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<Import Project="$(RootDirectory)\build\props\System.Reactive.props" />
<Import Project="$(RootDirectory)\build\props\System.Interactive.props" />
<Import Project="$(RootDirectory)\build\props\ReactiveProperty.props" />
<Import Project="$(RootDirectory)\build\props\Nito.AsyncEx.props" />

<!-- CS8032 -->
<Import Project="$(RootDirectory)\build\props\Microsoft.CodeAnalysis.Analyzers.props" />

<ItemGroup>
<EmbeddedResource Include="Resources\index.html" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NuGet.ProjectModel" Version="6.4.0" />
<PackageReference Include="NuGet.Protocol" Version="6.4.0" />
<PackageReference Include="NuGet.Resolver" Version="6.4.0" />
<PackageReference Include="Nito.AsyncEx" />
<PackageReference Include="ReactiveProperty" />
<PackageReference Include="System.Reactive" />
<PackageReference Include="System.Interactive" />
<PackageReference Include="System.Interactive.Async" />

<PackageReference Include="NuGet.ProjectModel" />
<PackageReference Include="NuGet.Protocol" />
<PackageReference Include="NuGet.Resolver" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Beutl.Api/Services/ExtensionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public TExtension[] GetExtensions<TExtension>()
return null;
}

public WorkspaceItemExtension? MatchWorkspaceItemExtension(string file)
public ProjectItemExtension? MatchProjectItemExtension(string file)
{
foreach (Extension extension in AllExtensions)
{
if (extension is WorkspaceItemExtension wsiExtension &&
if (extension is ProjectItemExtension wsiExtension &&
wsiExtension.IsSupported(file))
{
return wsiExtension;
Expand All @@ -88,11 +88,11 @@ public TExtension[] GetExtensions<TExtension>()
return null;
}

public IEnumerable<WorkspaceItemExtension> MatchWorkspaceItemExtensions(string file)
public IEnumerable<ProjectItemExtension> MatchProjectItemExtensions(string file)
{
foreach (Extension extension in AllExtensions)
{
if (extension is WorkspaceItemExtension wsiExtension &&
if (extension is ProjectItemExtension wsiExtension &&
wsiExtension.IsSupported(file))
{
yield return wsiExtension;
Expand Down
2 changes: 0 additions & 2 deletions src/Beutl.Configuration/BackupConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ public sealed class BackupConfig : ConfigurationBase
static BackupConfig()
{
BackupSettingsProperty = ConfigureProperty<bool, BackupConfig>(nameof(BackupSettings))
.SerializeName("backup-settings")
.DefaultValue(true)
.PropertyFlags(PropertyFlags.NotifyChanged)
.Register();
}

Expand Down
29 changes: 13 additions & 16 deletions src/Beutl.Configuration/ExtensionConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,30 @@ public TypeLazy(string formattedTypeName)
// Keyには拡張子を含める
public CoreDictionary<string, ICoreList<TypeLazy>> EditorExtensions { get; } = new();

public override void ReadFromJson(JsonNode json)
public override void ReadFromJson(JsonObject json)
{
base.ReadFromJson(json);
if (json is JsonObject jsonObject)
if (json.TryGetPropertyValue("editor-extensions", out JsonNode? eeNode)
&& eeNode is JsonObject eeObject)
{
if (jsonObject.TryGetPropertyValue("editor-extensions", out JsonNode? eeNode)
&& eeNode is JsonObject eeObject)
EditorExtensions.Clear();
foreach (KeyValuePair<string, JsonNode?> item in eeObject)
{
EditorExtensions.Clear();
foreach (KeyValuePair<string, JsonNode?> item in eeObject)
if (item.Value is JsonArray jsonArray)
{
if (item.Value is JsonArray jsonArray)
{
EditorExtensions.Add(item.Key, new CoreList<TypeLazy>(jsonArray.OfType<JsonValue>()
.Select(value => value.TryGetValue(out string? type) ? type : null)
.Select(str => new TypeLazy(str!))
.Where(type => type.FormattedTypeName != null)!));
}
EditorExtensions.Add(item.Key, new CoreList<TypeLazy>(jsonArray.OfType<JsonValue>()
.Select(value => value.TryGetValue(out string? type) ? type : null)
.Select(str => new TypeLazy(str!))
.Where(type => type.FormattedTypeName != null)!));
}
}
}
}

public override void WriteToJson(ref JsonNode json)
public override void WriteToJson(JsonObject json)
{
base.WriteToJson(ref json);
base.WriteToJson(json);

var eeObject = new JsonObject();
foreach ((string key, ICoreList<TypeLazy> value) in EditorExtensions)
{
Expand Down
31 changes: 14 additions & 17 deletions src/Beutl.Configuration/FontConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,30 @@ public FontConfig()

public ObservableCollection<string> FontDirectories { get; } = CreateDefaultFontDirectories();

public override void ReadFromJson(JsonNode json)
public override void ReadFromJson(JsonObject json)
{
base.ReadFromJson(json);
if (json is JsonObject jsonObject)
if (json.TryGetPropertyValue("directories", out JsonNode? dirsNode)
&& dirsNode is JsonArray dirsArray)
{
if (jsonObject.TryGetPropertyValue("directories", out JsonNode? dirsNode)
&& dirsNode is JsonArray dirsArray)
{
string[] array = dirsArray.Select(i => (string?)i).Where(i => i != null).ToArray()!;
string[] fontDirs = FontDirectories.ToArray();
string[] array = dirsArray.Select(i => (string?)i).Where(i => i != null).ToArray()!;
string[] fontDirs = FontDirectories.ToArray();

foreach (string item in array.Except(fontDirs))
{
FontDirectories.Add(item);
}
foreach (string item in array.Except(fontDirs))
{
FontDirectories.Add(item);
}

foreach (string item in fontDirs.Except(array))
{
FontDirectories.Remove(item);
}
foreach (string item in fontDirs.Except(array))
{
FontDirectories.Remove(item);
}
}
}

public override void WriteToJson(ref JsonNode json)
public override void WriteToJson(JsonObject json)
{
base.WriteToJson(ref json);
base.WriteToJson(json);
json["directories"] = new JsonArray(FontDirectories.Select(i => JsonValue.Create(i)).ToArray());
}

Expand Down
24 changes: 12 additions & 12 deletions src/Beutl.Configuration/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ public void Save(string file)
Directory.CreateDirectory(dir);
}

JsonNode fontNode = new JsonObject();
FontConfig.WriteToJson(ref fontNode);
var fontNode = new JsonObject();
FontConfig.WriteToJson(fontNode);
_json["font"] = fontNode;

JsonNode viewNode = new JsonObject();
ViewConfig.WriteToJson(ref viewNode);
var viewNode = new JsonObject();
ViewConfig.WriteToJson(viewNode);
_json["view"] = viewNode;

JsonNode extensionNode = new JsonObject();
ExtensionConfig.WriteToJson(ref extensionNode);
var extensionNode = new JsonObject();
ExtensionConfig.WriteToJson(extensionNode);
_json["extension"] = extensionNode;

JsonNode backupNode = new JsonObject();
BackupConfig.WriteToJson(ref backupNode);
var backupNode = new JsonObject();
BackupConfig.WriteToJson(backupNode);
_json["backup"] = backupNode;

_json.JsonSave(file);
Expand All @@ -76,10 +76,10 @@ public void Restore(string file)
RemoveHandlers();
if (JsonHelper.JsonRestore(file) is JsonObject json)
{
FontConfig.ReadFromJson(json["font"]!);
ViewConfig.ReadFromJson(json["view"]!);
ExtensionConfig.ReadFromJson(json["extension"]!);
BackupConfig.ReadFromJson(json["backup"]!);
FontConfig.ReadFromJson((JsonObject)json["font"]!);
ViewConfig.ReadFromJson((JsonObject)json["view"]!);
ExtensionConfig.ReadFromJson((JsonObject)json["extension"]!);
BackupConfig.ReadFromJson((JsonObject)json["backup"]!);

_json = json;
}
Expand Down
Loading
Loading