修改LoadOptions的归属

This commit is contained in:
ww-rm
2025-06-14 11:14:27 +08:00
parent 6fe639d6dd
commit 0e7e7dd5d9
3 changed files with 59 additions and 59 deletions

View File

@@ -25,6 +25,12 @@ namespace SpineViewer.Models
/// </summary> /// </summary>
public class SpineObjectModel : ObservableObject, SFML.Graphics.Drawable, IDisposable public class SpineObjectModel : ObservableObject, SFML.Graphics.Drawable, IDisposable
{ {
/// <summary>
/// 一些加载默认选项
/// </summary>
public static SpineObjectLoadOptions LoadOptions => _loadOptions;
private static readonly SpineObjectLoadOptions _loadOptions = new();
/// <summary> /// <summary>
/// 日志器 /// 日志器
/// </summary> /// </summary>
@@ -42,7 +48,20 @@ namespace SpineViewer.Models
/// </summary> /// </summary>
public SpineObjectModel(string skelPath, string? atlasPath = null) 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(); _skins = _spineObject.Data.Skins.Select(v => v.Name).ToImmutableArray();
_slotAttachments = _spineObject.Data.SlotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.Keys); _slotAttachments = _spineObject.Data.SlotAttachments.ToFrozenDictionary(it => it.Key, it => it.Value.Keys);
_animations = _spineObject.Data.Animations.Select(v => v.Name).ToImmutableArray(); _animations = _spineObject.Data.Animations.Select(v => v.Name).ToImmutableArray();
@@ -475,4 +494,20 @@ namespace SpineViewer.Models
public int TrackIndex { get; } = trackIndex; public int TrackIndex { get; } = trackIndex;
public string? AnimationName { get; } = animationName; 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; }
}
} }

View File

@@ -159,68 +159,68 @@ namespace SpineViewer.ViewModels.MainWindow
public bool UsePma public bool UsePma
{ {
get => SpineObjectListViewModel.LoadOptions.UsePma; get => SpineObjectModel.LoadOptions.UsePma;
set => SetProperty(SpineObjectListViewModel.LoadOptions.UsePma, value, v => SpineObjectListViewModel.LoadOptions.UsePma = v); set => SetProperty(SpineObjectModel.LoadOptions.UsePma, value, v => SpineObjectModel.LoadOptions.UsePma = v);
} }
public bool DebugTexture public bool DebugTexture
{ {
get => SpineObjectListViewModel.LoadOptions.DebugTexture; get => SpineObjectModel.LoadOptions.DebugTexture;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugTexture, value, v => SpineObjectListViewModel.LoadOptions.DebugTexture = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugTexture, value, v => SpineObjectModel.LoadOptions.DebugTexture = v);
} }
public bool DebugBounds public bool DebugBounds
{ {
get => SpineObjectListViewModel.LoadOptions.DebugBounds; get => SpineObjectModel.LoadOptions.DebugBounds;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugBounds, value, v => SpineObjectListViewModel.LoadOptions.DebugBounds = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugBounds, value, v => SpineObjectModel.LoadOptions.DebugBounds = v);
} }
public bool DebugBones public bool DebugBones
{ {
get => SpineObjectListViewModel.LoadOptions.DebugBones; get => SpineObjectModel.LoadOptions.DebugBones;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugBones, value, v => SpineObjectListViewModel.LoadOptions.DebugBones = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugBones, value, v => SpineObjectModel.LoadOptions.DebugBones = v);
} }
public bool DebugRegions public bool DebugRegions
{ {
get => SpineObjectListViewModel.LoadOptions.DebugRegions; get => SpineObjectModel.LoadOptions.DebugRegions;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugRegions, value, v => SpineObjectListViewModel.LoadOptions.DebugRegions = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugRegions, value, v => SpineObjectModel.LoadOptions.DebugRegions = v);
} }
public bool DebugMeshHulls public bool DebugMeshHulls
{ {
get => SpineObjectListViewModel.LoadOptions.DebugMeshHulls; get => SpineObjectModel.LoadOptions.DebugMeshHulls;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugMeshHulls, value, v => SpineObjectListViewModel.LoadOptions.DebugMeshHulls = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugMeshHulls, value, v => SpineObjectModel.LoadOptions.DebugMeshHulls = v);
} }
public bool DebugMeshes public bool DebugMeshes
{ {
get => SpineObjectListViewModel.LoadOptions.DebugMeshes; get => SpineObjectModel.LoadOptions.DebugMeshes;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugMeshes, value, v => SpineObjectListViewModel.LoadOptions.DebugMeshes = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugMeshes, value, v => SpineObjectModel.LoadOptions.DebugMeshes = v);
} }
public bool DebugBoundingBoxes public bool DebugBoundingBoxes
{ {
get => SpineObjectListViewModel.LoadOptions.DebugBoundingBoxes; get => SpineObjectModel.LoadOptions.DebugBoundingBoxes;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugBoundingBoxes, value, v => SpineObjectListViewModel.LoadOptions.DebugBoundingBoxes = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugBoundingBoxes, value, v => SpineObjectModel.LoadOptions.DebugBoundingBoxes = v);
} }
public bool DebugPaths public bool DebugPaths
{ {
get => SpineObjectListViewModel.LoadOptions.DebugPaths; get => SpineObjectModel.LoadOptions.DebugPaths;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugPaths, value, v => SpineObjectListViewModel.LoadOptions.DebugPaths = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugPaths, value, v => SpineObjectModel.LoadOptions.DebugPaths = v);
} }
public bool DebugPoints public bool DebugPoints
{ {
get => SpineObjectListViewModel.LoadOptions.DebugPoints; get => SpineObjectModel.LoadOptions.DebugPoints;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugPoints, value, v => SpineObjectListViewModel.LoadOptions.DebugPoints = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugPoints, value, v => SpineObjectModel.LoadOptions.DebugPoints = v);
} }
public bool DebugClippings public bool DebugClippings
{ {
get => SpineObjectListViewModel.LoadOptions.DebugClippings; get => SpineObjectModel.LoadOptions.DebugClippings;
set => SetProperty(SpineObjectListViewModel.LoadOptions.DebugClippings, value, v => SpineObjectListViewModel.LoadOptions.DebugClippings = v); set => SetProperty(SpineObjectModel.LoadOptions.DebugClippings, value, v => SpineObjectModel.LoadOptions.DebugClippings = v);
} }
#endregion #endregion

View File

@@ -21,12 +21,6 @@ namespace SpineViewer.ViewModels.MainWindow
{ {
public class SpineObjectListViewModel : ObservableObject public class SpineObjectListViewModel : ObservableObject
{ {
/// <summary>
/// 加载选项
/// </summary>
public static SpineLoadOptions LoadOptions => _loadOptions;
private static readonly SpineLoadOptions _loadOptions = new();
private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary> /// <summary>
@@ -349,20 +343,7 @@ namespace SpineViewer.ViewModels.MainWindow
{ {
try try
{ {
var sp = new SpineObjectModel(skelPath, atlasPath) 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
};
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp); lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
return true; return true;
} }
@@ -373,21 +354,5 @@ namespace SpineViewer.ViewModels.MainWindow
} }
return false; 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; }
}
} }
} }