Core: Use a shared_ptr for i18n categories.

This does not make them thread safe, but it reduces the chances of a crash
a bit (see #12594.)
This commit is contained in:
Unknown W. Brackets 2020-01-26 10:43:18 -08:00
parent a4ba5d4859
commit 5009698cc0
54 changed files with 244 additions and 240 deletions

View file

@ -340,7 +340,7 @@ void CWCheatEngine::CreateCheatFile() {
fclose(f); fclose(f);
} }
if (!File::Exists(activeCheatFile)) { if (!File::Exists(activeCheatFile)) {
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Unable to create cheat file, disk may be full")); host->NotifyUserMessage(err->T("Unable to create cheat file, disk may be full"));
} }
} }

View file

@ -202,7 +202,7 @@ void PSPDialog::DisplayButtons(int flags, const char *caption)
truncate_cpy(safeCaption, caption); truncate_cpy(safeCaption, caption);
} }
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
float x1 = 183.5f, x2 = 261.5f; float x1 = 183.5f, x2 = 261.5f;
if (GetCommonParam()->buttonSwap == 1) { if (GetCommonParam()->buttonSwap == 1) {
x1 = 261.5f; x1 = 261.5f;

View file

@ -156,7 +156,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)
if (hasYesNo) if (hasYesNo)
{ {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
const char *choiceText; const char *choiceText;
u32 yesColor, noColor; u32 yesColor, noColor;
float x, w; float x, w;
@ -193,7 +193,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)
} }
if (hasOK) { if (hasOK) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
float x, w; float x, w;
x = 240.0f; x = 240.0f;
w = 15.0f; w = 15.0f;

View file

@ -62,14 +62,14 @@ void PSPNetconfDialog::DrawBanner() {
// TODO: Draw a hexagon icon // TODO: Draw a hexagon icon
PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF)); PPGeDrawImage(10, 6, 12.0f, 12.0f, 1, 10, 1, 10, 10, 10, CalcFadedColor(0xFFFFFFFF));
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
PPGeDrawText(di->T("Network Connection"), 30, 11, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText(di->T("Network Connection"), 30, 11, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
} }
int PSPNetconfDialog::Update(int animSpeed) { int PSPNetconfDialog::Update(int animSpeed) {
UpdateButtons(); UpdateButtons();
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f; const float WRAP_WIDTH = 254.0f;
const int confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? I_CROSS : I_CIRCLE; const int confirmBtnImage = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? I_CROSS : I_CIRCLE;
const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE; const int confirmBtn = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;

View file

@ -917,7 +917,7 @@ int PSPOskDialog::Update(int animSpeed) {
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363)); PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));
RenderKeyboard(); RenderKeyboard();
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
PPGeDrawImage(I_SQUARE, 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF)); PPGeDrawImage(I_SQUARE, 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawText(di->T("Space"), 390, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText(di->T("Space"), 390, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));

View file

@ -280,7 +280,7 @@ const std::string PSPSaveDialog::GetSelectedSaveDirName() const
void PSPSaveDialog::DisplayBanner(int which) void PSPSaveDialog::DisplayBanner(int which)
{ {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
PPGeDrawRect(0, 0, 480, 23, CalcFadedColor(0x65636358)); PPGeDrawRect(0, 0, 480, 23, CalcFadedColor(0x65636358));
const char *title; const char *title;
switch (which) switch (which)
@ -394,7 +394,7 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
{ {
std::lock_guard<std::mutex> guard(paramLock); std::lock_guard<std::mutex> guard(paramLock);
if (param.GetFileInfo(currentSelectedSave).size == 0) { if (param.GetFileInfo(currentSelectedSave).size == 0) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
PPGeDrawText(di->T("NEW DATA"), 180, 136, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF)); PPGeDrawText(di->T("NEW DATA"), 180, 136, PPGE_ALIGN_VCENTER, 0.6f, CalcFadedColor(0xFFFFFFFF));
} else { } else {
char title[512]; char title[512];
@ -539,7 +539,7 @@ void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
float h2 = h * (float)n / 2.0f; float h2 = h * (float)n / 2.0f;
if (hasYesNo) if (hasYesNo)
{ {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
const char *choiceText; const char *choiceText;
u32 yesColor, noColor; u32 yesColor, noColor;
float x, w; float x, w;
@ -621,7 +621,7 @@ int PSPSaveDialog::Update(int animSpeed)
cancelButtonFlag = CTRL_CIRCLE; cancelButtonFlag = CTRL_CIRCLE;
} }
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
switch (display) switch (display)
{ {

View file

@ -392,7 +392,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
if (!pspFileSystem.GetFileInfo(dirPath).exists) { if (!pspFileSystem.GetFileInfo(dirPath).exists) {
if (!pspFileSystem.MkDir(dirPath)) { if (!pspFileSystem.MkDir(dirPath)) {
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Unable to write savedata, disk may be full")); host->NotifyUserMessage(err->T("Unable to write savedata, disk may be full"));
} }
} }
@ -422,7 +422,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
} }
if (EncryptData(decryptMode, cryptedData, &cryptedSize, &aligned_len, cryptedHash, (hasKey ? param->key : 0)) != 0) { if (EncryptData(decryptMode, cryptedData, &cryptedSize, &aligned_len, cryptedHash, (hasKey ? param->key : 0)) != 0) {
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f); host->NotifyUserMessage(err->T("Save encryption failed. This save won't work on real PSP"), 6.0f);
ERROR_LOG(SCEUTILITY,"Save encryption failed. This save won't work on real PSP"); ERROR_LOG(SCEUTILITY,"Save encryption failed. This save won't work on real PSP");
delete[] cryptedData; delete[] cryptedData;
@ -689,7 +689,7 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, co
// Don't notify the user if we're not going to upgrade the save. // Don't notify the user if we're not going to upgrade the save.
if (!g_Config.bEncryptSave) { if (!g_Config.bEncryptSave) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
host->NotifyUserMessage(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f); host->NotifyUserMessage(di->T("When you save, it will load on a PSP, but not an older PPSSPP"), 6.0f);
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f); host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
} }
@ -701,7 +701,7 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, co
} }
if (g_Config.bSavedataUpgrade) { if (g_Config.bSavedataUpgrade) {
decryptMode = prevCryptMode; decryptMode = prevCryptMode;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
host->NotifyUserMessage(di->T("When you save, it will not work on outdated PSP Firmware anymore"), 6.0f); host->NotifyUserMessage(di->T("When you save, it will not work on outdated PSP Firmware anymore"), 6.0f);
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f); host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
} }

View file

@ -64,7 +64,7 @@ u32 BlockDevice::CalculateCRC() {
} }
void BlockDevice::NotifyReadError() { void BlockDevice::NotifyReadError() {
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
if (!reportedError_) { if (!reportedError_) {
host->NotifyUserMessage(err->T("Game disc read error - ISO corrupt"), 6.0f); host->NotifyUserMessage(err->T("Game disc read error - ISO corrupt"), 6.0f);
reportedError_ = true; reportedError_ = true;

View file

@ -251,7 +251,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam
if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) { if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) {
// This is returned when the disk is full. // This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data")); host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM; error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else if (!success) { } else if (!success) {
@ -315,7 +315,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam
} }
} else if (errno == ENOSPC) { } else if (errno == ENOSPC) {
// This is returned when the disk is full. // This is returned when the disk is full.
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data")); host->NotifyUserMessage(err->T("Disk full while writing data"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM; error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else { } else {
@ -383,7 +383,7 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)
if (diskFull) { if (diskFull) {
ERROR_LOG(FILESYS, "Disk full"); ERROR_LOG(FILESYS, "Disk full");
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data")); host->NotifyUserMessage(err->T("Disk full while writing data"));
// We only return an error when the disk is actually full. // We only return an error when the disk is actually full.
// When writing this would cause the disk to be full, so it wasn't written, we return 0. // When writing this would cause the disk to be full, so it wasn't written, we return 0.

View file

@ -1457,7 +1457,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
int sent = send(metasocket, (char*)&packet, sizeof(packet), 0); int sent = send(metasocket, (char*)&packet, sizeof(packet), 0);
changeBlockingMode(metasocket, 1); // Change to non-blocking changeBlockingMode(metasocket, 1); // Change to non-blocking
if (sent > 0) { if (sent > 0) {
I18NCategory *n = GetI18NCategory("Networking"); auto n = GetI18NCategory("Networking");
host->NotifyUserMessage(n->T("Network Initialized"), 1.0); host->NotifyUserMessage(n->T("Network Initialized"), 1.0);
return 0; return 0;
} }

View file

@ -720,7 +720,7 @@ void __DisplayFlip(int cyclesLate) {
static bool hasNotifiedSlow = false; static bool hasNotifiedSlow = false;
if (!g_Config.bHideSlowWarnings && !hasNotifiedSlow && PSP_CoreParameter().fpsLimit == FPSLimit::NORMAL && IsRunningSlow()) { if (!g_Config.bHideSlowWarnings && !hasNotifiedSlow && PSP_CoreParameter().fpsLimit == FPSLimit::NORMAL && IsRunningSlow()) {
#ifndef _DEBUG #ifndef _DEBUG
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
if (g_Config.bSoftwareRendering) { if (g_Config.bSoftwareRendering) {
host->NotifyUserMessage(err->T("Running slow: Try turning off Software Rendering"), 6.0f, 0xFF30D0D0); host->NotifyUserMessage(err->T("Running slow: Try turning off Software Rendering"), 6.0f, 0xFF30D0D0);
} else { } else {

View file

@ -381,7 +381,7 @@ namespace SaveState
return StringFromFormat("%s (%c)", title.c_str(), slotChar); return StringFromFormat("%s (%c)", title.c_str(), slotChar);
} }
if (detectSlot(UNDO_STATE_EXTENSION)) { if (detectSlot(UNDO_STATE_EXTENSION)) {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
// Allow the number to be positioned where it makes sense. // Allow the number to be positioned where it makes sense.
std::string undo = sy->T("undo %c"); std::string undo = sy->T("undo %c");
return title + " (" + StringFromFormat(undo.c_str(), slotChar) + ")"; return title + " (" + StringFromFormat(undo.c_str(), slotChar) + ")";
@ -402,7 +402,7 @@ namespace SaveState
} }
// The file can't be loaded - let's note that. // The file can't be loaded - let's note that.
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
return File::GetFilename(filename) + " " + sy->T("(broken)"); return File::GetFilename(filename) + " " + sy->T("(broken)");
} }
@ -437,7 +437,7 @@ namespace SaveState
if (!fn.empty()) { if (!fn.empty()) {
Load(fn, callback, cbUserData); Load(fn, callback, cbUserData);
} else { } else {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
if (callback) if (callback)
callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData); callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData);
} }
@ -494,7 +494,7 @@ namespace SaveState
SaveScreenshot(shot, Callback(), 0); SaveScreenshot(shot, Callback(), 0);
Save(fn + ".tmp", renameCallback, cbUserData); Save(fn + ".tmp", renameCallback, cbUserData);
} else { } else {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
if (callback) if (callback)
callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData); callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData);
} }
@ -729,7 +729,7 @@ namespace SaveState
std::string reason; std::string reason;
std::string title; std::string title;
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
const char *i18nLoadFailure = sc->T("Load savestate failed", ""); const char *i18nLoadFailure = sc->T("Load savestate failed", "");
const char *i18nSaveFailure = sc->T("Save State Failed", ""); const char *i18nSaveFailure = sc->T("Save State Failed", "");
if (strlen(i18nLoadFailure) == 0) if (strlen(i18nLoadFailure) == 0)

View file

@ -168,7 +168,7 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, bool isOverride) {
} }
if (filenameWarning) { if (filenameWarning) {
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("textures.ini filenames may not be cross-platform"), 6.0f); host->NotifyUserMessage(err->T("textures.ini filenames may not be cross-platform"), 6.0f);
} }

View file

@ -261,7 +261,7 @@ bool GameManager::InstallGame(const std::string &url, const std::string &fileNam
return InstallRawISO(fileName, shortFilename, deleteAfter); return InstallRawISO(fileName, shortFilename, deleteAfter);
} }
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
installInProgress_ = true; installInProgress_ = true;
std::string pspGame = GetSysDirectory(DIRECTORY_GAME); std::string pspGame = GetSysDirectory(DIRECTORY_GAME);
@ -312,7 +312,7 @@ bool GameManager::InstallGame(const std::string &url, const std::string &fileNam
} }
bool GameManager::DetectTexturePackDest(struct zip *z, int iniIndex, std::string *dest) { bool GameManager::DetectTexturePackDest(struct zip *z, int iniIndex, std::string *dest) {
I18NCategory *iz = GetI18NCategory("InstallZip"); auto iz = GetI18NCategory("InstallZip");
struct zip_stat zstat; struct zip_stat zstat;
zip_stat_index(z, iniIndex, 0, &zstat); zip_stat_index(z, iniIndex, 0, &zstat);
@ -491,7 +491,7 @@ bool GameManager::InstallMemstickGame(struct zip *z, const std::string &zipfile,
size_t allBytes = 0; size_t allBytes = 0;
size_t bytesCopied = 0; size_t bytesCopied = 0;
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
auto fileAllowed = [&](const char *fn) { auto fileAllowed = [&](const char *fn) {
if (!allowRoot && strchr(fn, '/') == 0) if (!allowRoot && strchr(fn, '/') == 0)

View file

@ -1906,7 +1906,7 @@ void FramebufferManagerCommon::UpdateFramebufUsage(VirtualFramebuffer *vfb) {
} }
void FramebufferManagerCommon::ShowScreenResolution() { void FramebufferManagerCommon::ShowScreenResolution() {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
std::ostringstream messageStream; std::ostringstream messageStream;
messageStream << gr->T("Internal Resolution") << ": "; messageStream << gr->T("Internal Resolution") << ": ";

View file

@ -101,7 +101,7 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
// Disable hardware tessellation bacause DX9 is still unsupported. // Disable hardware tessellation bacause DX9 is still unsupported.
g_Config.bHardwareTessellation = false; g_Config.bHardwareTessellation = false;
ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation"); ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF); host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF);
} }
} }

View file

@ -588,7 +588,7 @@ VSShader *ShaderManagerDX9::ApplyShader(int prim, u32 vertType) {
vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform); vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform);
if (vs->Failed()) { if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform"); ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
if (!g_Config.bHideSlowWarnings) { if (!g_Config.bHideSlowWarnings) {
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF); host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);

View file

@ -112,7 +112,7 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
if (!gstate_c.SupportsAll(GPU_SUPPORTS_VERTEX_TEXTURE_FETCH | GPU_SUPPORTS_TEXTURE_FLOAT) || !hasTexelFetch) { if (!gstate_c.SupportsAll(GPU_SUPPORTS_VERTEX_TEXTURE_FETCH | GPU_SUPPORTS_TEXTURE_FLOAT) || !hasTexelFetch) {
g_Config.bHardwareTessellation = false; g_Config.bHardwareTessellation = false;
ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation"); ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF); host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF);
} }
} }

View file

@ -678,7 +678,7 @@ Shader *ShaderManagerGLES::ApplyVertexShader(int prim, u32 vertType, VShaderID *
// Vertex shader not in cache. Let's compile it. // Vertex shader not in cache. Let's compile it.
vs = CompileVertexShader(*VSID); vs = CompileVertexShader(*VSID);
if (vs->Failed()) { if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform"); ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
if (!g_Config.bHideSlowWarnings) { if (!g_Config.bHideSlowWarnings) {
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF); host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);

View file

@ -219,7 +219,7 @@ void TextureCacheGLES::StartFrame() {
lowMemoryMode_ = true; lowMemoryMode_ = true;
decimationCounter_ = 0; decimationCounter_ = 0;
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
if (standardScaleFactor_ > 1) { if (standardScaleFactor_ > 1) {
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f); host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else { } else {

View file

@ -1122,7 +1122,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
// TODO: We should stall the GPU here and wipe things out of memory. // TODO: We should stall the GPU here and wipe things out of memory.
// As is, it will almost definitely fail the second time, but next frame it may recover. // As is, it will almost definitely fail the second time, but next frame it may recover.
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
if (scaleFactor > 1) { if (scaleFactor > 1) {
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f); host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else { } else {

View file

@ -471,7 +471,7 @@ bool MainUI::event(QEvent *e) {
} }
break; break;
} else if (e->type() == browseFolderEvent) { } else if (e->type() == browseFolderEvent) {
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
QString fileName = QFileDialog::getExistingDirectory(nullptr, mm->T("Choose folder"), g_Config.currentDirectory.c_str()); QString fileName = QFileDialog::getExistingDirectory(nullptr, mm->T("Choose folder"), g_Config.currentDirectory.c_str());
if (QDir(fileName).exists()) { if (QDir(fileName).exists()) {
NativeMessageReceived("browse_folderSelect", fileName.toStdString().c_str()); NativeMessageReceived("browse_folderSelect", fileName.toStdString().c_str());

View file

@ -33,13 +33,13 @@
void Combo_keyScreen::CreateViews() { void Combo_keyScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *co = GetI18NCategory("Controls"); auto co = GetI18NCategory("Controls");
root_ = new LinearLayout(ORIENT_VERTICAL); root_ = new LinearLayout(ORIENT_VERTICAL);
root_->Add(new ItemHeader(co->T("Combo Key Setting"))); root_->Add(new ItemHeader(co->T("Combo Key Setting")));
LinearLayout *root__ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0)); LinearLayout *root__ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0));
root_->Add(root__); root_->Add(root__);
LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(120, FILL_PARENT)); LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(120, FILL_PARENT));
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
static const int comboKeyImages[5] = { static const int comboKeyImages[5] = {
I_1, I_2, I_3, I_4, I_5, I_1, I_2, I_3, I_4, I_5,
@ -113,7 +113,7 @@ void Combo_keyScreen::CreateViews() {
std::map<std::string, int>::iterator imageFinder; std::map<std::string, int>::iterator imageFinder;
I18NCategory *mc = GetI18NCategory("MappableControls"); auto mc = GetI18NCategory("MappableControls");
for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) { for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) {
LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));

View file

@ -88,7 +88,7 @@ void ControlMapper::Update() {
void ControlMapper::Refresh() { void ControlMapper::Refresh() {
bool hasFocus = UI::GetFocusedView() == this; bool hasFocus = UI::GetFocusedView() == this;
Clear(); Clear();
I18NCategory *mc = GetI18NCategory("MappableControls"); auto mc = GetI18NCategory("MappableControls");
std::map<std::string, int> keyImages; std::map<std::string, int> keyImages;
keyImages["Circle"] = I_CIRCLE; keyImages["Circle"] = I_CIRCLE;
@ -186,28 +186,28 @@ void ControlMapper::MappedCallback(KeyDef kdf) {
UI::EventReturn ControlMapper::OnReplace(UI::EventParams &params) { UI::EventReturn ControlMapper::OnReplace(UI::EventParams &params) {
actionIndex_ = atoi(params.v->Tag().c_str()); actionIndex_ = atoi(params.v->Tag().c_str());
action_ = REPLACEONE; action_ = REPLACEONE;
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km)); scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km));
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
UI::EventReturn ControlMapper::OnReplaceAll(UI::EventParams &params) { UI::EventReturn ControlMapper::OnReplaceAll(UI::EventParams &params) {
action_ = REPLACEALL; action_ = REPLACEALL;
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km)); scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km));
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
UI::EventReturn ControlMapper::OnAdd(UI::EventParams &params) { UI::EventReturn ControlMapper::OnAdd(UI::EventParams &params) {
action_ = ADD; action_ = ADD;
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km)); scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km));
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
UI::EventReturn ControlMapper::OnAddMouse(UI::EventParams &params) { UI::EventReturn ControlMapper::OnAddMouse(UI::EventParams &params) {
action_ = ADD; action_ = ADD;
g_Config.bMapMouse = true; g_Config.bMapMouse = true;
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
scrm_->push(new KeyMappingNewMouseKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km)); scrm_->push(new KeyMappingNewMouseKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1), km));
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
@ -224,7 +224,7 @@ void ControlMappingScreen::CreateViews() {
using namespace UI; using namespace UI;
mappers_.clear(); mappers_.clear();
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
root_ = new LinearLayout(ORIENT_HORIZONTAL); root_ = new LinearLayout(ORIENT_HORIZONTAL);
@ -275,7 +275,7 @@ UI::EventReturn ControlMappingScreen::OnAutoConfigure(UI::EventParams &params) {
for (auto s = seenPads.begin(), end = seenPads.end(); s != end; ++s) { for (auto s = seenPads.begin(), end = seenPads.end(); s != end; ++s) {
items.push_back(*s); items.push_back(*s);
} }
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
ListPopupScreen *autoConfList = new ListPopupScreen(km->T("Autoconfigure for device"), items, -1); ListPopupScreen *autoConfList = new ListPopupScreen(km->T("Autoconfigure for device"), items, -1);
if (params.v) if (params.v)
autoConfList->SetPopupOrigin(params.v); autoConfList->SetPopupOrigin(params.v);
@ -306,8 +306,8 @@ void ControlMappingScreen::KeyMapped(int pspkey) { // Notification to let us re
void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) { void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI; using namespace UI;
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
I18NCategory *mc = GetI18NCategory("MappableControls"); auto mc = GetI18NCategory("MappableControls");
std::string pspButtonName = KeyMap::GetPspButtonName(this->pspBtn_); std::string pspButtonName = KeyMap::GetPspButtonName(this->pspBtn_);
@ -334,7 +334,7 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) {
void KeyMappingNewMouseKeyDialog::CreatePopupContents(UI::ViewGroup *parent) { void KeyMappingNewMouseKeyDialog::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI; using namespace UI;
I18NCategory *km = GetI18NCategory("KeyMapping"); auto km = GetI18NCategory("KeyMapping");
parent->Add(new TextView(std::string(km->T("You can press ESC to cancel.")), new LinearLayoutParams(Margins(10, 0)))); parent->Add(new TextView(std::string(km->T("You can press ESC to cancel.")), new LinearLayoutParams(Margins(10, 0))));
} }
@ -544,7 +544,7 @@ bool AnalogTestScreen::axis(const AxisInput &axis) {
void AnalogTestScreen::CreateViews() { void AnalogTestScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
root_ = new LinearLayout(ORIENT_VERTICAL); root_ = new LinearLayout(ORIENT_VERTICAL);
@ -627,8 +627,8 @@ bool TouchTestScreen::touch(const TouchInput &touch) {
void TouchTestScreen::CreateViews() { void TouchTestScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
root_ = new LinearLayout(ORIENT_VERTICAL); root_ = new LinearLayout(ORIENT_VERTICAL);
LinearLayout *theTwo = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0f)); LinearLayout *theTwo = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0f));
root_->Add(theTwo); root_->Add(theTwo);

View file

@ -18,8 +18,9 @@
#pragma once #pragma once
#include <functional> #include <functional>
#include <vector> #include <memory>
#include <mutex> #include <mutex>
#include <vector>
#include "i18n/i18n.h" #include "i18n/i18n.h"
#include "ui/view.h" #include "ui/view.h"
@ -51,7 +52,7 @@ private:
class KeyMappingNewKeyDialog : public PopupScreen { class KeyMappingNewKeyDialog : public PopupScreen {
public: public:
explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, I18NCategory *i18n) explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n)
: PopupScreen(i18n->T("Map Key"), "Cancel", ""), callback_(callback), mapped_(false) { : PopupScreen(i18n->T("Map Key"), "Cancel", ""), callback_(callback), mapped_(false) {
pspBtn_ = btn; pspBtn_ = btn;
} }
@ -74,7 +75,7 @@ private:
class KeyMappingNewMouseKeyDialog : public PopupScreen { class KeyMappingNewMouseKeyDialog : public PopupScreen {
public: public:
explicit KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, I18NCategory *i18n) explicit KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n)
: PopupScreen(i18n->T("Map Mouse"), "", ""), callback_(callback), mapped_(false) { : PopupScreen(i18n->T("Map Mouse"), "", ""), callback_(callback), mapped_(false) {
pspBtn_ = btn; pspBtn_ = btn;
} }

View file

@ -79,8 +79,8 @@ void CwCheatScreen::CreateCodeList() {
void CwCheatScreen::CreateViews() { void CwCheatScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *cw = GetI18NCategory("CwCheats"); auto cw = GetI18NCategory("CwCheats");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
CreateCodeList(); CreateCodeList();
g_Config.bReloadCheats = true; g_Config.bReloadCheats = true;
root_ = new LinearLayout(ORIENT_HORIZONTAL); root_ = new LinearLayout(ORIENT_HORIZONTAL);

View file

@ -66,8 +66,8 @@ static const char *logLevelList[] = {
void DevMenu::CreatePopupContents(UI::ViewGroup *parent) { void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI; using namespace UI;
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)); ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f));
LinearLayout *items = new LinearLayout(ORIENT_VERTICAL); LinearLayout *items = new LinearLayout(ORIENT_VERTICAL);
@ -189,7 +189,7 @@ void LogScreen::update() {
void LogScreen::CreateViews() { void LogScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); LinearLayout *outer = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
root_ = outer; root_ = outer;
@ -223,8 +223,8 @@ UI::EventReturn LogScreen::OnSubmit(UI::EventParams &e) {
void LogConfigScreen::CreateViews() { void LogConfigScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
root_ = new ScrollView(ORIENT_VERTICAL); root_ = new ScrollView(ORIENT_VERTICAL);
@ -294,7 +294,7 @@ UI::EventReturn LogConfigScreen::OnLogLevelChange(UI::EventParams &e) {
} }
UI::EventReturn LogConfigScreen::OnLogLevel(UI::EventParams &e) { UI::EventReturn LogConfigScreen::OnLogLevel(UI::EventParams &e) {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
auto logLevelScreen = new LogLevelScreen(dev->T("Log Level")); auto logLevelScreen = new LogLevelScreen(dev->T("Log Level"));
logLevelScreen->OnChoice.Handle(this, &LogConfigScreen::OnLogLevelChange); logLevelScreen->OnChoice.Handle(this, &LogConfigScreen::OnLogLevelChange);
@ -364,8 +364,8 @@ static const JitDisableFlag jitDisableFlags[] = {
void JitDebugScreen::CreateViews() { void JitDebugScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
root_ = new ScrollView(ORIENT_VERTICAL); root_ = new ScrollView(ORIENT_VERTICAL);
@ -417,9 +417,9 @@ void SystemInfoScreen::CreateViews() {
using namespace UI; using namespace UI;
// NOTE: Do not translate this section. It will change a lot and will be impossible to keep up. // NOTE: Do not translate this section. It will change a lot and will be impossible to keep up.
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *si = GetI18NCategory("SysInfo"); auto si = GetI18NCategory("SysInfo");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f)); ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
@ -674,7 +674,7 @@ void SystemInfoScreen::CreateViews() {
void AddressPromptScreen::CreatePopupContents(UI::ViewGroup *parent) { void AddressPromptScreen::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI; using namespace UI;
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
addrView_ = new TextView(dev->T("Enter address"), ALIGN_HCENTER, false); addrView_ = new TextView(dev->T("Enter address"), ALIGN_HCENTER, false);
parent->Add(addrView_); parent->Add(addrView_);
@ -728,7 +728,7 @@ void AddressPromptScreen::BackspaceDigit() {
} }
void AddressPromptScreen::UpdatePreviewDigits() { void AddressPromptScreen::UpdatePreviewDigits() {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
if (addr_ != 0) { if (addr_ != 0) {
char temp[32]; char temp[32];
@ -761,8 +761,8 @@ bool AddressPromptScreen::key(const KeyInput &key) {
// Three panes: Block chooser, MIPS view, ARM/x86 view // Three panes: Block chooser, MIPS view, ARM/x86 view
void JitCompareScreen::CreateViews() { void JitCompareScreen::CreateViews() {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
using namespace UI; using namespace UI;
@ -807,7 +807,7 @@ void JitCompareScreen::UpdateDisasm() {
using namespace UI; using namespace UI;
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
JitBlockCacheDebugInterface *blockCacheDebug = MIPSComp::jit->GetBlockCacheDebugInterface(); JitBlockCacheDebugInterface *blockCacheDebug = MIPSComp::jit->GetBlockCacheDebugInterface();
@ -898,7 +898,7 @@ UI::EventReturn JitCompareScreen::OnShowStats(UI::EventParams &e) {
UI::EventReturn JitCompareScreen::OnSelectBlock(UI::EventParams &e) { UI::EventReturn JitCompareScreen::OnSelectBlock(UI::EventParams &e) {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
auto addressPrompt = new AddressPromptScreen(dev->T("Block address")); auto addressPrompt = new AddressPromptScreen(dev->T("Block address"));
addressPrompt->OnChoice.Handle(this, &JitCompareScreen::OnBlockAddress); addressPrompt->OnChoice.Handle(this, &JitCompareScreen::OnBlockAddress);
@ -1042,7 +1042,7 @@ struct { DebugShaderType type; const char *name; } shaderTypes[] = {
void ShaderListScreen::CreateViews() { void ShaderListScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
LinearLayout *layout = new LinearLayout(ORIENT_VERTICAL); LinearLayout *layout = new LinearLayout(ORIENT_VERTICAL);
root_ = layout; root_ = layout;
@ -1071,7 +1071,7 @@ UI::EventReturn ShaderListScreen::OnShaderClick(UI::EventParams &e) {
void ShaderViewScreen::CreateViews() { void ShaderViewScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
LinearLayout *layout = new LinearLayout(ORIENT_VERTICAL); LinearLayout *layout = new LinearLayout(ORIENT_VERTICAL);
root_ = layout; root_ = layout;

View file

@ -19,6 +19,7 @@
#include <functional> #include <functional>
#include <map> #include <map>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
@ -31,7 +32,7 @@
class DevMenu : public PopupScreen { class DevMenu : public PopupScreen {
public: public:
DevMenu(I18NCategory *i18n) : PopupScreen(i18n->T("Dev Tools")) {} DevMenu(std::shared_ptr<I18NCategory> i18n) : PopupScreen(i18n->T("Dev Tools")) {}
void CreatePopupContents(UI::ViewGroup *parent) override; void CreatePopupContents(UI::ViewGroup *parent) override;
void dialogFinished(const Screen *dialog, DialogResult result) override; void dialogFinished(const Screen *dialog, DialogResult result) override;

View file

@ -101,7 +101,7 @@ void Discord::SetPresenceGame(const char *gameTitle) {
} }
#ifdef ENABLE_DISCORD #ifdef ENABLE_DISCORD
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
DiscordRichPresence discordPresence{}; DiscordRichPresence discordPresence{};
discordPresence.state = gameTitle; discordPresence.state = gameTitle;
@ -127,7 +127,7 @@ void Discord::SetPresenceMenu() {
} }
#ifdef ENABLE_DISCORD #ifdef ENABLE_DISCORD
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
DiscordRichPresence discordPresence{}; DiscordRichPresence discordPresence{};
discordPresence.state = sc->T("In menu"); discordPresence.state = sc->T("In menu");

View file

@ -231,9 +231,9 @@ void DisplayLayoutScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
I18NCategory *co = GetI18NCategory("Controls"); auto co = GetI18NCategory("Controls");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));

View file

@ -95,7 +95,7 @@ extern bool g_TakeScreenshot;
static void __EmuScreenVblank() static void __EmuScreenVblank()
{ {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
if (frameStep_ && lastNumFlips != gpuStats.numFlips) if (frameStep_ && lastNumFlips != gpuStats.numFlips)
{ {
@ -192,7 +192,7 @@ void EmuScreen::bootGame(const std::string &filename) {
if (!bootAllowStorage(filename)) if (!bootAllowStorage(filename))
return; return;
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
invalid_ = true; invalid_ = true;
@ -267,17 +267,17 @@ void EmuScreen::bootGame(const std::string &filename) {
} }
if (PSP_CoreParameter().compat.flags().RequireBufferedRendering && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { if (PSP_CoreParameter().compat.flags().RequireBufferedRendering && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("BufferedRenderingRequired", "Warning: This game requires Rendering Mode to be set to Buffered."), 15.0f); host->NotifyUserMessage(gr->T("BufferedRenderingRequired", "Warning: This game requires Rendering Mode to be set to Buffered."), 15.0f);
} }
if (PSP_CoreParameter().compat.flags().RequireBlockTransfer && g_Config.bBlockTransferGPU == false) { if (PSP_CoreParameter().compat.flags().RequireBlockTransfer && g_Config.bBlockTransferGPU == false) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("BlockTransferRequired", "Warning: This game requires Simulate Block Transfer Mode to be set to On."), 15.0f); host->NotifyUserMessage(gr->T("BlockTransferRequired", "Warning: This game requires Simulate Block Transfer Mode to be set to On."), 15.0f);
} }
if (PSP_CoreParameter().compat.flags().RequireDefaultCPUClock && g_Config.iLockedCPUSpeed != 0) { if (PSP_CoreParameter().compat.flags().RequireDefaultCPUClock && g_Config.iLockedCPUSpeed != 0) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
host->NotifyUserMessage(gr->T("DefaultCPUClockRequired", "Warning: This game requires the CPU clock to be set to default."), 15.0f); host->NotifyUserMessage(gr->T("DefaultCPUClockRequired", "Warning: This game requires the CPU clock to be set to default."), 15.0f);
} }
@ -293,7 +293,7 @@ void EmuScreen::bootComplete() {
NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str()); NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str());
autoLoad(); autoLoad();
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
#ifndef MOBILE_DEVICE #ifndef MOBILE_DEVICE
if (g_Config.bFirstRun) { if (g_Config.bFirstRun) {
@ -318,7 +318,7 @@ void EmuScreen::bootComplete() {
#endif #endif
if (Core_GetPowerSaving()) { if (Core_GetPowerSaving()) {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
#ifdef __ANDROID__ #ifdef __ANDROID__
osm.Show(sy->T("WARNING: Android battery save mode is on"), 2.0f, 0xFFFFFF, -1, true, "core_powerSaving"); osm.Show(sy->T("WARNING: Android battery save mode is on"), 2.0f, 0xFFFFFF, -1, true, "core_powerSaving");
#else #else
@ -474,7 +474,7 @@ bool EmuScreen::touch(const TouchInput &touch) {
} }
void EmuScreen::onVKeyDown(int virtualKeyCode) { void EmuScreen::onVKeyDown(int virtualKeyCode) {
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
switch (virtualKeyCode) { switch (virtualKeyCode) {
case VIRTKEY_UNTHROTTLE: case VIRTKEY_UNTHROTTLE:
@ -635,7 +635,7 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) {
} }
void EmuScreen::onVKeyUp(int virtualKeyCode) { void EmuScreen::onVKeyUp(int virtualKeyCode) {
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
switch (virtualKeyCode) { switch (virtualKeyCode) {
case VIRTKEY_UNTHROTTLE: case VIRTKEY_UNTHROTTLE:
@ -959,8 +959,8 @@ protected:
void EmuScreen::CreateViews() { void EmuScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *sc = GetI18NCategory("Screen"); auto sc = GetI18NCategory("Screen");
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
const Bounds &bounds = screenManager()->getUIContext()->GetBounds(); const Bounds &bounds = screenManager()->getUIContext()->GetBounds();
InitPadLayout(bounds.w, bounds.h); InitPadLayout(bounds.w, bounds.h);
@ -1030,7 +1030,7 @@ void EmuScreen::CreateViews() {
} }
UI::EventReturn EmuScreen::OnDevTools(UI::EventParams &params) { UI::EventReturn EmuScreen::OnDevTools(UI::EventParams &params) {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
DevMenu *devMenu = new DevMenu(dev); DevMenu *devMenu = new DevMenu(dev);
if (params.v) if (params.v)
devMenu->SetPopupOrigin(params.v); devMenu->SetPopupOrigin(params.v);
@ -1072,7 +1072,7 @@ void EmuScreen::update() {
quit_ = true; quit_ = true;
return; return;
} }
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
std::string errLoadingFile = gamePath_ + "\n"; std::string errLoadingFile = gamePath_ + "\n";
errLoadingFile.append(err->T("Error loading file", "Could not load game")); errLoadingFile.append(err->T("Error loading file", "Could not load game"));
errLoadingFile.append(" "); errLoadingFile.append(" ");

View file

@ -78,8 +78,8 @@ GPUDriverTestScreen::~GPUDriverTestScreen() {
void GPUDriverTestScreen::CreateViews() { void GPUDriverTestScreen::CreateViews() {
// Don't bother with views for now. // Don't bother with views for now.
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *cr = GetI18NCategory("PSPCredits"); auto cr = GetI18NCategory("PSPCredits");
AnchorLayout *anchor = new AnchorLayout(); AnchorLayout *anchor = new AnchorLayout();
root_ = anchor; root_ = anchor;

View file

@ -50,9 +50,9 @@ void GameScreen::CreateViews() {
if (info && !info->id.empty()) if (info && !info->id.empty())
saveDirs = info->GetSaveDataDirectories(); // Get's very heavy, let's not do it in update() saveDirs = info->GetSaveDataDirectories(); // Get's very heavy, let's not do it in update()
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
I18NCategory *pa = GetI18NCategory("Pause"); auto pa = GetI18NCategory("Pause");
// Information in the top left. // Information in the top left.
// Back button to the bottom left. // Back button to the bottom left.
@ -176,8 +176,8 @@ void GameScreen::CallbackDeleteConfig(bool yes) {
UI::EventReturn GameScreen::OnDeleteConfig(UI::EventParams &e) UI::EventReturn GameScreen::OnDeleteConfig(UI::EventParams &e)
{ {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
screenManager()->push( screenManager()->push(
new PromptScreen(di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), new PromptScreen(di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"),
std::bind(&GameScreen::CallbackDeleteConfig, this, std::placeholders::_1))); std::bind(&GameScreen::CallbackDeleteConfig, this, std::placeholders::_1)));
@ -188,7 +188,7 @@ UI::EventReturn GameScreen::OnDeleteConfig(UI::EventParams &e)
void GameScreen::render() { void GameScreen::render() {
UIScreen::render(); UIScreen::render();
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
Draw::DrawContext *thin3d = screenManager()->getDrawContext(); Draw::DrawContext *thin3d = screenManager()->getDrawContext();
@ -277,8 +277,8 @@ UI::EventReturn GameScreen::OnGameSettings(UI::EventParams &e) {
} }
UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) { UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
if (info) { if (info) {
// Check that there's any savedata to delete // Check that there's any savedata to delete
@ -303,8 +303,8 @@ void GameScreen::CallbackDeleteSaveData(bool yes) {
} }
UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) { UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
if (info) { if (info) {
screenManager()->push( screenManager()->push(
@ -380,7 +380,7 @@ SetBackgroundPopupScreen::SetBackgroundPopupScreen(const std::string &title, con
} }
void SetBackgroundPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { void SetBackgroundPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
parent->Add(new UI::TextView(ga->T("One moment please..."), ALIGN_LEFT | ALIGN_VCENTER, false, new UI::LinearLayoutParams(UI::Margins(10, 0, 10, 10)))); parent->Add(new UI::TextView(ga->T("One moment please..."), ALIGN_LEFT | ALIGN_VCENTER, false, new UI::LinearLayoutParams(UI::Margins(10, 0, 10, 10))));
} }
@ -415,7 +415,7 @@ void SetBackgroundPopupScreen::update() {
} }
UI::EventReturn GameScreen::OnSetBackground(UI::EventParams &e) { UI::EventReturn GameScreen::OnSetBackground(UI::EventParams &e) {
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
// This popup is used to prevent any race condition: // This popup is used to prevent any race condition:
// g_gameInfoCache may take time to load the data, and a crash could happen if they exit before then. // g_gameInfoCache may take time to load the data, and a crash could happen if they exit before then.
SetBackgroundPopupScreen *pop = new SetBackgroundPopupScreen(ga->T("Setting Background"), gamePath_); SetBackgroundPopupScreen *pop = new SetBackgroundPopupScreen(ga->T("Setting Background"), gamePath_);

View file

@ -110,7 +110,7 @@ bool DoesBackendSupportHWTess() {
} }
static std::string PostShaderTranslateName(const char *value) { static std::string PostShaderTranslateName(const char *value) {
I18NCategory *ps = GetI18NCategory("PostShaders"); auto ps = GetI18NCategory("PostShaders");
const ShaderInfo *info = GetPostShaderInfo(value); const ShaderInfo *info = GetPostShaderInfo(value);
if (info) { if (info) {
return ps->T(value, info ? info->name.c_str() : value); return ps->T(value, info ? info->name.c_str() : value);
@ -149,16 +149,16 @@ void GameSettingsScreen::CreateViews() {
// Scrolling action menu to the right. // Scrolling action menu to the right.
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
I18NCategory *co = GetI18NCategory("Controls"); auto co = GetI18NCategory("Controls");
I18NCategory *a = GetI18NCategory("Audio"); auto a = GetI18NCategory("Audio");
I18NCategory *sa = GetI18NCategory("Savedata"); auto sa = GetI18NCategory("Savedata");
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
I18NCategory *n = GetI18NCategory("Networking"); auto n = GetI18NCategory("Networking");
I18NCategory *ms = GetI18NCategory("MainSettings"); auto ms = GetI18NCategory("MainSettings");
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
I18NCategory *ri = GetI18NCategory("RemoteISO"); auto ri = GetI18NCategory("RemoteISO");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
@ -291,7 +291,7 @@ void GameSettingsScreen::CreateViews() {
graphicsSettings->Add(new ItemHeader(gr->T("Features"))); graphicsSettings->Add(new ItemHeader(gr->T("Features")));
// Hide postprocess option on unsupported backends to avoid confusion. // Hide postprocess option on unsupported backends to avoid confusion.
if (GetGPUBackend() != GPUBackend::DIRECT3D9) { if (GetGPUBackend() != GPUBackend::DIRECT3D9) {
I18NCategory *ps = GetI18NCategory("PostShaders"); auto ps = GetI18NCategory("PostShaders");
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), &PostShaderTranslateName)); postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), &PostShaderTranslateName));
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader); postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
@ -871,7 +871,7 @@ void RecreateActivity() {
System_SendMessage("recreate", ""); System_SendMessage("recreate", "");
ILOG("Got back from recreate"); ILOG("Got back from recreate");
} else { } else {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
System_SendMessage("toast", gr->T("Must Restart", "You must restart PPSSPP for this change to take effect")); System_SendMessage("toast", gr->T("Must Restart", "You must restart PPSSPP for this change to take effect"));
} }
} }
@ -918,7 +918,7 @@ UI::EventReturn GameSettingsScreen::OnJitAffectingSetting(UI::EventParams &e) {
#if PPSSPP_PLATFORM(ANDROID) #if PPSSPP_PLATFORM(ANDROID)
UI::EventReturn GameSettingsScreen::OnChangeMemStickDir(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnChangeMemStickDir(UI::EventParams &e) {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
System_SendMessage("inputbox", (std::string(sy->T("Memory Stick Folder")) + ":" + g_Config.memStickDirectory).c_str()); System_SendMessage("inputbox", (std::string(sy->T("Memory Stick Folder")) + ":" + g_Config.memStickDirectory).c_str());
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
@ -956,7 +956,7 @@ UI::EventReturn GameSettingsScreen::OnSavePathMydoc(UI::EventParams &e) {
UI::EventReturn GameSettingsScreen::OnSavePathOther(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnSavePathOther(UI::EventParams &e) {
const std::string PPSSPPpath = File::GetExeDirectory(); const std::string PPSSPPpath = File::GetExeDirectory();
if (otherinstalled_) { if (otherinstalled_) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), di->T("Choose PPSSPP save folder")); std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), di->T("Choose PPSSPP save folder"));
if (folder.size()) { if (folder.size()) {
g_Config.memStickDirectory = folder; g_Config.memStickDirectory = folder;
@ -1085,8 +1085,8 @@ void GameSettingsScreen::onFinish(DialogResult result) {
void GameSettingsScreen::sendMessage(const char *message, const char *value) { void GameSettingsScreen::sendMessage(const char *message, const char *value) {
UIDialogScreenWithGameBackground::sendMessage(message, value); UIDialogScreenWithGameBackground::sendMessage(message, value);
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
if (!strcmp(message, "inputbox_completed")) { if (!strcmp(message, "inputbox_completed")) {
std::vector<std::string> inputboxValue; std::vector<std::string> inputboxValue;
@ -1121,7 +1121,7 @@ void GameSettingsScreen::sendMessage(const char *message, const char *value) {
#if PPSSPP_PLATFORM(ANDROID) #if PPSSPP_PLATFORM(ANDROID)
void GameSettingsScreen::CallbackMemstickFolder(bool yes) { void GameSettingsScreen::CallbackMemstickFolder(bool yes) {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
if (yes) { if (yes) {
std::string memstickDirFile = g_Config.internalDataDirectory + "/memstick_dir.txt"; std::string memstickDirFile = g_Config.internalDataDirectory + "/memstick_dir.txt";
@ -1177,7 +1177,7 @@ void GameSettingsScreen::CallbackRenderingDevice(bool yes) {
} }
UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
// It only makes sense to show the restart prompt if the backend was actually changed. // It only makes sense to show the restart prompt if the backend was actually changed.
if (g_Config.iGPUBackend != (int)GetGPUBackend()) { if (g_Config.iGPUBackend != (int)GetGPUBackend()) {
@ -1188,7 +1188,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) {
} }
UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
// It only makes sense to show the restart prompt if the device was actually changed. // It only makes sense to show the restart prompt if the device was actually changed.
std::string *deviceNameSetting = GPUDeviceNameSetting(); std::string *deviceNameSetting = GPUDeviceNameSetting();
@ -1205,7 +1205,7 @@ UI::EventReturn GameSettingsScreen::OnCameraDeviceChange(UI::EventParams& e) {
} }
UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnAudioDevice(UI::EventParams &e) {
I18NCategory *a = GetI18NCategory("Audio"); auto a = GetI18NCategory("Audio");
if (g_Config.sAudioDevice == a->T("Auto")) { if (g_Config.sAudioDevice == a->T("Auto")) {
g_Config.sAudioDevice.clear(); g_Config.sAudioDevice.clear();
} }
@ -1231,7 +1231,7 @@ UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) {
} }
UI::EventReturn GameSettingsScreen::OnChangeproAdhocServerAddress(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnChangeproAdhocServerAddress(UI::EventParams &e) {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
#if defined(__ANDROID__) #if defined(__ANDROID__)
System_SendMessage("inputbox", ("IP:" + g_Config.proAdhocServer).c_str()); System_SendMessage("inputbox", ("IP:" + g_Config.proAdhocServer).c_str());
@ -1254,7 +1254,7 @@ UI::EventReturn GameSettingsScreen::OnComboKey(UI::EventParams &e) {
} }
UI::EventReturn GameSettingsScreen::OnLanguage(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnLanguage(UI::EventParams &e) {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
auto langScreen = new NewLanguageScreen(dev->T("Language")); auto langScreen = new NewLanguageScreen(dev->T("Language"));
langScreen->OnChoice.Handle(this, &GameSettingsScreen::OnLanguageChange); langScreen->OnChoice.Handle(this, &GameSettingsScreen::OnLanguageChange);
if (e.v) if (e.v)
@ -1273,7 +1273,7 @@ UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {
} }
UI::EventReturn GameSettingsScreen::OnPostProcShader(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnPostProcShader(UI::EventParams &e) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader")); auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"));
procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange); procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange);
if (e.v) if (e.v)
@ -1337,11 +1337,11 @@ void DeveloperToolsScreen::CreateViews() {
settingsScroll->SetTag("DevToolsSettings"); settingsScroll->SetTag("DevToolsSettings");
root_->Add(settingsScroll); root_->Add(settingsScroll);
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
I18NCategory *a = GetI18NCategory("Audio"); auto a = GetI18NCategory("Audio");
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
AddStandardBack(root_); AddStandardBack(root_);
@ -1413,8 +1413,8 @@ void GameSettingsScreen::CallbackRestoreDefaults(bool yes) {
} }
UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
if (g_Config.bGameSpecific) if (g_Config.bGameSpecific)
{ {
screenManager()->push( screenManager()->push(
@ -1506,9 +1506,9 @@ void DeveloperToolsScreen::update() {
void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) { void HostnameSelectScreen::CreatePopupContents(UI::ViewGroup *parent) {
using namespace UI; using namespace UI;
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *n = GetI18NCategory("Networking"); auto n = GetI18NCategory("Networking");
LinearLayout *valueRow = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, Margins(0, 0, 0, 10))); LinearLayout *valueRow = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, Margins(0, 0, 0, 10)));

View file

@ -34,8 +34,8 @@ void InstallZipScreen::CreateViews() {
FileInfo fileInfo; FileInfo fileInfo;
bool success = getFileInfo(zipPath_.c_str(), &fileInfo); bool success = getFileInfo(zipPath_.c_str(), &fileInfo);
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *iz = GetI18NCategory("InstallZip"); auto iz = GetI18NCategory("InstallZip");
Margins actionMenuMargins(0, 100, 15, 0); Margins actionMenuMargins(0, 100, 15, 0);
@ -106,7 +106,7 @@ UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams &params) {
} }
void InstallZipScreen::update() { void InstallZipScreen::update() {
I18NCategory *iz = GetI18NCategory("InstallZip"); auto iz = GetI18NCategory("InstallZip");
using namespace UI; using namespace UI;
if (g_GameManager.GetState() != GameManagerState::IDLE) { if (g_GameManager.GetState() != GameManagerState::IDLE) {

View file

@ -523,7 +523,7 @@ void GameBrowser::Refresh() {
Clear(); Clear();
Add(new Spacer(1.0f)); Add(new Spacer(1.0f));
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
// No topbar on recent screen // No topbar on recent screen
if (DisplayTopBar()) { if (DisplayTopBar()) {
@ -777,7 +777,7 @@ void MainScreen::CreateViews() {
bool vertical = UseVerticalLayout(); bool vertical = UseVerticalLayout();
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
Margins actionMenuMargins(0, 10, 10, 0); Margins actionMenuMargins(0, 10, 10, 0);
@ -954,7 +954,7 @@ void MainScreen::CreateViews() {
root_->SetDefaultFocusView(tabHolder_); root_->SetDefaultFocusView(tabHolder_);
} }
I18NCategory *u = GetI18NCategory("Upgrade"); auto u = GetI18NCategory("Upgrade");
upgradeBar_ = 0; upgradeBar_ = 0;
if (!g_Config.upgradeMessage.empty()) { if (!g_Config.upgradeMessage.empty()) {
@ -1255,8 +1255,8 @@ void MainScreen::dialogFinished(const Screen *dialog, DialogResult result) {
void UmdReplaceScreen::CreateViews() { void UmdReplaceScreen::CreateViews() {
using namespace UI; using namespace UI;
Margins actionMenuMargins(0, 100, 15, 0); Margins actionMenuMargins(0, 100, 15, 0);
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0)); TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0));
leftColumn->SetTag("UmdReplace"); leftColumn->SetTag("UmdReplace");

View file

@ -183,7 +183,7 @@ void HandleCommonMessages(const char *message, const char *value, ScreenManager
UpdateUIState(UISTATE_MENU); UpdateUIState(UISTATE_MENU);
manager->push(new GameSettingsScreen("")); manager->push(new GameSettingsScreen(""));
} else if (!strcmp(message, "language screen") && isActiveScreen) { } else if (!strcmp(message, "language screen") && isActiveScreen) {
I18NCategory *dev = GetI18NCategory("Developer"); auto dev = GetI18NCategory("Developer");
auto langScreen = new NewLanguageScreen(dev->T("Language")); auto langScreen = new NewLanguageScreen(dev->T("Language"));
langScreen->OnChoice.Add([](UI::EventParams &) { langScreen->OnChoice.Add([](UI::EventParams &) {
NativeMessageReceived("recreateviews", ""); NativeMessageReceived("recreateviews", "");
@ -247,7 +247,7 @@ void UIDialogScreenWithBackground::DrawBackground(UIContext &dc) {
void UIDialogScreenWithBackground::AddStandardBack(UI::ViewGroup *parent) { void UIDialogScreenWithBackground::AddStandardBack(UI::ViewGroup *parent) {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
parent->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack); parent->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
} }
@ -257,7 +257,7 @@ void UIDialogScreenWithBackground::sendMessage(const char *message, const char *
PromptScreen::PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function<void(bool)> callback) PromptScreen::PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function<void(bool)> callback)
: message_(message), callback_(callback) { : message_(message), callback_(callback) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
yesButtonText_ = di->T(yesButtonText.c_str()); yesButtonText_ = di->T(yesButtonText.c_str());
noButtonText_ = di->T(noButtonText.c_str()); noButtonText_ = di->T(noButtonText.c_str());
} }
@ -303,7 +303,7 @@ void PromptScreen::TriggerFinish(DialogResult result) {
} }
PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title) { PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title) {
I18NCategory *ps = GetI18NCategory("PostShaders"); auto ps = GetI18NCategory("PostShaders");
ReloadAllPostShaderInfo(); ReloadAllPostShaderInfo();
shaders_ = GetAllPostShaderInfo(); shaders_ = GetAllPostShaderInfo();
std::vector<std::string> items; std::vector<std::string> items;
@ -487,8 +487,8 @@ void LogoScreen::render() {
::DrawBackground(dc, alpha); ::DrawBackground(dc, alpha);
I18NCategory *cr = GetI18NCategory("PSPCredits"); auto cr = GetI18NCategory("PSPCredits");
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
char temp[256]; char temp[256];
// Manually formatting UTF-8 is fun. \xXX doesn't work everywhere. // Manually formatting UTF-8 is fun. \xXX doesn't work everywhere.
snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5); snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5);
@ -518,8 +518,8 @@ void LogoScreen::render() {
void CreditsScreen::CreateViews() { void CreditsScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *cr = GetI18NCategory("PSPCredits"); auto cr = GetI18NCategory("PSPCredits");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
Button *back = root_->Add(new Button(di->T("Back"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, 10, false))); Button *back = root_->Add(new Button(di->T("Back"), new AnchorLayoutParams(260, 64, NONE, NONE, 10, 10, false)));
@ -589,7 +589,7 @@ UI::EventReturn CreditsScreen::OnDiscord(UI::EventParams &e) {
} }
UI::EventReturn CreditsScreen::OnShare(UI::EventParams &e) { UI::EventReturn CreditsScreen::OnShare(UI::EventParams &e) {
I18NCategory *cr = GetI18NCategory("PSPCredits"); auto cr = GetI18NCategory("PSPCredits");
System_SendMessage("sharetext", cr->T("CheckOutPPSSPP", "Check out PPSSPP, the awesome PSP emulator: http://www.ppsspp.org/")); System_SendMessage("sharetext", cr->T("CheckOutPPSSPP", "Check out PPSSPP, the awesome PSP emulator: http://www.ppsspp.org/"));
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
@ -608,7 +608,7 @@ void CreditsScreen::update() {
void CreditsScreen::render() { void CreditsScreen::render() {
UIScreen::render(); UIScreen::render();
I18NCategory *cr = GetI18NCategory("PSPCredits"); auto cr = GetI18NCategory("PSPCredits");
std::string specialthanksMaxim = "Maxim "; std::string specialthanksMaxim = "Maxim ";
specialthanksMaxim += cr->T("specialthanksMaxim", "for his amazing Atrac3+ decoder work"); specialthanksMaxim += cr->T("specialthanksMaxim", "for his amazing Atrac3+ decoder work");

View file

@ -661,7 +661,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
} }
I18NCategory *des = GetI18NCategory("DesktopUI"); auto des = GetI18NCategory("DesktopUI");
// Note to translators: do not translate this/add this to PPSSPP-lang's files. // Note to translators: do not translate this/add this to PPSSPP-lang's files.
// It's intended to be custom for every user. // It's intended to be custom for every user.
// Only add it to your own personal copies of PPSSPP. // Only add it to your own personal copies of PPSSPP.
@ -956,7 +956,7 @@ void TakeScreenshot() {
if (success) { if (success) {
osm.Show(filename); osm.Show(filename);
} else { } else {
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
osm.Show(err->T("Could not save screenshot file")); osm.Show(err->T("Could not save screenshot file"));
} }
} }
@ -1105,7 +1105,7 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
UIBackgroundInit(*uiContext); UIBackgroundInit(*uiContext);
} }
if (msg == "savestate_displayslot") { if (msg == "savestate_displayslot") {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1); std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1);
// Show for the same duration as the preview. // Show for the same duration as the preview.
osm.Show(msg, 2.0f, 0xFFFFFF, -1, true, "savestate_slot"); osm.Show(msg, 2.0f, 0xFFFFFF, -1, true, "savestate_slot");
@ -1119,7 +1119,7 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
} }
if (msg == "core_powerSaving") { if (msg == "core_powerSaving") {
if (value != "false") { if (value != "false") {
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
#ifdef __ANDROID__ #ifdef __ANDROID__
osm.Show(sy->T("WARNING: Android battery save mode is on"), 2.0f, 0xFFFFFF, -1, true, "core_powerSaving"); osm.Show(sy->T("WARNING: Android battery save mode is on"), 2.0f, 0xFFFFFF, -1, true, "core_powerSaving");
#else #else

View file

@ -16,6 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <algorithm> #include <algorithm>
#include <memory>
#include "i18n/i18n.h" #include "i18n/i18n.h"
#include "gfx_es2/draw_buffer.h" #include "gfx_es2/draw_buffer.h"
#include "ui/view.h" #include "ui/view.h"
@ -155,7 +156,7 @@ void AsyncImageFileView::Draw(UIContext &dc) {
class ScreenshotViewScreen : public PopupScreen { class ScreenshotViewScreen : public PopupScreen {
public: public:
ScreenshotViewScreen(std::string filename, std::string title, int slot, I18NCategory *i18n) ScreenshotViewScreen(std::string filename, std::string title, int slot, std::shared_ptr<I18NCategory> i18n)
: PopupScreen(title, i18n->T("Load State"), "Back"), filename_(filename), slot_(slot) {} // PopupScreen will translate Back on its own : PopupScreen(title, i18n->T("Load State"), "Back"), filename_(filename), slot_(slot) {} // PopupScreen will translate Back on its own
int GetSlot() const { int GetSlot() const {
@ -232,7 +233,7 @@ SaveSlotView::SaveSlotView(const std::string &gameFilename, int slot, UI::Layout
AsyncImageFileView *fv = Add(new AsyncImageFileView(screenshotFilename_, IS_DEFAULT, wq, new UI::LayoutParams(82 * 2, 47 * 2))); AsyncImageFileView *fv = Add(new AsyncImageFileView(screenshotFilename_, IS_DEFAULT, wq, new UI::LayoutParams(82 * 2, 47 * 2)));
fv->SetOverlayText(StringFromFormat("%d", slot_ + 1)); fv->SetOverlayText(StringFromFormat("%d", slot_ + 1));
I18NCategory *pa = GetI18NCategory("Pause"); auto pa = GetI18NCategory("Pause");
LinearLayout *buttons = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)); LinearLayout *buttons = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT));
buttons->SetSpacing(2.0); buttons->SetSpacing(2.0);
@ -321,8 +322,8 @@ void GamePauseScreen::CreateViews() {
using namespace UI; using namespace UI;
Margins scrollMargins(0, 20, 0, 0); Margins scrollMargins(0, 20, 0, 0);
Margins actionMenuMargins(0, 20, 15, 0); Margins actionMenuMargins(0, 20, 15, 0);
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
I18NCategory *pa = GetI18NCategory("Pause"); auto pa = GetI18NCategory("Pause");
root_ = new LinearLayout(ORIENT_HORIZONTAL); root_ = new LinearLayout(ORIENT_HORIZONTAL);
@ -377,12 +378,12 @@ void GamePauseScreen::CreateViews() {
// TODO, also might be nice to show overall compat rating here? // TODO, also might be nice to show overall compat rating here?
// Based on their platform or even cpu/gpu/config. Would add an API for it. // Based on their platform or even cpu/gpu/config. Would add an API for it.
if (Reporting::IsSupported() && g_paramSFO.GetValueString("DISC_ID").size()) { if (Reporting::IsSupported() && g_paramSFO.GetValueString("DISC_ID").size()) {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
rightColumnItems->Add(new Choice(rp->T("ReportButton", "Report Feedback")))->OnClick.Handle(this, &GamePauseScreen::OnReportFeedback); rightColumnItems->Add(new Choice(rp->T("ReportButton", "Report Feedback")))->OnClick.Handle(this, &GamePauseScreen::OnReportFeedback);
} }
rightColumnItems->Add(new Spacer(25.0)); rightColumnItems->Add(new Spacer(25.0));
if (g_Config.bPauseMenuExitsEmulator) { if (g_Config.bPauseMenuExitsEmulator) {
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
rightColumnItems->Add(new Choice(mm->T("Exit")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); rightColumnItems->Add(new Choice(mm->T("Exit")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu);
} else { } else {
rightColumnItems->Add(new Choice(pa->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); rightColumnItems->Add(new Choice(pa->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu);
@ -421,7 +422,7 @@ UI::EventReturn GamePauseScreen::OnScreenshotClicked(UI::EventParams &e) {
if (SaveState::HasSaveInSlot(gamePath_, slot)) { if (SaveState::HasSaveInSlot(gamePath_, slot)) {
std::string fn = v->GetScreenshotFilename(); std::string fn = v->GetScreenshotFilename();
std::string title = v->GetScreenshotTitle(); std::string title = v->GetScreenshotTitle();
I18NCategory *pa = GetI18NCategory("Pause"); auto pa = GetI18NCategory("Pause");
Screen *screen = new ScreenshotViewScreen(fn, title, v->GetSlot(), pa); Screen *screen = new ScreenshotViewScreen(fn, title, v->GetSlot(), pa);
screenManager()->push(screen); screenManager()->push(screen);
} }
@ -487,8 +488,8 @@ UI::EventReturn GamePauseScreen::OnCreateConfig(UI::EventParams &e)
UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e) UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e)
{ {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ga = GetI18NCategory("Game"); auto ga = GetI18NCategory("Game");
screenManager()->push( screenManager()->push(
new PromptScreen(di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), new PromptScreen(di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"),
std::bind(&GamePauseScreen::CallbackDeleteConfig, this, std::placeholders::_1))); std::bind(&GamePauseScreen::CallbackDeleteConfig, this, std::placeholders::_1)));

View file

@ -181,8 +181,8 @@ void RemoteISOScreen::update() {
} }
void RemoteISOScreen::CreateViews() { void RemoteISOScreen::CreateViews() {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ri = GetI18NCategory("RemoteISO"); auto ri = GetI18NCategory("RemoteISO");
Margins actionMenuMargins(0, 20, 15, 0); Margins actionMenuMargins(0, 20, 15, 0);
Margins contentMargins(0, 20, 5, 5); Margins contentMargins(0, 20, 5, 5);
@ -276,8 +276,8 @@ RemoteISOConnectScreen::~RemoteISOConnectScreen() {
} }
void RemoteISOConnectScreen::CreateViews() { void RemoteISOConnectScreen::CreateViews() {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ri = GetI18NCategory("RemoteISO"); auto ri = GetI18NCategory("RemoteISO");
Margins actionMenuMargins(0, 20, 15, 0); Margins actionMenuMargins(0, 20, 15, 0);
Margins contentMargins(0, 20, 5, 5); Margins contentMargins(0, 20, 5, 5);
@ -300,7 +300,7 @@ void RemoteISOConnectScreen::CreateViews() {
} }
void RemoteISOConnectScreen::update() { void RemoteISOConnectScreen::update() {
I18NCategory *ri = GetI18NCategory("RemoteISO"); auto ri = GetI18NCategory("RemoteISO");
UIScreenWithBackground::update(); UIScreenWithBackground::update();
@ -412,8 +412,8 @@ RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::
void RemoteISOBrowseScreen::CreateViews() { void RemoteISOBrowseScreen::CreateViews() {
bool vertical = UseVerticalLayout(); bool vertical = UseVerticalLayout();
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *ri = GetI18NCategory("RemoteISO"); auto ri = GetI18NCategory("RemoteISO");
Margins actionMenuMargins(0, 10, 10, 0); Margins actionMenuMargins(0, 10, 10, 0);
@ -478,7 +478,7 @@ void RemoteISOSettingsScreen::update() {
} }
void RemoteISOSettingsScreen::CreateViews() { void RemoteISOSettingsScreen::CreateViews() {
I18NCategory *ri = GetI18NCategory("RemoteISO"); auto ri = GetI18NCategory("RemoteISO");
ViewGroup *remoteisoSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *remoteisoSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
remoteisoSettingsScroll->SetTag("RemoteISOSettings"); remoteisoSettingsScroll->SetTag("RemoteISOSettings");

View file

@ -66,7 +66,7 @@ RatingChoice::RatingChoice(const char *captionKey, int *value, LayoutParams *lay
: LinearLayout(ORIENT_VERTICAL, layoutParams), value_(value) { : LinearLayout(ORIENT_VERTICAL, layoutParams), value_(value) {
SetSpacing(0.0f); SetSpacing(0.0f);
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
group_ = new LinearLayout(ORIENT_HORIZONTAL); group_ = new LinearLayout(ORIENT_HORIZONTAL);
Add(new TextView(rp->T(captionKey), FLAG_WRAP_TEXT, false))->SetShadow(true); Add(new TextView(rp->T(captionKey), FLAG_WRAP_TEXT, false))->SetShadow(true);
Add(group_); Add(group_);
@ -98,7 +98,7 @@ RatingChoice *RatingChoice::SetEnabledPtr(bool *ptr) {
} }
void RatingChoice::SetupChoices() { void RatingChoice::SetupChoices() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
AddChoice(0, rp->T("Bad")); AddChoice(0, rp->T("Bad"));
AddChoice(1, rp->T("OK")); AddChoice(1, rp->T("OK"));
AddChoice(2, rp->T("Great")); AddChoice(2, rp->T("Great"));
@ -146,7 +146,7 @@ CompatRatingChoice::CompatRatingChoice(const char *captionKey, int *value, Layou
} }
void CompatRatingChoice::SetupChoices() { void CompatRatingChoice::SetupChoices() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
group_->Clear(); group_->Clear();
AddChoice(0, rp->T("Perfect")); AddChoice(0, rp->T("Perfect"));
AddChoice(1, rp->T("Plays")); AddChoice(1, rp->T("Plays"));
@ -219,9 +219,9 @@ EventReturn ReportScreen::HandleReportingChange(EventParams &e) {
} }
void ReportScreen::CreateViews() { void ReportScreen::CreateViews() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *sy = GetI18NCategory("System"); auto sy = GetI18NCategory("System");
Margins actionMenuMargins(0, 20, 15, 0); Margins actionMenuMargins(0, 20, 15, 0);
Margins contentMargins(0, 20, 5, 5); Margins contentMargins(0, 20, 5, 5);
@ -301,7 +301,7 @@ void ReportScreen::UpdateSubmit() {
} }
void ReportScreen::UpdateOverallDescription() { void ReportScreen::UpdateOverallDescription() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
const char *desc; const char *desc;
uint32_t c = 0xFFFFFFFF; uint32_t c = 0xFFFFFFFF;
switch (overall_) { switch (overall_) {
@ -351,8 +351,8 @@ ReportFinishScreen::ReportFinishScreen(const std::string &gamePath, ReportingOve
} }
void ReportFinishScreen::CreateViews() { void ReportFinishScreen::CreateViews() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
Margins actionMenuMargins(0, 20, 15, 0); Margins actionMenuMargins(0, 20, 15, 0);
Margins contentMargins(0, 20, 5, 5); Margins contentMargins(0, 20, 5, 5);
@ -386,7 +386,7 @@ void ReportFinishScreen::CreateViews() {
} }
void ReportFinishScreen::update() { void ReportFinishScreen::update() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
if (!setStatus_) { if (!setStatus_) {
Reporting::ReportStatus status = Reporting::GetStatus(); Reporting::ReportStatus status = Reporting::GetStatus();
@ -412,7 +412,7 @@ void ReportFinishScreen::update() {
} }
void ReportFinishScreen::ShowSuggestions() { void ReportFinishScreen::ShowSuggestions() {
I18NCategory *rp = GetI18NCategory("Reporting"); auto rp = GetI18NCategory("Reporting");
auto suggestions = Reporting::CompatibilitySuggestions(); auto suggestions = Reporting::CompatibilitySuggestions();
if (score_ == ReportingOverallScore::PERFECT || score_ == ReportingOverallScore::PLAYABLE) { if (score_ == ReportingOverallScore::PERFECT || score_ == ReportingOverallScore::PLAYABLE) {

View file

@ -80,7 +80,7 @@ public:
LinearLayout *toprow = new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT)); LinearLayout *toprow = new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
content->Add(toprow); content->Add(toprow);
I18NCategory *sa = GetI18NCategory("Savedata"); auto sa = GetI18NCategory("Savedata");
if (ginfo->fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY) { if (ginfo->fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY) {
std::string savedata_detail = ginfo->paramSFO.GetValueString("SAVEDATA_DETAIL"); std::string savedata_detail = ginfo->paramSFO.GetValueString("SAVEDATA_DETAIL");
std::string savedata_title = ginfo->paramSFO.GetValueString("SAVEDATA_TITLE"); std::string savedata_title = ginfo->paramSFO.GetValueString("SAVEDATA_TITLE");
@ -108,7 +108,7 @@ public:
content->Add(new TextView(GetFileDateAsString(savePath_), 0, true, new LinearLayoutParams(Margins(10, 5))))->SetTextColor(textStyle.fgColor); content->Add(new TextView(GetFileDateAsString(savePath_), 0, true, new LinearLayoutParams(Margins(10, 5))))->SetTextColor(textStyle.fgColor);
} }
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
LinearLayout *buttons = new LinearLayout(ORIENT_HORIZONTAL); LinearLayout *buttons = new LinearLayout(ORIENT_HORIZONTAL);
buttons->Add(new Button(di->T("Back"), new LinearLayoutParams(1.0)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack); buttons->Add(new Button(di->T("Back"), new LinearLayoutParams(1.0)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
buttons->Add(new Button(di->T("Delete"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &SavedataPopupScreen::OnDeleteButtonClick); buttons->Add(new Button(di->T("Delete"), new LinearLayoutParams(1.0)))->OnClick.Handle(this, &SavedataPopupScreen::OnDeleteButtonClick);
@ -394,8 +394,8 @@ void SavedataBrowser::Refresh() {
Clear(); Clear();
Add(new Spacer(1.0f)); Add(new Spacer(1.0f));
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
I18NCategory *sa = GetI18NCategory("Savedata"); auto sa = GetI18NCategory("Savedata");
SortedLinearLayout *gl = new SortedLinearLayout(UI::ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); SortedLinearLayout *gl = new SortedLinearLayout(UI::ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
gl->SetSpacing(4.0f); gl->SetSpacing(4.0f);
@ -458,8 +458,8 @@ SavedataScreen::~SavedataScreen() {
void SavedataScreen::CreateViews() { void SavedataScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *sa = GetI18NCategory("Savedata"); auto sa = GetI18NCategory("Savedata");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
std::string savedata_dir = GetSysDirectory(DIRECTORY_SAVEDATA); std::string savedata_dir = GetSysDirectory(DIRECTORY_SAVEDATA);
std::string savestate_dir = GetSysDirectory(DIRECTORY_SAVESTATE); std::string savestate_dir = GetSysDirectory(DIRECTORY_SAVESTATE);

View file

@ -240,8 +240,8 @@ void ProductView::CreateViews() {
Add(new TextView(entry_.name)); Add(new TextView(entry_.name));
Add(new TextView(entry_.author)); Add(new TextView(entry_.author));
I18NCategory *st = GetI18NCategory("Store"); auto st = GetI18NCategory("Store");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
wasInstalled_ = IsGameInstalled(); wasInstalled_ = IsGameInstalled();
if (!wasInstalled_) { if (!wasInstalled_) {
installButton_ = Add(new Button(st->T("Install"))); installButton_ = Add(new Button(st->T("Install")));
@ -431,8 +431,8 @@ void StoreScreen::CreateViews() {
root_ = new LinearLayout(ORIENT_VERTICAL); root_ = new LinearLayout(ORIENT_VERTICAL);
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *st = GetI18NCategory("Store"); auto st = GetI18NCategory("Store");
// Top bar // Top bar
LinearLayout *topBar = root_->Add(new LinearLayout(ORIENT_HORIZONTAL)); LinearLayout *topBar = root_->Add(new LinearLayout(ORIENT_HORIZONTAL));

View file

@ -23,8 +23,8 @@
void TiltAnalogSettingsScreen::CreateViews() { void TiltAnalogSettingsScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *co = GetI18NCategory("Controls"); auto co = GetI18NCategory("Controls");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
root_ = new ScrollView(ORIENT_VERTICAL); root_ = new ScrollView(ORIENT_VERTICAL);
root_->SetTag("TiltAnalogSettings"); root_->SetTag("TiltAnalogSettings");

View file

@ -356,8 +356,8 @@ void TouchControlLayoutScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *co = GetI18NCategory("Controls"); auto co = GetI18NCategory("Controls");
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
@ -395,7 +395,7 @@ void TouchControlLayoutScreen::CreateViews() {
// serves no other purpose. // serves no other purpose.
AnchorLayout *controlsHolder = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); AnchorLayout *controlsHolder = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
I18NCategory *ms = GetI18NCategory("MainSettings"); auto ms = GetI18NCategory("MainSettings");
//tabHolder->AddTab(ms->T("Controls"), controlsHolder); //tabHolder->AddTab(ms->T("Controls"), controlsHolder);

View file

@ -42,8 +42,8 @@ private:
void TouchControlVisibilityScreen::CreateViews() { void TouchControlVisibilityScreen::CreateViews() {
using namespace UI; using namespace UI;
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
I18NCategory *co = GetI18NCategory("Controls"); auto co = GetI18NCategory("Controls");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
@ -91,7 +91,7 @@ void TouchControlVisibilityScreen::CreateViews() {
toggles_.push_back({ "Alt speed 2", &g_Config.touchSpeed2Key.show, -1 }); toggles_.push_back({ "Alt speed 2", &g_Config.touchSpeed2Key.show, -1 });
toggles_.push_back({ "Rapid Fire", &g_Config.touchRapidFireKey.show, -1 }); toggles_.push_back({ "Rapid Fire", &g_Config.touchRapidFireKey.show, -1 });
I18NCategory *mc = GetI18NCategory("MappableControls"); auto mc = GetI18NCategory("MappableControls");
for (auto toggle : toggles_) { for (auto toggle : toggles_) {
LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));

View file

@ -135,7 +135,7 @@ void MainThreadFunc() {
if (g_Config.sFailedGPUBackends.find("ALL") != std::string::npos) { if (g_Config.sFailedGPUBackends.find("ALL") != std::string::npos) {
Reporting::ReportMessage("Graphics init error: %s", "ALL"); Reporting::ReportMessage("Graphics init error: %s", "ALL");
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
const char *defaultErrorAll = "Failed initializing any graphics. Try upgrading your graphics drivers."; const char *defaultErrorAll = "Failed initializing any graphics. Try upgrading your graphics drivers.";
const char *genericError = err->T("GenericAllGraphicsError", defaultErrorAll); const char *genericError = err->T("GenericAllGraphicsError", defaultErrorAll);
std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error")); std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error"));
@ -163,7 +163,7 @@ void MainThreadFunc() {
W32Util::ExitAndRestart(); W32Util::ExitAndRestart();
} }
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
Reporting::ReportMessage("Graphics init error: %s", error_string.c_str()); Reporting::ReportMessage("Graphics init error: %s", error_string.c_str());
const char *defaultErrorVulkan = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to OpenGL?\n\nError message:"; const char *defaultErrorVulkan = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to OpenGL?\n\nError message:";

View file

@ -142,7 +142,7 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
if (FAILED(hr)) { if (FAILED(hr)) {
const char *defaultError = "Your GPU does not appear to support Direct3D 11.\n\nWould you like to try again using Direct3D 9 instead?"; const char *defaultError = "Your GPU does not appear to support Direct3D 11.\n\nWould you like to try again using Direct3D 9 instead?";
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
std::wstring error; std::wstring error;

View file

@ -236,7 +236,7 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) {
// GL_VERSION GL_VENDOR GL_RENDERER // GL_VERSION GL_VENDOR GL_RENDERER
// "1.4.0 - Build 8.14.10.2364" "intel" intel Pineview Platform // "1.4.0 - Build 8.14.10.2364" "intel" intel Pineview Platform
I18NCategory *err = GetI18NCategory("Error"); auto err = GetI18NCategory("Error");
std::string glVersion = (const char *)glGetString(GL_VERSION); std::string glVersion = (const char *)glGetString(GL_VERSION);
std::string glRenderer = (const char *)glGetString(GL_RENDERER); std::string glRenderer = (const char *)glGetString(GL_RENDERER);

View file

@ -125,7 +125,7 @@ namespace MainWindow {
} }
void CreateHelpMenu(HMENU menu) { void CreateHelpMenu(HMENU menu) {
I18NCategory *des = GetI18NCategory("DesktopUI"); auto des = GetI18NCategory("DesktopUI");
const std::wstring visitMainWebsite = ConvertUTF8ToWString(des->T("www.ppsspp.org")); const std::wstring visitMainWebsite = ConvertUTF8ToWString(des->T("www.ppsspp.org"));
const std::wstring visitForum = ConvertUTF8ToWString(des->T("PPSSPP Forums")); const std::wstring visitForum = ConvertUTF8ToWString(des->T("PPSSPP Forums"));
@ -171,7 +171,7 @@ namespace MainWindow {
return false; return false;
} }
I18NCategory *ps = GetI18NCategory("PostShaders"); auto ps = GetI18NCategory("PostShaders");
HMENU shaderMenu = GetSubmenuById(menu, ID_OPTIONS_SHADER_MENU); HMENU shaderMenu = GetSubmenuById(menu, ID_OPTIONS_SHADER_MENU);
EmptySubMenu(shaderMenu); EmptySubMenu(shaderMenu);
@ -202,7 +202,7 @@ namespace MainWindow {
} }
static void TranslateMenuItem(const HMENU hMenu, const int menuID, const std::wstring& accelerator = L"", const char *key = nullptr) { static void TranslateMenuItem(const HMENU hMenu, const int menuID, const std::wstring& accelerator = L"", const char *key = nullptr) {
I18NCategory *des = GetI18NCategory("DesktopUI"); auto des = GetI18NCategory("DesktopUI");
std::wstring translated; std::wstring translated;
if (key == nullptr || !strcmp(key, "")) { if (key == nullptr || !strcmp(key, "")) {
@ -474,7 +474,7 @@ namespace MainWindow {
} }
static void setRenderingMode(int mode) { static void setRenderingMode(int mode) {
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
g_Config.iRenderingMode = mode; g_Config.iRenderingMode = mode;
switch (g_Config.iRenderingMode) { switch (g_Config.iRenderingMode) {
@ -499,7 +499,7 @@ namespace MainWindow {
g_Config.iFrameSkip = FRAMESKIP_OFF; g_Config.iFrameSkip = FRAMESKIP_OFF;
} }
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
std::ostringstream messageStream; std::ostringstream messageStream;
messageStream << gr->T("Frame Skipping") << ":" << " "; messageStream << gr->T("Frame Skipping") << ":" << " ";
@ -519,7 +519,7 @@ namespace MainWindow {
g_Config.iFrameSkipType = 0; g_Config.iFrameSkipType = 0;
} }
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
std::ostringstream messageStream; std::ostringstream messageStream;
messageStream << gr->T("Frame Skipping Type") << ":" << " "; messageStream << gr->T("Frame Skipping Type") << ":" << " ";
@ -553,7 +553,7 @@ namespace MainWindow {
void MainWindowMenu_Process(HWND hWnd, WPARAM wParam) { void MainWindowMenu_Process(HWND hWnd, WPARAM wParam) {
std::string fn; std::string fn;
I18NCategory *gr = GetI18NCategory("Graphics"); auto gr = GetI18NCategory("Graphics");
int wmId = LOWORD(wParam); int wmId = LOWORD(wParam);
int wmEvent = HIWORD(wParam); int wmEvent = HIWORD(wParam);

View file

@ -297,7 +297,7 @@ void System_SendMessage(const char *command, const char *parameter) {
} else if (!strcmp(command, "browse_file")) { } else if (!strcmp(command, "browse_file")) {
MainWindow::BrowseAndBoot(""); MainWindow::BrowseAndBoot("");
} else if (!strcmp(command, "browse_folder")) { } else if (!strcmp(command, "browse_folder")) {
I18NCategory *mm = GetI18NCategory("MainMenu"); auto mm = GetI18NCategory("MainMenu");
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), mm->T("Choose folder")); std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), mm->T("Choose folder"));
if (folder.size()) if (folder.size())
NativeMessageReceived("browse_folderSelect", folder.c_str()); NativeMessageReceived("browse_folderSelect", folder.c_str());

View file

@ -15,7 +15,7 @@ std::string I18NRepo::LanguageID() {
void I18NRepo::Clear() { void I18NRepo::Clear() {
for (auto iter = cats_.begin(); iter != cats_.end(); ++iter) { for (auto iter = cats_.begin(); iter != cats_.end(); ++iter) {
delete iter->second; iter->second.reset();
} }
cats_.clear(); cats_.clear();
} }
@ -52,14 +52,14 @@ void I18NCategory::SetMap(const std::map<std::string, std::string> &m) {
} }
} }
I18NCategory *I18NRepo::GetCategory(const char *category) { std::shared_ptr<I18NCategory> I18NRepo::GetCategory(const char *category) {
auto iter = cats_.find(category); auto iter = cats_.find(category);
if (iter != cats_.end()) { if (iter != cats_.end()) {
return iter->second; return iter->second;
} else { } else {
I18NCategory *c = new I18NCategory(this, category); I18NCategory *c = new I18NCategory(this, category);
cats_[category] = c; cats_[category].reset(c);
return c; return cats_[category];
} }
} }
@ -96,7 +96,7 @@ bool I18NRepo::LoadIni(const std::string &languageID, const std::string &overrid
for (auto iter = sections.begin(); iter != sections.end(); ++iter) { for (auto iter = sections.begin(); iter != sections.end(); ++iter) {
if (iter->name() != "") { if (iter->name() != "") {
cats_[iter->name()] = LoadSection(&(*iter), iter->name().c_str()); cats_[iter->name()].reset(LoadSection(&(*iter), iter->name().c_str()));
} }
} }
@ -124,7 +124,7 @@ void I18NRepo::SaveIni(const std::string &languageID) {
ini.Save(GetIniPath(languageID)); ini.Save(GetIniPath(languageID));
} }
void I18NRepo::SaveSection(IniFile &ini, IniFile::Section *section, I18NCategory *cat) { void I18NRepo::SaveSection(IniFile &ini, IniFile::Section *section, std::shared_ptr<I18NCategory> cat) {
const std::map<std::string, std::string> &missed = cat->Missed(); const std::map<std::string, std::string> &missed = cat->Missed();
for (auto iter = missed.begin(); iter != missed.end(); ++iter) { for (auto iter = missed.begin(); iter != missed.end(); ++iter) {

View file

@ -9,6 +9,7 @@
// As usual, everything is UTF-8. Nothing else allowed. // As usual, everything is UTF-8. Nothing else allowed.
#include <map> #include <map>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
@ -76,7 +77,7 @@ public:
std::string LanguageID(); std::string LanguageID();
I18NCategory *GetCategory(const char *categoryName); std::shared_ptr<I18NCategory> GetCategory(const char *categoryName);
bool HasCategory(const char *categoryName) const { bool HasCategory(const char *categoryName) const {
return cats_.find(categoryName) != cats_.end(); return cats_.find(categoryName) != cats_.end();
} }
@ -86,9 +87,9 @@ private:
std::string GetIniPath(const std::string &languageID) const; std::string GetIniPath(const std::string &languageID) const;
void Clear(); void Clear();
I18NCategory *LoadSection(const IniFile::Section *section, const char *name); I18NCategory *LoadSection(const IniFile::Section *section, const char *name);
void SaveSection(IniFile &ini, IniFile::Section *section, I18NCategory *cat); void SaveSection(IniFile &ini, IniFile::Section *section, std::shared_ptr<I18NCategory> cat);
std::map<std::string, I18NCategory *> cats_; std::map<std::string, std::shared_ptr<I18NCategory>> cats_;
std::string languageID_; std::string languageID_;
DISALLOW_COPY_AND_ASSIGN(I18NRepo); DISALLOW_COPY_AND_ASSIGN(I18NRepo);
@ -98,7 +99,7 @@ extern I18NRepo i18nrepo;
// These are simply talking to the one global instance of I18NRepo. // These are simply talking to the one global instance of I18NRepo.
inline I18NCategory *GetI18NCategory(const char *categoryName) { inline std::shared_ptr<I18NCategory> GetI18NCategory(const char *categoryName) {
if (!categoryName) if (!categoryName)
return nullptr; return nullptr;
return i18nrepo.GetCategory(categoryName); return i18nrepo.GetCategory(categoryName);

View file

@ -233,7 +233,7 @@ UI::EventReturn UIScreen::OnCancel(UI::EventParams &e) {
PopupScreen::PopupScreen(std::string title, std::string button1, std::string button2) PopupScreen::PopupScreen(std::string title, std::string button1, std::string button2)
: box_(0), defaultButton_(nullptr), title_(title) { : box_(0), defaultButton_(nullptr), title_(title) {
I18NCategory *di = GetI18NCategory("Dialog"); auto di = GetI18NCategory("Dialog");
if (!button1.empty()) if (!button1.empty())
button1_ = di->T(button1.c_str()); button1_ = di->T(button1.c_str());
if (!button2.empty()) if (!button2.empty())
@ -427,7 +427,7 @@ std::string ChopTitle(const std::string &title) {
UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) { UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
restoreFocus_ = HasFocus(); restoreFocus_ = HasFocus();
I18NCategory *category = category_ ? GetI18NCategory(category_) : nullptr; auto category = category_ ? GetI18NCategory(category_) : nullptr;
std::vector<std::string> choices; std::vector<std::string> choices;
for (int i = 0; i < numChoices_; i++) { for (int i = 0; i < numChoices_; i++) {
@ -450,7 +450,7 @@ void PopupMultiChoice::Update() {
void PopupMultiChoice::UpdateText() { void PopupMultiChoice::UpdateText() {
if (!choices_) if (!choices_)
return; return;
I18NCategory *category = GetI18NCategory(category_); auto category = GetI18NCategory(category_);
// Clamp the value to be safe. // Clamp the value to be safe.
if (*value_ < minVal_ || *value_ > minVal_ + numChoices_ - 1) { if (*value_ < minVal_ || *value_ > minVal_ + numChoices_ - 1) {
valueText_ = "(invalid choice)"; // Shouldn't happen. Should be no need to translate this. valueText_ = "(invalid choice)"; // Shouldn't happen. Should be no need to translate this.
@ -865,7 +865,7 @@ void ChoiceWithValueDisplay::Draw(UIContext &dc) {
int paddingX = 12; int paddingX = 12;
dc.SetFontStyle(dc.theme->uiFont); dc.SetFontStyle(dc.theme->uiFont);
I18NCategory *category = GetI18NCategory(category_); auto category = GetI18NCategory(category_);
std::ostringstream valueText; std::ostringstream valueText;
if (translateCallback_ && sValue_) { if (translateCallback_ && sValue_) {
valueText << translateCallback_(sValue_->c_str()); valueText << translateCallback_(sValue_->c_str());