增加预览画面播放速度参数

This commit is contained in:
ww-rm
2025-07-24 20:38:55 +08:00
parent 1f56e2f03c
commit 4b64ec74c2
6 changed files with 41 additions and 22 deletions

View File

@@ -37,6 +37,8 @@ namespace SpineViewer.Models
public uint MaxFps { get; set; } = 30; public uint MaxFps { get; set; } = 30;
public float Speed { get; set; } = 1f;
public bool ShowAxis { get; set; } = true; public bool ShowAxis { get; set; } = true;
public Color BackgroundColor { get; set; } public Color BackgroundColor { get; set; }

View File

@@ -104,6 +104,7 @@
<s:String x:Key="Str_Zoom">Zoom</s:String> <s:String x:Key="Str_Zoom">Zoom</s:String>
<s:String x:Key="Str_Rotation">Rotation (Degrees)</s:String> <s:String x:Key="Str_Rotation">Rotation (Degrees)</s:String>
<s:String x:Key="Str_MaxFps">Max FPS</s:String> <s:String x:Key="Str_MaxFps">Max FPS</s:String>
<s:String x:Key="Str_PlaySpeed">Playback Speed</s:String>
<s:String x:Key="Str_RenderSelectedOnly">Render Selected Only</s:String> <s:String x:Key="Str_RenderSelectedOnly">Render Selected Only</s:String>
<s:String x:Key="Str_ShowAxis">Show Axis</s:String> <s:String x:Key="Str_ShowAxis">Show Axis</s:String>
<s:String x:Key="Str_BackgroundColor">Background Color</s:String> <s:String x:Key="Str_BackgroundColor">Background Color</s:String>

View File

@@ -104,6 +104,7 @@
<s:String x:Key="Str_Zoom">ズーム</s:String> <s:String x:Key="Str_Zoom">ズーム</s:String>
<s:String x:Key="Str_Rotation">回転(度)</s:String> <s:String x:Key="Str_Rotation">回転(度)</s:String>
<s:String x:Key="Str_MaxFps">最大FPS</s:String> <s:String x:Key="Str_MaxFps">最大FPS</s:String>
<s:String x:Key="Str_PlaySpeed">再生速度</s:String>
<s:String x:Key="Str_RenderSelectedOnly">選択のみレンダリング</s:String> <s:String x:Key="Str_RenderSelectedOnly">選択のみレンダリング</s:String>
<s:String x:Key="Str_ShowAxis">座標軸を表示</s:String> <s:String x:Key="Str_ShowAxis">座標軸を表示</s:String>
<s:String x:Key="Str_BackgroundColor">背景色</s:String> <s:String x:Key="Str_BackgroundColor">背景色</s:String>

View File

@@ -104,6 +104,7 @@
<s:String x:Key="Str_Zoom">缩放</s:String> <s:String x:Key="Str_Zoom">缩放</s:String>
<s:String x:Key="Str_Rotation">旋转(角度)</s:String> <s:String x:Key="Str_Rotation">旋转(角度)</s:String>
<s:String x:Key="Str_MaxFps">最大帧率</s:String> <s:String x:Key="Str_MaxFps">最大帧率</s:String>
<s:String x:Key="Str_PlaySpeed">播放速度</s:String>
<s:String x:Key="Str_RenderSelectedOnly">仅渲染选中</s:String> <s:String x:Key="Str_RenderSelectedOnly">仅渲染选中</s:String>
<s:String x:Key="Str_ShowAxis">显示坐标轴</s:String> <s:String x:Key="Str_ShowAxis">显示坐标轴</s:String>
<s:String x:Key="Str_BackgroundColor">背景颜色</s:String> <s:String x:Key="Str_BackgroundColor">背景颜色</s:String>

View File

@@ -140,6 +140,13 @@ namespace SpineViewer.ViewModels.MainWindow
set => SetProperty(_renderer.MaxFps, value, v => _renderer.MaxFps = value); set => SetProperty(_renderer.MaxFps, value, v => _renderer.MaxFps = value);
} }
public float Speed
{
get => _speed;
set => SetProperty(ref _speed, Math.Clamp(value, 0.01f, 100f));
}
private float _speed = 1f;
public bool ShowAxis public bool ShowAxis
{ {
get => _showAxis; get => _showAxis;
@@ -193,15 +200,15 @@ namespace SpineViewer.ViewModels.MainWindow
}); });
private RelayCommand? _cmd_Restart; private RelayCommand? _cmd_Restart;
public RelayCommand Cmd_ForwardStep => _cmd_ForwardStep ??= new(() => public RelayCommand Cmd_ForwardStep => _cmd_ForwardStep ??= new(() =>
{ {
lock (_forwardDeltaLock) _forwardDelta += _renderer.MaxFps > 0 ? 1f / _renderer.MaxFps : 0.001f; lock (_forwardDeltaLock) _forwardDelta += _renderer.MaxFps > 0 ? 1f / _renderer.MaxFps : 0.001f;
}); });
private RelayCommand? _cmd_ForwardStep; private RelayCommand? _cmd_ForwardStep;
public RelayCommand Cmd_ForwardFast => _cmd_ForwardFast ??= new(() => public RelayCommand Cmd_ForwardFast => _cmd_ForwardFast ??= new(() =>
{ {
lock (_forwardDeltaLock) _forwardDelta += _renderer.MaxFps > 0 ? 10f / _renderer.MaxFps : 0.01f; lock (_forwardDeltaLock) _forwardDelta += _renderer.MaxFps > 0 ? 10f / _renderer.MaxFps : 0.01f;
}); });
private RelayCommand? _cmd_ForwardFast; private RelayCommand? _cmd_ForwardFast;
@@ -390,7 +397,7 @@ namespace SpineViewer.ViewModels.MainWindow
if (_cancelToken?.IsCancellationRequested ?? true) break; // 提前中止 if (_cancelToken?.IsCancellationRequested ?? true) break; // 提前中止
sp.Update(0); // 避免物理效果出现问题 sp.Update(0); // 避免物理效果出现问题
sp.Update(delta); sp.Update(delta * _speed);
// 为选中对象绘制一个半透明背景 // 为选中对象绘制一个半透明背景
if (sp.IsSelected) if (sp.IsSelected)
@@ -426,7 +433,7 @@ namespace SpineViewer.ViewModels.MainWindow
} }
public RendererWorkspaceConfigModel WorkspaceConfig public RendererWorkspaceConfigModel WorkspaceConfig
{ {
// TODO: 背景图片 // TODO: 背景图片
get get
{ {
@@ -441,23 +448,25 @@ namespace SpineViewer.ViewModels.MainWindow
FlipX = FlipX, FlipX = FlipX,
FlipY = FlipY, FlipY = FlipY,
MaxFps = MaxFps, MaxFps = MaxFps,
Speed = Speed,
ShowAxis = ShowAxis, ShowAxis = ShowAxis,
BackgroundColor = BackgroundColor, BackgroundColor = BackgroundColor,
}; };
} }
set set
{ {
ResolutionX = value.ResolutionX; ResolutionX = value.ResolutionX;
ResolutionY = value.ResolutionY; ResolutionY = value.ResolutionY;
CenterX = value.CenterX; CenterX = value.CenterX;
CenterY = value.CenterY; CenterY = value.CenterY;
Zoom = value.Zoom; Zoom = value.Zoom;
Rotation = value.Rotation; Rotation = value.Rotation;
FlipX = value.FlipX; FlipX = value.FlipX;
FlipY = value.FlipY; FlipY = value.FlipY;
MaxFps = value.MaxFps; MaxFps = value.MaxFps;
ShowAxis = value.ShowAxis; Speed = value.Speed;
BackgroundColor = value.BackgroundColor; ShowAxis = value.ShowAxis;
BackgroundColor = value.BackgroundColor;
} }
} }
} }

View File

@@ -693,6 +693,7 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 水平分辨率 --> <!-- 水平分辨率 -->
@@ -731,13 +732,17 @@
<Label Grid.Row="8" Grid.Column="0" Content="{DynamicResource Str_MaxFps}"/> <Label Grid.Row="8" Grid.Column="0" Content="{DynamicResource Str_MaxFps}"/>
<TextBox Grid.Row="8" Grid.Column="1" Text="{Binding MaxFps}"/> <TextBox Grid.Row="8" Grid.Column="1" Text="{Binding MaxFps}"/>
<!-- 播放速度 -->
<Label Grid.Row="9" Grid.Column="0" Content="{DynamicResource Str_PlaySpeed}"/>
<TextBox Grid.Row="9" Grid.Column="1" Text="{Binding Speed}"/>
<!-- 显示坐标轴 --> <!-- 显示坐标轴 -->
<Label Grid.Row="9" Grid.Column="0" Content="{DynamicResource Str_ShowAxis}"/> <Label Grid.Row="10" Grid.Column="0" Content="{DynamicResource Str_ShowAxis}"/>
<ToggleButton Grid.Row="9" Grid.Column="1" IsChecked="{Binding ShowAxis}"/> <ToggleButton Grid.Row="10" Grid.Column="1" IsChecked="{Binding ShowAxis}"/>
<!-- 背景颜色 --> <!-- 背景颜色 -->
<Label Grid.Row="10" Grid.Column="0" Content="{DynamicResource Str_BackgroundColor}" ToolTip="#AARRGGBB"/> <Label Grid.Row="11" Grid.Column="0" Content="{DynamicResource Str_BackgroundColor}" ToolTip="#AARRGGBB"/>
<TextBox Grid.Row="10" Grid.Column="1" Text="{Binding BackgroundColor}" ToolTip="#AARRGGBB"/> <TextBox Grid.Row="11" Grid.Column="1" Text="{Binding BackgroundColor}" ToolTip="#AARRGGBB"/>
<!-- 背景图案 --> <!-- 背景图案 -->
<!-- 背景图案模式 --> <!-- 背景图案模式 -->