aboutsummaryrefslogtreecommitdiff
path: root/src/qt_common/qt_string_lookup.h
blob: daefe20a1a40f0eb7dd09f786aed7ac163858fc0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>
#include <QString>
#include "frozen/map.h"
#include "frozen/string.h"

/// Small helper to look up enums.
/// res = the result code
/// base = the base matching value in the StringKey table
#define LOOKUP_ENUM(res, base)                                                                     \
    QtCommon::StringLookup::Lookup(                                                                \
        QtCommon::StringLookup::StringKey((int)res + (int)QtCommon::StringLookup::base))

namespace QtCommon::StringLookup {

Q_NAMESPACE

// TODO(crueter): QML interface
enum StringKey {
    DataManagerSavesTooltip,
    DataManagerShadersTooltip,
    DataManagerUserNandTooltip,
    DataManagerSysNandTooltip,
    DataManagerModsTooltip,

    // Key install results
    KeyInstallSuccess,
    KeyInstallInvalidDir,
    KeyInstallErrorFailedCopy,
    KeyInstallErrorWrongFilename,
    KeyInstallErrorFailedInit,

    // Firmware install results
    FwInstallSuccess,
    FwInstallNoNCAs,
    FwInstallFailedDelete,
    FwInstallFailedCopy,
    FwInstallFailedCorrupted,

    // Firmware Check results
    FwCheckErrorFirmwareMissing,
    FwCheckErrorFirmwareCorrupted,

    // user data migrator
    MigrationPromptPrefix,
    MigrationPrompt,
    MigrationTooltipClearShader,
    MigrationTooltipKeepOld,
    MigrationTooltipClearOld,
    MigrationTooltipLinkOld,

    // ryujinx
    KvdbNonexistent,
    KvdbNoHeader,
    KvdbInvalidMagic,
    KvdbMisaligned,
    KvdbNoImens,
    RyujinxNoSaveId,
};

// 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
    {DataManagerSavesTooltip,
     QT_TR_NOOP("Contains game save data. DO NOT REMOVE UNLESS YOU KNOW WHAT YOU'RE DOING!")},
    {DataManagerShadersTooltip,
     QT_TR_NOOP("Contains Vulkan and OpenGL pipeline caches. Generally safe to remove.")},
    {DataManagerUserNandTooltip, QT_TR_NOOP("Contains updates and DLC for games.")},
    {DataManagerSysNandTooltip, QT_TR_NOOP("Contains firmware and applet data.")},
    {DataManagerModsTooltip, QT_TR_NOOP("Contains game mods, patches, and cheats.")},

    // Key install
    // 5-9
    {KeyInstallSuccess, QT_TR_NOOP("Decryption Keys were successfully installed")},
    {KeyInstallInvalidDir, QT_TR_NOOP("Unable to read key directory, aborting")},
    {KeyInstallErrorFailedCopy, QT_TR_NOOP("One or more keys failed to copy.")},
    {KeyInstallErrorWrongFilename,
     QT_TR_NOOP("Verify your keys file has a .keys extension and try again.")},
    {KeyInstallErrorFailedInit,
     QT_TR_NOOP(
         "Decryption Keys failed to initialize. Check that your dumping tools are up to date and "
         "re-dump keys.")},

    // fw install
    // 10-14
    {FwInstallSuccess, QT_TR_NOOP("Successfully installed firmware version %1")},
    {FwInstallNoNCAs, QT_TR_NOOP("Unable to locate potential firmware NCA files")},
    {FwInstallFailedDelete, QT_TR_NOOP("Failed to delete one or more firmware files.")},
    {FwInstallFailedCopy, QT_TR_NOOP("One or more firmware files failed to copy into NAND.")},
    {FwInstallFailedCorrupted,
     QT_TR_NOOP(
         "Firmware installation cancelled, firmware may be in a bad state or corrupted. Restart "
         "Eden or re-install firmware.")},

    {FwCheckErrorFirmwareMissing,
     QT_TR_NOOP(
         "Firmware missing. Firmware is required to run certain games and use the Home Menu.")},
    {FwCheckErrorFirmwareCorrupted,
     QT_TR_NOOP(
         "Firmware reported as present, but was unable to be read. Check for decryption keys and "
         "redump firmware if necessary.")},

    // migrator
    // 17-22
    {MigrationPromptPrefix, QT_TR_NOOP("Eden has detected user data for the following emulators:")},
    {MigrationPrompt,
     QT_TR_NOOP("Would you like to migrate your data for use in Eden?\n"
                "Select the corresponding button to migrate data from that emulator.\n"
                "This may take a while.")},
    {MigrationTooltipClearShader, QT_TR_NOOP("Clearing shader cache is recommended for all "
                                             "users.\nDo not uncheck unless you know what "
                                             "you're doing.")},
    {MigrationTooltipKeepOld,
     QT_TR_NOOP("Keeps the old data directory. This is recommended if you aren't\n"
                "space-constrained and want to keep separate data for the old emulator.")},
    {MigrationTooltipClearOld, QT_TR_NOOP("Deletes the old data directory.\nThis is recommended on "
                                          "devices with space constraints.")},
    {MigrationTooltipLinkOld,
     QT_TR_NOOP("Creates a filesystem link between the old directory and Eden directory.\n"
                "This is recommended if you want to share data between emulators.")},

    // why am I writing these comments again
    // 23-28
    {KvdbNonexistent, QT_TR_NOOP("Ryujinx title database does not exist.")},
    {KvdbNoHeader, QT_TR_NOOP("Invalid header on Ryujinx title database.")},
    {KvdbInvalidMagic, QT_TR_NOOP("Invalid magic header on Ryujinx title database.")},
    {KvdbMisaligned, QT_TR_NOOP("Invalid byte alignment on Ryujinx title database.")},
    {KvdbNoImens, QT_TR_NOOP("No items found in Ryujinx title database.")},
    {RyujinxNoSaveId, QT_TR_NOOP("Title %1 not found in Ryujinx title database.")},
};

static inline const QString Lookup(StringKey key) {
    return QObject::tr(strings.at(key).data());
}

} // namespace QtCommon::StringLookup