FifoPlayer: Move instance to System.

This commit is contained in:
Admiral H. Curtiss
2024-01-05 09:31:59 +01:00
parent 2f7f7afe6d
commit fc2ec826d4
13 changed files with 76 additions and 56 deletions

View File

@ -37,7 +37,7 @@ constexpr int PART_START_ROLE = Qt::UserRole + 1;
// Values range from 1 to number of parts
constexpr int PART_END_ROLE = Qt::UserRole + 2;
FIFOAnalyzer::FIFOAnalyzer()
FIFOAnalyzer::FIFOAnalyzer(FifoPlayer& fifo_player) : m_fifo_player(fifo_player)
{
CreateWidgets();
ConnectWidgets();
@ -138,7 +138,7 @@ void FIFOAnalyzer::UpdateTree()
{
m_tree_widget->clear();
if (!FifoPlayer::GetInstance().IsPlaying())
if (!m_fifo_player.IsPlaying())
{
m_tree_widget->addTopLevelItem(new QTreeWidgetItem({tr("No recording loaded.")}));
return;
@ -148,7 +148,7 @@ void FIFOAnalyzer::UpdateTree()
m_tree_widget->addTopLevelItem(recording_item);
auto* file = FifoPlayer::GetInstance().GetFile();
auto* file = m_fifo_player.GetFile();
const u32 frame_count = file->GetFrameCount();
@ -158,7 +158,7 @@ void FIFOAnalyzer::UpdateTree()
recording_item->addChild(frame_item);
const AnalyzedFrameInfo& frame_info = FifoPlayer::GetInstance().GetAnalyzedFrameInfo(frame);
const AnalyzedFrameInfo& frame_info = m_fifo_player.GetAnalyzedFrameInfo(frame);
ASSERT(frame_info.parts.size() != 0);
Common::EnumMap<u32, FramePartType::EFBCopy> part_counts;
@ -339,7 +339,7 @@ void FIFOAnalyzer::UpdateDetails()
m_search_previous->setEnabled(false);
m_search_label->clear();
if (!FifoPlayer::GetInstance().IsPlaying())
if (!m_fifo_player.IsPlaying())
return;
const auto items = m_tree_widget->selectedItems();
@ -351,8 +351,8 @@ void FIFOAnalyzer::UpdateDetails()
const u32 start_part_nr = items[0]->data(0, PART_START_ROLE).toUInt();
const u32 end_part_nr = items[0]->data(0, PART_END_ROLE).toUInt();
const AnalyzedFrameInfo& frame_info = FifoPlayer::GetInstance().GetAnalyzedFrameInfo(frame_nr);
const auto& fifo_frame = FifoPlayer::GetInstance().GetFile()->GetFrame(frame_nr);
const AnalyzedFrameInfo& frame_info = m_fifo_player.GetAnalyzedFrameInfo(frame_nr);
const auto& fifo_frame = m_fifo_player.GetFile()->GetFrame(frame_nr);
const u32 object_start = frame_info.parts[start_part_nr].m_start;
const u32 object_end = frame_info.parts[end_part_nr].m_end;
@ -386,7 +386,7 @@ void FIFOAnalyzer::BeginSearch()
{
const QString search_str = m_search_edit->text();
if (!FifoPlayer::GetInstance().IsPlaying())
if (!m_fifo_player.IsPlaying())
return;
const auto items = m_tree_widget->selectedItems();
@ -434,8 +434,8 @@ void FIFOAnalyzer::BeginSearch()
const u32 start_part_nr = items[0]->data(0, PART_START_ROLE).toUInt();
const u32 end_part_nr = items[0]->data(0, PART_END_ROLE).toUInt();
const AnalyzedFrameInfo& frame_info = FifoPlayer::GetInstance().GetAnalyzedFrameInfo(frame_nr);
const FifoFrameInfo& fifo_frame = FifoPlayer::GetInstance().GetFile()->GetFrame(frame_nr);
const AnalyzedFrameInfo& frame_info = m_fifo_player.GetAnalyzedFrameInfo(frame_nr);
const FifoFrameInfo& fifo_frame = m_fifo_player.GetFile()->GetFrame(frame_nr);
const u32 object_start = frame_info.parts[start_part_nr].m_start;
const u32 object_end = frame_info.parts[end_part_nr].m_end;
@ -750,7 +750,7 @@ void FIFOAnalyzer::UpdateDescription()
{
m_entry_detail_browser->clear();
if (!FifoPlayer::GetInstance().IsPlaying())
if (!m_fifo_player.IsPlaying())
return;
const auto items = m_tree_widget->selectedItems();
@ -766,8 +766,8 @@ void FIFOAnalyzer::UpdateDescription()
const u32 end_part_nr = items[0]->data(0, PART_END_ROLE).toUInt();
const u32 entry_nr = m_detail_list->currentRow();
const AnalyzedFrameInfo& frame_info = FifoPlayer::GetInstance().GetAnalyzedFrameInfo(frame_nr);
const FifoFrameInfo& fifo_frame = FifoPlayer::GetInstance().GetFile()->GetFrame(frame_nr);
const AnalyzedFrameInfo& frame_info = m_fifo_player.GetAnalyzedFrameInfo(frame_nr);
const FifoFrameInfo& fifo_frame = m_fifo_player.GetFile()->GetFrame(frame_nr);
const u32 object_start = frame_info.parts[start_part_nr].m_start;
const u32 object_end = frame_info.parts[end_part_nr].m_end;

View File

@ -9,6 +9,7 @@
#include "Common/CommonTypes.h"
class FifoPlayer;
class QGroupBox;
class QLabel;
class QLineEdit;
@ -23,7 +24,7 @@ class FIFOAnalyzer final : public QWidget
Q_OBJECT
public:
explicit FIFOAnalyzer();
explicit FIFOAnalyzer(FifoPlayer& fifo_player);
~FIFOAnalyzer();
void Update();
@ -42,6 +43,8 @@ private:
void UpdateDetails();
void UpdateDescription();
FifoPlayer& m_fifo_player;
QTreeWidget* m_tree_widget;
QListWidget* m_detail_list;
QTextBrowser* m_entry_detail_browser;

View File

@ -32,7 +32,8 @@
#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"
FIFOPlayerWindow::FIFOPlayerWindow(QWidget* parent) : QWidget(parent)
FIFOPlayerWindow::FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent)
: QWidget(parent), m_fifo_player(fifo_player)
{
setWindowTitle(tr("FIFO Player"));
setWindowIcon(Resources::GetAppIcon());
@ -46,9 +47,9 @@ FIFOPlayerWindow::FIFOPlayerWindow(QWidget* parent) : QWidget(parent)
UpdateControls();
FifoPlayer::GetInstance().SetFileLoadedCallback(
m_fifo_player.SetFileLoadedCallback(
[this] { QueueOnObject(this, &FIFOPlayerWindow::OnFIFOLoaded); });
FifoPlayer::GetInstance().SetFrameWrittenCallback([this] {
m_fifo_player.SetFrameWrittenCallback([this] {
QueueOnObject(this, [this] {
UpdateInfo();
UpdateControls();
@ -68,8 +69,8 @@ FIFOPlayerWindow::FIFOPlayerWindow(QWidget* parent) : QWidget(parent)
FIFOPlayerWindow::~FIFOPlayerWindow()
{
FifoPlayer::GetInstance().SetFileLoadedCallback({});
FifoPlayer::GetInstance().SetFrameWrittenCallback({});
m_fifo_player.SetFileLoadedCallback({});
m_fifo_player.SetFrameWrittenCallback({});
}
void FIFOPlayerWindow::CreateWidgets()
@ -160,7 +161,7 @@ void FIFOPlayerWindow::CreateWidgets()
m_tab_widget = new QTabWidget(this);
m_analyzer = new FIFOAnalyzer;
m_analyzer = new FIFOAnalyzer(m_fifo_player);
m_tab_widget->addTab(m_main_widget, tr("Play / Record"));
m_tab_widget->addTab(m_analyzer, tr("Analyze"));
@ -262,7 +263,7 @@ void FIFOPlayerWindow::OnEmulationStarted()
{
UpdateControls();
if (FifoPlayer::GetInstance().GetFile())
if (m_fifo_player.GetFile())
OnFIFOLoaded();
}
@ -286,14 +287,13 @@ void FIFOPlayerWindow::OnRecordingDone()
void FIFOPlayerWindow::UpdateInfo()
{
if (FifoPlayer::GetInstance().IsPlaying())
if (m_fifo_player.IsPlaying())
{
FifoDataFile* file = FifoPlayer::GetInstance().GetFile();
m_info_label->setText(
tr("%1 frame(s)\n%2 object(s)\nCurrent Frame: %3")
.arg(QString::number(file->GetFrameCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameObjectCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameNum())));
FifoDataFile* file = m_fifo_player.GetFile();
m_info_label->setText(tr("%1 frame(s)\n%2 object(s)\nCurrent Frame: %3")
.arg(QString::number(file->GetFrameCount()),
QString::number(m_fifo_player.GetCurrentFrameObjectCount()),
QString::number(m_fifo_player.GetCurrentFrameNum())));
return;
}
@ -327,9 +327,9 @@ void FIFOPlayerWindow::UpdateInfo()
void FIFOPlayerWindow::OnFIFOLoaded()
{
FifoDataFile* file = FifoPlayer::GetInstance().GetFile();
FifoDataFile* file = m_fifo_player.GetFile();
auto object_count = FifoPlayer::GetInstance().GetMaxObjectCount();
auto object_count = m_fifo_player.GetMaxObjectCount();
auto frame_count = file->GetFrameCount();
m_frame_range_to->setMaximum(frame_count - 1);
@ -356,7 +356,7 @@ void FIFOPlayerWindow::OnConfigChanged()
void FIFOPlayerWindow::OnLimitsChanged()
{
FifoPlayer& player = FifoPlayer::GetInstance();
FifoPlayer& player = m_fifo_player;
player.SetFrameRangeStart(m_frame_range_from->value());
player.SetFrameRangeEnd(m_frame_range_to->value());
@ -377,7 +377,7 @@ void FIFOPlayerWindow::UpdateControls()
{
bool running = Core::IsRunning();
bool is_recording = FifoRecorder::GetInstance().IsRecording();
bool is_playing = FifoPlayer::GetInstance().IsPlaying();
bool is_playing = m_fifo_player.IsPlaying();
m_frame_range_from->setEnabled(is_playing);
m_frame_range_from_label->setEnabled(is_playing);

View File

@ -13,13 +13,14 @@ class QPushButton;
class QSpinBox;
class QTabWidget;
class ToolTipCheckBox;
class FifoPlayer;
class FIFOAnalyzer;
class FIFOPlayerWindow : public QWidget
{
Q_OBJECT
public:
explicit FIFOPlayerWindow(QWidget* parent = nullptr);
explicit FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent = nullptr);
~FIFOPlayerWindow();
signals:
@ -49,6 +50,8 @@ private:
bool eventFilter(QObject* object, QEvent* event) final override;
FifoPlayer& m_fifo_player;
QLabel* m_info_label;
QPushButton* m_load;
QPushButton* m_save;

View File

@ -1363,7 +1363,7 @@ void MainWindow::ShowFIFOPlayer()
{
if (!m_fifo_window)
{
m_fifo_window = new FIFOPlayerWindow;
m_fifo_window = new FIFOPlayerWindow(Core::System::GetInstance().GetFifoPlayer());
connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
[this](const QString& path) { StartGame(path, ScanForSecondDisc::No); });
}