2017-08-30 14:44:28 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-08-30 14:44:28 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/FIFO/FIFOPlayerWindow.h"
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QDialogButtonBox>
|
2021-02-16 19:24:57 +00:00
|
|
|
#include <QEvent>
|
2017-08-30 14:44:28 +00:00
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QHBoxLayout>
|
2021-02-16 19:24:57 +00:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QKeySequence>
|
2017-08-30 14:44:28 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSpinBox>
|
2018-05-14 20:01:23 +00:00
|
|
|
#include <QTabWidget>
|
2017-08-30 14:44:28 +00:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/FifoPlayer/FifoDataFile.h"
|
|
|
|
#include "Core/FifoPlayer/FifoPlayer.h"
|
|
|
|
#include "Core/FifoPlayer/FifoRecorder.h"
|
|
|
|
|
2022-01-06 22:38:09 +00:00
|
|
|
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/FIFO/FIFOAnalyzer.h"
|
2021-10-10 02:28:59 +00:00
|
|
|
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
2019-03-04 19:49:00 +00:00
|
|
|
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/QtUtils/QueueOnObject.h"
|
2021-02-16 19:24:57 +00:00
|
|
|
#include "DolphinQt/Resources.h"
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings.h"
|
2017-08-30 14:44:28 +00:00
|
|
|
|
2024-01-05 08:31:59 +00:00
|
|
|
FIFOPlayerWindow::FIFOPlayerWindow(FifoPlayer& fifo_player, QWidget* parent)
|
|
|
|
: QWidget(parent), m_fifo_player(fifo_player)
|
2017-08-30 14:44:28 +00:00
|
|
|
{
|
|
|
|
setWindowTitle(tr("FIFO Player"));
|
2021-02-16 19:24:57 +00:00
|
|
|
setWindowIcon(Resources::GetAppIcon());
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
CreateWidgets();
|
2022-01-17 18:59:57 +00:00
|
|
|
LoadSettings();
|
2017-08-30 14:44:28 +00:00
|
|
|
ConnectWidgets();
|
2022-01-06 22:38:09 +00:00
|
|
|
AddDescriptions();
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
UpdateInfo();
|
|
|
|
|
|
|
|
UpdateControls();
|
|
|
|
|
2024-01-05 08:31:59 +00:00
|
|
|
m_fifo_player.SetFileLoadedCallback(
|
2017-08-30 14:44:28 +00:00
|
|
|
[this] { QueueOnObject(this, &FIFOPlayerWindow::OnFIFOLoaded); });
|
2024-01-05 08:31:59 +00:00
|
|
|
m_fifo_player.SetFrameWrittenCallback([this] {
|
2017-11-24 22:11:29 +00:00
|
|
|
QueueOnObject(this, [this] {
|
|
|
|
UpdateInfo();
|
|
|
|
UpdateControls();
|
|
|
|
});
|
|
|
|
});
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
|
2021-03-16 04:02:25 +00:00
|
|
|
if (state == Core::State::Running && m_emu_state != Core::State::Paused)
|
2017-08-30 14:44:28 +00:00
|
|
|
OnEmulationStarted();
|
|
|
|
else if (state == Core::State::Uninitialized)
|
|
|
|
OnEmulationStopped();
|
2021-03-16 04:02:25 +00:00
|
|
|
m_emu_state = state;
|
2017-08-30 14:44:28 +00:00
|
|
|
});
|
2021-02-16 19:24:57 +00:00
|
|
|
|
|
|
|
installEventFilter(this);
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FIFOPlayerWindow::~FIFOPlayerWindow()
|
|
|
|
{
|
2024-01-05 08:31:59 +00:00
|
|
|
m_fifo_player.SetFileLoadedCallback({});
|
|
|
|
m_fifo_player.SetFrameWrittenCallback({});
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::CreateWidgets()
|
|
|
|
{
|
|
|
|
auto* layout = new QVBoxLayout;
|
|
|
|
|
|
|
|
// Info
|
|
|
|
auto* info_group = new QGroupBox(tr("File Info"));
|
|
|
|
auto* info_layout = new QHBoxLayout;
|
|
|
|
|
|
|
|
m_info_label = new QLabel;
|
|
|
|
info_layout->addWidget(m_info_label);
|
|
|
|
info_group->setLayout(info_layout);
|
|
|
|
|
|
|
|
m_info_label->setFixedHeight(QFontMetrics(font()).lineSpacing() * 3);
|
|
|
|
|
|
|
|
// Object Range
|
|
|
|
auto* object_range_group = new QGroupBox(tr("Object Range"));
|
|
|
|
auto* object_range_layout = new QHBoxLayout;
|
|
|
|
|
|
|
|
m_object_range_from = new QSpinBox;
|
|
|
|
m_object_range_from_label = new QLabel(tr("From:"));
|
|
|
|
m_object_range_to = new QSpinBox;
|
|
|
|
m_object_range_to_label = new QLabel(tr("To:"));
|
|
|
|
|
|
|
|
object_range_layout->addWidget(m_object_range_from_label);
|
|
|
|
object_range_layout->addWidget(m_object_range_from);
|
|
|
|
object_range_layout->addWidget(m_object_range_to_label);
|
|
|
|
object_range_layout->addWidget(m_object_range_to);
|
|
|
|
object_range_group->setLayout(object_range_layout);
|
|
|
|
|
|
|
|
// Frame Range
|
|
|
|
auto* frame_range_group = new QGroupBox(tr("Frame Range"));
|
|
|
|
auto* frame_range_layout = new QHBoxLayout;
|
|
|
|
|
|
|
|
m_frame_range_from = new QSpinBox;
|
|
|
|
m_frame_range_from_label = new QLabel(tr("From:"));
|
|
|
|
m_frame_range_to = new QSpinBox;
|
|
|
|
m_frame_range_to_label = new QLabel(tr("To:"));
|
|
|
|
|
|
|
|
frame_range_layout->addWidget(m_frame_range_from_label);
|
|
|
|
frame_range_layout->addWidget(m_frame_range_from);
|
|
|
|
frame_range_layout->addWidget(m_frame_range_to_label);
|
|
|
|
frame_range_layout->addWidget(m_frame_range_to);
|
|
|
|
frame_range_group->setLayout(frame_range_layout);
|
|
|
|
|
|
|
|
// Playback Options
|
|
|
|
auto* playback_group = new QGroupBox(tr("Playback Options"));
|
|
|
|
auto* playback_layout = new QGridLayout;
|
2022-01-06 22:38:09 +00:00
|
|
|
m_early_memory_updates = new ToolTipCheckBox(tr("Early Memory Updates"));
|
2022-01-06 22:47:36 +00:00
|
|
|
m_loop = new ToolTipCheckBox(tr("Loop"));
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
playback_layout->addWidget(object_range_group, 0, 0);
|
|
|
|
playback_layout->addWidget(frame_range_group, 0, 1);
|
2022-01-06 22:47:36 +00:00
|
|
|
playback_layout->addWidget(m_early_memory_updates, 1, 0);
|
|
|
|
playback_layout->addWidget(m_loop, 1, 1);
|
2017-08-30 14:44:28 +00:00
|
|
|
playback_group->setLayout(playback_layout);
|
|
|
|
|
|
|
|
// Recording Options
|
|
|
|
auto* recording_group = new QGroupBox(tr("Recording Options"));
|
|
|
|
auto* recording_layout = new QHBoxLayout;
|
|
|
|
m_frame_record_count = new QSpinBox;
|
|
|
|
m_frame_record_count_label = new QLabel(tr("Frames to Record:"));
|
|
|
|
|
|
|
|
m_frame_record_count->setMinimum(1);
|
|
|
|
m_frame_record_count->setMaximum(3600);
|
|
|
|
m_frame_record_count->setValue(3);
|
|
|
|
|
|
|
|
recording_layout->addWidget(m_frame_record_count_label);
|
|
|
|
recording_layout->addWidget(m_frame_record_count);
|
|
|
|
recording_group->setLayout(recording_layout);
|
|
|
|
|
|
|
|
m_button_box = new QDialogButtonBox(QDialogButtonBox::Close);
|
|
|
|
|
|
|
|
// Action Buttons
|
|
|
|
m_load = m_button_box->addButton(tr("Load..."), QDialogButtonBox::ActionRole);
|
|
|
|
m_save = m_button_box->addButton(tr("Save..."), QDialogButtonBox::ActionRole);
|
|
|
|
m_record = m_button_box->addButton(tr("Record"), QDialogButtonBox::ActionRole);
|
|
|
|
m_stop = m_button_box->addButton(tr("Stop"), QDialogButtonBox::ActionRole);
|
|
|
|
|
|
|
|
layout->addWidget(info_group);
|
|
|
|
layout->addWidget(playback_group);
|
|
|
|
layout->addWidget(recording_group);
|
|
|
|
layout->addWidget(m_button_box);
|
|
|
|
|
2021-09-06 01:51:52 +00:00
|
|
|
m_main_widget = new QWidget(this);
|
|
|
|
m_main_widget->setLayout(layout);
|
2018-05-14 20:01:23 +00:00
|
|
|
|
2021-09-06 01:51:52 +00:00
|
|
|
m_tab_widget = new QTabWidget(this);
|
2018-05-14 20:01:23 +00:00
|
|
|
|
2024-01-05 08:31:59 +00:00
|
|
|
m_analyzer = new FIFOAnalyzer(m_fifo_player);
|
2018-05-14 20:01:23 +00:00
|
|
|
|
2021-09-06 01:51:52 +00:00
|
|
|
m_tab_widget->addTab(m_main_widget, tr("Play / Record"));
|
|
|
|
m_tab_widget->addTab(m_analyzer, tr("Analyze"));
|
2018-05-14 20:01:23 +00:00
|
|
|
|
|
|
|
auto* tab_layout = new QVBoxLayout;
|
2021-09-06 01:51:52 +00:00
|
|
|
tab_layout->addWidget(m_tab_widget);
|
2018-05-14 20:01:23 +00:00
|
|
|
|
|
|
|
setLayout(tab_layout);
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 22:38:09 +00:00
|
|
|
void FIFOPlayerWindow::LoadSettings()
|
|
|
|
{
|
|
|
|
m_early_memory_updates->setChecked(Config::Get(Config::MAIN_FIFOPLAYER_EARLY_MEMORY_UPDATES));
|
2022-01-06 22:47:36 +00:00
|
|
|
m_loop->setChecked(Config::Get(Config::MAIN_FIFOPLAYER_LOOP_REPLAY));
|
2022-01-06 22:38:09 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 14:44:28 +00:00
|
|
|
void FIFOPlayerWindow::ConnectWidgets()
|
|
|
|
{
|
2019-04-22 23:44:00 +00:00
|
|
|
connect(m_load, &QPushButton::clicked, this, &FIFOPlayerWindow::LoadRecording);
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(m_save, &QPushButton::clicked, this, &FIFOPlayerWindow::SaveRecording);
|
|
|
|
connect(m_record, &QPushButton::clicked, this, &FIFOPlayerWindow::StartRecording);
|
|
|
|
connect(m_stop, &QPushButton::clicked, this, &FIFOPlayerWindow::StopRecording);
|
2021-02-16 19:24:57 +00:00
|
|
|
connect(m_button_box, &QDialogButtonBox::rejected, this, &FIFOPlayerWindow::hide);
|
2022-01-06 22:38:09 +00:00
|
|
|
connect(m_early_memory_updates, &QCheckBox::toggled, this, &FIFOPlayerWindow::OnConfigChanged);
|
2022-01-06 22:47:36 +00:00
|
|
|
connect(m_loop, &QCheckBox::toggled, this, &FIFOPlayerWindow::OnConfigChanged);
|
2022-01-06 22:38:09 +00:00
|
|
|
|
2023-11-04 21:01:39 +00:00
|
|
|
connect(m_frame_range_from, &QSpinBox::valueChanged, this, &FIFOPlayerWindow::OnLimitsChanged);
|
|
|
|
connect(m_frame_range_to, &QSpinBox::valueChanged, this, &FIFOPlayerWindow::OnLimitsChanged);
|
|
|
|
|
|
|
|
connect(m_object_range_from, &QSpinBox::valueChanged, this, &FIFOPlayerWindow::OnLimitsChanged);
|
|
|
|
connect(m_object_range_to, &QSpinBox::valueChanged, this, &FIFOPlayerWindow::OnLimitsChanged);
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 22:38:09 +00:00
|
|
|
void FIFOPlayerWindow::AddDescriptions()
|
|
|
|
{
|
|
|
|
static const char TR_MEMORY_UPDATES_DESCRIPTION[] = QT_TR_NOOP(
|
|
|
|
"If enabled, then all memory updates happen at once before the first frame.<br><br>"
|
|
|
|
"Causes issues with many fifologs, but can be useful for testing.<br><br>"
|
|
|
|
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
|
2022-01-06 22:47:36 +00:00
|
|
|
static const char TR_LOOP_DESCRIPTION[] =
|
|
|
|
QT_TR_NOOP("If unchecked, then playback of the fifolog stops after the final frame.<br><br>"
|
|
|
|
"This is generally only useful when a frame-dumping option is enabled.<br><br>"
|
|
|
|
"<dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
|
2022-01-06 22:38:09 +00:00
|
|
|
|
|
|
|
m_early_memory_updates->SetDescription(tr(TR_MEMORY_UPDATES_DESCRIPTION));
|
2022-01-06 22:47:36 +00:00
|
|
|
m_loop->SetDescription(tr(TR_LOOP_DESCRIPTION));
|
2022-01-06 22:38:09 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 14:44:28 +00:00
|
|
|
void FIFOPlayerWindow::LoadRecording()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString path = DolphinFileDialog::getOpenFileName(this, tr("Open FIFO log"), QString(),
|
|
|
|
tr("Dolphin FIFO Log (*.dff)"));
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
if (path.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
emit LoadFIFORequested(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::SaveRecording()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString path = DolphinFileDialog::getSaveFileName(this, tr("Save FIFO log"), QString(),
|
|
|
|
tr("Dolphin FIFO Log (*.dff)"));
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
if (path.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
FifoDataFile* file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
bool result = file->Save(path.toStdString());
|
|
|
|
|
|
|
|
if (!result)
|
2019-03-03 15:26:23 +00:00
|
|
|
{
|
2019-03-04 19:49:00 +00:00
|
|
|
ModalMessageBox::critical(this, tr("Error"), tr("Failed to save FIFO log."));
|
2019-03-03 15:26:23 +00:00
|
|
|
}
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::StartRecording()
|
|
|
|
{
|
|
|
|
// Start recording
|
|
|
|
FifoRecorder::GetInstance().StartRecording(m_frame_record_count->value(), [this] {
|
|
|
|
QueueOnObject(this, [this] { OnRecordingDone(); });
|
|
|
|
});
|
|
|
|
|
|
|
|
UpdateControls();
|
|
|
|
|
|
|
|
UpdateInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::StopRecording()
|
|
|
|
{
|
|
|
|
FifoRecorder::GetInstance().StopRecording();
|
|
|
|
|
|
|
|
UpdateControls();
|
|
|
|
UpdateInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::OnEmulationStarted()
|
|
|
|
{
|
|
|
|
UpdateControls();
|
2018-05-22 02:37:08 +00:00
|
|
|
|
2024-01-05 08:31:59 +00:00
|
|
|
if (m_fifo_player.GetFile())
|
2018-05-22 02:37:08 +00:00
|
|
|
OnFIFOLoaded();
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::OnEmulationStopped()
|
|
|
|
{
|
|
|
|
// If we have previously been recording, stop now.
|
|
|
|
if (FifoRecorder::GetInstance().IsRecording())
|
|
|
|
StopRecording();
|
|
|
|
|
|
|
|
UpdateControls();
|
2021-09-06 01:51:52 +00:00
|
|
|
// When emulation stops, switch away from the analyzer tab, as it no longer shows anything useful
|
|
|
|
m_tab_widget->setCurrentWidget(m_main_widget);
|
2021-02-13 02:49:23 +00:00
|
|
|
m_analyzer->Update();
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::OnRecordingDone()
|
|
|
|
{
|
|
|
|
UpdateInfo();
|
|
|
|
UpdateControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::UpdateInfo()
|
|
|
|
{
|
2024-01-05 08:31:59 +00:00
|
|
|
if (m_fifo_player.IsPlaying())
|
2017-08-30 14:44:28 +00:00
|
|
|
{
|
2024-01-05 08:31:59 +00:00
|
|
|
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())));
|
2017-08-30 14:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FifoRecorder::GetInstance().IsRecordingDone())
|
|
|
|
{
|
|
|
|
FifoDataFile* file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
size_t fifo_bytes = 0;
|
|
|
|
size_t mem_bytes = 0;
|
|
|
|
|
|
|
|
for (u32 i = 0; i < file->GetFrameCount(); ++i)
|
|
|
|
{
|
|
|
|
fifo_bytes += file->GetFrame(i).fifoData.size();
|
|
|
|
for (const auto& mem_update : file->GetFrame(i).memoryUpdates)
|
|
|
|
mem_bytes += mem_update.data.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_info_label->setText(tr("%1 FIFO bytes\n%2 memory bytes\n%3 frames")
|
|
|
|
.arg(QString::number(fifo_bytes), QString::number(mem_bytes),
|
|
|
|
QString::number(file->GetFrameCount())));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Core::IsRunning() && FifoRecorder::GetInstance().IsRecording())
|
|
|
|
{
|
|
|
|
m_info_label->setText(tr("Recording..."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_info_label->setText(tr("No file loaded / recorded."));
|
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::OnFIFOLoaded()
|
|
|
|
{
|
2024-01-05 08:31:59 +00:00
|
|
|
FifoDataFile* file = m_fifo_player.GetFile();
|
2017-08-30 14:44:28 +00:00
|
|
|
|
2024-01-05 08:31:59 +00:00
|
|
|
auto object_count = m_fifo_player.GetMaxObjectCount();
|
2017-08-30 14:44:28 +00:00
|
|
|
auto frame_count = file->GetFrameCount();
|
|
|
|
|
2021-02-09 00:25:57 +00:00
|
|
|
m_frame_range_to->setMaximum(frame_count - 1);
|
2021-02-09 00:10:57 +00:00
|
|
|
m_object_range_to->setMaximum(object_count - 1);
|
2017-08-30 14:44:28 +00:00
|
|
|
|
2021-03-17 19:08:11 +00:00
|
|
|
m_frame_range_from->setValue(0);
|
|
|
|
m_object_range_from->setValue(0);
|
2021-02-09 00:25:57 +00:00
|
|
|
m_frame_range_to->setValue(frame_count - 1);
|
2021-02-09 00:10:57 +00:00
|
|
|
m_object_range_to->setValue(object_count - 1);
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
UpdateInfo();
|
|
|
|
UpdateLimits();
|
|
|
|
UpdateControls();
|
2018-05-14 20:01:23 +00:00
|
|
|
|
|
|
|
m_analyzer->Update();
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 22:38:09 +00:00
|
|
|
void FIFOPlayerWindow::OnConfigChanged()
|
2017-08-30 14:44:28 +00:00
|
|
|
{
|
2022-01-06 22:38:09 +00:00
|
|
|
Config::SetBase(Config::MAIN_FIFOPLAYER_EARLY_MEMORY_UPDATES,
|
|
|
|
m_early_memory_updates->isChecked());
|
2022-01-06 22:47:36 +00:00
|
|
|
Config::SetBase(Config::MAIN_FIFOPLAYER_LOOP_REPLAY, m_loop->isChecked());
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::OnLimitsChanged()
|
|
|
|
{
|
2024-01-05 08:31:59 +00:00
|
|
|
FifoPlayer& player = m_fifo_player;
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
player.SetFrameRangeStart(m_frame_range_from->value());
|
|
|
|
player.SetFrameRangeEnd(m_frame_range_to->value());
|
|
|
|
player.SetObjectRangeStart(m_object_range_from->value());
|
|
|
|
player.SetObjectRangeEnd(m_object_range_to->value());
|
|
|
|
UpdateLimits();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::UpdateLimits()
|
|
|
|
{
|
2021-02-09 00:25:57 +00:00
|
|
|
m_frame_range_from->setMaximum(m_frame_range_to->value());
|
|
|
|
m_frame_range_to->setMinimum(m_frame_range_from->value());
|
2021-02-09 00:10:57 +00:00
|
|
|
m_object_range_from->setMaximum(m_object_range_to->value());
|
|
|
|
m_object_range_to->setMinimum(m_object_range_from->value());
|
2017-08-30 14:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FIFOPlayerWindow::UpdateControls()
|
|
|
|
{
|
|
|
|
bool running = Core::IsRunning();
|
|
|
|
bool is_recording = FifoRecorder::GetInstance().IsRecording();
|
2024-01-05 08:31:59 +00:00
|
|
|
bool is_playing = m_fifo_player.IsPlaying();
|
2017-08-30 14:44:28 +00:00
|
|
|
|
|
|
|
m_frame_range_from->setEnabled(is_playing);
|
|
|
|
m_frame_range_from_label->setEnabled(is_playing);
|
|
|
|
m_frame_range_to->setEnabled(is_playing);
|
|
|
|
m_frame_range_to_label->setEnabled(is_playing);
|
|
|
|
m_object_range_from->setEnabled(is_playing);
|
|
|
|
m_object_range_from_label->setEnabled(is_playing);
|
|
|
|
m_object_range_to->setEnabled(is_playing);
|
|
|
|
m_object_range_to_label->setEnabled(is_playing);
|
|
|
|
|
|
|
|
bool enable_frame_record_count = !is_playing && !is_recording;
|
|
|
|
|
|
|
|
m_frame_record_count_label->setEnabled(enable_frame_record_count);
|
|
|
|
m_frame_record_count->setEnabled(enable_frame_record_count);
|
|
|
|
|
|
|
|
m_load->setEnabled(!running);
|
|
|
|
m_record->setEnabled(running && !is_playing);
|
|
|
|
|
|
|
|
m_stop->setVisible(running && is_recording);
|
|
|
|
m_record->setVisible(!m_stop->isVisible());
|
|
|
|
|
|
|
|
m_save->setEnabled(FifoRecorder::GetInstance().IsRecordingDone());
|
|
|
|
}
|
2021-02-16 19:24:57 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|