Added AchievementsWindow QDialog

AchievementsWindow is the dialog box that will eventually contain the settings and progress data for RetroAchievements on Dolphin. This adds the barebones dialog, and connects it to MainWindow's MenuBar.
This commit is contained in:
LillyJadeKatrin 2023-05-26 09:35:50 -04:00
parent da77084d2f
commit e1e662b86a
8 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,48 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef USE_RETRO_ACHIEVEMENTS
#include "DolphinQt/Achievements/AchievementsWindow.h"
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
{
setWindowTitle(tr("Achievements"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
CreateMainLayout();
ConnectWidgets();
}
void AchievementsWindow::showEvent(QShowEvent* event)
{
QDialog::showEvent(event);
update();
}
void AchievementsWindow::CreateMainLayout()
{
auto* layout = new QVBoxLayout();
m_button_box = new QDialogButtonBox(QDialogButtonBox::Close);
layout->addWidget(m_button_box);
WrapInScrollArea(this, layout);
}
void AchievementsWindow::ConnectWidgets()
{
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
}
void AchievementsWindow::UpdateData()
{
update();
}
#endif // USE_RETRO_ACHIEVEMENTS

View File

@ -0,0 +1,26 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#ifdef USE_RETRO_ACHIEVEMENTS
#include <QDialog>
class QDialogButtonBox;
class AchievementsWindow : public QDialog
{
Q_OBJECT
public:
explicit AchievementsWindow(QWidget* parent);
void UpdateData();
private:
void CreateMainLayout();
void showEvent(QShowEvent* event);
void ConnectWidgets();
QDialogButtonBox* m_button_box;
};
#endif // USE_RETRO_ACHIEVEMENTS

View File

@ -27,6 +27,8 @@ add_executable(dolphin-emu
CheatSearchWidget.h CheatSearchWidget.h
CheatsManager.cpp CheatsManager.cpp
CheatsManager.h CheatsManager.h
Achievements/AchievementsWindow.cpp
Achievements/AchievementsWindow.h
Config/ARCodeWidget.cpp Config/ARCodeWidget.cpp
Config/ARCodeWidget.h Config/ARCodeWidget.h
Config/CheatCodeEditor.cpp Config/CheatCodeEditor.cpp

View File

@ -50,6 +50,7 @@
<ClCompile Include="CheatSearchFactoryWidget.cpp" /> <ClCompile Include="CheatSearchFactoryWidget.cpp" />
<ClCompile Include="CheatSearchWidget.cpp" /> <ClCompile Include="CheatSearchWidget.cpp" />
<ClCompile Include="CheatsManager.cpp" /> <ClCompile Include="CheatsManager.cpp" />
<ClCompile Include="Achievements\AchievementsWindow.cpp" />
<ClCompile Include="Config\ARCodeWidget.cpp" /> <ClCompile Include="Config\ARCodeWidget.cpp" />
<ClCompile Include="Config\CheatCodeEditor.cpp" /> <ClCompile Include="Config\CheatCodeEditor.cpp" />
<ClCompile Include="Config\CheatWarningWidget.cpp" /> <ClCompile Include="Config\CheatWarningWidget.cpp" />
@ -252,6 +253,7 @@
<QtMoc Include="CheatSearchFactoryWidget.h" /> <QtMoc Include="CheatSearchFactoryWidget.h" />
<QtMoc Include="CheatSearchWidget.h" /> <QtMoc Include="CheatSearchWidget.h" />
<QtMoc Include="CheatsManager.h" /> <QtMoc Include="CheatsManager.h" />
<QtMoc Include="Achievements\AchievementsWindow.h" />
<QtMoc Include="Config\ARCodeWidget.h" /> <QtMoc Include="Config\ARCodeWidget.h" />
<QtMoc Include="Config\CheatWarningWidget.h" /> <QtMoc Include="Config\CheatWarningWidget.h" />
<QtMoc Include="Config\CommonControllersWidget.h" /> <QtMoc Include="Config\CommonControllersWidget.h" />

View File

@ -72,6 +72,7 @@
#include "DiscIO/RiivolutionPatcher.h" #include "DiscIO/RiivolutionPatcher.h"
#include "DolphinQt/AboutDialog.h" #include "DolphinQt/AboutDialog.h"
#include "DolphinQt/Achievements/AchievementsWindow.h"
#include "DolphinQt/CheatsManager.h" #include "DolphinQt/CheatsManager.h"
#include "DolphinQt/Config/ControllersWindow.h" #include "DolphinQt/Config/ControllersWindow.h"
#include "DolphinQt/Config/FreeLookWindow.h" #include "DolphinQt/Config/FreeLookWindow.h"
@ -544,6 +545,10 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::ShowInfinityBase, this, &MainWindow::ShowInfinityBase); connect(m_menu_bar, &MenuBar::ShowInfinityBase, this, &MainWindow::ShowInfinityBase);
connect(m_menu_bar, &MenuBar::ConnectWiiRemote, this, &MainWindow::OnConnectWiiRemote); 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 // Movie
connect(m_menu_bar, &MenuBar::PlayRecording, this, &MainWindow::OnPlayRecording); connect(m_menu_bar, &MenuBar::PlayRecording, this, &MainWindow::OnPlayRecording);
connect(m_menu_bar, &MenuBar::StartRecording, this, &MainWindow::OnStartRecording); connect(m_menu_bar, &MenuBar::StartRecording, this, &MainWindow::OnStartRecording);
@ -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() void MainWindow::ShowMemcardManager()
{ {
GCMemcardManager manager(this); GCMemcardManager manager(this);

View File

@ -16,6 +16,7 @@
class QStackedWidget; class QStackedWidget;
class QString; class QString;
class AchievementsWindow;
class BreakpointWidget; class BreakpointWidget;
struct BootParameters; struct BootParameters;
class CheatsManager; class CheatsManager;
@ -168,6 +169,10 @@ private:
void ShowCheatsManager(); void ShowCheatsManager();
void ShowRiivolutionBootWidget(const UICommon::GameFile& game); void ShowRiivolutionBootWidget(const UICommon::GameFile& game);
#ifdef USE_RETRO_ACHIEVEMENTS
void ShowAchievementsWindow();
#endif // USE_RETRO_ACHIEVEMENTS
void NetPlayInit(); void NetPlayInit();
bool NetPlayJoin(); bool NetPlayJoin();
bool NetPlayHost(const UICommon::GameFile& game); bool NetPlayHost(const UICommon::GameFile& game);
@ -241,6 +246,10 @@ private:
static constexpr int num_wii_controllers = 4; static constexpr int num_wii_controllers = 4;
std::array<WiiTASInputWindow*, num_wii_controllers> m_wii_tas_input_windows{}; 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; BreakpointWidget* m_breakpoint_widget;
CodeWidget* m_code_widget; CodeWidget* m_code_widget;
JITWidget* m_jit_widget; JITWidget* m_jit_widget;

View File

@ -21,6 +21,7 @@
#include "Core/Boot/Boot.h" #include "Core/Boot/Boot.h"
#include "Core/CommonTitles.h" #include "Core/CommonTitles.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/MainSettings.h" #include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
@ -236,6 +237,15 @@ void MenuBar::AddToolsMenu()
tools_menu->addSeparator(); 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")); QMenu* gc_ipl = tools_menu->addMenu(tr("Load GameCube Main Menu"));
m_ntscj_ipl = gc_ipl->addAction(tr("NTSC-J"), this, m_ntscj_ipl = gc_ipl->addAction(tr("NTSC-J"), this,

View File

@ -93,6 +93,10 @@ signals:
void ShowInfinityBase(); void ShowInfinityBase();
void ConnectWiiRemote(int id); void ConnectWiiRemote(int id);
#ifdef USE_RETRO_ACHIEVEMENTS
void ShowAchievementsWindow();
#endif // USE_RETRO_ACHIEVEMENTS
// Options // Options
void Configure(); void Configure();
void ConfigureGraphics(); void ConfigureGraphics();