diff --git a/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp b/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp index 8d01663c87..4a278c3649 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp @@ -81,4 +81,9 @@ void AchievementsWindow::UpdateData() update(); } +void AchievementsWindow::ForceSettingsTab() +{ + m_tab_widget->setCurrentIndex(0); +} + #endif // USE_RETRO_ACHIEVEMENTS diff --git a/Source/Core/DolphinQt/Achievements/AchievementsWindow.h b/Source/Core/DolphinQt/Achievements/AchievementsWindow.h index 6fd7165e1f..381a0aafb5 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementsWindow.h +++ b/Source/Core/DolphinQt/Achievements/AchievementsWindow.h @@ -22,6 +22,7 @@ class AchievementsWindow : public QDialog public: explicit AchievementsWindow(QWidget* parent); void UpdateData(); + void ForceSettingsTab(); private: void CreateMainLayout(); diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 391b1f1afb..a7eac856d0 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -102,6 +102,8 @@ add_executable(dolphin-emu Config/GraphicsModListWidget.h Config/GraphicsModWarningWidget.cpp Config/GraphicsModWarningWidget.h + Config/HardcoreWarningWidget.cpp + Config/HardcoreWarningWidget.h Config/InfoWidget.cpp Config/InfoWidget.h Config/LogConfigWidget.cpp diff --git a/Source/Core/DolphinQt/Config/HardcoreWarningWidget.cpp b/Source/Core/DolphinQt/Config/HardcoreWarningWidget.cpp new file mode 100644 index 0000000000..c2db01d077 --- /dev/null +++ b/Source/Core/DolphinQt/Config/HardcoreWarningWidget.cpp @@ -0,0 +1,62 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#ifdef USE_RETRO_ACHIEVEMENTS +#include "DolphinQt/Config/HardcoreWarningWidget.h" + +#include +#include +#include +#include +#include + +#include "Core/Config/AchievementSettings.h" +#include "Core/ConfigManager.h" +#include "Core/Core.h" + +#include "DolphinQt/Settings.h" + +HardcoreWarningWidget::HardcoreWarningWidget(QWidget* parent) : QWidget(parent) +{ + CreateWidgets(); + ConnectWidgets(); + + connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] { Update(); }); + + Update(); +} + +void HardcoreWarningWidget::CreateWidgets() +{ + const auto size = 1.5 * QFontMetrics(font()).height(); + + QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size); + + auto* icon = new QLabel; + icon->setPixmap(warning_icon); + + m_text = new QLabel(tr("This feature is disabled in hardcore mode.")); + m_settings_button = new QPushButton(tr("Achievement Settings")); + + auto* layout = new QHBoxLayout; + + layout->addWidget(icon); + layout->addWidget(m_text, 1); + layout->addWidget(m_settings_button); + + layout->setContentsMargins(0, 0, 0, 0); + + setLayout(layout); +} + +void HardcoreWarningWidget::ConnectWidgets() +{ + connect(m_settings_button, &QPushButton::clicked, this, + &HardcoreWarningWidget::OpenAchievementSettings); +} + +void HardcoreWarningWidget::Update() +{ + setHidden(!Config::Get(Config::RA_HARDCORE_ENABLED)); +} +#endif // USE_RETRO_ACHIEVEMENTS diff --git a/Source/Core/DolphinQt/Config/HardcoreWarningWidget.h b/Source/Core/DolphinQt/Config/HardcoreWarningWidget.h new file mode 100644 index 0000000000..c4a20eba96 --- /dev/null +++ b/Source/Core/DolphinQt/Config/HardcoreWarningWidget.h @@ -0,0 +1,30 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#ifdef USE_RETRO_ACHIEVEMENTS +#include + +class QLabel; +class QPushButton; + +class HardcoreWarningWidget : public QWidget +{ + Q_OBJECT +public: + explicit HardcoreWarningWidget(QWidget* parent); + +signals: + void OpenAchievementSettings(); + +private: + void CreateWidgets(); + void ConnectWidgets(); + + void Update(); + + QLabel* m_text; + QPushButton* m_settings_button; +}; +#endif // USE_RETRO_ACHIEVEMENTS diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 36e4b44d31..9ad07befec 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -31,10 +31,8 @@ $(ProjectDir)Settings;%(AdditionalIncludeDirectories) $(ProjectDir)TAS;%(AdditionalIncludeDirectories) $(ProjectDir)VideoInterface;%(AdditionalIncludeDirectories) - _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING;%(PreprocessorDefinitions) - $(SourceDir)PCH;%(AdditionalIncludeDirectories) Use @@ -87,6 +85,7 @@ + @@ -239,7 +238,7 @@ - + @@ -298,6 +297,7 @@ + diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index d9eda82bb1..6cf6ac57bd 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -1971,6 +1971,12 @@ void MainWindow::ShowAchievementsWindow() m_achievements_window->raise(); m_achievements_window->activateWindow(); } + +void MainWindow::ShowAchievementSettings() +{ + ShowAchievementsWindow(); + m_achievements_window->ForceSettingsTab(); +} #endif // USE_RETRO_ACHIEVEMENTS void MainWindow::ShowMemcardManager() diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index ce6beb1578..1f53d5e1ff 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -175,6 +175,7 @@ private: #ifdef USE_RETRO_ACHIEVEMENTS void ShowAchievementsWindow(); + void ShowAchievementSettings(); #endif // USE_RETRO_ACHIEVEMENTS void NetPlayInit();