Skip to content
Permalink
Browse files

Common/MsgHandler: Namespace code within the Common namespace

Closes another gap in the Common library where code isn't being
namespaced under it.
  • Loading branch information...
lioncash committed Jun 17, 2019
1 parent e7dd46a commit 4f1f55093fcf98aa1592b6b8b1ad0d33c4461b50
@@ -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);

@@ -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
@@ -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
@@ -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);
@@ -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;
}
@@ -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);
}
@@ -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");
}
@@ -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;
@@ -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)

0 comments on commit 4f1f550

Please sign in to comment.
You can’t perform that action at this time.