mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Added Hardcore Warning Widget
This widget will be used in several places to notify the player that a feature has been disabled because hardcore mode is on. It includes a button to open the Achievement Settings so that Hardcore Mode may be turned off. Also included is the framework required to open AchievementsWindow specifically on the Settings tab.
This commit is contained in:
parent
138e68ef9f
commit
71f3039f96
@ -81,4 +81,9 @@ void AchievementsWindow::UpdateData()
|
||||
update();
|
||||
}
|
||||
|
||||
void AchievementsWindow::ForceSettingsTab()
|
||||
{
|
||||
m_tab_widget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
@ -22,6 +22,7 @@ class AchievementsWindow : public QDialog
|
||||
public:
|
||||
explicit AchievementsWindow(QWidget* parent);
|
||||
void UpdateData();
|
||||
void ForceSettingsTab();
|
||||
|
||||
private:
|
||||
void CreateMainLayout();
|
||||
|
@ -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
|
||||
|
62
Source/Core/DolphinQt/Config/HardcoreWarningWidget.cpp
Normal file
62
Source/Core/DolphinQt/Config/HardcoreWarningWidget.cpp
Normal file
@ -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 <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
|
||||
#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
|
30
Source/Core/DolphinQt/Config/HardcoreWarningWidget.h
Normal file
30
Source/Core/DolphinQt/Config/HardcoreWarningWidget.h
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2023 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
#include <QWidget>
|
||||
|
||||
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
|
@ -31,10 +31,8 @@
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)Settings;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)TAS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)VideoInterface;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
||||
<!--Qt 6.3.0 headers use std::aligned_storage instead of alignas-->
|
||||
<PreprocessorDefinitions>_SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
||||
<!--Jump through some hoops to generate a pch file local to this project-->
|
||||
<AdditionalIncludeDirectories>$(SourceDir)PCH;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
@ -87,6 +85,7 @@
|
||||
<ClCompile Include="Config\Graphics\PostProcessingConfigWindow.cpp" />
|
||||
<ClCompile Include="Config\GraphicsModListWidget.cpp" />
|
||||
<ClCompile Include="Config\GraphicsModWarningWidget.cpp" />
|
||||
<ClCompile Include="Config\HardcoreWarningWidget.cpp" />
|
||||
<ClCompile Include="Config\InfoWidget.cpp" />
|
||||
<ClCompile Include="Config\LogConfigWidget.cpp" />
|
||||
<ClCompile Include="Config\LogWidget.cpp" />
|
||||
@ -239,7 +238,7 @@
|
||||
<ClInclude Include="Config\Mapping\MappingIndicator.h" />
|
||||
<ClInclude Include="Config\Mapping\MappingNumeric.h" />
|
||||
<ClInclude Include="Config\NewPatchDialog.h" />
|
||||
<ClInclude Include="Config\PatchesWidget.h" />
|
||||
<QtMoc Include="Config\PatchesWidget.h" />
|
||||
<ClInclude Include="Debugger\RegisterColumn.h" />
|
||||
<ClInclude Include="GBAHost.h" />
|
||||
<ClInclude Include="QtUtils\ActionHelper.h" />
|
||||
@ -298,6 +297,7 @@
|
||||
<QtMoc Include="Config\Graphics\PostProcessingConfigWindow.h" />
|
||||
<QtMoc Include="Config\GraphicsModListWidget.h" />
|
||||
<QtMoc Include="Config\GraphicsModWarningWidget.h" />
|
||||
<QtMoc Include="Config\HardcoreWarningWidget.h" />
|
||||
<QtMoc Include="Config\InfoWidget.h" />
|
||||
<QtMoc Include="Config\LogConfigWidget.h" />
|
||||
<QtMoc Include="Config\LogWidget.h" />
|
||||
|
@ -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()
|
||||
|
@ -175,6 +175,7 @@ private:
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
void ShowAchievementsWindow();
|
||||
void ShowAchievementSettings();
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
void NetPlayInit();
|
||||
|
Loading…
Reference in New Issue
Block a user