Browse Source

move fwcheck strings to QtCommon

Signed-off-by: crueter <crueter@eden-emu.dev>
pull/3004/head
crueter 3 months ago
parent
commit
693ef9c9c6
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 2
      src/core/crypto/key_manager.cpp
  2. 19
      src/frontend_common/firmware_manager.h
  3. 26
      src/qt_common/qt_string_lookup.h
  4. 7
      src/yuzu/main_window.cpp

2
src/core/crypto/key_manager.cpp

@ -41,7 +41,7 @@
namespace Core::Crypto { namespace Core::Crypto {
namespace { namespace {
constexpr u64 CURRENT_CRYPTO_REVISION = 0x15;
constexpr u64 CURRENT_CRYPTO_REVISION = 0x5;
using Common::AsArray; using Common::AsArray;

19
src/frontend_common/firmware_manager.h

@ -53,21 +53,12 @@ inline constexpr bool GameRequiresFirmware(u64 program_id)
!= FIRMWARE_REQUIRED_GAMES.end(); != FIRMWARE_REQUIRED_GAMES.end();
} }
enum FirmwareCheckResult { enum FirmwareCheckResult {
FirmwareGood, FirmwareGood,
ErrorFirmwareMissing, ErrorFirmwareMissing,
ErrorFirmwareCorrupted, ErrorFirmwareCorrupted,
}; };
static constexpr std::array<const char *, 4> FIRMWARE_CHECK_STRINGS = {
"",
"Firmware missing. Firmware is required to run certain games and use the Home Menu. "
"Eden only works with firmware 19.0.1 and earlier.",
"Firmware reported as present, but was unable to be read. Check for decryption keys and "
"redump firmware if necessary."
};
/** /**
* \brief Checks for installed firmware within the system. * \brief Checks for installed firmware within the system.
* \param system The system to check for firmware. * \param system The system to check for firmware.
@ -98,16 +89,6 @@ inline bool CheckFirmwarePresence(Core::System &system)
*/ */
FirmwareCheckResult VerifyFirmware(Core::System &system); FirmwareCheckResult VerifyFirmware(Core::System &system);
/**
* \brief Get a string representation of a result from CheckFirmwareVersion.
* \param result The result code.
* \return A string representation of the passed result code.
*/
inline constexpr const char *GetFirmwareCheckString(FirmwareCheckResult result)
{
return FIRMWARE_CHECK_STRINGS.at(static_cast<std::size_t>(result));
}
/** /**
* @brief Get the currently installed firmware version. * @brief Get the currently installed firmware version.
* @param system The system to check firmware on. * @param system The system to check firmware on.

26
src/qt_common/qt_string_lookup.h

@ -11,8 +11,8 @@
/// Small helper to look up enums. /// Small helper to look up enums.
/// res = the result code /// res = the result code
/// base = the base matching value in the StringKey table /// base = the base matching value in the StringKey table
#define LOOKUP_ENUM(res, base) StringLookup::Lookup( \
static_cast<StringLookup::StringKey>((int) res + (int) StringLookup::base))
#define LOOKUP_ENUM(res, base) QtCommon::StringLookup::Lookup( \
QtCommon::StringLookup::StringKey((int) res + (int) QtCommon::StringLookup::base))
namespace QtCommon::StringLookup { namespace QtCommon::StringLookup {
@ -40,6 +40,10 @@ enum StringKey {
FwInstallFailedCopy, FwInstallFailedCopy,
FwInstallFailedCorrupted, FwInstallFailedCorrupted,
// Firmware Check results
FwCheckErrorFirmwareMissing,
FwCheckErrorFirmwareCorrupted,
// user data migrator // user data migrator
MigrationPromptPrefix, MigrationPromptPrefix,
MigrationPrompt, MigrationPrompt,
@ -55,10 +59,11 @@ enum StringKey {
KvdbMisaligned, KvdbMisaligned,
KvdbNoImens, KvdbNoImens,
RyujinxNoSaveId, RyujinxNoSaveId,
}; };
static const constexpr frozen::map<StringKey, frozen::string, 27> strings = {
// NB: the constexpr check always succeeds (in clangd at least) if size arg < size
// always triple-check the size arg
static const constexpr frozen::map<StringKey, frozen::string, 29> strings = {
// 0-4 // 0-4
{SavesTooltip, {SavesTooltip,
QT_TR_NOOP("Contains game save data. DO NOT REMOVE UNLESS YOU KNOW WHAT YOU'RE DOING!")}, QT_TR_NOOP("Contains game save data. DO NOT REMOVE UNLESS YOU KNOW WHAT YOU'RE DOING!")},
@ -91,8 +96,17 @@ static const constexpr frozen::map<StringKey, frozen::string, 27> strings = {
"Firmware installation cancelled, firmware may be in a bad state or corrupted. Restart " "Firmware installation cancelled, firmware may be in a bad state or corrupted. Restart "
"Eden or re-install firmware.")}, "Eden or re-install firmware.")},
{FwCheckErrorFirmwareMissing,
QT_TR_NOOP(
"Firmware missing. Firmware is required to run certain games and use the Home Menu. "
"Versions 19.0.1 or earlier are recommended, as 20.0.0+ is currently experimental.")},
{FwCheckErrorFirmwareCorrupted,
QT_TR_NOOP(
"Firmware reported as present, but was unable to be read. Check for decryption keys and "
"redump firmware if necessary.")},
// migrator // migrator
// 15-20
// 17-22
{MigrationPromptPrefix, QT_TR_NOOP("Eden has detected user data for the following emulators:")}, {MigrationPromptPrefix, QT_TR_NOOP("Eden has detected user data for the following emulators:")},
{MigrationPrompt, {MigrationPrompt,
QT_TR_NOOP("Would you like to migrate your data for use in Eden?\n" QT_TR_NOOP("Would you like to migrate your data for use in Eden?\n"
@ -113,7 +127,7 @@ static const constexpr frozen::map<StringKey, frozen::string, 27> strings = {
"This is recommended if you want to share data between emulators.")}, "This is recommended if you want to share data between emulators.")},
// why am I writing these comments again // why am I writing these comments again
// 21-26
// 23-28
{KvdbNonexistent, QT_TR_NOOP("Ryujinx title database does not exist.")}, {KvdbNonexistent, QT_TR_NOOP("Ryujinx title database does not exist.")},
{KvdbNoHeader, QT_TR_NOOP("Invalid header on Ryujinx title database.")}, {KvdbNoHeader, QT_TR_NOOP("Invalid header on Ryujinx title database.")},
{KvdbInvalidMagic, QT_TR_NOOP("Invalid magic header on Ryujinx title database.")}, {KvdbInvalidMagic, QT_TR_NOOP("Invalid magic header on Ryujinx title database.")},

7
src/yuzu/main_window.cpp

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Qt on macOS doesn't define VMA shit // Qt on macOS doesn't define VMA shit
#include "qt_common/qt_string_lookup.h"
#if defined(QT_STATICPLUGIN) && !defined(__APPLE__) #if defined(QT_STATICPLUGIN) && !defined(__APPLE__)
#undef VMA_IMPLEMENTATION #undef VMA_IMPLEMENTATION
#endif #endif
@ -4058,14 +4059,16 @@ void MainWindow::OnOpenControllerMenu() {
void MainWindow::OnHomeMenu() { void MainWindow::OnHomeMenu() {
auto result = FirmwareManager::VerifyFirmware(*QtCommon::system.get()); auto result = FirmwareManager::VerifyFirmware(*QtCommon::system.get());
using namespace QtCommon::StringLookup;
switch (result) { switch (result) {
case FirmwareManager::ErrorFirmwareMissing: case FirmwareManager::ErrorFirmwareMissing:
QMessageBox::warning(this, tr("No firmware available"), QMessageBox::warning(this, tr("No firmware available"),
tr("Please install firmware to use the Home Menu."));
Lookup(FwCheckErrorFirmwareMissing));
return; return;
case FirmwareManager::ErrorFirmwareCorrupted: case FirmwareManager::ErrorFirmwareCorrupted:
QMessageBox::warning(this, tr("Firmware Corrupted"), QMessageBox::warning(this, tr("Firmware Corrupted"),
tr(FirmwareManager::GetFirmwareCheckString(result)));
Lookup(FwCheckErrorFirmwareCorrupted));
return; return;
default: default:
break; break;

Loading…
Cancel
Save