Skip to content

Commit

Permalink
Merge pull request #12606 from unknownbrackets/i18n-lock
Browse files Browse the repository at this point in the history
Core: Use a shared_ptr for i18n categories
  • Loading branch information
unknownbrackets authored Feb 9, 2020
2 parents a4ba5d4 + 5009698 commit 84c1fc8
Show file tree
Hide file tree
Showing 54 changed files with 244 additions and 240 deletions.
2 changes: 1 addition & 1 deletion Core/CwCheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void CWCheatEngine::CreateCheatFile() {
fclose(f);
}
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"));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Dialog/PSPDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void PSPDialog::DisplayButtons(int flags, const char *caption)
truncate_cpy(safeCaption, caption);
}

I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
float x1 = 183.5f, x2 = 261.5f;
if (GetCommonParam()->buttonSwap == 1) {
x1 = 261.5f;
Expand Down
4 changes: 2 additions & 2 deletions Core/Dialog/PSPMsgDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)

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

if (hasOK) {
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
float x, w;
x = 240.0f;
w = 15.0f;
Expand Down
6 changes: 3 additions & 3 deletions Core/Dialog/PSPNetconfDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ void PSPNetconfDialog::DrawBanner() {

// TODO: Draw a hexagon icon
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));
}

int PSPNetconfDialog::Update(int animSpeed) {
UpdateButtons();
I18NCategory *di = GetI18NCategory("Dialog");
I18NCategory *err = GetI18NCategory("Error");
auto di = GetI18NCategory("Dialog");
auto err = GetI18NCategory("Error");
const float WRAP_WIDTH = 254.0f;
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;
Expand Down
2 changes: 1 addition & 1 deletion Core/Dialog/PSPOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ int PSPOskDialog::Update(int animSpeed) {
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));
RenderKeyboard();

I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");

PPGeDrawImage(I_SQUARE, 365, 222, 16, 16, 0, CalcFadedColor(0xFFFFFFFF));
PPGeDrawText(di->T("Space"), 390, 222, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
Expand Down
8 changes: 4 additions & 4 deletions Core/Dialog/PSPSaveDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const std::string PSPSaveDialog::GetSelectedSaveDirName() const

void PSPSaveDialog::DisplayBanner(int which)
{
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
PPGeDrawRect(0, 0, 480, 23, CalcFadedColor(0x65636358));
const char *title;
switch (which)
Expand Down Expand Up @@ -394,7 +394,7 @@ void PSPSaveDialog::DisplaySaveDataInfo1()
{
std::lock_guard<std::mutex> guard(paramLock);
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));
} else {
char title[512];
Expand Down Expand Up @@ -539,7 +539,7 @@ void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
float h2 = h * (float)n / 2.0f;
if (hasYesNo)
{
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");
const char *choiceText;
u32 yesColor, noColor;
float x, w;
Expand Down Expand Up @@ -621,7 +621,7 @@ int PSPSaveDialog::Update(int animSpeed)
cancelButtonFlag = CTRL_CIRCLE;
}

I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");

switch (display)
{
Expand Down
8 changes: 4 additions & 4 deletions Core/Dialog/SavedataParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD

if (!pspFileSystem.GetFileInfo(dirPath).exists) {
if (!pspFileSystem.MkDir(dirPath)) {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Unable to write savedata, disk may be full"));
}
}
Expand Down Expand Up @@ -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) {
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);
ERROR_LOG(SCEUTILITY,"Save encryption failed. This save won't work on real PSP");
delete[] cryptedData;
Expand Down Expand Up @@ -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.
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("Old savedata detected"), 6.0f);
}
Expand All @@ -701,7 +701,7 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, co
}
if (g_Config.bSavedataUpgrade) {
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("Old savedata detected"), 6.0f);
}
Expand Down
2 changes: 1 addition & 1 deletion Core/FileSystems/BlockDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ u32 BlockDevice::CalculateCRC() {
}

void BlockDevice::NotifyReadError() {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (!reportedError_) {
host->NotifyUserMessage(err->T("Game disc read error - ISO corrupt"), 6.0f);
reportedError_ = true;
Expand Down
6 changes: 3 additions & 3 deletions Core/FileSystems/DirectoryFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam

if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) {
// 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"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else if (!success) {
Expand Down Expand Up @@ -315,7 +315,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam
}
} else if (errno == ENOSPC) {
// 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"));
error = SCE_KERNEL_ERROR_ERRNO_NO_PERM;
} else {
Expand Down Expand Up @@ -383,7 +383,7 @@ size_t DirectoryFileHandle::Write(const u8* pointer, s64 size)

if (diskFull) {
ERROR_LOG(FILESYS, "Disk full");
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("Disk full while writing data"));
// 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.
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/proAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
int sent = send(metasocket, (char*)&packet, sizeof(packet), 0);
changeBlockingMode(metasocket, 1); // Change to non-blocking
if (sent > 0) {
I18NCategory *n = GetI18NCategory("Networking");
auto n = GetI18NCategory("Networking");
host->NotifyUserMessage(n->T("Network Initialized"), 1.0);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ void __DisplayFlip(int cyclesLate) {
static bool hasNotifiedSlow = false;
if (!g_Config.bHideSlowWarnings && !hasNotifiedSlow && PSP_CoreParameter().fpsLimit == FPSLimit::NORMAL && IsRunningSlow()) {
#ifndef _DEBUG
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (g_Config.bSoftwareRendering) {
host->NotifyUserMessage(err->T("Running slow: Try turning off Software Rendering"), 6.0f, 0xFF30D0D0);
} else {
Expand Down
10 changes: 5 additions & 5 deletions Core/SaveState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ namespace SaveState
return StringFromFormat("%s (%c)", title.c_str(), slotChar);
}
if (detectSlot(UNDO_STATE_EXTENSION)) {
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
// Allow the number to be positioned where it makes sense.
std::string undo = sy->T("undo %c");
return title + " (" + StringFromFormat(undo.c_str(), slotChar) + ")";
Expand All @@ -402,7 +402,7 @@ namespace SaveState
}

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

Expand Down Expand Up @@ -437,7 +437,7 @@ namespace SaveState
if (!fn.empty()) {
Load(fn, callback, cbUserData);
} else {
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
if (callback)
callback(Status::FAILURE, sy->T("Failed to load state. Error in the file system."), cbUserData);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ namespace SaveState
SaveScreenshot(shot, Callback(), 0);
Save(fn + ".tmp", renameCallback, cbUserData);
} else {
I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
if (callback)
callback(Status::FAILURE, sy->T("Failed to save state. Error in the file system."), cbUserData);
}
Expand Down Expand Up @@ -729,7 +729,7 @@ namespace SaveState
std::string reason;
std::string title;

I18NCategory *sc = GetI18NCategory("Screen");
auto sc = GetI18NCategory("Screen");
const char *i18nLoadFailure = sc->T("Load savestate failed", "");
const char *i18nSaveFailure = sc->T("Save State Failed", "");
if (strlen(i18nLoadFailure) == 0)
Expand Down
2 changes: 1 addition & 1 deletion Core/TextureReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, bool isOverride) {
}

if (filenameWarning) {
I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
host->NotifyUserMessage(err->T("textures.ini filenames may not be cross-platform"), 6.0f);
}

Expand Down
6 changes: 3 additions & 3 deletions Core/Util/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool GameManager::InstallGame(const std::string &url, const std::string &fileNam
return InstallRawISO(fileName, shortFilename, deleteAfter);
}

I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");
installInProgress_ = true;

std::string pspGame = GetSysDirectory(DIRECTORY_GAME);
Expand Down Expand Up @@ -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) {
I18NCategory *iz = GetI18NCategory("InstallZip");
auto iz = GetI18NCategory("InstallZip");

struct zip_stat zstat;
zip_stat_index(z, iniIndex, 0, &zstat);
Expand Down Expand Up @@ -491,7 +491,7 @@ bool GameManager::InstallMemstickGame(struct zip *z, const std::string &zipfile,
size_t allBytes = 0;
size_t bytesCopied = 0;

I18NCategory *sy = GetI18NCategory("System");
auto sy = GetI18NCategory("System");

auto fileAllowed = [&](const char *fn) {
if (!allowRoot && strchr(fn, '/') == 0)
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ void FramebufferManagerCommon::UpdateFramebufUsage(VirtualFramebuffer *vfb) {
}

void FramebufferManagerCommon::ShowScreenResolution() {
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");

std::ostringstream messageStream;
messageStream << gr->T("Internal Resolution") << ": ";
Expand Down
2 changes: 1 addition & 1 deletion GPU/Directx9/GPU_DX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
// Disable hardware tessellation bacause DX9 is still unsupported.
g_Config.bHardwareTessellation = false;
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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/Directx9/ShaderManagerDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ VSShader *ShaderManagerDX9::ApplyShader(int prim, u32 vertType) {
vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform);

if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
if (!g_Config.bHideSlowWarnings) {
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/GPU_GLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
g_Config.bHardwareTessellation = false;
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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/ShaderManagerGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ Shader *ShaderManagerGLES::ApplyVertexShader(int prim, u32 vertType, VShaderID *
// Vertex shader not in cache. Let's compile it.
vs = CompileVertexShader(*VSID);
if (vs->Failed()) {
I18NCategory *gr = GetI18NCategory("Graphics");
auto gr = GetI18NCategory("Graphics");
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
if (!g_Config.bHideSlowWarnings) {
host->NotifyUserMessage(gr->T("hardware transform error - falling back to software"), 2.5f, 0xFF3030FF);
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/TextureCacheGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void TextureCacheGLES::StartFrame() {
lowMemoryMode_ = true;
decimationCounter_ = 0;

I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (standardScaleFactor_ > 1) {
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
// 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.

I18NCategory *err = GetI18NCategory("Error");
auto err = GetI18NCategory("Error");
if (scaleFactor > 1) {
host->NotifyUserMessage(err->T("Warning: Video memory FULL, reducing upscaling and switching to slow caching mode"), 2.0f);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Qt/QtMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ bool MainUI::event(QEvent *e) {
}
break;
} 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());
if (QDir(fileName).exists()) {
NativeMessageReceived("browse_folderSelect", fileName.toStdString().c_str());
Expand Down
6 changes: 3 additions & 3 deletions UI/ComboKeyMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

void Combo_keyScreen::CreateViews() {
using namespace UI;
I18NCategory *co = GetI18NCategory("Controls");
auto co = GetI18NCategory("Controls");
root_ = new LinearLayout(ORIENT_VERTICAL);
root_->Add(new ItemHeader(co->T("Combo Key Setting")));
LinearLayout *root__ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(1.0));
root_->Add(root__);
LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(120, FILL_PARENT));
I18NCategory *di = GetI18NCategory("Dialog");
auto di = GetI18NCategory("Dialog");

static const int comboKeyImages[5] = {
I_1, I_2, I_3, I_4, I_5,
Expand Down Expand Up @@ -113,7 +113,7 @@ void Combo_keyScreen::CreateViews() {

std::map<std::string, int>::iterator imageFinder;

I18NCategory *mc = GetI18NCategory("MappableControls");
auto mc = GetI18NCategory("MappableControls");

for (auto i = keyToggles.begin(); i != keyToggles.end(); ++i) {
LinearLayout *row = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
Expand Down
Loading

0 comments on commit 84c1fc8

Please sign in to comment.