Files
MesenCE/UI/ViewModels/VideoRecordConfigViewModel.cs
SourMesen 40335ce735 UI: Update to Avalonia 12, .NET 10 and replace ReactiveUI with MVVM community toolkit (#142)
Also fixes DX11.0 support (for Win7 PCs that aren't fully updated), which stopped working after the recent variable refresh rate changes
2026-07-03 16:04:42 +09:00

39 lines
1.3 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using Mesen.Config;
using Mesen.Interop;
using Mesen.Utilities;
using System;
using System.IO;
namespace Mesen.ViewModels
{
public partial class VideoRecordConfigViewModel : DisposableViewModel
{
[ObservableProperty] public partial string SavePath { get; set; }
[ObservableProperty] public partial VideoRecordConfig Config { get; set; }
[ObservableProperty] public partial bool CompressionAvailable { get; private set; }
public VideoRecordConfigViewModel()
{
Config = ConfigManager.Config.VideoRecord.Clone();
SavePath = Path.Join(ConfigManager.AviFolder, EmuApi.GetRomInfo().GetRomName() + (Config.Codec == VideoCodec.GIF ? ".gif" : ".avi"));
AddDisposable(Config.ObserveProp(nameof(VideoRecordConfig.Codec), () => {
CompressionAvailable = Config.Codec == VideoCodec.ZMBV || Config.Codec == VideoCodec.CSCD;
if(Config.Codec == VideoCodec.GIF && Path.GetExtension(SavePath).ToLowerInvariant() != ".gif") {
SavePath = Path.ChangeExtension(SavePath, ".gif");
} else if(Config.Codec != VideoCodec.GIF && Path.GetExtension(SavePath).ToLowerInvariant() == ".gif") {
SavePath = Path.ChangeExtension(SavePath, ".avi");
}
}));
}
public void SaveConfig()
{
ConfigManager.Config.VideoRecord = Config.Clone();
}
}
}