diff --git a/SpineViewer/Models/SpineObjectModel.cs b/SpineViewer/Models/SpineObjectModel.cs
index 069d267..461211f 100644
--- a/SpineViewer/Models/SpineObjectModel.cs
+++ b/SpineViewer/Models/SpineObjectModel.cs
@@ -25,6 +25,12 @@ namespace SpineViewer.Models
///
public class SpineObjectModel : ObservableObject, SFML.Graphics.Drawable, IDisposable
{
+ ///
+ /// 一些加载默认选项
+ ///
+ public static SpineObjectLoadOptions LoadOptions => _loadOptions;
+ private static readonly SpineObjectLoadOptions _loadOptions = new();
+
///
/// 日志器
///
@@ -42,7 +48,20 @@ namespace SpineViewer.Models
///
public SpineObjectModel(string skelPath, string? atlasPath = null)
{
- _spineObject = new(skelPath, atlasPath);
+ _spineObject = new(skelPath, atlasPath)
+ {
+ UsePma = _loadOptions.UsePma,
+ DebugTexture = _loadOptions.DebugTexture,
+ DebugBounds = _loadOptions.DebugBounds,
+ DebugRegions = _loadOptions.DebugRegions,
+ DebugMeshHulls = _loadOptions.DebugMeshHulls,
+ DebugMeshes = _loadOptions.DebugMeshes,
+ DebugBoundingBoxes = _loadOptions.DebugBoundingBoxes,
+ DebugPaths = _loadOptions.DebugPaths,
+ DebugPoints = _loadOptions.DebugPoints,
+ DebugClippings = _loadOptions.DebugClippings
+ };
+
_skins = _spineObject.Data.Skins.Select(v => v.Name).ToImmutableArray();
_slotAttachments = _spineObject.Data.SlotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.Keys);
_animations = _spineObject.Data.Animations.Select(v => v.Name).ToImmutableArray();
@@ -475,4 +494,20 @@ namespace SpineViewer.Models
public int TrackIndex { get; } = trackIndex;
public string? AnimationName { get; } = animationName;
}
+
+ public class SpineObjectLoadOptions
+ {
+ public bool AutoSave { get; set; }
+ public bool UsePma { get; set; }
+ public bool DebugTexture { get; set; } = true;
+ public bool DebugBounds { get; set; }
+ public bool DebugBones { get; set; }
+ public bool DebugRegions { get; set; }
+ public bool DebugMeshHulls { get; set; }
+ public bool DebugMeshes { get; set; }
+ public bool DebugBoundingBoxes { get; set; }
+ public bool DebugPaths { get; set; }
+ public bool DebugPoints { get; set; }
+ public bool DebugClippings { get; set; }
+ }
}
diff --git a/SpineViewer/ViewModels/MainWindow/PreferenceViewModel.cs b/SpineViewer/ViewModels/MainWindow/PreferenceViewModel.cs
index d8c35fd..32117b7 100644
--- a/SpineViewer/ViewModels/MainWindow/PreferenceViewModel.cs
+++ b/SpineViewer/ViewModels/MainWindow/PreferenceViewModel.cs
@@ -159,68 +159,68 @@ namespace SpineViewer.ViewModels.MainWindow
public bool UsePma
{
- get => SpineObjectListViewModel.LoadOptions.UsePma;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.UsePma, value, v => SpineObjectListViewModel.LoadOptions.UsePma = v);
+ get => SpineObjectModel.LoadOptions.UsePma;
+ set => SetProperty(SpineObjectModel.LoadOptions.UsePma, value, v => SpineObjectModel.LoadOptions.UsePma = v);
}
public bool DebugTexture
{
- get => SpineObjectListViewModel.LoadOptions.DebugTexture;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugTexture, value, v => SpineObjectListViewModel.LoadOptions.DebugTexture = v);
+ get => SpineObjectModel.LoadOptions.DebugTexture;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugTexture, value, v => SpineObjectModel.LoadOptions.DebugTexture = v);
}
public bool DebugBounds
{
- get => SpineObjectListViewModel.LoadOptions.DebugBounds;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugBounds, value, v => SpineObjectListViewModel.LoadOptions.DebugBounds = v);
+ get => SpineObjectModel.LoadOptions.DebugBounds;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugBounds, value, v => SpineObjectModel.LoadOptions.DebugBounds = v);
}
public bool DebugBones
{
- get => SpineObjectListViewModel.LoadOptions.DebugBones;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugBones, value, v => SpineObjectListViewModel.LoadOptions.DebugBones = v);
+ get => SpineObjectModel.LoadOptions.DebugBones;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugBones, value, v => SpineObjectModel.LoadOptions.DebugBones = v);
}
public bool DebugRegions
{
- get => SpineObjectListViewModel.LoadOptions.DebugRegions;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugRegions, value, v => SpineObjectListViewModel.LoadOptions.DebugRegions = v);
+ get => SpineObjectModel.LoadOptions.DebugRegions;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugRegions, value, v => SpineObjectModel.LoadOptions.DebugRegions = v);
}
public bool DebugMeshHulls
{
- get => SpineObjectListViewModel.LoadOptions.DebugMeshHulls;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugMeshHulls, value, v => SpineObjectListViewModel.LoadOptions.DebugMeshHulls = v);
+ get => SpineObjectModel.LoadOptions.DebugMeshHulls;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugMeshHulls, value, v => SpineObjectModel.LoadOptions.DebugMeshHulls = v);
}
public bool DebugMeshes
{
- get => SpineObjectListViewModel.LoadOptions.DebugMeshes;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugMeshes, value, v => SpineObjectListViewModel.LoadOptions.DebugMeshes = v);
+ get => SpineObjectModel.LoadOptions.DebugMeshes;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugMeshes, value, v => SpineObjectModel.LoadOptions.DebugMeshes = v);
}
public bool DebugBoundingBoxes
{
- get => SpineObjectListViewModel.LoadOptions.DebugBoundingBoxes;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugBoundingBoxes, value, v => SpineObjectListViewModel.LoadOptions.DebugBoundingBoxes = v);
+ get => SpineObjectModel.LoadOptions.DebugBoundingBoxes;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugBoundingBoxes, value, v => SpineObjectModel.LoadOptions.DebugBoundingBoxes = v);
}
public bool DebugPaths
{
- get => SpineObjectListViewModel.LoadOptions.DebugPaths;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugPaths, value, v => SpineObjectListViewModel.LoadOptions.DebugPaths = v);
+ get => SpineObjectModel.LoadOptions.DebugPaths;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugPaths, value, v => SpineObjectModel.LoadOptions.DebugPaths = v);
}
public bool DebugPoints
{
- get => SpineObjectListViewModel.LoadOptions.DebugPoints;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugPoints, value, v => SpineObjectListViewModel.LoadOptions.DebugPoints = v);
+ get => SpineObjectModel.LoadOptions.DebugPoints;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugPoints, value, v => SpineObjectModel.LoadOptions.DebugPoints = v);
}
public bool DebugClippings
{
- get => SpineObjectListViewModel.LoadOptions.DebugClippings;
- set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugClippings, value, v => SpineObjectListViewModel.LoadOptions.DebugClippings = v);
+ get => SpineObjectModel.LoadOptions.DebugClippings;
+ set => SetProperty(SpineObjectModel.LoadOptions.DebugClippings, value, v => SpineObjectModel.LoadOptions.DebugClippings = v);
}
#endregion
diff --git a/SpineViewer/ViewModels/MainWindow/SpineObjectListViewModel.cs b/SpineViewer/ViewModels/MainWindow/SpineObjectListViewModel.cs
index 031ead1..ac6db0f 100644
--- a/SpineViewer/ViewModels/MainWindow/SpineObjectListViewModel.cs
+++ b/SpineViewer/ViewModels/MainWindow/SpineObjectListViewModel.cs
@@ -21,12 +21,6 @@ namespace SpineViewer.ViewModels.MainWindow
{
public class SpineObjectListViewModel : ObservableObject
{
- ///
- /// 加载选项
- ///
- public static SpineLoadOptions LoadOptions => _loadOptions;
- private static readonly SpineLoadOptions _loadOptions = new();
-
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
///
@@ -349,20 +343,7 @@ namespace SpineViewer.ViewModels.MainWindow
{
try
{
- var sp = new SpineObjectModel(skelPath, atlasPath)
- {
- UsePma = _loadOptions.UsePma,
- DebugTexture = _loadOptions.DebugTexture,
- DebugBounds = _loadOptions.DebugBounds,
- DebugRegions = _loadOptions.DebugRegions,
- DebugMeshHulls = _loadOptions.DebugMeshHulls,
- DebugMeshes = _loadOptions.DebugMeshes,
- DebugBoundingBoxes = _loadOptions.DebugBoundingBoxes,
- DebugPaths = _loadOptions.DebugPaths,
- DebugPoints = _loadOptions.DebugPoints,
- DebugClippings = _loadOptions.DebugClippings
- };
-
+ var sp = new SpineObjectModel(skelPath, atlasPath);
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
return true;
}
@@ -373,21 +354,5 @@ namespace SpineViewer.ViewModels.MainWindow
}
return false;
}
-
- public class SpineLoadOptions
- {
- // TODO: 判断是否记忆参数
- public bool UsePma { get; set; }
- public bool DebugTexture { get; set; } = true;
- public bool DebugBounds { get; set; }
- public bool DebugBones { get; set; }
- public bool DebugRegions { get; set; }
- public bool DebugMeshHulls { get; set; }
- public bool DebugMeshes { get; set; }
- public bool DebugBoundingBoxes { get; set; }
- public bool DebugPaths { get; set; }
- public bool DebugPoints { get; set; }
- public bool DebugClippings { get; set; }
- }
}
}