2019-03-31 02:49:57 +00:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "DolphinQt/TAS/TASCheckBox.h"
|
|
|
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
|
|
|
#include "Core/Movie.h"
|
2020-06-30 19:07:25 +00:00
|
|
|
#include "DolphinQt/TAS/TASInputWindow.h"
|
2019-03-31 02:49:57 +00:00
|
|
|
|
2020-06-30 19:07:25 +00:00
|
|
|
TASCheckBox::TASCheckBox(const QString& text, TASInputWindow* parent)
|
|
|
|
: QCheckBox(text, parent), m_parent(parent)
|
2019-03-31 02:49:57 +00:00
|
|
|
{
|
|
|
|
setTristate(true);
|
|
|
|
}
|
|
|
|
|
2020-01-27 02:41:28 +00:00
|
|
|
bool TASCheckBox::GetValue() const
|
2019-03-31 02:49:57 +00:00
|
|
|
{
|
|
|
|
if (checkState() == Qt::PartiallyChecked)
|
2020-06-30 19:07:25 +00:00
|
|
|
{
|
|
|
|
const u64 frames_elapsed = Movie::GetCurrentFrame() - m_frame_turbo_started;
|
|
|
|
return frames_elapsed % m_turbo_total_frames < m_turbo_press_frames;
|
|
|
|
}
|
2019-03-31 02:49:57 +00:00
|
|
|
|
|
|
|
return isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TASCheckBox::mousePressEvent(QMouseEvent* event)
|
|
|
|
{
|
|
|
|
if (event->button() != Qt::RightButton)
|
|
|
|
{
|
|
|
|
setChecked(!isChecked());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkState() == Qt::PartiallyChecked)
|
|
|
|
{
|
|
|
|
setCheckState(Qt::Unchecked);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-30 19:07:25 +00:00
|
|
|
m_frame_turbo_started = Movie::GetCurrentFrame();
|
|
|
|
m_turbo_press_frames = m_parent->GetTurboPressFrames();
|
|
|
|
m_turbo_total_frames = m_turbo_press_frames + m_parent->GetTurboReleaseFrames();
|
2019-03-31 02:49:57 +00:00
|
|
|
setCheckState(Qt::PartiallyChecked);
|
|
|
|
}
|