增加语言设置

This commit is contained in:
ww-rm
2025-06-14 01:57:39 +08:00
parent b3010360b4
commit 7ec938b415
14 changed files with 265 additions and 137 deletions

View File

@@ -21,6 +21,12 @@ namespace SpineViewer.ViewModels.MainWindow
{
public class SpineObjectListViewModel : ObservableObject
{
/// <summary>
/// 加载选项
/// </summary>
public static SpineLoadOptions LoadOptions => _loadOptions;
private static readonly SpineLoadOptions _loadOptions = new();
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
@@ -249,41 +255,6 @@ namespace SpineViewer.ViewModels.MainWindow
return true;
}
/// <summary>
/// 安全地在末尾添加一个模型, 发生错误会输出日志
/// </summary>
/// <returns>是否添加成功</returns>
public bool AddSpineObject(string skelPath, string? atlasPath = null)
{
try
{
// TODO: 判断是否记忆参数
var pre = _vmMain.PreferenceViewModel;
var sp = new SpineObjectModel(skelPath, atlasPath)
{
UsePma = pre.UsePma,
DebugTexture = pre.DebugTexture,
DebugBounds = pre.DebugBounds,
DebugRegions = pre.DebugRegions,
DebugMeshHulls = pre.DebugMeshHulls,
DebugMeshes = pre.DebugMeshes,
DebugBoundingBoxes = pre.DebugBoundingBoxes,
DebugPaths = pre.DebugPaths,
DebugPoints = pre.DebugPoints,
DebugClippings = pre.DebugClippings
};
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
return true;
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
_logger.Error("Failed to load: {0}, {1}", skelPath, ex.Message);
}
return false;
}
/// <summary>
/// 从路径列表添加对象
/// </summary>
@@ -369,5 +340,54 @@ namespace SpineViewer.ViewModels.MainWindow
_logger.LogCurrentProcessMemoryUsage();
}
/// <summary>
/// 安全地在末尾添加一个模型, 发生错误会输出日志
/// </summary>
/// <returns>是否添加成功</returns>
public bool AddSpineObject(string skelPath, string? atlasPath = null)
{
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
};
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
return true;
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
_logger.Error("Failed to load: {0}, {1}", skelPath, ex.Message);
}
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; }
}
}
}