diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp index 1cbe08b8549..e189d782967 100644 --- a/audio/mididrv.cpp +++ b/audio/mididrv.cpp @@ -173,7 +173,7 @@ Common::U32String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringT MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // Query the selected music device (defaults to MT_AUTO device). - Common::String selDevStr = ConfMan.hasKey("music_driver") ? ConfMan.get("music_driver") : Common::String("auto"); + Common::U32String selDevStr = ConfMan.hasKey("music_driver") ? ConfMan.get("music_driver") : Common::String("auto"); if ((flags & MDT_PREFER_FLUID) && selDevStr == "auto") { selDevStr = "fluidsynth"; } @@ -256,8 +256,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // we display a warning and continue. failedDevStr = selDevStr; Common::U32String warningMsg = Common::String::format( - Common::convertFromU32String(_("The selected audio device '%s' was not found (e.g. might be turned off or disconnected).")).c_str(), - failedDevStr.c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); + _("The selected audio device '%s' was not found (e.g. might be turned off or disconnected).").encode().c_str(), + failedDevStr.encode() + " " + _("Attempting to fall back to the next available device...").encode()); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -269,9 +269,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { } else { // If the expressly selected device cannot be used we display a warning and continue. failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName); - Common::String warningMsg = Common::String::format( - Common::convertFromU32String(_("The selected audio device '%s' cannot be used. See log file for more information.")).c_str(), - failedDevStr.c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); + Common::U32String warningMsg = Common::String::format( + _("The selected audio device '%s' cannot be used. See log file for more information.").encode().c_str(), + failedDevStr.encode() + " " + _("Attempting to fall back to the next available device...").encode()); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -307,9 +307,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // we display a warning and continue. Don't warn about the missing device if we did already (this becomes relevant if the // missing device is selected as preferred device and also as GM or MT-32 device). if (failedDevStr != devStr) { - Common::String warningMsg = Common::String::format( - Common::convertFromU32String(_("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected).")).c_str(), - devStr.c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); + Common::U32String warningMsg = Common::String::format( + _("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected).").encode().c_str(), + devStr + " " + _("Attempting to fall back to the next available device...").encode()); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -324,9 +324,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // Don't warn about the failing device if we did already (this becomes relevant if the failing // device is selected as preferred device and also as GM or MT-32 device). if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) { - Common::String warningMsg = Common::String::format( - Common::convertFromU32String(_("The preferred audio device '%s' cannot be used. See log file for more information.")).c_str(), - getDeviceString(hdl, MidiDriver::kDeviceName).c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); + Common::U32String warningMsg = Common::String::format( + _("The preferred audio device '%s' cannot be used. See log file for more information.").encode().c_str(), + getDeviceString(hdl, MidiDriver::kDeviceName).encode() + " " + _("Attempting to fall back to the next available device...").encode()); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } diff --git a/backends/cloud/storage.cpp b/backends/cloud/storage.cpp index 90a554bf9d5..2569b38bf5b 100644 --- a/backends/cloud/storage.cpp +++ b/backends/cloud/storage.cpp @@ -346,7 +346,7 @@ void Storage::directoryDownloadedCallback(FileArrayResponse response) { Common::U32String message; if (response.value.size()) { message = Common::String::format( - Common::convertFromU32String(_("Download complete.\nFailed to download %u files.")).c_str(), + _("Download complete.\nFailed to download %u files.").encode().c_str(), response.value.size()); } else { message = _("Download complete."); diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index ecf4ddb1825..1414fff63f2 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -583,7 +583,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { #ifdef USE_OSD int windowWidth = 0, windowHeight = 0; getWindowSizeFromSdl(&windowWidth, &windowHeight); - const Common::U32String osdMsg = Common::String::format(Common::convertFromU32String(_("Resolution: %dx%d")).c_str(), windowWidth, windowHeight); + const Common::U32String osdMsg = Common::String::format(_("Resolution: %dx%d").encode().c_str(), windowWidth, windowHeight); displayMessageOnOSD(osdMsg); #endif @@ -660,8 +660,8 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { #ifdef USE_OSD Common::U32String message = Common::String::format("%s: %s", - _("Stretch mode"), - _(stretchModes[index].description) + _("Stretch mode").encode().c_str(), + _(stretchModes[index].description).encode().c_str() ); displayMessageOnOSD(message); #endif diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 0d9b3ef9c95..159c39912ff 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -2466,7 +2466,7 @@ void SurfaceSdlGraphicsManager::handleScalerHotkeys(int scalefactor, int scalerT if (newScalerName) { const Common::U32String message = Common::String::format( "%s %s\n%d x %d -> %d x %d", - _("Active graphics filter:"), + _("Active graphics filter:").encode().c_str(), newScalerName, _videoMode.screenWidth, _videoMode.screenHeight, _hwScreen->w, _hwScreen->h); @@ -2500,13 +2500,13 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) { Common::U32String message; if (_videoMode.aspectRatioCorrection) message = Common::String::format("%s\n%d x %d -> %d x %d", - _("Enabled aspect ratio correction"), + _("Enabled aspect ratio correction").encode().c_str(), _videoMode.screenWidth, _videoMode.screenHeight, _hwScreen->w, _hwScreen->h ); else message = Common::String::format("%s\n%d x %d -> %d x %d", - _("Disabled aspect ratio correction"), + _("Disabled aspect ratio correction").encode().c_str(), _videoMode.screenWidth, _videoMode.screenHeight, _hwScreen->w, _hwScreen->h ); @@ -2553,8 +2553,8 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) { #ifdef USE_OSD Common::U32String message = Common::String::format("%s: %s", - _("Stretch mode"), - _(s_supportedStretchModes[index].description) + _("Stretch mode").encode().c_str(), + _(s_supportedStretchModes[index].description).encode().c_str() ); displayMessageOnOSD(message); #endif diff --git a/backends/networking/sdl_net/handlers/filespagehandler.cpp b/backends/networking/sdl_net/handlers/filespagehandler.cpp index fd5a37bcca3..b40dd1a53c4 100644 --- a/backends/networking/sdl_net/handlers/filespagehandler.cpp +++ b/backends/networking/sdl_net/handlers/filespagehandler.cpp @@ -229,7 +229,7 @@ void FilesPageHandler::handle(Client &client) { replace(response, "{create_directory_desc}", _("Type new directory name:").encode()); replace(response, "{upload_file_desc}", _("Select a file to upload:").encode()); replace(response, "{or_upload_directory_desc}", _("Or select a directory (works in Chrome only):").encode()); - replace(response, "{index_of_directory}", Common::String::format("%s %s", Common::convertFromU32String(_("Index of")).c_str(), encodeHtmlEntities(getDisplayPath(client.queryParameter("path"))).c_str())); + replace(response, "{index_of_directory}", Common::String::format("%s %s", _("Index of").encode().c_str(), encodeHtmlEntities(getDisplayPath(client.queryParameter("path"))))); replace(response, "{content}", content); LocalWebserver::setClientGetHandler(client, response); } diff --git a/common/achievements.cpp b/common/achievements.cpp index 6f3cf6d3a06..7a7292522eb 100644 --- a/common/achievements.cpp +++ b/common/achievements.cpp @@ -89,7 +89,7 @@ bool AchievementsManager::setAchievement(const String &id, const String &display if (!displayedMessage.empty() && g_system) { U32String msg; - msg = Common::String::format("%s\n%s", _("Achievement unlocked!"), displayedMessage.c_str()); + msg = Common::String::format("%s\n%s", _("Achievement unlocked!").encode().c_str(), displayedMessage.c_str()); g_system->displayMessageOnOSD(msg); } diff --git a/common/translation.cpp b/common/translation.cpp index 7a8ad64e9b4..46d333e8c16 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -144,17 +144,17 @@ U32String TranslationManager::getTranslation(const char *message, const char *co } // Find the context we want if (context == nullptr || *context == '\0' || leftIndex == rightIndex) - return _currentTranslationMessages[leftIndex].msgstr.c_str(); + return _currentTranslationMessages[leftIndex].msgstr; // We could use again binary search, but there should be only a small number of contexts. while (rightIndex > leftIndex) { compareResult = strcmp(context, _currentTranslationMessages[rightIndex].msgctxt.c_str()); if (compareResult == 0) - return _currentTranslationMessages[rightIndex].msgstr.c_str(); + return _currentTranslationMessages[rightIndex].msgstr; else if (compareResult > 0) break; --rightIndex; } - return _currentTranslationMessages[leftIndex].msgstr.c_str(); + return _currentTranslationMessages[leftIndex].msgstr; } else if (compareResult < 0) rightIndex = midIndex - 1; else diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp index 8edf0435a54..aeb4d927cd4 100644 --- a/gui/downloaddialog.cpp +++ b/gui/downloaddialog.cpp @@ -149,7 +149,7 @@ bool DownloadDialog::selectDirectories() { return false; } GUI::MessageDialog alert( - Common::String::format(Common::convertFromU32String(_("The \"%s\" already exists in the specified directory.\nDo you really want to download files into that directory?")).c_str(), remoteDirectory.name().c_str()), + Common::String::format(_("The \"%s\" already exists in the specified directory.\nDo you really want to download files into that directory?").encode().c_str(), remoteDirectory.name().c_str()), _("Yes"), _("No") ); @@ -212,14 +212,14 @@ Common::U32String DownloadDialog::getSizeLabelText() { Common::String downloaded, downloadedUnits, total, totalUnits; downloaded = getHumanReadableBytes(CloudMan.getDownloadBytesNumber(), downloadedUnits); total = getHumanReadableBytes(CloudMan.getDownloadTotalBytesNumber(), totalUnits); - return Common::U32String::format(Common::convertFromU32String(_("Downloaded %s %s / %s %s")).c_str(), downloaded.c_str(), _(downloadedUnits.c_str()), total.c_str(), _(totalUnits.c_str())); + return Common::String::format(_("Downloaded %s %s / %s %s").encode().c_str(), downloaded.c_str(), _(downloadedUnits.c_str()).encode().c_str(), total.c_str(), _(totalUnits.c_str()).encode().c_str()); } Common::U32String DownloadDialog::getSpeedLabelText() { Common::String speed, speedUnits; speed = getHumanReadableBytes(CloudMan.getDownloadSpeed(), speedUnits); speedUnits += "/s"; - return Common::U32String::format(_("Download speed: %s %s").encode().c_str(), speed.c_str(), _(speedUnits).encode().c_str()); + return Common::String::format(_("Download speed: %s %s").encode().c_str(), speed.c_str(), _(speedUnits).encode().c_str()); } void DownloadDialog::refreshWidgets() { diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 64946119c2c..345db60cf91 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -266,14 +266,14 @@ void MassAddDialog::handleTickle() { buf = _("Scan complete!"); _dirProgressText->setLabel(buf); - buf = Common::U32String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games.")).c_str(), _games.size(), _oldGamesCount); + buf = Common::String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games.")).c_str(), _games.size(), _oldGamesCount); _gameProgressText->setLabel(buf); } else { - buf = Common::U32String::format(Common::convertFromU32String(_("Scanned %d directories ...")).c_str(), _dirsScanned); + buf = Common::String::format(Common::convertFromU32String(_("Scanned %d directories ...")).c_str(), _dirsScanned); _dirProgressText->setLabel(buf); - buf = Common::U32String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games ...")).c_str(), _games.size(), _oldGamesCount); + buf = Common::String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games ...")).c_str(), _games.size(), _oldGamesCount); _gameProgressText->setLabel(buf); } diff --git a/gui/options.cpp b/gui/options.cpp index ac88e8488b4..b58016957c2 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1170,12 +1170,12 @@ void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::Strin } if (nHidden) { - Common::U32String hiddenStr = Common::U32String::format(Common::convertFromU32String(_("%d hidden achievements remaining")).c_str(), nHidden); + Common::U32String hiddenStr = Common::String::format(Common::convertFromU32String(_("%d hidden achievements remaining")).c_str(), nHidden); new StaticTextWidget(scrollContainer, lineHeight, yPos, width, yStep, hiddenStr, Graphics::kTextAlignStart); } if (nMax) { - Common::U32String totalStr = Common::U32String::format(Common::convertFromU32String(_("Achievements unlocked: %d/%d")).c_str(), nAchieved, nMax); + Common::U32String totalStr = Common::String::format(Common::convertFromU32String(_("Achievements unlocked: %d/%d")).c_str(), nAchieved, nMax); new StaticTextWidget(scrollContainer, lineHeight, lineHeight, width, yStep, totalStr, Graphics::kTextAlignStart); SliderWidget *progressBar; @@ -2148,7 +2148,7 @@ void GlobalOptionsDialog::addNetworkControls(GuiObject *boss, const Common::Stri uint32 port = Networking::LocalWebserver::getPort(); _serverPortDesc = new StaticTextWidget(boss, prefix + "ServerPortDesc", (_("Server's port:")), _("Port for server to use")); - _serverPort = new EditTextWidget(boss, prefix + "ServerPortEditText", Common::U32String::format("%u", port), Common::U32String("")); + _serverPort = new EditTextWidget(boss, prefix + "ServerPortEditText", Common::String::format("%u", port), Common::U32String("")); _serverPortClearButton = addClearButton(boss, prefix + "ServerPortClearButton", kServerPortClearCmd); if (lowres) { @@ -2805,7 +2805,7 @@ void GlobalOptionsDialog::setupCloudTab() { uint64 usedSpace = CloudMan.getStorageUsedSpace(_selectedStorageIndex); Common::String usedSpaceNumber, usedSpaceUnits; usedSpaceNumber = Common::getHumanReadableBytes(usedSpace, usedSpaceUnits); - _storageUsedSpace->setLabel(Common::U32String::format("%s %s", usedSpaceNumber.c_str(), _(usedSpaceUnits.c_str()).encode().c_str())); + _storageUsedSpace->setLabel(Common::String::format("%s %s", usedSpaceNumber.c_str(), _(usedSpaceUnits.c_str()).encode().c_str())); _storageUsedSpace->setVisible(shownConnectedInfo); } if (_storageSyncHint) { diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 4aa051a6991..48369033f0c 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -1182,7 +1182,7 @@ void SavenameDialog::open() { Dialog::open(); setResult(-1); - _title->setLabel(Common::U32String::format(Common::convertFromU32String(_("Enter a description for slot %d:")).c_str(), _targetSlot)); + _title->setLabel(Common::String::format(Common::convertFromU32String(_("Enter a description for slot %d:")).c_str(), _targetSlot)); } void SavenameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {