28 changes: 28 additions & 0 deletions Source/Core/DolphinQt/Achievements/AchievementsWindow.h
@@ -0,0 +1,28 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#ifdef USE_RETRO_ACHIEVEMENTS
#include <QDialog>

class QTabWidget;
class QDialogButtonBox;

class AchievementsWindow : public QDialog
{
Q_OBJECT
public:
explicit AchievementsWindow(QWidget* parent);
void UpdateData();

private:
void CreateMainLayout();
void showEvent(QShowEvent* event);
void ConnectWidgets();

QTabWidget* m_tab_widget;
QDialogButtonBox* m_button_box;
};

#endif // USE_RETRO_ACHIEVEMENTS
4 changes: 4 additions & 0 deletions Source/Core/DolphinQt/CMakeLists.txt
Expand Up @@ -27,6 +27,10 @@ add_executable(dolphin-emu
CheatSearchWidget.h
CheatsManager.cpp
CheatsManager.h
Achievements/AchievementSettingsWidget.cpp
Achievements/AchievementSettingsWidget.h
Achievements/AchievementsWindow.cpp
Achievements/AchievementsWindow.h
Config/ARCodeWidget.cpp
Config/ARCodeWidget.h
Config/CheatCodeEditor.cpp
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DolphinQt/DolphinQt.vcxproj
Expand Up @@ -50,6 +50,8 @@
<ClCompile Include="CheatSearchFactoryWidget.cpp" />
<ClCompile Include="CheatSearchWidget.cpp" />
<ClCompile Include="CheatsManager.cpp" />
<ClCompile Include="Achievements\AchievementSettingsWidget.cpp" />
<ClCompile Include="Achievements\AchievementsWindow.cpp" />
<ClCompile Include="Config\ARCodeWidget.cpp" />
<ClCompile Include="Config\CheatCodeEditor.cpp" />
<ClCompile Include="Config\CheatWarningWidget.cpp" />
Expand Down Expand Up @@ -252,6 +254,8 @@
<QtMoc Include="CheatSearchFactoryWidget.h" />
<QtMoc Include="CheatSearchWidget.h" />
<QtMoc Include="CheatsManager.h" />
<QtMoc Include="Achievements\AchievementSettingsWidget.h" />
<QtMoc Include="Achievements\AchievementsWindow.h" />
<QtMoc Include="Config\ARCodeWidget.h" />
<QtMoc Include="Config\CheatWarningWidget.h" />
<QtMoc Include="Config\CommonControllersWidget.h" />
Expand Down
19 changes: 19 additions & 0 deletions Source/Core/DolphinQt/MainWindow.cpp
Expand Up @@ -72,6 +72,7 @@
#include "DiscIO/RiivolutionPatcher.h"

#include "DolphinQt/AboutDialog.h"
#include "DolphinQt/Achievements/AchievementsWindow.h"
#include "DolphinQt/CheatsManager.h"
#include "DolphinQt/Config/ControllersWindow.h"
#include "DolphinQt/Config/FreeLookWindow.h"
Expand Down Expand Up @@ -544,6 +545,10 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::ShowInfinityBase, this, &MainWindow::ShowInfinityBase);
connect(m_menu_bar, &MenuBar::ConnectWiiRemote, this, &MainWindow::OnConnectWiiRemote);

#ifdef USE_RETRO_ACHIEVEMENTS
connect(m_menu_bar, &MenuBar::ShowAchievementsWindow, this, &MainWindow::ShowAchievementsWindow);
#endif // USE_RETRO_ACHIEVEMENTS

// Movie
connect(m_menu_bar, &MenuBar::PlayRecording, this, &MainWindow::OnPlayRecording);
connect(m_menu_bar, &MenuBar::StartRecording, this, &MainWindow::OnStartRecording);
Expand Down Expand Up @@ -1892,6 +1897,20 @@ void MainWindow::OnConnectWiiRemote(int id)
});
}

#ifdef USE_RETRO_ACHIEVEMENTS
void MainWindow::ShowAchievementsWindow()
{
if (!m_achievements_window)
{
m_achievements_window = new AchievementsWindow(this);
}

m_achievements_window->show();
m_achievements_window->raise();
m_achievements_window->activateWindow();
}
#endif // USE_RETRO_ACHIEVEMENTS

void MainWindow::ShowMemcardManager()
{
GCMemcardManager manager(this);
Expand Down
9 changes: 9 additions & 0 deletions Source/Core/DolphinQt/MainWindow.h
Expand Up @@ -16,6 +16,7 @@
class QStackedWidget;
class QString;

class AchievementsWindow;
class BreakpointWidget;
struct BootParameters;
class CheatsManager;
Expand Down Expand Up @@ -168,6 +169,10 @@ class MainWindow final : public QMainWindow
void ShowCheatsManager();
void ShowRiivolutionBootWidget(const UICommon::GameFile& game);

#ifdef USE_RETRO_ACHIEVEMENTS
void ShowAchievementsWindow();
#endif // USE_RETRO_ACHIEVEMENTS

void NetPlayInit();
bool NetPlayJoin();
bool NetPlayHost(const UICommon::GameFile& game);
Expand Down Expand Up @@ -241,6 +246,10 @@ class MainWindow final : public QMainWindow
static constexpr int num_wii_controllers = 4;
std::array<WiiTASInputWindow*, num_wii_controllers> m_wii_tas_input_windows{};

#ifdef USE_RETRO_ACHIEVEMENTS
AchievementsWindow* m_achievements_window = nullptr;
#endif // USE_RETRO_ACHIEVEMENTS

BreakpointWidget* m_breakpoint_widget;
CodeWidget* m_code_widget;
JITWidget* m_jit_widget;
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/DolphinQt/MenuBar.cpp
Expand Up @@ -21,6 +21,7 @@

#include "Core/Boot/Boot.h"
#include "Core/CommonTitles.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
Expand Down Expand Up @@ -236,6 +237,15 @@ void MenuBar::AddToolsMenu()

tools_menu->addSeparator();

#ifdef USE_RETRO_ACHIEVEMENTS
if (Config::Get(Config::RA_ENABLED))
{
tools_menu->addAction(tr("Achievements"), this, [this] { emit ShowAchievementsWindow(); });

tools_menu->addSeparator();
}
#endif // USE_RETRO_ACHIEVEMENTS

QMenu* gc_ipl = tools_menu->addMenu(tr("Load GameCube Main Menu"));

m_ntscj_ipl = gc_ipl->addAction(tr("NTSC-J"), this,
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DolphinQt/MenuBar.h
Expand Up @@ -93,6 +93,10 @@ class MenuBar final : public QMenuBar
void ShowInfinityBase();
void ConnectWiiRemote(int id);

#ifdef USE_RETRO_ACHIEVEMENTS
void ShowAchievementsWindow();
#endif // USE_RETRO_ACHIEVEMENTS

// Options
void Configure();
void ConfigureGraphics();
Expand Down