Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## v0.16.11

- 增加 shift 切换缩放倍数
- 改善后台性能
- 修复字体显示颜色问题
- 调整浏览目录参数保存至用户状态
- 调整浏览面板至最后

## v0.16.10

- 增加 Linux 平台 CLI 工具构建
Expand Down
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Mouse interactions in the preview panel:

- **Left click**: select and drag models. Hold `Ctrl` for multi-selection (synchronized with the model list).
- **Right click**: drag the entire canvas.
- **Mouse wheel**: zoom in/out. Hold `Ctrl` to scale selected models together.
- **Mouse wheel**: zoom in/out. Hold `Ctrl` to scale selected models together, use `Shift` to switch zoom factor.
- **Render selected only**: preview only the selected models, selection can only be changed via the left panel.

Playback controls below the preview allow time adjustment, acting as a simple player.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ https://github.com/user-attachments/assets/37b6b730-088a-4352-827a-c338127a16f0

- 左键可以选择和拖拽模型, 按下 `Ctrl` 键可以实现多选, 与左侧列表选择是联动的.
- 右键对整体画面进行拖动.
- 滚轮进行画面缩放, 按住 `Ctrl` 可以对选中的模型进行批量缩放.
- 滚轮进行画面缩放, 按住 `Ctrl` 可以对选中的模型进行批量缩放, `Shift` 可以切换缩放倍数.
- 仅渲染选中模式, 在该模式下, 预览画面仅包含被选中的模型, 并且只能通过左侧列表改变选中状态.

预览画面下方按钮支持对画面时间进行调整, 可以当作一个简易的播放器.
Expand Down
2 changes: 1 addition & 1 deletion Spine/Spine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<TargetFramework>net8.0</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.10</Version>
<Version>0.16.11</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions SpineViewer/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ namespace SpineViewer
public partial class App : Application
{
#if DEBUG
public const bool IsDebug = true;
public const string AppName = "SpineViewer_D";
public const string ProgId = "SpineViewer_D.skel";
#else
public const bool IsDebug = false;
public const string AppName = "SpineViewer";
public const string ProgId = "SpineViewer.skel";
#endif
Expand Down
6 changes: 6 additions & 0 deletions SpineViewer/Models/UserStateModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class UserStateModel

#endregion

#region 浏览页面状态

public string? ExploringDirectory { get; set; }

#endregion

#region 预览画面状态

public uint ResolutionX { get; set; } = 1500;
Expand Down
1 change: 0 additions & 1 deletion SpineViewer/Models/WorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace SpineViewer.Models
{
public class WorkspaceModel
{
public string? ExploringDirectory { get; set; }
public RendererWorkspaceConfigModel RendererConfig { get; set; } = new();
public List<SpineObjectWorkspaceConfigModel> LoadedSpineObjects { get; set; } = [];
}
Expand Down
2 changes: 1 addition & 1 deletion SpineViewer/SpineViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.16.10</Version>
<Version>0.16.11</Version>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
</PropertyGroup>
Expand Down
21 changes: 18 additions & 3 deletions SpineViewer/ViewModels/MainWindow/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ public MainWindowViewModel(ISFMLRenderer sfmlRenderer, ISFMLRenderer wallpaperRe
_preferenceViewModel = new(this);
}

public string Title => $"SpineViewer - v{App.Version}";
public bool IsDebug => App.IsDebug;

public string Title => $"{App.AppName} - v{App.Version}";

public Visibility Visibility
{
get => _visibility;
set
{
if (SetProperty(ref _visibility, value))
{
OnPropertyChanged(nameof(IsVisible));
}
}
}
private Visibility _visibility = Visibility.Visible;

public bool IsVisible => _visibility == Visibility.Visible;

/// <summary>
/// 指示是否通过托盘图标进行退出
Expand Down Expand Up @@ -164,14 +181,12 @@ public WorkspaceModel Workspace
{
return new()
{
ExploringDirectory = _explorerListViewModel.CurrentDirectory,
RendererConfig = _sfmlRendererViewModel.WorkspaceConfig,
LoadedSpineObjects = _spineObjectListViewModel.LoadedSpineObjects
};
}
set
{
_explorerListViewModel.CurrentDirectory = value.ExploringDirectory;
_sfmlRendererViewModel.WorkspaceConfig = value.RendererConfig;
_spineObjectListViewModel.LoadedSpineObjects = value.LoadedSpineObjects;
}
Expand Down
67 changes: 28 additions & 39 deletions SpineViewer/ViewModels/MainWindow/SFMLRendererViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public bool FlipY
public uint MaxFps
{
get => _renderer.MaxFps;
set => SetProperty(_renderer.MaxFps, value, v => _renderer.MaxFps = value);
set => SetProperty(_renderer.MaxFps, value, v => _renderer.MaxFps = _wallpaperRenderer.MaxFps = value);
}

public float Speed
Expand Down Expand Up @@ -320,7 +320,8 @@ private set

public void CanvasMouseWheelScrolled(object? s, SFML.Window.MouseWheelScrollEventArgs e)
{
var factor = e.Delta > 0 ? 1.1f : 0.9f;
float delta = ((Keyboard.Modifiers & ModifierKeys.Shift) == 0) ? 0.1f : 0.01f;
var factor = e.Delta > 0 ? (1f + delta) : (1f - delta);
if ((Keyboard.Modifiers & ModifierKeys.Control) == 0)
{
Zoom = Math.Clamp(Zoom * factor, 0.001f, 1000f); // 滚轮缩放限制一下缩放范围
Expand Down Expand Up @@ -484,21 +485,17 @@ private void RenderTask()
_forwardDelta = 0;
}

using var v = _renderer.GetView();
_renderer.Clear(_backgroundColor);
using var view = _renderer.GetView();
_wallpaperRenderer.SetView(view);

if (_wallpaperView)
{
_wallpaperRenderer.SetView(v);
_wallpaperRenderer.Clear(_backgroundColor);
}
if (_vmMain.IsVisible) _renderer.Clear(_backgroundColor);
if (_wallpaperView) _wallpaperRenderer.Clear(_backgroundColor);

// 渲染背景
lock (_bgLock)
{
if (_backgroundImageSprite is not null)
{
using var view = _renderer.GetView();
var bg = _backgroundImageSprite;
var viewSize = view.Size;
var bgSize = bg.Texture.Size;
Expand All @@ -521,16 +518,13 @@ private void RenderTask()
bg.Scale = new(signX * scaleX, signY * scaleY);
bg.Position = view.Center;
bg.Rotation = view.Rotation;
_renderer.Draw(bg);

if (_wallpaperView)
{
_wallpaperRenderer.Draw(bg);
}
if (_vmMain.IsVisible) _renderer.Draw(bg);
if (_wallpaperView) _wallpaperRenderer.Draw(bg);
}
}

if (_showAxis)
if (_showAxis && _vmMain.IsVisible)
{
// 画一个很长的坐标轴, 用 1e9 比较合适
_axisVertices[0] = new(new(-1e9f, 0), _axisColor);
Expand All @@ -551,35 +545,30 @@ private void RenderTask()
sp.Update(0); // 避免物理效果出现问题
sp.Update(delta * _speed);

// 为选中对象绘制一个半透明背景
if (sp.IsSelected)
if (_vmMain.IsVisible)
{
var rc = sp.GetCurrentBounds().ToFloatRect();
_selectedBackgroundVertices[0] = new(new(rc.Left, rc.Top), _selectedBackgroundColor);
_selectedBackgroundVertices[1] = new(new(rc.Left + rc.Width, rc.Top), _selectedBackgroundColor);
_selectedBackgroundVertices[2] = new(new(rc.Left + rc.Width, rc.Top + rc.Height), _selectedBackgroundColor);
_selectedBackgroundVertices[3] = new(new(rc.Left, rc.Top + rc.Height), _selectedBackgroundColor);
_renderer.Draw(_selectedBackgroundVertices);
}

// 仅在预览画面临时启用调试模式
sp.EnableDebug = true;
_renderer.Draw(sp);
sp.EnableDebug = false;
// 为选中对象绘制一个半透明背景
if (sp.IsSelected)
{
var rc = sp.GetCurrentBounds().ToFloatRect();
_selectedBackgroundVertices[0] = new(new(rc.Left, rc.Top), _selectedBackgroundColor);
_selectedBackgroundVertices[1] = new(new(rc.Left + rc.Width, rc.Top), _selectedBackgroundColor);
_selectedBackgroundVertices[2] = new(new(rc.Left + rc.Width, rc.Top + rc.Height), _selectedBackgroundColor);
_selectedBackgroundVertices[3] = new(new(rc.Left, rc.Top + rc.Height), _selectedBackgroundColor);
_renderer.Draw(_selectedBackgroundVertices);
}

if (_wallpaperView)
{
_wallpaperRenderer.Draw(sp);
// 仅在预览画面临时启用调试模式
sp.EnableDebug = true;
_renderer.Draw(sp);
sp.EnableDebug = false;
}
if (_wallpaperView) _wallpaperRenderer.Draw(sp);
}
}

_renderer.Display();

if (_wallpaperView)
{
_wallpaperRenderer.Display();
}
if (_vmMain.IsVisible) _renderer.Display();
if (_wallpaperView) _wallpaperRenderer.Display();
}
}
catch (Exception ex)
Expand Down
Loading
Loading