diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 85bc526ae6..61b1ad6142 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -111,7 +111,7 @@ add_executable(dolphin-emu QtUtils/WinIconHelper.cpp QtUtils/WrapInScrollArea.cpp QtUtils/AspectRatioWidget.cpp - ResourcePackManager.cpp + ResourcePackManager.cpp Settings/AdvancedPane.cpp Settings/AudioPane.cpp Settings/GameCubePane.cpp @@ -122,6 +122,7 @@ add_executable(dolphin-emu Settings/USBDeviceAddToWhitelistDialog.cpp TAS/GCTASInputWindow.cpp TAS/WiiTASInputWindow.cpp + TAS/TASCheckBox.cpp TAS/TASInputWindow.cpp TAS/StickWidget.cpp TAS/IRWidget.cpp diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index e2fefa340c..243560abf6 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -115,6 +115,7 @@ + @@ -263,6 +264,7 @@ + @@ -342,6 +344,7 @@ + diff --git a/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp b/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp index f45c5fa9aa..1cb606b807 100644 --- a/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp +++ b/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp @@ -14,6 +14,8 @@ #include "Common/CommonTypes.h" +#include "DolphinQt/TAS/TASCheckBox.h" + #include "InputCommon/GCPadStatus.h" GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : TASInputWindow(parent) @@ -41,18 +43,18 @@ GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : TASInputWindow(pa triggers_layout->addLayout(r_trigger_layout); m_triggers_box->setLayout(triggers_layout); - m_a_button = new QCheckBox(QStringLiteral("&A")); - m_b_button = new QCheckBox(QStringLiteral("&B")); - m_x_button = new QCheckBox(QStringLiteral("&X")); - m_y_button = new QCheckBox(QStringLiteral("&Y")); - m_z_button = new QCheckBox(QStringLiteral("&Z")); - m_l_button = new QCheckBox(QStringLiteral("&L")); - m_r_button = new QCheckBox(QStringLiteral("&R")); - m_start_button = new QCheckBox(QStringLiteral("&START")); - m_left_button = new QCheckBox(QStringLiteral("L&eft")); - m_up_button = new QCheckBox(QStringLiteral("&Up")); - m_down_button = new QCheckBox(QStringLiteral("&Down")); - m_right_button = new QCheckBox(QStringLiteral("R&ight")); + m_a_button = new TASCheckBox(QStringLiteral("&A")); + m_b_button = new TASCheckBox(QStringLiteral("&B")); + m_x_button = new TASCheckBox(QStringLiteral("&X")); + m_y_button = new TASCheckBox(QStringLiteral("&Y")); + m_z_button = new TASCheckBox(QStringLiteral("&Z")); + m_l_button = new TASCheckBox(QStringLiteral("&L")); + m_r_button = new TASCheckBox(QStringLiteral("&R")); + m_start_button = new TASCheckBox(QStringLiteral("&START")); + m_left_button = new TASCheckBox(QStringLiteral("L&eft")); + m_up_button = new TASCheckBox(QStringLiteral("&Up")); + m_down_button = new TASCheckBox(QStringLiteral("&Down")); + m_right_button = new TASCheckBox(QStringLiteral("R&ight")); auto* buttons_layout = new QGridLayout; buttons_layout->addWidget(m_a_button, 0, 0); diff --git a/Source/Core/DolphinQt/TAS/GCTASInputWindow.h b/Source/Core/DolphinQt/TAS/GCTASInputWindow.h index a75a4a76d9..724eb05846 100644 --- a/Source/Core/DolphinQt/TAS/GCTASInputWindow.h +++ b/Source/Core/DolphinQt/TAS/GCTASInputWindow.h @@ -6,9 +6,9 @@ #include "DolphinQt/TAS/TASInputWindow.h" -class QCheckBox; class QGroupBox; class QSpinBox; +class TASCheckBox; struct GCPadStatus; class GCTASInputWindow : public TASInputWindow @@ -19,18 +19,18 @@ public: void GetValues(GCPadStatus* pad); private: - QCheckBox* m_a_button; - QCheckBox* m_b_button; - QCheckBox* m_x_button; - QCheckBox* m_y_button; - QCheckBox* m_z_button; - QCheckBox* m_l_button; - QCheckBox* m_r_button; - QCheckBox* m_start_button; - QCheckBox* m_left_button; - QCheckBox* m_up_button; - QCheckBox* m_down_button; - QCheckBox* m_right_button; + TASCheckBox* m_a_button; + TASCheckBox* m_b_button; + TASCheckBox* m_x_button; + TASCheckBox* m_y_button; + TASCheckBox* m_z_button; + TASCheckBox* m_l_button; + TASCheckBox* m_r_button; + TASCheckBox* m_start_button; + TASCheckBox* m_left_button; + TASCheckBox* m_up_button; + TASCheckBox* m_down_button; + TASCheckBox* m_right_button; QSpinBox* m_l_trigger_value; QSpinBox* m_r_trigger_value; QSpinBox* m_x_main_stick_value; diff --git a/Source/Core/DolphinQt/TAS/TASCheckBox.cpp b/Source/Core/DolphinQt/TAS/TASCheckBox.cpp new file mode 100644 index 0000000000..9f4d34514e --- /dev/null +++ b/Source/Core/DolphinQt/TAS/TASCheckBox.cpp @@ -0,0 +1,40 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/TAS/TASCheckBox.h" + +#include + +#include "Core/Movie.h" + +TASCheckBox::TASCheckBox(const QString& text) : QCheckBox(text) +{ + setTristate(true); +} + +bool TASCheckBox::GetValue() +{ + if (checkState() == Qt::PartiallyChecked) + return Movie::GetCurrentFrame() % 2 == static_cast(m_trigger_on_odd); + + return isChecked(); +} + +void TASCheckBox::mousePressEvent(QMouseEvent* event) +{ + if (event->button() != Qt::RightButton) + { + setChecked(!isChecked()); + return; + } + + if (checkState() == Qt::PartiallyChecked) + { + setCheckState(Qt::Unchecked); + return; + } + + m_trigger_on_odd = Movie::GetCurrentFrame() % 2 == 0; + setCheckState(Qt::PartiallyChecked); +} diff --git a/Source/Core/DolphinQt/TAS/TASCheckBox.h b/Source/Core/DolphinQt/TAS/TASCheckBox.h new file mode 100644 index 0000000000..a39cd446bf --- /dev/null +++ b/Source/Core/DolphinQt/TAS/TASCheckBox.h @@ -0,0 +1,24 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +class QMouseEvent; + +class TASCheckBox : public QCheckBox +{ + Q_OBJECT +public: + explicit TASCheckBox(const QString& text); + + bool GetValue(); + +protected: + void mousePressEvent(QMouseEvent* event) override; + +private: + bool m_trigger_on_odd; +}; diff --git a/Source/Core/DolphinQt/TAS/TASInputWindow.cpp b/Source/Core/DolphinQt/TAS/TASInputWindow.cpp index e87f358889..a559ae887c 100644 --- a/Source/Core/DolphinQt/TAS/TASInputWindow.cpp +++ b/Source/Core/DolphinQt/TAS/TASInputWindow.cpp @@ -18,6 +18,7 @@ #include "DolphinQt/QtUtils/AspectRatioWidget.h" #include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/TAS/StickWidget.h" +#include "DolphinQt/TAS/TASCheckBox.h" #include "DolphinQt/TAS/TASInputWindow.h" #include "InputCommon/GCPadStatus.h" @@ -130,7 +131,7 @@ QSpinBox* TASInputWindow::CreateSliderValuePair(QBoxLayout* layout, u16 max, } template -void TASInputWindow::GetButton(QCheckBox* checkbox, UX& buttons, UX mask) +void TASInputWindow::GetButton(TASCheckBox* checkbox, UX& buttons, UX mask) { const bool pressed = (buttons & mask) != 0; if (m_use_controller->isChecked()) @@ -147,13 +148,13 @@ void TASInputWindow::GetButton(QCheckBox* checkbox, UX& buttons, UX mask) } } - if (checkbox->isChecked()) + if (checkbox->GetValue()) buttons |= mask; else buttons &= ~mask; } -template void TASInputWindow::GetButton(QCheckBox* button, u8& pad, u8 mask); -template void TASInputWindow::GetButton(QCheckBox* button, u16& pad, u16 mask); +template void TASInputWindow::GetButton(TASCheckBox* button, u8& pad, u8 mask); +template void TASInputWindow::GetButton(TASCheckBox* button, u16& pad, u16 mask); void TASInputWindow::GetSpinBoxU8(QSpinBox* spin, u8& controller_value) { diff --git a/Source/Core/DolphinQt/TAS/TASInputWindow.h b/Source/Core/DolphinQt/TAS/TASInputWindow.h index 66d6239abf..90e25b03f2 100644 --- a/Source/Core/DolphinQt/TAS/TASInputWindow.h +++ b/Source/Core/DolphinQt/TAS/TASInputWindow.h @@ -15,6 +15,7 @@ class QDialog; class QGroupBox; class QSpinBox; class QString; +class TASCheckBox; class TASInputWindow : public QDialog { @@ -32,13 +33,13 @@ protected: Qt::Orientation orientation, QWidget* shortcut_widget, bool invert = false); template - void GetButton(QCheckBox* button, UX& pad, UX mask); + void GetButton(TASCheckBox* button, UX& pad, UX mask); void GetSpinBoxU8(QSpinBox* spin, u8& controller_value); void GetSpinBoxU16(QSpinBox* spin, u16& controller_value); QCheckBox* m_use_controller; private: - std::map m_checkbox_set_by_controller; + std::map m_checkbox_set_by_controller; std::map m_spinbox_most_recent_values_u8; std::map m_spinbox_most_recent_values_u16; }; diff --git a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp index c22f28dd2e..904e21bf15 100644 --- a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp +++ b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp @@ -31,6 +31,7 @@ #include "DolphinQt/QtUtils/AspectRatioWidget.h" #include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/TAS/IRWidget.h" +#include "DolphinQt/TAS/TASCheckBox.h" #include "DolphinQt/TAS/WiiTASInputWindow.h" #include "InputCommon/InputConfig.h" @@ -161,19 +162,19 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow( triggers_layout->addLayout(r_trigger_layout); m_triggers_box->setLayout(triggers_layout); - m_a_button = new QCheckBox(QStringLiteral("&A")); - m_b_button = new QCheckBox(QStringLiteral("&B")); - m_1_button = new QCheckBox(QStringLiteral("&1")); - m_2_button = new QCheckBox(QStringLiteral("&2")); - m_plus_button = new QCheckBox(QStringLiteral("&+")); - m_minus_button = new QCheckBox(QStringLiteral("&-")); - m_home_button = new QCheckBox(QStringLiteral("&HOME")); - m_left_button = new QCheckBox(QStringLiteral("&Left")); - m_up_button = new QCheckBox(QStringLiteral("&Up")); - m_down_button = new QCheckBox(QStringLiteral("&Down")); - m_right_button = new QCheckBox(QStringLiteral("&Right")); - m_c_button = new QCheckBox(QStringLiteral("&C")); - m_z_button = new QCheckBox(QStringLiteral("&Z")); + m_a_button = new TASCheckBox(QStringLiteral("&A")); + m_b_button = new TASCheckBox(QStringLiteral("&B")); + m_1_button = new TASCheckBox(QStringLiteral("&1")); + m_2_button = new TASCheckBox(QStringLiteral("&2")); + m_plus_button = new TASCheckBox(QStringLiteral("&+")); + m_minus_button = new TASCheckBox(QStringLiteral("&-")); + m_home_button = new TASCheckBox(QStringLiteral("&HOME")); + m_left_button = new TASCheckBox(QStringLiteral("&Left")); + m_up_button = new TASCheckBox(QStringLiteral("&Up")); + m_down_button = new TASCheckBox(QStringLiteral("&Down")); + m_right_button = new TASCheckBox(QStringLiteral("&Right")); + m_c_button = new TASCheckBox(QStringLiteral("&C")); + m_z_button = new TASCheckBox(QStringLiteral("&Z")); auto* buttons_layout = new QGridLayout; buttons_layout->addWidget(m_a_button, 0, 0); @@ -202,21 +203,21 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow( m_nunchuk_buttons_box = new QGroupBox(tr("Nunchuk Buttons")); m_nunchuk_buttons_box->setLayout(nunchuk_buttons_layout); - m_classic_a_button = new QCheckBox(QStringLiteral("&A")); - m_classic_b_button = new QCheckBox(QStringLiteral("&B")); - m_classic_x_button = new QCheckBox(QStringLiteral("&X")); - m_classic_y_button = new QCheckBox(QStringLiteral("&Y")); - m_classic_l_button = new QCheckBox(QStringLiteral("&L")); - m_classic_r_button = new QCheckBox(QStringLiteral("&R")); - m_classic_zl_button = new QCheckBox(QStringLiteral("&ZL")); - m_classic_zr_button = new QCheckBox(QStringLiteral("ZR")); - m_classic_plus_button = new QCheckBox(QStringLiteral("&+")); - m_classic_minus_button = new QCheckBox(QStringLiteral("&-")); - m_classic_home_button = new QCheckBox(QStringLiteral("&HOME")); - m_classic_left_button = new QCheckBox(QStringLiteral("L&eft")); - m_classic_up_button = new QCheckBox(QStringLiteral("&Up")); - m_classic_down_button = new QCheckBox(QStringLiteral("&Down")); - m_classic_right_button = new QCheckBox(QStringLiteral("R&ight")); + m_classic_a_button = new TASCheckBox(QStringLiteral("&A")); + m_classic_b_button = new TASCheckBox(QStringLiteral("&B")); + m_classic_x_button = new TASCheckBox(QStringLiteral("&X")); + m_classic_y_button = new TASCheckBox(QStringLiteral("&Y")); + m_classic_l_button = new TASCheckBox(QStringLiteral("&L")); + m_classic_r_button = new TASCheckBox(QStringLiteral("&R")); + m_classic_zl_button = new TASCheckBox(QStringLiteral("&ZL")); + m_classic_zr_button = new TASCheckBox(QStringLiteral("ZR")); + m_classic_plus_button = new TASCheckBox(QStringLiteral("&+")); + m_classic_minus_button = new TASCheckBox(QStringLiteral("&-")); + m_classic_home_button = new TASCheckBox(QStringLiteral("&HOME")); + m_classic_left_button = new TASCheckBox(QStringLiteral("L&eft")); + m_classic_up_button = new TASCheckBox(QStringLiteral("&Up")); + m_classic_down_button = new TASCheckBox(QStringLiteral("&Down")); + m_classic_right_button = new TASCheckBox(QStringLiteral("R&ight")); auto* classic_buttons_layout = new QGridLayout; classic_buttons_layout->addWidget(m_classic_a_button, 0, 0); diff --git a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h index d3a830b138..0d75bd1a9d 100644 --- a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h +++ b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h @@ -16,9 +16,9 @@ namespace WiimoteEmu class EncryptionKey; } -class QCheckBox; class QGroupBox; class QSpinBox; +class TASCheckBox; class WiiTASInputWindow : public TASInputWindow { @@ -31,34 +31,34 @@ public: private: void UpdateExt(u8 ext); int m_num; - QCheckBox* m_a_button; - QCheckBox* m_b_button; - QCheckBox* m_1_button; - QCheckBox* m_2_button; - QCheckBox* m_plus_button; - QCheckBox* m_minus_button; - QCheckBox* m_home_button; - QCheckBox* m_left_button; - QCheckBox* m_up_button; - QCheckBox* m_down_button; - QCheckBox* m_right_button; - QCheckBox* m_c_button; - QCheckBox* m_z_button; - QCheckBox* m_classic_a_button; - QCheckBox* m_classic_b_button; - QCheckBox* m_classic_x_button; - QCheckBox* m_classic_y_button; - QCheckBox* m_classic_plus_button; - QCheckBox* m_classic_minus_button; - QCheckBox* m_classic_l_button; - QCheckBox* m_classic_r_button; - QCheckBox* m_classic_zl_button; - QCheckBox* m_classic_zr_button; - QCheckBox* m_classic_home_button; - QCheckBox* m_classic_left_button; - QCheckBox* m_classic_up_button; - QCheckBox* m_classic_down_button; - QCheckBox* m_classic_right_button; + TASCheckBox* m_a_button; + TASCheckBox* m_b_button; + TASCheckBox* m_1_button; + TASCheckBox* m_2_button; + TASCheckBox* m_plus_button; + TASCheckBox* m_minus_button; + TASCheckBox* m_home_button; + TASCheckBox* m_left_button; + TASCheckBox* m_up_button; + TASCheckBox* m_down_button; + TASCheckBox* m_right_button; + TASCheckBox* m_c_button; + TASCheckBox* m_z_button; + TASCheckBox* m_classic_a_button; + TASCheckBox* m_classic_b_button; + TASCheckBox* m_classic_x_button; + TASCheckBox* m_classic_y_button; + TASCheckBox* m_classic_plus_button; + TASCheckBox* m_classic_minus_button; + TASCheckBox* m_classic_l_button; + TASCheckBox* m_classic_r_button; + TASCheckBox* m_classic_zl_button; + TASCheckBox* m_classic_zr_button; + TASCheckBox* m_classic_home_button; + TASCheckBox* m_classic_left_button; + TASCheckBox* m_classic_up_button; + TASCheckBox* m_classic_down_button; + TASCheckBox* m_classic_right_button; QSpinBox* m_remote_orientation_x_value; QSpinBox* m_remote_orientation_y_value; QSpinBox* m_remote_orientation_z_value;