GUI: U32: Remove u32::format references

- Removed because implicit conversion can simply handle this usecase
This commit is contained in:
aryanrawlani28 2020-06-15 00:55:56 +05:30 committed by Eugene Sandulenko
parent 160a1320cc
commit b9a449480b
11 changed files with 37 additions and 37 deletions

View file

@ -173,7 +173,7 @@ Common::U32String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringT
MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// Query the selected music device (defaults to MT_AUTO device). // 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") { if ((flags & MDT_PREFER_FLUID) && selDevStr == "auto") {
selDevStr = "fluidsynth"; selDevStr = "fluidsynth";
} }
@ -256,8 +256,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
// we display a warning and continue. // we display a warning and continue.
failedDevStr = selDevStr; failedDevStr = selDevStr;
Common::U32String warningMsg = Common::String::format( 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(), _("The selected audio device '%s' was not found (e.g. might be turned off or disconnected).").encode().c_str(),
failedDevStr.c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); failedDevStr.encode() + " " + _("Attempting to fall back to the next available device...").encode());
GUI::MessageDialog dialog(warningMsg); GUI::MessageDialog dialog(warningMsg);
dialog.runModal(); dialog.runModal();
} }
@ -269,9 +269,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
} else { } else {
// If the expressly selected device cannot be used we display a warning and continue. // If the expressly selected device cannot be used we display a warning and continue.
failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName); failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName);
Common::String warningMsg = Common::String::format( Common::U32String warningMsg = Common::String::format(
Common::convertFromU32String(_("The selected audio device '%s' cannot be used. See log file for more information.")).c_str(), _("The selected audio device '%s' cannot be used. See log file for more information.").encode().c_str(),
failedDevStr.c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); failedDevStr.encode() + " " + _("Attempting to fall back to the next available device...").encode());
GUI::MessageDialog dialog(warningMsg); GUI::MessageDialog dialog(warningMsg);
dialog.runModal(); 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 // 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). // missing device is selected as preferred device and also as GM or MT-32 device).
if (failedDevStr != devStr) { if (failedDevStr != devStr) {
Common::String warningMsg = Common::String::format( Common::U32String warningMsg = Common::String::format(
Common::convertFromU32String(_("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected).")).c_str(), _("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected).").encode().c_str(),
devStr.c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); devStr + " " + _("Attempting to fall back to the next available device...").encode());
GUI::MessageDialog dialog(warningMsg); GUI::MessageDialog dialog(warningMsg);
dialog.runModal(); 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 // 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). // device is selected as preferred device and also as GM or MT-32 device).
if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) { if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) {
Common::String warningMsg = Common::String::format( Common::U32String warningMsg = Common::String::format(
Common::convertFromU32String(_("The preferred audio device '%s' cannot be used. See log file for more information.")).c_str(), _("The preferred audio device '%s' cannot be used. See log file for more information.").encode().c_str(),
getDeviceString(hdl, MidiDriver::kDeviceName).c_str()) + " " + Common::convertFromU32String(_("Attempting to fall back to the next available device...")).c_str(); getDeviceString(hdl, MidiDriver::kDeviceName).encode() + " " + _("Attempting to fall back to the next available device...").encode());
GUI::MessageDialog dialog(warningMsg); GUI::MessageDialog dialog(warningMsg);
dialog.runModal(); dialog.runModal();
} }

View file

@ -346,7 +346,7 @@ void Storage::directoryDownloadedCallback(FileArrayResponse response) {
Common::U32String message; Common::U32String message;
if (response.value.size()) { if (response.value.size()) {
message = Common::String::format( 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()); response.value.size());
} else { } else {
message = _("Download complete."); message = _("Download complete.");

View file

@ -583,7 +583,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
#ifdef USE_OSD #ifdef USE_OSD
int windowWidth = 0, windowHeight = 0; int windowWidth = 0, windowHeight = 0;
getWindowSizeFromSdl(&windowWidth, &windowHeight); 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); displayMessageOnOSD(osdMsg);
#endif #endif
@ -660,8 +660,8 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
#ifdef USE_OSD #ifdef USE_OSD
Common::U32String message = Common::String::format("%s: %s", Common::U32String message = Common::String::format("%s: %s",
_("Stretch mode"), _("Stretch mode").encode().c_str(),
_(stretchModes[index].description) _(stretchModes[index].description).encode().c_str()
); );
displayMessageOnOSD(message); displayMessageOnOSD(message);
#endif #endif

View file

@ -2466,7 +2466,7 @@ void SurfaceSdlGraphicsManager::handleScalerHotkeys(int scalefactor, int scalerT
if (newScalerName) { if (newScalerName) {
const Common::U32String message = Common::String::format( const Common::U32String message = Common::String::format(
"%s %s\n%d x %d -> %d x %d", "%s %s\n%d x %d -> %d x %d",
_("Active graphics filter:"), _("Active graphics filter:").encode().c_str(),
newScalerName, newScalerName,
_videoMode.screenWidth, _videoMode.screenHeight, _videoMode.screenWidth, _videoMode.screenHeight,
_hwScreen->w, _hwScreen->h); _hwScreen->w, _hwScreen->h);
@ -2500,13 +2500,13 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
Common::U32String message; Common::U32String message;
if (_videoMode.aspectRatioCorrection) if (_videoMode.aspectRatioCorrection)
message = Common::String::format("%s\n%d x %d -> %d x %d", 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, _videoMode.screenWidth, _videoMode.screenHeight,
_hwScreen->w, _hwScreen->h _hwScreen->w, _hwScreen->h
); );
else else
message = Common::String::format("%s\n%d x %d -> %d x %d", 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, _videoMode.screenWidth, _videoMode.screenHeight,
_hwScreen->w, _hwScreen->h _hwScreen->w, _hwScreen->h
); );
@ -2553,8 +2553,8 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
#ifdef USE_OSD #ifdef USE_OSD
Common::U32String message = Common::String::format("%s: %s", Common::U32String message = Common::String::format("%s: %s",
_("Stretch mode"), _("Stretch mode").encode().c_str(),
_(s_supportedStretchModes[index].description) _(s_supportedStretchModes[index].description).encode().c_str()
); );
displayMessageOnOSD(message); displayMessageOnOSD(message);
#endif #endif

View file

@ -229,7 +229,7 @@ void FilesPageHandler::handle(Client &client) {
replace(response, "{create_directory_desc}", _("Type new directory name:").encode()); replace(response, "{create_directory_desc}", _("Type new directory name:").encode());
replace(response, "{upload_file_desc}", _("Select a file to upload:").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, "{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); replace(response, "{content}", content);
LocalWebserver::setClientGetHandler(client, response); LocalWebserver::setClientGetHandler(client, response);
} }

View file

@ -89,7 +89,7 @@ bool AchievementsManager::setAchievement(const String &id, const String &display
if (!displayedMessage.empty() && g_system) { if (!displayedMessage.empty() && g_system) {
U32String msg; 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); g_system->displayMessageOnOSD(msg);
} }

View file

@ -144,17 +144,17 @@ U32String TranslationManager::getTranslation(const char *message, const char *co
} }
// Find the context we want // Find the context we want
if (context == nullptr || *context == '\0' || leftIndex == rightIndex) 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. // We could use again binary search, but there should be only a small number of contexts.
while (rightIndex > leftIndex) { while (rightIndex > leftIndex) {
compareResult = strcmp(context, _currentTranslationMessages[rightIndex].msgctxt.c_str()); compareResult = strcmp(context, _currentTranslationMessages[rightIndex].msgctxt.c_str());
if (compareResult == 0) if (compareResult == 0)
return _currentTranslationMessages[rightIndex].msgstr.c_str(); return _currentTranslationMessages[rightIndex].msgstr;
else if (compareResult > 0) else if (compareResult > 0)
break; break;
--rightIndex; --rightIndex;
} }
return _currentTranslationMessages[leftIndex].msgstr.c_str(); return _currentTranslationMessages[leftIndex].msgstr;
} else if (compareResult < 0) } else if (compareResult < 0)
rightIndex = midIndex - 1; rightIndex = midIndex - 1;
else else

View file

@ -149,7 +149,7 @@ bool DownloadDialog::selectDirectories() {
return false; return false;
} }
GUI::MessageDialog alert( 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"), _("Yes"),
_("No") _("No")
); );
@ -212,14 +212,14 @@ Common::U32String DownloadDialog::getSizeLabelText() {
Common::String downloaded, downloadedUnits, total, totalUnits; Common::String downloaded, downloadedUnits, total, totalUnits;
downloaded = getHumanReadableBytes(CloudMan.getDownloadBytesNumber(), downloadedUnits); downloaded = getHumanReadableBytes(CloudMan.getDownloadBytesNumber(), downloadedUnits);
total = getHumanReadableBytes(CloudMan.getDownloadTotalBytesNumber(), totalUnits); 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::U32String DownloadDialog::getSpeedLabelText() {
Common::String speed, speedUnits; Common::String speed, speedUnits;
speed = getHumanReadableBytes(CloudMan.getDownloadSpeed(), speedUnits); speed = getHumanReadableBytes(CloudMan.getDownloadSpeed(), speedUnits);
speedUnits += "/s"; 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() { void DownloadDialog::refreshWidgets() {

View file

@ -266,14 +266,14 @@ void MassAddDialog::handleTickle() {
buf = _("Scan complete!"); buf = _("Scan complete!");
_dirProgressText->setLabel(buf); _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); _gameProgressText->setLabel(buf);
} else { } 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); _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); _gameProgressText->setLabel(buf);
} }

View file

@ -1170,12 +1170,12 @@ void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::Strin
} }
if (nHidden) { 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); new StaticTextWidget(scrollContainer, lineHeight, yPos, width, yStep, hiddenStr, Graphics::kTextAlignStart);
} }
if (nMax) { 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); new StaticTextWidget(scrollContainer, lineHeight, lineHeight, width, yStep, totalStr, Graphics::kTextAlignStart);
SliderWidget *progressBar; SliderWidget *progressBar;
@ -2148,7 +2148,7 @@ void GlobalOptionsDialog::addNetworkControls(GuiObject *boss, const Common::Stri
uint32 port = Networking::LocalWebserver::getPort(); uint32 port = Networking::LocalWebserver::getPort();
_serverPortDesc = new StaticTextWidget(boss, prefix + "ServerPortDesc", (_("Server's port:")), _("Port for server to use")); _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); _serverPortClearButton = addClearButton(boss, prefix + "ServerPortClearButton", kServerPortClearCmd);
if (lowres) { if (lowres) {
@ -2805,7 +2805,7 @@ void GlobalOptionsDialog::setupCloudTab() {
uint64 usedSpace = CloudMan.getStorageUsedSpace(_selectedStorageIndex); uint64 usedSpace = CloudMan.getStorageUsedSpace(_selectedStorageIndex);
Common::String usedSpaceNumber, usedSpaceUnits; Common::String usedSpaceNumber, usedSpaceUnits;
usedSpaceNumber = Common::getHumanReadableBytes(usedSpace, 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); _storageUsedSpace->setVisible(shownConnectedInfo);
} }
if (_storageSyncHint) { if (_storageSyncHint) {

View file

@ -1182,7 +1182,7 @@ void SavenameDialog::open() {
Dialog::open(); Dialog::open();
setResult(-1); 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) { void SavenameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {