Skip to content

Commit

Permalink
Add Hardcore switch to Achievement Settings dialog
Browse files Browse the repository at this point in the history
This adds the actual switch to turn on Hardcore Mode to the settings tab of the Achievements dialog. It is accompanied by a large tooltip warning explaining what it does and when it can be enabled.
The switch is only enabled to be turned on when no game is running, so that games are started in hardcore mode and can only be loaded via the console's memory card, as in the original hardware. Hardcore may be turned off while a game is running, but cannot be turned back on until the game is disabled.
The toggle trigger for hardcore mode also automatically disables the settings that are not allowed during hardcore mode.
Finally, the original flag in AchievementSettingsWidget to set whether things are enabled in hardcore mode (primarily Leaderboards) is replaced with the actual Hardcore Mode setting.
  • Loading branch information
LillyJadeKatrin committed Jun 8, 2023
1 parent 5d0d27b commit bc99ef6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
44 changes: 41 additions & 3 deletions Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp
Expand Up @@ -13,6 +13,7 @@

#include "Core/AchievementManager.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/FreeLookSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"

Expand All @@ -24,8 +25,6 @@
#include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h"

static constexpr bool hardcore_mode_enabled = false;

AchievementSettingsWidget::AchievementSettingsWidget(QWidget* parent,
AchievementsWindow* parent_window)
: QWidget(parent), parent_window(parent_window)
Expand Down Expand Up @@ -75,6 +74,19 @@ void AchievementSettingsWidget::CreateLayout()
"achievements.<br><br>Unofficial achievements may be optional or unfinished achievements "
"that have not been deemed official by RetroAchievements and may be useful for testing or "
"simply for fun."));
m_common_hardcore_enabled_input = new ToolTipCheckBox(tr("Enable Hardcore Mode"));
m_common_hardcore_enabled_input->SetDescription(
tr("Enable Hardcore Mode on RetroAchievements.<br><br>Hardcore Mode is intended to provide "
"an experience as close to gaming on the original hardware as possible. RetroAchievements "
"rankings are primarily oriented towards Hardcore points (Softcore points are tracked but "
"not as heavily emphasized) and leaderboards require Hardcore Mode to be on.<br><br>To "
"ensure this experience, the following features will be disabled, as they give emulator "
"players an advantage over console players:<br>- Loading states<br> Saving states is "
"allowed<br>- Emulator speeds below 100%<br> Includes frame step<br> Turbo is "
"allowed<br>- Cheats<br>- Debug UI<br>- Freelook<br><br><dolphin_emphasis>This cannot be "
"turned on while a game is playing.</dolphin_emphasis><br>Close your current game before "
"enabling.<br>Be aware that turning Hardcore Mode off while a game is running requires "
"the game to be closed before re-enabling."));
m_common_encore_enabled_input = new ToolTipCheckBox(tr("Enable Encore Achievements"));
m_common_encore_enabled_input->SetDescription(tr(
"Enable unlocking achievements in Encore Mode.<br><br>Encore Mode re-enables achievements "
Expand All @@ -92,6 +104,7 @@ void AchievementSettingsWidget::CreateLayout()
m_common_layout->addWidget(m_common_achievements_enabled_input);
m_common_layout->addWidget(m_common_leaderboards_enabled_input);
m_common_layout->addWidget(m_common_rich_presence_enabled_input);
m_common_layout->addWidget(m_common_hardcore_enabled_input);
m_common_layout->addWidget(m_common_unofficial_enabled_input);
m_common_layout->addWidget(m_common_encore_enabled_input);

Expand All @@ -111,6 +124,8 @@ void AchievementSettingsWidget::ConnectWidgets()
&AchievementSettingsWidget::ToggleLeaderboards);
connect(m_common_rich_presence_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleRichPresence);
connect(m_common_hardcore_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleHardcore);
connect(m_common_unofficial_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleUnofficial);
connect(m_common_encore_enabled_input, &QCheckBox::toggled, this,
Expand All @@ -129,6 +144,7 @@ void AchievementSettingsWidget::LoadSettings()
{
bool enabled = Config::Get(Config::RA_ENABLED);
bool achievements_enabled = Config::Get(Config::RA_ACHIEVEMENTS_ENABLED);
bool hardcore_enabled = Config::Get(Config::RA_HARDCORE_ENABLED);
bool logged_out = Config::Get(Config::RA_API_TOKEN).empty();
std::string username = Config::Get(Config::RA_USERNAME);

Expand All @@ -151,12 +167,17 @@ void AchievementSettingsWidget::LoadSettings()

SignalBlocking(m_common_leaderboards_enabled_input)
->setChecked(Config::Get(Config::RA_LEADERBOARDS_ENABLED));
SignalBlocking(m_common_leaderboards_enabled_input)->setEnabled(enabled && hardcore_mode_enabled);
SignalBlocking(m_common_leaderboards_enabled_input)->setEnabled(enabled && hardcore_enabled);

SignalBlocking(m_common_rich_presence_enabled_input)
->setChecked(Config::Get(Config::RA_RICH_PRESENCE_ENABLED));
SignalBlocking(m_common_rich_presence_enabled_input)->setEnabled(enabled);

SignalBlocking(m_common_hardcore_enabled_input)
->setChecked(Config::Get(Config::RA_HARDCORE_ENABLED));
SignalBlocking(m_common_hardcore_enabled_input)
->setEnabled(enabled && (hardcore_enabled || Core::GetState() == Core::State::Uninitialized));

SignalBlocking(m_common_unofficial_enabled_input)
->setChecked(Config::Get(Config::RA_UNOFFICIAL_ENABLED));
SignalBlocking(m_common_unofficial_enabled_input)->setEnabled(enabled && achievements_enabled);
Expand All @@ -176,6 +197,8 @@ void AchievementSettingsWidget::SaveSettings()
m_common_leaderboards_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_RICH_PRESENCE_ENABLED,
m_common_rich_presence_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_HARDCORE_ENABLED,
m_common_hardcore_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_UNOFFICIAL_ENABLED,
m_common_unofficial_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_ENCORE_ENABLED, m_common_encore_enabled_input->isChecked());
Expand Down Expand Up @@ -224,6 +247,21 @@ void AchievementSettingsWidget::ToggleRichPresence()
AchievementManager::GetInstance()->ActivateDeactivateRichPresence();
}

void AchievementSettingsWidget::ToggleHardcore()
{
SaveSettings();
if (Config::Get(Config::RA_HARDCORE_ENABLED))
{
if (Config::Get(Config::MAIN_EMULATION_SPEED) < 1.0f)
Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, 1.0f);
Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, false);
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, false);
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_DEBUGGING, false);
Settings::Instance().SetCheatsEnabled(false);
Settings::Instance().SetDebugModeEnabled(false);
}
}

void AchievementSettingsWidget::ToggleUnofficial()
{
SaveSettings();
Expand Down
Expand Up @@ -36,7 +36,6 @@ class AchievementSettingsWidget final : public QWidget
void ToggleLeaderboards();
void ToggleRichPresence();
void ToggleHardcore();
void ToggleBadgeIcons();
void ToggleUnofficial();
void ToggleEncore();

Expand All @@ -55,6 +54,7 @@ class AchievementSettingsWidget final : public QWidget
ToolTipCheckBox* m_common_achievements_enabled_input;
ToolTipCheckBox* m_common_leaderboards_enabled_input;
ToolTipCheckBox* m_common_rich_presence_enabled_input;
ToolTipCheckBox* m_common_hardcore_enabled_input;
ToolTipCheckBox* m_common_unofficial_enabled_input;
ToolTipCheckBox* m_common_encore_enabled_input;
};
Expand Down

0 comments on commit bc99ef6

Please sign in to comment.