summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp
diff options
context:
space:
mode:
authorMat M <mathew1800@gmail.com>2021-05-14 15:51:53 -0400
committerGitHub <noreply@github.com>2021-05-14 15:51:53 -0400
commitd74a1068b8d78a48d06998dc7a8d7d4a6298f5b8 (patch)
treeb65fff3409805dc6ee852f832f718355861b4a72 /Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp
parent41befc21cd1124fc8e1e47aeeb8c02d0e110be9b (diff)
parent77b1cca987974c8e6e322989e19e406b58dd0fcb (diff)
Merge pull request #9540 from Pokechu22/better-fifo-analyzer-part-2
Fifo analyzer quality of life improvements
Diffstat (limited to 'Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp')
-rw-r--r--Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp51
1 files changed, 37 insertions, 14 deletions
diff --git a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp
index ae351792fe..dc1b4f44b7 100644
--- a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp
+++ b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp
@@ -6,9 +6,13 @@
#include <QCheckBox>
#include <QDialogButtonBox>
+#include <QEvent>
#include <QFileDialog>
#include <QGroupBox>
#include <QHBoxLayout>
+#include <QIcon>
+#include <QKeyEvent>
+#include <QKeySequence>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
@@ -26,12 +30,13 @@
#include "DolphinQt/FIFO/FIFOAnalyzer.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"
+#include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h"
-FIFOPlayerWindow::FIFOPlayerWindow(QWidget* parent) : QDialog(parent)
+FIFOPlayerWindow::FIFOPlayerWindow(QWidget* parent) : QWidget(parent)
{
setWindowTitle(tr("FIFO Player"));
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ setWindowIcon(Resources::GetAppIcon());
CreateWidgets();
ConnectWidgets();
@@ -50,11 +55,14 @@ FIFOPlayerWindow::FIFOPlayerWindow(QWidget* parent) : QDialog(parent)
});
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
- if (state == Core::State::Running)
+ if (state == Core::State::Running && m_emu_state != Core::State::Paused)
OnEmulationStarted();
else if (state == Core::State::Uninitialized)
OnEmulationStopped();
+ m_emu_state = state;
});
+
+ installEventFilter(this);
}
FIFOPlayerWindow::~FIFOPlayerWindow()
@@ -166,7 +174,7 @@ void FIFOPlayerWindow::ConnectWidgets()
connect(m_save, &QPushButton::clicked, this, &FIFOPlayerWindow::SaveRecording);
connect(m_record, &QPushButton::clicked, this, &FIFOPlayerWindow::StartRecording);
connect(m_stop, &QPushButton::clicked, this, &FIFOPlayerWindow::StopRecording);
- connect(m_button_box, &QDialogButtonBox::rejected, this, &FIFOPlayerWindow::reject);
+ connect(m_button_box, &QDialogButtonBox::rejected, this, &FIFOPlayerWindow::hide);
connect(m_early_memory_updates, &QCheckBox::toggled, this,
&FIFOPlayerWindow::OnEarlyMemoryUpdatesChanged);
connect(m_frame_range_from, qOverload<int>(&QSpinBox::valueChanged), this,
@@ -244,6 +252,7 @@ void FIFOPlayerWindow::OnEmulationStopped()
StopRecording();
UpdateControls();
+ m_analyzer->Update();
}
void FIFOPlayerWindow::OnRecordingDone()
@@ -260,7 +269,7 @@ void FIFOPlayerWindow::UpdateInfo()
m_info_label->setText(
tr("%1 frame(s)\n%2 object(s)\nCurrent Frame: %3")
.arg(QString::number(file->GetFrameCount()),
- QString::number(FifoPlayer::GetInstance().GetFrameObjectCount()),
+ QString::number(FifoPlayer::GetInstance().GetCurrentFrameObjectCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameNum())));
return;
}
@@ -297,14 +306,16 @@ void FIFOPlayerWindow::OnFIFOLoaded()
{
FifoDataFile* file = FifoPlayer::GetInstance().GetFile();
- auto object_count = FifoPlayer::GetInstance().GetFrameObjectCount();
+ auto object_count = FifoPlayer::GetInstance().GetMaxObjectCount();
auto frame_count = file->GetFrameCount();
- m_frame_range_to->setMaximum(frame_count);
- m_object_range_to->setMaximum(object_count);
+ m_frame_range_to->setMaximum(frame_count - 1);
+ m_object_range_to->setMaximum(object_count - 1);
- m_frame_range_to->setValue(frame_count);
- m_object_range_to->setValue(object_count);
+ m_frame_range_from->setValue(0);
+ m_object_range_from->setValue(0);
+ m_frame_range_to->setValue(frame_count - 1);
+ m_object_range_to->setValue(object_count - 1);
UpdateInfo();
UpdateLimits();
@@ -331,10 +342,10 @@ void FIFOPlayerWindow::OnLimitsChanged()
void FIFOPlayerWindow::UpdateLimits()
{
- m_frame_range_from->setMaximum(std::max(m_frame_range_to->value() - 1, 0));
- m_frame_range_to->setMinimum(m_frame_range_from->value() + 1);
- m_object_range_from->setMaximum(std::max(m_object_range_to->value() - 1, 0));
- m_object_range_to->setMinimum(m_object_range_from->value() + 1);
+ m_frame_range_from->setMaximum(m_frame_range_to->value());
+ m_frame_range_to->setMinimum(m_frame_range_from->value());
+ m_object_range_from->setMaximum(m_object_range_to->value());
+ m_object_range_to->setMinimum(m_object_range_from->value());
}
void FIFOPlayerWindow::UpdateControls()
@@ -367,3 +378,15 @@ void FIFOPlayerWindow::UpdateControls()
m_save->setEnabled(FifoRecorder::GetInstance().IsRecordingDone());
}
+
+bool FIFOPlayerWindow::eventFilter(QObject* object, QEvent* event)
+{
+ // Close when escape is pressed
+ if (event->type() == QEvent::KeyPress)
+ {
+ if (static_cast<QKeyEvent*>(event)->matches(QKeySequence::Cancel))
+ hide();
+ }
+
+ return false;
+}