UI: Added shortcuts to start/stop recording video/audio/movies
This commit is contained in:
parent
d8b91efd65
commit
42015e9f8c
11 changed files with 95 additions and 13 deletions
|
@ -48,11 +48,7 @@ void MovieManager::Play(VirtualFile file, bool forTest)
|
|||
void MovieManager::Stop()
|
||||
{
|
||||
_player.reset();
|
||||
|
||||
if(_recorder) {
|
||||
_recorder->Stop();
|
||||
_recorder.reset();
|
||||
}
|
||||
_recorder.reset();
|
||||
}
|
||||
|
||||
bool MovieManager::Playing()
|
||||
|
|
|
@ -25,6 +25,7 @@ MovieRecorder::MovieRecorder(shared_ptr<Console> console)
|
|||
|
||||
MovieRecorder::~MovieRecorder()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
bool MovieRecorder::Record(RecordMovieOptions options)
|
||||
|
|
|
@ -373,6 +373,10 @@ enum class EmulatorShortcut
|
|||
// Everything below this is handled UI-side
|
||||
TakeScreenshot,
|
||||
|
||||
ToggleRecordVideo,
|
||||
ToggleRecordAudio,
|
||||
ToggleRecordMovie,
|
||||
|
||||
IncreaseSpeed,
|
||||
DecreaseSpeed,
|
||||
MaxSpeed,
|
||||
|
|
|
@ -116,7 +116,6 @@ void VideoRenderer::StopRecording()
|
|||
{
|
||||
shared_ptr<IVideoRecorder> recorder = _recorder;
|
||||
if(recorder) {
|
||||
recorder->StopRecording();
|
||||
MessageManager::DisplayMessage("VideoRecorder", "VideoRecorderStopped", recorder->GetOutputFile());
|
||||
}
|
||||
_recorder.reset();
|
||||
|
|
|
@ -9,9 +9,11 @@ WaveRecorder::WaveRecorder(string outputFile, uint32_t sampleRate, bool isStereo
|
|||
_streamSize = 0;
|
||||
_sampleRate = sampleRate;
|
||||
_isStereo = isStereo;
|
||||
WriteHeader();
|
||||
|
||||
MessageManager::DisplayMessage("SoundRecorder", "SoundRecorderStarted", _outputFile);
|
||||
|
||||
if(_stream) {
|
||||
WriteHeader();
|
||||
MessageManager::DisplayMessage("SoundRecorder", "SoundRecorderStarted", _outputFile);
|
||||
}
|
||||
}
|
||||
|
||||
WaveRecorder::~WaveRecorder()
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace Mesen.GUI.Config
|
|||
{
|
||||
public class MovieRecordConfig
|
||||
{
|
||||
public RecordMovieFrom RecordFrom;
|
||||
public string Author;
|
||||
public string Description;
|
||||
public RecordMovieFrom RecordFrom = RecordMovieFrom.CurrentState;
|
||||
public string Author = "";
|
||||
public string Description = "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,10 @@ namespace Mesen.GUI.Config.Shortcuts
|
|||
// Everything below this is handled UI-side
|
||||
TakeScreenshot,
|
||||
|
||||
ToggleRecordVideo,
|
||||
ToggleRecordAudio,
|
||||
ToggleRecordMovie,
|
||||
|
||||
IncreaseSpeed,
|
||||
DecreaseSpeed,
|
||||
MaxSpeed,
|
||||
|
|
|
@ -787,6 +787,10 @@
|
|||
<Message ID="EmulatorShortcutMappings_ToggleSprites">Toggle Sprites</Message>
|
||||
<Message ID="EmulatorShortcutMappings_EnableAllLayers">Enable All Layers</Message>
|
||||
|
||||
<Message ID="EmulatorShortcutMappings_ToggleRecordVideo">Start/Stop Recording Video</Message>
|
||||
<Message ID="EmulatorShortcutMappings_ToggleRecordAudio">Start/Stop Recording Audio</Message>
|
||||
<Message ID="EmulatorShortcutMappings_ToggleRecordMovie">Start/Stop Recording Movie</Message>
|
||||
|
||||
<Message ID="EmulatorShortcutMappings_MaxSpeed">Toggle Maximum Speed</Message>
|
||||
<Message ID="EmulatorShortcutMappings_LoadRandomGame">Load Random Game</Message>
|
||||
<Message ID="EmulatorShortcutMappings_SaveStateSlot1">Save State - Slot 1</Message>
|
||||
|
|
|
@ -97,6 +97,8 @@ namespace Mesen.GUI.Emulation
|
|||
LoadPatchFile(filename);
|
||||
} else if(Path.GetExtension(filename).ToLowerInvariant() == ".mss") {
|
||||
EmuApi.LoadStateFile(filename);
|
||||
} else if(IsRunning() && Path.GetExtension(filename).ToLowerInvariant() == ".msm") {
|
||||
RecordApi.MoviePlay(filename);
|
||||
} else {
|
||||
LoadRom(filename);
|
||||
}
|
||||
|
|
|
@ -113,6 +113,10 @@ namespace Mesen.GUI.Emulation
|
|||
case EmulatorShortcut.ToggleSprites: ToggleSprites(); break;
|
||||
case EmulatorShortcut.EnableAllLayers: EnableAllLayers(); break;
|
||||
|
||||
case EmulatorShortcut.ToggleRecordVideo: ToggleRecordVideo(); break;
|
||||
case EmulatorShortcut.ToggleRecordAudio: ToggleRecordAudio(); break;
|
||||
case EmulatorShortcut.ToggleRecordMovie: ToggleRecordMovie(); break;
|
||||
|
||||
case EmulatorShortcut.TakeScreenshot: EmuApi.TakeScreenshot(); break;
|
||||
|
||||
case EmulatorShortcut.LoadStateFromFile: SaveStateManager.LoadStateFromFile(); break;
|
||||
|
@ -162,7 +166,69 @@ namespace Mesen.GUI.Emulation
|
|||
_displayManager.SetFullscreenState(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void ToggleRecordVideo()
|
||||
{
|
||||
if(!EmuApi.IsRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(RecordApi.AviIsRecording()) {
|
||||
RecordApi.AviStop();
|
||||
} else {
|
||||
string filename = GetOutputFilename(ConfigManager.AviFolder, ConfigManager.Config.AviRecord.Codec == VideoCodec.GIF ? ".gif" : ".avi");
|
||||
RecordApi.AviRecord(filename, ConfigManager.Config.AviRecord.Codec, ConfigManager.Config.AviRecord.CompressionLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ToggleRecordAudio()
|
||||
{
|
||||
if(!EmuApi.IsRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(RecordApi.WaveIsRecording()) {
|
||||
RecordApi.WaveStop();
|
||||
} else {
|
||||
string filename = GetOutputFilename(ConfigManager.WaveFolder, ".wav");
|
||||
RecordApi.WaveRecord(filename);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ToggleRecordMovie()
|
||||
{
|
||||
if(!EmuApi.IsRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!RecordApi.MoviePlaying() && !NetplayApi.IsConnected()) {
|
||||
if(RecordApi.MovieRecording()) {
|
||||
RecordApi.MovieStop();
|
||||
} else {
|
||||
RecordMovieOptions options = new RecordMovieOptions(
|
||||
GetOutputFilename(ConfigManager.MovieFolder, ".msm"),
|
||||
ConfigManager.Config.MovieRecord.Author,
|
||||
ConfigManager.Config.MovieRecord.Description,
|
||||
ConfigManager.Config.MovieRecord.RecordFrom
|
||||
);
|
||||
RecordApi.MovieRecord(ref options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetOutputFilename(string folder, string ext)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
string baseName = EmuApi.GetRomInfo().GetRomName();
|
||||
string dateTime = " " + now.ToShortDateString() + " " + now.ToLongTimeString();
|
||||
string filename = baseName + dateTime + ext;
|
||||
|
||||
//Replace any illegal chars with _
|
||||
filename = string.Join("_", filename.Split(Path.GetInvalidFileNameChars()));
|
||||
|
||||
return Path.Combine(folder, filename);
|
||||
}
|
||||
|
||||
private void OpenFile()
|
||||
{
|
||||
using(OpenFileDialog ofd = new OpenFileDialog()) {
|
||||
|
|
|
@ -48,6 +48,10 @@ namespace Mesen.GUI.Forms.Config
|
|||
EmulatorShortcut.PowerOff,
|
||||
EmulatorShortcut.Exit,
|
||||
|
||||
EmulatorShortcut.ToggleRecordVideo,
|
||||
EmulatorShortcut.ToggleRecordAudio,
|
||||
EmulatorShortcut.ToggleRecordMovie,
|
||||
|
||||
EmulatorShortcut.TakeScreenshot,
|
||||
EmulatorShortcut.RunSingleFrame,
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue