2011-03-27 02:55:08 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
#include "FifoPlayerDlg.h"
|
|
|
|
#include "FileUtil.h"
|
|
|
|
#include "Thread.h"
|
|
|
|
#include "FifoPlayer/FifoPlayer.h"
|
|
|
|
#include "FifoPlayer/FifoRecorder.h"
|
|
|
|
#include <wx/spinctrl.h>
|
|
|
|
|
|
|
|
DECLARE_EVENT_TYPE(RECORDING_FINISHED_EVENT, -1)
|
|
|
|
DEFINE_EVENT_TYPE(RECORDING_FINISHED_EVENT)
|
|
|
|
|
|
|
|
DECLARE_EVENT_TYPE(FRAME_WRITTEN_EVENT, -1)
|
|
|
|
DEFINE_EVENT_TYPE(FRAME_WRITTEN_EVENT)
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
std::recursive_mutex sMutex;
|
|
|
|
wxEvtHandler *volatile FifoPlayerDlg::m_EvtHandler = NULL;
|
|
|
|
|
|
|
|
FifoPlayerDlg::FifoPlayerDlg(wxWindow * const parent) :
|
|
|
|
wxDialog(parent, wxID_ANY, _("FIFO Player"), wxDefaultPosition, wxDefaultSize),
|
|
|
|
m_FramesToRecord(1)
|
|
|
|
{
|
|
|
|
CreateGUIControls();
|
|
|
|
|
|
|
|
sMutex.lock();
|
|
|
|
m_EvtHandler = GetEventHandler();
|
|
|
|
sMutex.unlock();
|
|
|
|
|
|
|
|
FifoPlayer::GetInstance().SetFileLoadedCallback(FileLoaded);
|
|
|
|
FifoPlayer::GetInstance().SetFrameWrittenCallback(FrameWritten);
|
|
|
|
}
|
|
|
|
|
|
|
|
FifoPlayerDlg::~FifoPlayerDlg()
|
|
|
|
{
|
|
|
|
Disconnect(RECORDING_FINISHED_EVENT, wxCommandEventHandler(FifoPlayerDlg::OnRecordingFinished), NULL, this);
|
|
|
|
Disconnect(FRAME_WRITTEN_EVENT, wxCommandEventHandler(FifoPlayerDlg::OnFrameWritten), NULL, this);
|
|
|
|
|
|
|
|
// Disconnect Events
|
2011-04-17 21:39:58 +00:00
|
|
|
Disconnect(wxEVT_PAINT, wxPaintEventHandler(FifoPlayerDlg::OnPaint), NULL, this);
|
|
|
|
m_FrameFromCtrl->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnFrameFrom), NULL, this);
|
|
|
|
m_FrameToCtrl->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnFrameTo), NULL, this);
|
|
|
|
m_ObjectFromCtrl->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnObjectFrom), NULL, this);
|
|
|
|
m_ObjectToCtrl->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnObjectTo), NULL, this);
|
|
|
|
m_EarlyMemoryUpdates->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnCheckEarlyMemoryUpdates), NULL, this);
|
|
|
|
m_RecordStop->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnRecordStop), NULL, this);
|
|
|
|
m_Save->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnSaveFile), NULL, this);
|
|
|
|
m_FramesToRecordCtrl->Disconnect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnNumFramesToRecord), NULL, this);
|
|
|
|
m_Close->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnCloseClick), NULL, this);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
FifoPlayer::GetInstance().SetFrameWrittenCallback(NULL);
|
|
|
|
|
|
|
|
sMutex.lock();
|
|
|
|
m_EvtHandler = NULL;
|
|
|
|
sMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::CreateGUIControls()
|
|
|
|
{
|
2011-04-17 21:39:58 +00:00
|
|
|
SetSizeHints(wxDefaultSize, wxDefaultSize);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxBoxSizer* sMain;
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain = new wxBoxSizer(wxVERTICAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_Notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_PlayPage = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sPlayPage;
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage = new wxBoxSizer(wxVERTICAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* sPlayInfo;
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayInfo = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("File Info")), wxVERTICAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_NumFramesLabel = new wxStaticText(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_NumFramesLabel->Wrap(-1);
|
|
|
|
sPlayInfo->Add(m_NumFramesLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_CurrentFrameLabel = new wxStaticText(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_CurrentFrameLabel->Wrap(-1);
|
|
|
|
sPlayInfo->Add(m_CurrentFrameLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_NumObjectsLabel = new wxStaticText(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_NumObjectsLabel->Wrap(-1);
|
|
|
|
sPlayInfo->Add(m_NumObjectsLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sPlayInfo, 1, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* sFrameRange;
|
2011-04-17 21:39:58 +00:00
|
|
|
sFrameRange = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("Frame Range")), wxHORIZONTAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameFromLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("From"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_FrameFromLabel->Wrap(-1);
|
|
|
|
sFrameRange->Add(m_FrameFromLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameFromCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10, 0);
|
|
|
|
sFrameRange->Add(m_FrameFromCtrl, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameToLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("To"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_FrameToLabel->Wrap(-1);
|
|
|
|
sFrameRange->Add(m_FrameToLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameToCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), wxSP_ARROW_KEYS, 0, 10, 0);
|
|
|
|
sFrameRange->Add(m_FrameToCtrl, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sFrameRange, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* sObjectRange;
|
2011-04-17 21:39:58 +00:00
|
|
|
sObjectRange = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("Object Range")), wxHORIZONTAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectFromLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("From"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_ObjectFromLabel->Wrap(-1);
|
|
|
|
sObjectRange->Add(m_ObjectFromLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectFromCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10000, 0);
|
|
|
|
sObjectRange->Add(m_ObjectFromCtrl, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectToLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("To"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_ObjectToLabel->Wrap(-1);
|
|
|
|
sObjectRange->Add(m_ObjectToLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectToCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10000, 0);
|
|
|
|
sObjectRange->Add(m_ObjectToCtrl, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sObjectRange, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* sPlayOptions;
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayOptions = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("Playback Options")), wxVERTICAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EarlyMemoryUpdates = new wxCheckBox(m_PlayPage, wxID_ANY, _("Early Memory Updates"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
sPlayOptions->Add(m_EarlyMemoryUpdates, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sPlayOptions, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_PlayPage->SetSizer(sPlayPage);
|
2011-03-27 02:55:08 +00:00
|
|
|
m_PlayPage->Layout();
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Fit(m_PlayPage);
|
2011-04-27 01:10:58 +00:00
|
|
|
m_Notebook->AddPage(m_PlayPage, _("Play"), true);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordPage = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sRecordPage;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage = new wxBoxSizer(wxVERTICAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* sRecordInfo;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordInfo = new wxStaticBoxSizer(new wxStaticBox(m_RecordPage, wxID_ANY, _("Recording Info")), wxVERTICAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordingFifoSizeLabel = new wxStaticText(m_RecordPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_RecordingFifoSizeLabel->Wrap(-1);
|
|
|
|
sRecordInfo->Add(m_RecordingFifoSizeLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordingMemSizeLabel = new wxStaticText(m_RecordPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_RecordingMemSizeLabel->Wrap(-1);
|
|
|
|
sRecordInfo->Add(m_RecordingMemSizeLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordingFramesLabel = new wxStaticText(m_RecordPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_RecordingFramesLabel->Wrap(-1);
|
|
|
|
sRecordInfo->Add(m_RecordingFramesLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Add(sRecordInfo, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxBoxSizer* sRecordButtons;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordButtons = new wxBoxSizer(wxHORIZONTAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordStop = new wxButton(m_RecordPage, wxID_ANY, _("Record"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
sRecordButtons->Add(m_RecordStop, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_Save = new wxButton(m_RecordPage, wxID_ANY, _("Save"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
sRecordButtons->Add(m_Save, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Add(sRecordButtons, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxStaticBoxSizer* sRecordingOptions;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordingOptions = new wxStaticBoxSizer(new wxStaticBox(m_RecordPage, wxID_ANY, _("Recording Options")), wxHORIZONTAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FramesToRecordLabel = new wxStaticText(m_RecordPage, wxID_ANY, _("Frames To Record"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
m_FramesToRecordLabel->Wrap(-1);
|
|
|
|
sRecordingOptions->Add(m_FramesToRecordLabel, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FramesToRecordCtrl = new wxSpinCtrl(m_RecordPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10000, 1);
|
|
|
|
sRecordingOptions->Add(m_FramesToRecordCtrl, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Add(sRecordingOptions, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordPage->SetSizer(sRecordPage);
|
2011-03-27 02:55:08 +00:00
|
|
|
m_RecordPage->Layout();
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Fit(m_RecordPage);
|
|
|
|
m_Notebook->AddPage(m_RecordPage, _("Record"), false);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain->Add(m_Notebook, 1, wxEXPAND | wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxBoxSizer* sButtons;
|
2011-04-17 21:39:58 +00:00
|
|
|
sButtons = new wxBoxSizer(wxHORIZONTAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
wxBoxSizer* sCloseButtonExpander;
|
2011-04-17 21:39:58 +00:00
|
|
|
sCloseButtonExpander = new wxBoxSizer(wxHORIZONTAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sButtons->Add(sCloseButtonExpander, 1, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_Close = new wxButton(this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, 0);
|
|
|
|
sButtons->Add(m_Close, 0, wxALL, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain->Add(sButtons, 0, wxEXPAND, 5);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
SetSizer(sMain);
|
2011-03-27 02:55:08 +00:00
|
|
|
Layout();
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain->Fit(this);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
Center(wxBOTH);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
// Connect Events
|
2011-04-17 21:39:58 +00:00
|
|
|
Connect(wxEVT_PAINT, wxPaintEventHandler(FifoPlayerDlg::OnPaint));
|
|
|
|
m_FrameFromCtrl->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnFrameFrom), NULL, this);
|
|
|
|
m_FrameToCtrl->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnFrameTo), NULL, this);
|
|
|
|
m_ObjectFromCtrl->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnObjectFrom), NULL, this);
|
|
|
|
m_ObjectToCtrl->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnObjectTo), NULL, this);
|
|
|
|
m_EarlyMemoryUpdates->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnCheckEarlyMemoryUpdates), NULL, this);
|
|
|
|
m_RecordStop->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnRecordStop), NULL, this);
|
|
|
|
m_Save->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnSaveFile), NULL, this);
|
|
|
|
m_FramesToRecordCtrl->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler(FifoPlayerDlg::OnNumFramesToRecord), NULL, this);
|
|
|
|
m_Close->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FifoPlayerDlg::OnCloseClick), NULL, this);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
Connect(RECORDING_FINISHED_EVENT, wxCommandEventHandler(FifoPlayerDlg::OnRecordingFinished), NULL, this);
|
|
|
|
Connect(FRAME_WRITTEN_EVENT, wxCommandEventHandler(FifoPlayerDlg::OnFrameWritten), NULL, this);
|
|
|
|
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnPaint(wxPaintEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
UpdatePlayGui();
|
|
|
|
UpdateRecorderGui();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnFrameFrom(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
|
|
|
player.SetFrameRangeStart(event.GetPosition());
|
|
|
|
|
|
|
|
m_FrameFromCtrl->SetValue(player.GetFrameRangeStart());
|
|
|
|
m_FrameToCtrl->SetValue(player.GetFrameRangeEnd());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnFrameTo(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
|
|
|
player.SetFrameRangeEnd(event.GetPosition());
|
|
|
|
|
|
|
|
m_FrameFromCtrl->SetValue(player.GetFrameRangeStart());
|
|
|
|
m_FrameToCtrl->SetValue(player.GetFrameRangeEnd());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnObjectFrom(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer::GetInstance().SetObjectRangeStart(event.GetPosition());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnObjectTo(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer::GetInstance().SetObjectRangeEnd(event.GetPosition());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnCheckEarlyMemoryUpdates(wxCommandEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer::GetInstance().SetEarlyMemoryUpdates(event.IsChecked());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnSaveFile(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
wxString path = wxSaveFileSelector(_("Dolphin FIFO"), wxT("dff"), wxEmptyString, this);
|
|
|
|
|
|
|
|
if (!path.empty())
|
|
|
|
{
|
|
|
|
wxBeginBusyCursor();
|
|
|
|
bool result = file->Save(path.mb_str());
|
|
|
|
wxEndBusyCursor();
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
PanicAlert("Error saving file");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnRecordStop(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoRecorder& recorder = FifoRecorder::GetInstance();
|
|
|
|
|
|
|
|
if (recorder.IsRecording())
|
|
|
|
{
|
|
|
|
recorder.StopRecording();
|
|
|
|
m_RecordStop->Disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
recorder.StartRecording(m_FramesToRecord, RecordingFinished);
|
|
|
|
m_RecordStop->SetLabel(_("Stop"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnNumFramesToRecord(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
m_FramesToRecord = event.GetPosition();
|
|
|
|
|
|
|
|
// Entering 0 frames in the control indicates infinite frames to record
|
|
|
|
// The fifo recorder takes any value < 0 to be infinite frames
|
|
|
|
if (m_FramesToRecord < 1)
|
|
|
|
m_FramesToRecord = -1;
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnCloseClick(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnRecordingFinished(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
m_RecordStop->SetLabel(_("Record"));
|
|
|
|
m_RecordStop->Enable();
|
|
|
|
|
|
|
|
UpdateRecorderGui();
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnFrameWritten(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
m_CurrentFrameLabel->SetLabel(CreateCurrentFrameLabel());
|
|
|
|
m_NumObjectsLabel->SetLabel(CreateFileObjectCountLabel());
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::UpdatePlayGui()
|
|
|
|
{
|
|
|
|
m_NumFramesLabel->SetLabel(CreateFileFrameCountLabel());
|
|
|
|
m_CurrentFrameLabel->SetLabel(CreateCurrentFrameLabel());
|
|
|
|
m_NumObjectsLabel->SetLabel(CreateFileObjectCountLabel());
|
|
|
|
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
|
|
|
FifoDataFile *file = player.GetFile();
|
|
|
|
u32 frameCount = 0;
|
|
|
|
if (file)
|
|
|
|
frameCount = file->GetFrameCount();
|
|
|
|
|
|
|
|
m_FrameFromCtrl->SetRange(0, frameCount);
|
|
|
|
m_FrameFromCtrl->SetValue(player.GetFrameRangeStart());
|
|
|
|
|
|
|
|
m_FrameToCtrl->SetRange(0, frameCount);
|
|
|
|
m_FrameToCtrl->SetValue(player.GetFrameRangeEnd());
|
|
|
|
|
|
|
|
m_ObjectFromCtrl->SetValue(player.GetObjectRangeStart());
|
|
|
|
m_ObjectToCtrl->SetValue(player.GetObjectRangeEnd());
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::UpdateRecorderGui()
|
|
|
|
{
|
|
|
|
m_RecordingFifoSizeLabel->SetLabel(CreateRecordingFifoSizeLabel());
|
|
|
|
m_RecordingMemSizeLabel->SetLabel(CreateRecordingMemSizeLabel());
|
|
|
|
m_RecordingFramesLabel->SetLabel(CreateRecordingFrameCountLabel());
|
|
|
|
m_Save->Enable(GetSaveButtonEnabled());
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateFileFrameCountLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoPlayer::GetInstance().GetFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
return CreateIntegerLabel(file->GetFrameCount(), _("Frame"));
|
|
|
|
|
|
|
|
return _("No file loaded");
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateCurrentFrameLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoPlayer::GetInstance().GetFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
return _("Frame ") + wxString::Format(wxT("%i"), FifoPlayer::GetInstance().GetCurrentFrameNum());
|
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateFileObjectCountLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoPlayer::GetInstance().GetFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
return CreateIntegerLabel(FifoPlayer::GetInstance().GetFrameObjectCount(), _("Object"));
|
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateRecordingFifoSizeLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
int fifoBytes = 0;
|
|
|
|
for (int i = 0; i < file->GetFrameCount(); ++i)
|
|
|
|
fifoBytes += file->GetFrame(i).fifoDataSize;
|
|
|
|
|
|
|
|
return CreateIntegerLabel(fifoBytes, _("FIFO Byte"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return _("No recorded file");
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateRecordingMemSizeLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
int memBytes = 0;
|
|
|
|
for (int frameNum = 0; frameNum < file->GetFrameCount(); ++frameNum)
|
|
|
|
{
|
|
|
|
const vector<MemoryUpdate>& memUpdates = file->GetFrame(frameNum).memoryUpdates;
|
|
|
|
for (unsigned int i = 0; i < memUpdates.size(); ++i)
|
|
|
|
memBytes += memUpdates[i].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CreateIntegerLabel(memBytes, _("Memory Byte"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateRecordingFrameCountLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
int numFrames = file->GetFrameCount();
|
|
|
|
return CreateIntegerLabel(numFrames, _("Frame"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateIntegerLabel(int size, const wxString& label) const
|
|
|
|
{
|
|
|
|
wxString postfix;
|
|
|
|
if (size != 1)
|
|
|
|
postfix = _("s");
|
|
|
|
|
|
|
|
return wxString::Format(wxT("%i"), size) + wxT(" ") + label + postfix;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FifoPlayerDlg::GetSaveButtonEnabled() const
|
|
|
|
{
|
|
|
|
return (FifoRecorder::GetInstance().GetRecordedFile() != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::RecordingFinished()
|
|
|
|
{
|
|
|
|
sMutex.lock();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
if (m_EvtHandler)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event(RECORDING_FINISHED_EVENT);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EvtHandler->AddPendingEvent(event);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::FileLoaded()
|
|
|
|
{
|
|
|
|
sMutex.lock();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
if (m_EvtHandler)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxPaintEvent event;
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EvtHandler->AddPendingEvent(event);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::FrameWritten()
|
|
|
|
{
|
|
|
|
sMutex.lock();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
if (m_EvtHandler)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event(FRAME_WRITTEN_EVENT);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EvtHandler->AddPendingEvent(event);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sMutex.unlock();
|
2011-04-17 21:39:58 +00:00
|
|
|
}
|