Common/MsgHandler: Namespace code within the Common namespace

Closes another gap in the Common library where code isn't being
namespaced under it.
This commit is contained in:
Lioncash 2019-06-16 23:45:37 -04:00
parent e7dd46a531
commit 4f1f55093f
15 changed files with 214 additions and 143 deletions

View File

@ -151,7 +151,7 @@ void Host_TitleChanged()
{
}
static bool MsgAlert(const char* caption, const char* text, bool yes_no, MsgType /*style*/)
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType /*style*/)
{
JNIEnv* env = IDCache::GetEnvForThread();
@ -630,7 +630,7 @@ static void Run(JNIEnv* env, const std::vector<std::string>& paths, bool first_o
ASSERT(!paths.empty());
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", paths[0].c_str());
RegisterMsgAlertHandler(&MsgAlert);
Common::RegisterMsgAlertHandler(&MsgAlert);
Common::AndroidSetReportHandler(&ReportSend);
DolphinAnalytics::AndroidSetGetValFunc(&GetAnalyticValue);

View File

@ -19,6 +19,8 @@
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
namespace Common
{
namespace
{
// Default non library dependent panic alert
@ -129,3 +131,4 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
return true;
}
} // namespace Common

View File

@ -6,6 +6,8 @@
#include <string>
namespace Common
{
// Message alerts
enum class MsgType
{
@ -28,30 +30,69 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
#endif
;
void SetEnableAlert(bool enable);
} // namespace Common
#ifdef _WIN32
#define SuccessAlert(format, ...) MsgAlert(false, MsgType::Information, format, __VA_ARGS__)
#define PanicAlert(format, ...) MsgAlert(false, MsgType::Warning, format, __VA_ARGS__)
#define PanicYesNo(format, ...) MsgAlert(true, MsgType::Warning, format, __VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert(true, MsgType::Question, format, __VA_ARGS__)
#define CriticalAlert(format, ...) MsgAlert(false, MsgType::Critical, format, __VA_ARGS__)
#define SuccessAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__)
#define PanicAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__)
#define PanicYesNo(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__)
#define AskYesNo(format, ...) Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__)
#define CriticalAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__)
// Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertT(format, ...) MsgAlert(false, MsgType::Information, format, __VA_ARGS__)
#define PanicAlertT(format, ...) MsgAlert(false, MsgType::Warning, format, __VA_ARGS__)
#define PanicYesNoT(format, ...) MsgAlert(true, MsgType::Warning, format, __VA_ARGS__)
#define AskYesNoT(format, ...) MsgAlert(true, MsgType::Question, format, __VA_ARGS__)
#define CriticalAlertT(format, ...) MsgAlert(false, MsgType::Critical, format, __VA_ARGS__)
#define SuccessAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__)
#define PanicAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__)
#define PanicYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__)
#define AskYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__)
#define CriticalAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__)
#else
#define SuccessAlert(format, ...) MsgAlert(false, MsgType::Information, format, ##__VA_ARGS__)
#define PanicAlert(format, ...) MsgAlert(false, MsgType::Warning, format, ##__VA_ARGS__)
#define PanicYesNo(format, ...) MsgAlert(true, MsgType::Warning, format, ##__VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert(true, MsgType::Question, format, ##__VA_ARGS__)
#define CriticalAlert(format, ...) MsgAlert(false, MsgType::Critical, format, ##__VA_ARGS__)
#define SuccessAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__)
#define PanicAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, ##__VA_ARGS__)
#define PanicYesNo(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, ##__VA_ARGS__)
#define AskYesNo(format, ...) \
Common::MsgAlert(true, Common::MsgType::Question, format, ##__VA_ARGS__)
#define CriticalAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__)
// Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertT(format, ...) MsgAlert(false, MsgType::Information, format, ##__VA_ARGS__)
#define PanicAlertT(format, ...) MsgAlert(false, MsgType::Warning, format, ##__VA_ARGS__)
#define PanicYesNoT(format, ...) MsgAlert(true, MsgType::Warning, format, ##__VA_ARGS__)
#define AskYesNoT(format, ...) MsgAlert(true, MsgType::Question, format, ##__VA_ARGS__)
#define CriticalAlertT(format, ...) MsgAlert(false, MsgType::Critical, format, ##__VA_ARGS__)
#define SuccessAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__)
#define PanicAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, ##__VA_ARGS__)
#define PanicYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, ##__VA_ARGS__)
#define AskYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Question, format, ##__VA_ARGS__)
#define CriticalAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__)
#endif

View File

@ -805,7 +805,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
if (m_sync_save_data_count == 0)
SyncSaveDataResponse(true);
else
m_dialog->AppendChat(GetStringT("Synchronizing save data..."));
m_dialog->AppendChat(Common::GetStringT("Synchronizing save data..."));
}
break;
@ -1040,7 +1040,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
SyncCodeResponse(true);
}
else
m_dialog->AppendChat(GetStringT("Synchronizing Gecko codes..."));
m_dialog->AppendChat(Common::GetStringT("Synchronizing Gecko codes..."));
}
break;
@ -1109,7 +1109,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
SyncCodeResponse(true);
}
else
m_dialog->AppendChat(GetStringT("Synchronizing AR codes..."));
m_dialog->AppendChat(Common::GetStringT("Synchronizing AR codes..."));
}
break;
@ -1289,9 +1289,14 @@ void NetPlayClient::ThreadFunc()
qos_session = Common::QoSSession(m_server);
if (qos_session.Successful())
m_dialog->AppendChat(GetStringT("Quality of Service (QoS) was successfully enabled."));
{
m_dialog->AppendChat(
Common::GetStringT("Quality of Service (QoS) was successfully enabled."));
}
else
m_dialog->AppendChat(GetStringT("Quality of Service (QoS) couldn't be enabled."));
{
m_dialog->AppendChat(Common::GetStringT("Quality of Service (QoS) couldn't be enabled."));
}
}
while (m_do_loop.IsSet())
@ -1511,8 +1516,8 @@ bool NetPlayClient::StartGame(const std::string& path)
void NetPlayClient::SyncSaveDataResponse(const bool success)
{
m_dialog->AppendChat(success ? GetStringT("Data received!") :
GetStringT("Error processing data."));
m_dialog->AppendChat(success ? Common::GetStringT("Data received!") :
Common::GetStringT("Error processing data."));
if (success)
{
@ -1540,7 +1545,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
// If something failed, immediately report back that code sync failed
if (!success)
{
m_dialog->AppendChat(GetStringT("Error processing codes."));
m_dialog->AppendChat(Common::GetStringT("Error processing codes."));
sf::Packet response_packet;
response_packet << static_cast<MessageId>(NP_MSG_SYNC_CODES);
@ -1553,7 +1558,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
// If both gecko and AR codes have completely finished transferring, report back as successful
if (m_sync_gecko_codes_complete && m_sync_ar_codes_complete)
{
m_dialog->AppendChat(GetStringT("Codes received!"));
m_dialog->AppendChat(Common::GetStringT("Codes received!"));
sf::Packet response_packet;
response_packet << static_cast<MessageId>(NP_MSG_SYNC_CODES);

View File

@ -1049,7 +1049,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
m_save_data_synced_players++;
if (m_save_data_synced_players >= m_players.size() - 1)
{
m_dialog->AppendChat(GetStringT("All players' saves synchronized."));
m_dialog->AppendChat(Common::GetStringT("All players' saves synchronized."));
// Saves are synced, check if codes are as well and attempt to start the game
m_saves_synced = true;
@ -1061,8 +1061,8 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
case SYNC_SAVE_DATA_FAILURE:
{
m_dialog->AppendChat(
StringFromFormat(GetStringT("%s failed to synchronize.").c_str(), player.name.c_str()));
m_dialog->AppendChat(StringFromFormat(Common::GetStringT("%s failed to synchronize.").c_str(),
player.name.c_str()));
m_dialog->OnGameStartAborted();
ChunkedDataAbort();
m_start_pending = false;
@ -1093,7 +1093,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
{
if (++m_codes_synced_players >= m_players.size() - 1)
{
m_dialog->AppendChat(GetStringT("All players' codes synchronized."));
m_dialog->AppendChat(Common::GetStringT("All players' codes synchronized."));
// Codes are synced, check if saves are as well and attempt to start the game
m_codes_synced = true;
@ -1105,8 +1105,8 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
case SYNC_CODES_FAILURE:
{
m_dialog->AppendChat(StringFromFormat(GetStringT("%s failed to synchronize codes.").c_str(),
player.name.c_str()));
m_dialog->AppendChat(StringFromFormat(
Common::GetStringT("%s failed to synchronize codes.").c_str(), player.name.c_str()));
m_dialog->OnGameStartAborted();
m_start_pending = false;
}

View File

@ -437,11 +437,11 @@ std::string GetInfoStringOfSlot(int slot, bool translate)
{
std::string filename = MakeStateFilename(slot);
if (!File::Exists(filename))
return translate ? GetStringT("Empty") : "Empty";
return translate ? Common::GetStringT("Empty") : "Empty";
State::StateHeader header;
if (!ReadHeader(filename, header))
return translate ? GetStringT("Unknown") : "Unknown";
return translate ? Common::GetStringT("Unknown") : "Unknown";
return Common::Timer::GetDateTimeFormatted(header.time);
}

View File

@ -78,7 +78,7 @@ TitleDatabase::TitleDatabase()
// i18n: "Wii Menu" (or System Menu) refers to the Wii's main menu,
// which is (usually) the first thing users see when a Wii console starts.
m_base_map.emplace("0000000100000002", GetStringT("Wii Menu"));
m_base_map.emplace("0000000100000002", Common::GetStringT("Wii Menu"));
for (const auto& id : {"HAXX", "00010001af1bf516"})
m_base_map.emplace(id, "The Homebrew Channel");
}

View File

@ -200,7 +200,7 @@ bool CompressFileToBlob(const std::string& infile_path, const std::string& outfi
if (deflateInit(&z, 9) != Z_OK)
return false;
callback(GetStringT("Files opened, ready to compress."), 0, arg);
callback(Common::GetStringT("Files opened, ready to compress."), 0, arg);
CompressedBlobHeader header;
header.magic_cookie = GCZ_MAGIC;
@ -239,8 +239,8 @@ bool CompressFileToBlob(const std::string& infile_path, const std::string& outfi
if (inpos != 0)
ratio = (int)(100 * position / inpos);
std::string temp =
StringFromFormat(GetStringT("%i of %i blocks. Compression ratio %i%%").c_str(), i,
const std::string temp =
StringFromFormat(Common::GetStringT("%i of %i blocks. Compression ratio %i%%").c_str(), i,
header.num_blocks, ratio);
bool was_cancelled = !callback(temp, (float)i / (float)header.num_blocks, arg);
if (was_cancelled)
@ -332,7 +332,7 @@ bool CompressFileToBlob(const std::string& infile_path, const std::string& outfi
if (success)
{
callback(GetStringT("Done compressing disc image."), 1.0f, arg);
callback(Common::GetStringT("Done compressing disc image."), 1.0f, arg);
}
return success;
}
@ -381,7 +381,8 @@ bool DecompressBlobToFile(const std::string& infile_path, const std::string& out
{
if (i % progress_monitor == 0)
{
bool was_cancelled = !callback(GetStringT("Unpacking"), (float)i / (float)num_buffers, arg);
const bool was_cancelled =
!callback(Common::GetStringT("Unpacking"), (float)i / (float)num_buffers, arg);
if (was_cancelled)
{
success = false;

View File

@ -64,7 +64,7 @@ std::string GetName(Country country, bool translate)
break;
}
return translate ? GetStringT(name.c_str()) : name;
return translate ? Common::GetStringT(name.c_str()) : name;
}
std::string GetName(Language language, bool translate)
@ -108,7 +108,7 @@ std::string GetName(Language language, bool translate)
break;
}
return translate ? GetStringT(name.c_str()) : name;
return translate ? Common::GetStringT(name.c_str()) : name;
}
bool IsDisc(Platform volume_type)

View File

@ -70,7 +70,7 @@ void VolumeVerifier::Start()
CheckPartitions();
if (m_volume.GetVolumeType() == Platform::WiiWAD)
CheckCorrectlySigned(PARTITION_NONE, GetStringT("This title is not correctly signed."));
CheckCorrectlySigned(PARTITION_NONE, Common::GetStringT("This title is not correctly signed."));
CheckDiscSize();
CheckMisc();
@ -85,7 +85,8 @@ void VolumeVerifier::CheckPartitions()
if (m_volume.GetVolumeType() != Platform::WiiWAD &&
!m_volume.GetFileSystem(m_volume.GetGamePartition()))
{
AddProblem(Severity::High, GetStringT("The filesystem is invalid or could not be read."));
AddProblem(Severity::High,
Common::GetStringT("The filesystem is invalid or could not be read."));
}
return;
}
@ -98,7 +99,7 @@ void VolumeVerifier::CheckPartitions()
// The only game that has that many partitions in total is Super Smash Bros. Brawl,
// and that game places all partitions other than UPDATE and DATA in the second table.
AddProblem(Severity::Low,
GetStringT("There are too many partitions in the first partition table."));
Common::GetStringT("There are too many partitions in the first partition table."));
}
std::vector<u32> types;
@ -110,20 +111,20 @@ void VolumeVerifier::CheckPartitions()
}
if (std::find(types.cbegin(), types.cend(), PARTITION_UPDATE) == types.cend())
AddProblem(Severity::Low, GetStringT("The update partition is missing."));
AddProblem(Severity::Low, Common::GetStringT("The update partition is missing."));
if (std::find(types.cbegin(), types.cend(), PARTITION_DATA) == types.cend())
AddProblem(Severity::High, GetStringT("The data partition is missing."));
AddProblem(Severity::High, Common::GetStringT("The data partition is missing."));
const bool has_channel_partition =
std::find(types.cbegin(), types.cend(), PARTITION_CHANNEL) != types.cend();
if (ShouldHaveChannelPartition() && !has_channel_partition)
AddProblem(Severity::Medium, GetStringT("The channel partition is missing."));
AddProblem(Severity::Medium, Common::GetStringT("The channel partition is missing."));
const bool has_install_partition =
std::find(types.cbegin(), types.cend(), PARTITION_INSTALL) != types.cend();
if (ShouldHaveInstallPartition() && !has_install_partition)
AddProblem(Severity::High, GetStringT("The install partition is missing."));
AddProblem(Severity::High, Common::GetStringT("The install partition is missing."));
if (ShouldHaveMasterpiecePartitions() &&
types.cend() ==
@ -135,23 +136,24 @@ void VolumeVerifier::CheckPartitions()
// (French), Clásicos (Spanish), Capolavori (Italian), 클래식 게임 체험판 (Korean).
// If your language is not one of the languages above, consider leaving the string untranslated
// so that people will recognize it as the name of the game mode.
AddProblem(Severity::Medium, GetStringT("The Masterpiece partitions are missing."));
AddProblem(Severity::Medium, Common::GetStringT("The Masterpiece partitions are missing."));
}
for (const Partition& partition : partitions)
{
if (m_volume.GetPartitionType(partition) == PARTITION_UPDATE && partition.offset != 0x50000)
{
AddProblem(Severity::Low, GetStringT("The update partition is not at its normal position."));
AddProblem(Severity::Low,
Common::GetStringT("The update partition is not at its normal position."));
}
const u64 normal_data_offset = m_volume.IsEncryptedAndHashed() ? 0xF800000 : 0x838000;
if (m_volume.GetPartitionType(partition) == PARTITION_DATA &&
partition.offset != normal_data_offset && !has_channel_partition && !has_install_partition)
{
AddProblem(
Severity::Low,
GetStringT("The data partition is not at its normal position. This will affect the "
AddProblem(Severity::Low,
Common::GetStringT(
"The data partition is not at its normal position. This will affect the "
"emulated loading times. When using NetPlay or sending input recordings to "
"other people, you will experience desyncs if anyone is using a good dump."));
}
@ -167,7 +169,7 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (!type)
{
// Not sure if this can happen in practice
AddProblem(Severity::Medium, GetStringT("The type of a partition could not be read."));
AddProblem(Severity::Medium, Common::GetStringT("The type of a partition could not be read."));
return false;
}
@ -182,19 +184,22 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (partition.offset % VolumeWii::BLOCK_TOTAL_SIZE != 0 ||
m_volume.PartitionOffsetToRawOffset(0, partition) % VolumeWii::BLOCK_TOTAL_SIZE != 0)
{
AddProblem(Severity::Medium,
StringFromFormat(GetStringT("The %s partition is not properly aligned.").c_str(),
name.c_str()));
AddProblem(
Severity::Medium,
StringFromFormat(Common::GetStringT("The %s partition is not properly aligned.").c_str(),
name.c_str()));
}
CheckCorrectlySigned(
partition, StringFromFormat(GetStringT("The %s partition is not correctly signed.").c_str(),
name.c_str()));
partition,
StringFromFormat(Common::GetStringT("The %s partition is not correctly signed.").c_str(),
name.c_str()));
if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition))
{
std::string text = StringFromFormat(
GetStringT("The H3 hash table for the %s partition is not correct.").c_str(), name.c_str());
Common::GetStringT("The H3 hash table for the %s partition is not correct.").c_str(),
name.c_str());
AddProblem(Severity::Low, std::move(text));
}
@ -227,7 +232,8 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
// the Masterpiece partitions in Super Smash Bros. Brawl without removing them from
// the partition table. https://bugs.dolphin-emu.org/issues/8733
std::string text = StringFromFormat(
GetStringT("The %s partition does not seem to contain valid data.").c_str(), name.c_str());
Common::GetStringT("The %s partition does not seem to contain valid data.").c_str(),
name.c_str());
AddProblem(severity, std::move(text));
return false;
}
@ -236,7 +242,8 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (!filesystem)
{
std::string text = StringFromFormat(
GetStringT("The %s partition does not have a valid file system.").c_str(), name.c_str());
Common::GetStringT("The %s partition does not have a valid file system.").c_str(),
name.c_str());
AddProblem(severity, std::move(text));
return false;
}
@ -266,8 +273,9 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
{
// This is reached for hacked dumps where the update partition has been replaced with
// a very old update partition so that no updates will be installed.
AddProblem(Severity::Low,
GetStringT("The update partition does not contain the IOS used by this title."));
AddProblem(
Severity::Low,
Common::GetStringT("The update partition does not contain the IOS used by this title."));
}
}
@ -303,7 +311,7 @@ std::string VolumeVerifier::GetPartitionName(std::optional<u32> type) const
// (French), Clásicos (Spanish), Capolavori (Italian), 클래식 게임 체험판 (Korean).
// If your language is not one of the languages above, consider leaving the string untranslated
// so that people will recognize it as the name of the game mode.
name = StringFromFormat(GetStringT("%s (Masterpiece)").c_str(), name.c_str());
name = StringFromFormat(Common::GetStringT("%s (Masterpiece)").c_str(), name.c_str());
}
return name;
}
@ -381,10 +389,10 @@ void VolumeVerifier::CheckDiscSize()
biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
std::string text =
second_layer_missing ?
GetStringT(
Common::GetStringT(
"This disc image is too small and lacks some data. The problem is most likely that "
"this is a dual-layer disc that has been dumped as a single-layer disc.") :
GetStringT(
Common::GetStringT(
"This disc image is too small and lacks some data. If your dumping program saved "
"the disc image as several parts, you need to merge them into one file.");
AddProblem(Severity::High, std::move(text));
@ -393,17 +401,18 @@ void VolumeVerifier::CheckDiscSize()
if (ShouldBeDualLayer() && biggest_offset <= SL_DVD_R_SIZE)
{
AddProblem(
Severity::Medium,
GetStringT("This game has been hacked to fit on a single-layer DVD. Some content such as "
AddProblem(Severity::Medium,
Common::GetStringT(
"This game has been hacked to fit on a single-layer DVD. Some content such as "
"pre-rendered videos, extra languages or entire game modes will be broken. "
"This problem generally only exists in illegal copies of games."));
}
if (!m_volume.IsSizeAccurate())
{
AddProblem(Severity::Low, GetStringT("The format that the disc image is saved in does not "
"store the size of the disc image."));
AddProblem(Severity::Low,
Common::GetStringT("The format that the disc image is saved in does not "
"store the size of the disc image."));
}
else if (!m_is_tgc)
{
@ -420,8 +429,9 @@ void VolumeVerifier::CheckDiscSize()
{
if (debug && valid_retail_wii)
{
AddProblem(Severity::Low,
GetStringT("This debug disc image has the size of a retail disc image."));
AddProblem(
Severity::Low,
Common::GetStringT("This debug disc image has the size of a retail disc image."));
}
else
{
@ -431,15 +441,16 @@ void VolumeVerifier::CheckDiscSize()
if (small)
{
AddProblem(Severity::Low,
GetStringT("This disc image has an unusual size. This will likely make the "
"emulated loading times longer. When using NetPlay or sending "
"input recordings to other people, you will likely experience "
"desyncs if anyone is using a good dump."));
AddProblem(
Severity::Low,
Common::GetStringT("This disc image has an unusual size. This will likely make the "
"emulated loading times longer. When using NetPlay or sending "
"input recordings to other people, you will likely experience "
"desyncs if anyone is using a good dump."));
}
else
{
AddProblem(Severity::Low, GetStringT("This disc image has an unusual size."));
AddProblem(Severity::Low, Common::GetStringT("This disc image has an unusual size."));
}
}
}
@ -528,16 +539,17 @@ void VolumeVerifier::CheckMisc()
// Hacked version of the Wii Backup Disc (aka "pinkfish" disc).
std::string proper_game_id = game_id_unencrypted;
proper_game_id[0] = '4';
AddProblem(Severity::Low,
StringFromFormat(GetStringT("The game ID is %s but should be %s.").c_str(),
game_id_unencrypted.c_str(), proper_game_id.c_str()));
AddProblem(
Severity::Low,
StringFromFormat(Common::GetStringT("The game ID is %s but should be %s.").c_str(),
game_id_unencrypted.c_str(), proper_game_id.c_str()));
inconsistent_game_id = false;
}
}
if (inconsistent_game_id)
{
AddProblem(Severity::Low, GetStringT("The game ID is inconsistent."));
AddProblem(Severity::Low, Common::GetStringT("The game ID is inconsistent."));
}
}
@ -546,16 +558,16 @@ void VolumeVerifier::CheckMisc()
if (game_id_encrypted.size() < 4)
{
AddProblem(Severity::Low, GetStringT("The game ID is unusually short."));
AddProblem(Severity::Low, Common::GetStringT("The game ID is unusually short."));
}
else
{
const char country_code = game_id_encrypted[3];
if (CountryCodeToRegion(country_code, platform, region) != region)
{
AddProblem(
Severity::Medium,
GetStringT("The region code does not match the game ID. If this is because the "
AddProblem(Severity::Medium,
Common::GetStringT(
"The region code does not match the game ID. If this is because the "
"region code has been modified, the game might run at the wrong speed, "
"graphical elements might be offset, or the game might not run at all."));
}
@ -576,18 +588,19 @@ void VolumeVerifier::CheckMisc()
// This is intended to catch pirated Korean games that have had the IOS slot set to 36
// as a side effect of having to fakesign after changing the common key slot to 0.
// (IOS36 was the last IOS to have the Trucha bug.) https://bugs.dolphin-emu.org/issues/10319
AddProblem(Severity::High,
// i18n: You may want to leave the term "ERROR #002" untranslated,
// since the emulated software always displays it in English.
GetStringT("This Korean title is set to use an IOS that typically isn't used on "
"Korean consoles. This is likely to lead to ERROR #002."));
AddProblem(
Severity::High,
// i18n: You may want to leave the term "ERROR #002" untranslated,
// since the emulated software always displays it in English.
Common::GetStringT("This Korean title is set to use an IOS that typically isn't used on "
"Korean consoles. This is likely to lead to ERROR #002."));
}
if (ios_id >= 0x80)
{
// This is also intended to catch fakesigned pirated Korean games,
// but this time with the IOS slot set to cIOS instead of IOS36.
AddProblem(Severity::High, GetStringT("This title is set to use an invalid IOS."));
AddProblem(Severity::High, Common::GetStringT("This title is set to use an invalid IOS."));
}
}
@ -603,7 +616,7 @@ void VolumeVerifier::CheckMisc()
const Severity severity =
m_volume.GetVolumeType() == Platform::WiiWAD ? Severity::Low : Severity::High;
// i18n: This is "common" as in "shared", not the opposite of "uncommon"
AddProblem(severity, GetStringT("This title is set to use an invalid common key."));
AddProblem(severity, Common::GetStringT("This title is set to use an invalid common key."));
}
if (common_key == 1 && region != Region::NTSC_K)
@ -613,7 +626,7 @@ void VolumeVerifier::CheckMisc()
// https://forums.dolphin-emu.org/Thread-wiiware-chronos-twins-dx
AddProblem(Severity::High,
// i18n: This is "common" as in "shared", not the opposite of "uncommon"
GetStringT("This non-Korean title is set to use the Korean common key."));
Common::GetStringT("This non-Korean title is set to use the Korean common key."));
}
}
@ -622,11 +635,12 @@ void VolumeVerifier::CheckMisc()
constexpr u32 NKIT_MAGIC = 0x4E4B4954; // "NKIT"
if (m_volume.ReadSwapped<u32>(0x200, PARTITION_NONE) == NKIT_MAGIC)
{
AddProblem(Severity::Low,
GetStringT("This disc image is in the NKit format. It is not a good dump in its "
"current form, but it might become a good dump if converted back. "
"The CRC32 of this file might match the CRC32 of a good dump even "
"though the files are not identical."));
AddProblem(
Severity::Low,
Common::GetStringT("This disc image is in the NKit format. It is not a good dump in its "
"current form, but it might become a good dump if converted back. "
"The CRC32 of this file might match the CRC32 of a good dump even "
"though the files are not identical."));
}
}
}
@ -725,8 +739,9 @@ void VolumeVerifier::Process()
{
if (!CheckContentIntegrity(content))
{
AddProblem(Severity::High,
StringFromFormat(GetStringT("Content %08x is corrupt.").c_str(), content.id));
AddProblem(
Severity::High,
StringFromFormat(Common::GetStringT("Content %08x is corrupt.").c_str(), content.id));
}
m_content_index++;
@ -822,8 +837,8 @@ void VolumeVerifier::Finish()
{
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
std::string text = StringFromFormat(
GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), blocks,
name.c_str());
Common::GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(),
blocks, name.c_str());
AddProblem(Severity::Medium, std::move(text));
}
}
@ -834,8 +849,8 @@ void VolumeVerifier::Finish()
{
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
std::string text = StringFromFormat(
GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(), blocks,
name.c_str());
Common::GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(),
blocks, name.c_str());
AddProblem(Severity::Low, std::move(text));
}
}
@ -848,14 +863,15 @@ void VolumeVerifier::Finish()
if (m_is_datel)
{
m_result.summary_text = GetStringT("Dolphin is unable to verify unlicensed discs.");
m_result.summary_text = Common::GetStringT("Dolphin is unable to verify unlicensed discs.");
return;
}
if (m_is_tgc)
{
m_result.summary_text = GetStringT("Dolphin is unable to verify typical TGC files properly, "
"since they are not dumps of actual discs.");
m_result.summary_text =
Common::GetStringT("Dolphin is unable to verify typical TGC files properly, "
"since they are not dumps of actual discs.");
return;
}
@ -864,26 +880,28 @@ void VolumeVerifier::Finish()
case Severity::None:
if (IsWii(m_volume.GetVolumeType()) && !m_is_not_retail)
{
m_result.summary_text =
GetStringT("No problems were found. This does not guarantee that this is a good dump, "
"but since Wii titles contain a lot of verification data, it does mean that "
"there most likely are no problems that will affect emulation.");
m_result.summary_text = Common::GetStringT(
"No problems were found. This does not guarantee that this is a good dump, "
"but since Wii titles contain a lot of verification data, it does mean that "
"there most likely are no problems that will affect emulation.");
}
else
{
m_result.summary_text = GetStringT("No problems were found.");
m_result.summary_text = Common::GetStringT("No problems were found.");
}
break;
case Severity::Low:
m_result.summary_text = GetStringT("Problems with low severity were found. They will most "
"likely not prevent the game from running.");
m_result.summary_text =
Common::GetStringT("Problems with low severity were found. They will most "
"likely not prevent the game from running.");
break;
case Severity::Medium:
m_result.summary_text = GetStringT("Problems with medium severity were found. The whole game "
"or certain parts of the game might not work correctly.");
m_result.summary_text =
Common::GetStringT("Problems with medium severity were found. The whole game "
"or certain parts of the game might not work correctly.");
break;
case Severity::High:
m_result.summary_text = GetStringT(
m_result.summary_text = Common::GetStringT(
"Problems with high severity were found. The game will most likely not work at all.");
break;
}
@ -891,13 +909,14 @@ void VolumeVerifier::Finish()
if (m_volume.GetVolumeType() == Platform::GameCubeDisc)
{
m_result.summary_text +=
GetStringT("\n\nBecause GameCube disc images contain little verification data, "
"there may be problems that Dolphin is unable to detect.");
Common::GetStringT("\n\nBecause GameCube disc images contain little verification data, "
"there may be problems that Dolphin is unable to detect.");
}
else if (m_is_not_retail)
{
m_result.summary_text += GetStringT("\n\nBecause this title is not for retail Wii consoles, "
"Dolphin cannot verify that it hasn't been tampered with.");
m_result.summary_text +=
Common::GetStringT("\n\nBecause this title is not for retail Wii consoles, "
"Dolphin cannot verify that it hasn't been tampered with.");
}
}

View File

@ -35,7 +35,8 @@
#include "UICommon/CommandLineParse.h"
#include "UICommon/UICommon.h"
static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no, MsgType style)
static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no,
Common::MsgType style)
{
std::optional<bool> r = RunOnObject(QApplication::instance(), [&] {
ModalMessageBox message_box(QApplication::activeWindow());
@ -43,19 +44,19 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
message_box.setText(QString::fromUtf8(text));
message_box.setStandardButtons(yes_no ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok);
if (style == MsgType::Warning)
if (style == Common::MsgType::Warning)
message_box.addButton(QMessageBox::Ignore)->setText(QObject::tr("Ignore for this session"));
message_box.setIcon([&] {
switch (style)
{
case MsgType::Information:
case Common::MsgType::Information:
return QMessageBox::Information;
case MsgType::Question:
case Common::MsgType::Question:
return QMessageBox::Question;
case MsgType::Warning:
case Common::MsgType::Warning:
return QMessageBox::Warning;
case MsgType::Critical:
case Common::MsgType::Critical:
return QMessageBox::Critical;
}
// appease MSVC
@ -67,7 +68,7 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
return true;
if (button == QMessageBox::Ignore)
SetEnableAlert(false);
Common::SetEnableAlert(false);
return false;
});
@ -137,7 +138,7 @@ int main(int argc, char* argv[])
Settings::Instance().SetBatchModeEnabled(options.is_set("batch"));
// Hook up alerts from core
RegisterMsgAlertHandler(QtMsgAlertHandler);
Common::RegisterMsgAlertHandler(QtMsgAlertHandler);
// Hook up translations
Translation::Initialize();

View File

@ -263,7 +263,7 @@ void InterfacePane::OnSaveConfig()
settings.m_show_active_title = m_checkbox_show_active_title->isChecked();
settings.m_PauseOnFocusLost = m_checkbox_pause_on_focus_lost->isChecked();
SetEnableAlert(settings.bUsePanicHandlers);
Common::SetEnableAlert(settings.bUsePanicHandlers);
auto new_language = m_combobox_language->currentData().toString().toStdString();
if (new_language != SConfig::GetInstance().m_InterfaceLanguage)

View File

@ -292,7 +292,8 @@ static bool TryInstallTranslator(const QString& exact_language_code)
void Translation::Initialize()
{
// Hook up Dolphin internal translation
RegisterStringTranslator([](const char* text) { return QObject::tr(text).toStdString(); });
Common::RegisterStringTranslator(
[](const char* text) { return QObject::tr(text).toStdString(); });
// Hook up Qt translations
auto& configured_language = SConfig::GetInstance().m_InterfaceLanguage;

View File

@ -84,7 +84,7 @@ void Init()
GCAdapter::Init();
VideoBackendBase::ActivateBackend(SConfig::GetInstance().m_strVideoBackend);
SetEnableAlert(SConfig::GetInstance().bUsePanicHandlers);
Common::SetEnableAlert(SConfig::GetInstance().bUsePanicHandlers);
}
void Shutdown()
@ -440,7 +440,7 @@ std::string FormatSize(u64 bytes)
const double unit_size = std::pow(2, unit * 10);
std::stringstream ss;
ss << std::fixed << std::setprecision(2);
ss << bytes / unit_size << ' ' << GetStringT(unit_symbols[unit]);
ss << bytes / unit_size << ' ' << Common::GetStringT(unit_symbols[unit]);
return ss.str();
}

View File

@ -157,7 +157,7 @@ void ShaderCache::WaitForAsyncCompiler()
ImGui::SetNextWindowSize(ImVec2(400.0f * scale, 50.0f * scale), ImGuiCond_Always);
ImGui::SetNextWindowPosCenter(ImGuiCond_Always);
if (ImGui::Begin(GetStringT("Compiling Shaders").c_str(), nullptr,
if (ImGui::Begin(Common::GetStringT("Compiling Shaders").c_str(), nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav |