From 68d01321d62f39c757793c41b191944dadf8c2b2 Mon Sep 17 00:00:00 2001 From: aryanrawlani28 Date: Mon, 20 Jul 2020 18:06:37 +0530 Subject: [PATCH] GUI: U32: Downscale changes of U32, fix review issues This commit addresses a range of changes, within scummvm subproject. - Audio files, like mididrv, remove U32String based name and identifier, because ASCII only. - mididrv.cpp had some wrong format for warning messages, fix those - Message dialogs were modified to use default arguments more often, but reverting back to the orignal to minimize changes. - SetTooltip has a fake constructor that takes in a string, and use it. - U32Format had some break statements missing, add those. - RemapWidget: Use fake constructor for setLabel and setTooltip, to make minimal changes - SDL: setting text in clipboard no longer uses SDL_iconv_string - TTS: Override base class "say" with strings, so tts->say can be used with normal strings too. - About dialog: fix incorrect code for u32string variables - Fix some extra brackets - Some buttons were incorrectly removed from using translated labels, revert those - Message Dialog: Pass default and alt buttons as const references - Saveload Dialog: Use translations in missing places, use const-references. Also, use translations in a correct manner. - Use const references for tooltip in GraphicsWidget, EditTextWidget, error.cpp - DomainEditTextWidget: Use U32String for text --- audio/mididrv.cpp | 30 ++++++------- audio/mididrv.h | 4 +- audio/musicplugin.cpp | 20 ++++----- audio/musicplugin.h | 17 ++++---- audio/softsynth/mt32.cpp | 4 +- .../surfacesdl/surfacesdl-graphics.cpp | 4 +- backends/keymapper/remap-widget.cpp | 8 ++-- .../handlers/createdirectoryhandler.cpp | 2 +- backends/platform/sdl/sdl.cpp | 3 +- .../linux/linux-text-to-speech.cpp | 4 ++ .../linux/linux-text-to-speech.h | 1 + .../macosx/macosx-text-to-speech.h | 1 + .../macosx/macosx-text-to-speech.mm | 4 ++ base/commandLine.cpp | 2 +- common/ustr.cpp | 2 + gui/about.cpp | 3 +- gui/browser.cpp | 2 +- gui/editgamedialog.cpp | 26 ++++++------ gui/error.cpp | 2 +- gui/error.h | 2 +- gui/launcher.cpp | 2 +- gui/massadd.cpp | 8 ++-- gui/message.cpp | 14 ++++--- gui/message.h | 2 +- gui/options.cpp | 42 +++++++++---------- gui/predictivedialog.cpp | 12 +++--- gui/saveload-dialog.cpp | 16 +++---- gui/saveload-dialog.h | 2 +- gui/widget.cpp | 4 +- gui/widget.h | 5 ++- gui/widgets/edittext.cpp | 4 +- gui/widgets/edittext.h | 4 +- 32 files changed, 135 insertions(+), 121 deletions(-) diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp index 0b9cfc167ff..02fb25a1e80 100644 --- a/audio/mididrv.cpp +++ b/audio/mididrv.cpp @@ -146,7 +146,7 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) { return MT_INVALID; } -Common::U32String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) { +Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) { if (handle) { const PluginList p = MusicMan.getPlugins(); for (PluginList::const_iterator m = p.begin(); m != p.end(); m++) { @@ -173,11 +173,11 @@ Common::U32String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringT MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // Query the selected music device (defaults to MT_AUTO device). - Common::U32String selDevStr = ConfMan.hasKey("music_driver") ? ConfMan.get("music_driver") : Common::String("auto"); + Common::String selDevStr = ConfMan.hasKey("music_driver") ? ConfMan.get("music_driver") : Common::String("auto"); if ((flags & MDT_PREFER_FLUID) && selDevStr == "auto") { selDevStr = "fluidsynth"; } - DeviceHandle hdl = getDeviceHandle(selDevStr.empty() ? Common::U32String("auto") : selDevStr); + DeviceHandle hdl = getDeviceHandle(selDevStr.empty() ? Common::String("auto") : selDevStr); DeviceHandle reslt = 0; _forceTypeMT32 = false; @@ -250,14 +250,14 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { break; } - Common::U32String failedDevStr; + Common::String failedDevStr; if (getMusicType(hdl) == MT_INVALID) { // If the expressly selected driver or device cannot be found (no longer compiled in, turned off, etc.) // we display a warning and continue. failedDevStr = selDevStr; Common::U32String warningMsg = Common::U32String::format( - _("The selected audio device '%s' was not found (e.g. might be turned off or disconnected)."), - (failedDevStr + Common::U32String(" ") + _("Attempting to fall back to the next available device...")).encode().c_str()); + _("The selected audio device '%s' was not found (e.g. might be turned off or disconnected)."), failedDevStr.c_str()) + + Common::U32String(" ") + _("Attempting to fall back to the next available device..."); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -270,8 +270,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // If the expressly selected device cannot be used we display a warning and continue. failedDevStr = getDeviceString(hdl, MidiDriver::kDeviceName); Common::U32String warningMsg = Common::U32String::format( - _("The selected audio device '%s' cannot be used. See log file for more information."), - (failedDevStr + Common::U32String(" ") + _("Attempting to fall back to the next available device...")).encode().c_str()); + _("The selected audio device '%s' cannot be used. See log file for more information."), failedDevStr.c_str()) + + Common::U32String(" ") + _("Attempting to fall back to the next available device..."); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -286,7 +286,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { while (flags != MDT_NONE) { if ((flags & MDT_MIDI) && !skipMidi) { // If a preferred MT32 or GM device has been selected that device gets returned if available. - Common::U32String devStr; + Common::String devStr; if (flags & MDT_PREFER_MT32) devStr = ConfMan.hasKey("mt32_device") ? ConfMan.get("mt32_device") : Common::String("null"); else if (flags & MDT_PREFER_GM) @@ -296,7 +296,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // Default to Null device here, since we also register a default null setting for // the MT32 or GM device in the config manager. - hdl = getDeviceHandle(devStr.empty() ? Common::U32String("null") : devStr); + hdl = getDeviceHandle(devStr.empty() ? Common::String("null") : devStr); const MusicType type = getMusicType(hdl); // If we have a "Don't use GM/MT-32" setting we skip this part and jump @@ -308,8 +308,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // missing device is selected as preferred device and also as GM or MT-32 device). if (failedDevStr != devStr) { Common::U32String warningMsg = Common::U32String::format( - _("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected)."), - (devStr + Common::U32String(" ") + _("Attempting to fall back to the next available device...")).encode().c_str()); + _("The preferred audio device '%s' was not found (e.g. might be turned off or disconnected)."), devStr.c_str()) + + Common::U32String(" ") + _("Attempting to fall back to the next available device..."); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -325,8 +325,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // device is selected as preferred device and also as GM or MT-32 device). if (failedDevStr != getDeviceString(hdl, MidiDriver::kDeviceName)) { Common::U32String warningMsg = Common::U32String::format( - _("The preferred audio device '%s' cannot be used. See log file for more information."), - (getDeviceString(hdl, MidiDriver::kDeviceName) + Common::U32String(" ") + _("Attempting to fall back to the next available device...")).encode().c_str()); + _("The preferred audio device '%s' cannot be used. See log file for more information."), getDeviceString(hdl, MidiDriver::kDeviceName).c_str()) + + Common::U32String(" ") + _("Attempting to fall back to the next available device..."); GUI::MessageDialog dialog(warningMsg); dialog.runModal(); } @@ -446,7 +446,7 @@ bool MidiDriver::checkDevice(MidiDriver::DeviceHandle handle) { return false; } -MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::U32String &identifier) { +MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &identifier) { const PluginList p = MusicMan.getPlugins(); if (p.begin() == p.end()) diff --git a/audio/mididrv.h b/audio/mididrv.h index 7b5025eab48..6f37125cd79 100644 --- a/audio/mididrv.h +++ b/audio/mididrv.h @@ -253,7 +253,7 @@ public: static DeviceHandle detectDevice(int flags); /** Find the music driver matching the given driver name/description. */ - static DeviceHandle getDeviceHandle(const Common::U32String &identifier); + static DeviceHandle getDeviceHandle(const Common::String &identifier); /** Check whether the device with the given handle is available. */ static bool checkDevice(DeviceHandle handle); @@ -262,7 +262,7 @@ public: static MusicType getMusicType(DeviceHandle handle); /** Get the device description string matching the given device handle and the given type. */ - static Common::U32String getDeviceString(DeviceHandle handle, DeviceStringType type); + static Common::String getDeviceString(DeviceHandle handle, DeviceStringType type); /** Common operations to be done by all drivers on start of send */ void midiDriverCommonSend(uint32 b); diff --git a/audio/musicplugin.cpp b/audio/musicplugin.cpp index e18274cffc7..56f73fd57ef 100644 --- a/audio/musicplugin.cpp +++ b/audio/musicplugin.cpp @@ -25,12 +25,12 @@ #include "common/translation.h" MusicDevice::MusicDevice(MusicPluginObject const *musicPlugin, Common::String name, MusicType mt) : - _musicDriverName(_(musicPlugin->getName())), _musicDriverId(musicPlugin->getId()), - _name(_(name)), _type(mt) { + _musicDriverName(musicPlugin->getName()), _musicDriverId(musicPlugin->getId()), + _name(name), _type(mt) { } -Common::U32String MusicDevice::getCompleteName() { - Common::U32String name; +Common::String MusicDevice::getCompleteName() { + Common::String name; if (_name.empty()) { // Default device, just show the driver name @@ -38,18 +38,18 @@ Common::U32String MusicDevice::getCompleteName() { } else { // Show both device and driver names name = _name; - name += Common::U32String(" ["); + name += " ["; name += _musicDriverName; - name += Common::U32String("]"); + name += "]"; } return name; } -Common::U32String MusicDevice::getCompleteId() { - Common::U32String id = _musicDriverId; +Common::String MusicDevice::getCompleteId() { + Common::String id = _musicDriverId; if (!_name.empty()) { - id += Common::U32String("_"); + id += "_"; id += _name; } @@ -57,5 +57,5 @@ Common::U32String MusicDevice::getCompleteId() { } MidiDriver::DeviceHandle MusicDevice::getHandle() { - return (MidiDriver::DeviceHandle)Common::hashit(getCompleteId().encode().c_str()); + return (MidiDriver::DeviceHandle)Common::hashit(getCompleteId()); } diff --git a/audio/musicplugin.h b/audio/musicplugin.h index 9ae19e545b9..705d7a9552c 100644 --- a/audio/musicplugin.h +++ b/audio/musicplugin.h @@ -26,7 +26,6 @@ #include "base/plugins.h" #include "audio/mididrv.h" #include "common/list.h" -#include "common/ustr.h" namespace Common { class Error; @@ -43,29 +42,29 @@ class MusicDevice { public: MusicDevice(MusicPluginObject const *musicPlugin, Common::String name, MusicType mt); - const Common::U32String &getName() const { return _name; } - const Common::U32String &getMusicDriverName() const { return _musicDriverName; } - const Common::U32String &getMusicDriverId() const { return _musicDriverId; } + const Common::String &getName() const { return _name; } + const Common::String &getMusicDriverName() const { return _musicDriverName; } + const Common::String &getMusicDriverId() const { return _musicDriverId; } MusicType getMusicType() const { return _type; } /** * Returns a user readable string that contains the name of the current * device name (if it isn't the default one) and the name of the driver. */ - Common::U32String getCompleteName(); + Common::String getCompleteName(); /** * Returns a user readable string that contains the name of the current * device name (if it isn't the default one) and the id of the driver. */ - Common::U32String getCompleteId(); + Common::String getCompleteId(); MidiDriver::DeviceHandle getHandle(); private: - Common::U32String _name; - Common::U32String _musicDriverName; - Common::U32String _musicDriverId; + Common::String _name; + Common::String _musicDriverName; + Common::String _musicDriverId; MusicType _type; }; diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 7b09e286501..1a25109aedf 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -67,12 +67,12 @@ public: // Callbacks for reporting various errors and information void onErrorControlROM() { - GUI::MessageDialog dialog("MT32Emu: Init Error - Missing or invalid Control ROM image"); + GUI::MessageDialog dialog("MT32Emu: Init Error - Missing or invalid Control ROM image", "OK"); dialog.runModal(); error("MT32emu: Init Error - Missing or invalid Control ROM image"); } void onErrorPCMROM() { - GUI::MessageDialog dialog("MT32Emu: Init Error - Missing PCM ROM image"); + GUI::MessageDialog dialog("MT32Emu: Init Error - Missing PCM ROM image", "OK"); dialog.runModal(); error("MT32emu: Init Error - Missing PCM ROM image"); } diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index ecc6950cb36..1797e5d3645 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -2237,9 +2237,9 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const Common::U32String &msg // Split the message into separate lines. Common::Array lines; - Common::U32String::const_iterator itr = msg.begin(), strLineItrBegin = msg.begin(); + Common::U32String::const_iterator strLineItrBegin = msg.begin(); - for ( ; itr != msg.end(); itr++) { + for (Common::U32String::const_iterator itr = msg.begin(); itr != msg.end(); itr++) { if (*itr == '\n') { lines.push_back(Common::U32String(strLineItrBegin, itr)); strLineItrBegin = itr + 1; diff --git a/backends/keymapper/remap-widget.cpp b/backends/keymapper/remap-widget.cpp index abd3caf7e64..4c81b29258a 100644 --- a/backends/keymapper/remap-widget.cpp +++ b/backends/keymapper/remap-widget.cpp @@ -219,8 +219,8 @@ void RemapWidget::startRemapping(uint actionIndex) { _remapTimeout = g_system->getMillis() + kRemapTimeoutDelay; _remapInputWatcher->startWatching(); - _actions[actionIndex].keyButton->setLabel(U32String("...")); - _actions[actionIndex].keyButton->setTooltip(U32String("")); + _actions[actionIndex].keyButton->setLabel("..."); + _actions[actionIndex].keyButton->setTooltip(""); _actions[actionIndex].keyButton->markAsDirty(); g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); @@ -301,8 +301,8 @@ void RemapWidget::refreshKeymap() { row.keyButton->setLabel(keysLabel); row.keyButton->setTooltip(keysLabel); } else { - row.keyButton->setLabel(U32String("-")); - row.keyButton->setTooltip(U32String("")); + row.keyButton->setLabel("-"); + row.keyButton->setTooltip(""); } KeymapTitleRow &keymapTitle = _keymapSeparators[row.keymap]; diff --git a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp index e00e583485f..96f13737366 100644 --- a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp +++ b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp @@ -57,7 +57,7 @@ void CreateDirectoryHandler::handle(Client &client) { // check that is not an absolute root if (path == "" || path == "/") { - handleError(client, Common::convertFromU32String(_("Can't create directory here!")).c_str()); + handleError(client, Common::convertFromU32String(_("Can't create directory here!"))); return; } diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 8bea8dda95e..2fe96929865 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -519,10 +519,9 @@ Common::U32String OSystem_SDL::getTextFromClipboard() { bool OSystem_SDL::setTextInClipboard(const Common::U32String &text) { // The encoding we need to use is UTF-8. Assume we currently have the // current TranslationManager encoding or ISO-8859-1. - char *utf8_text = SDL_iconv_string("UTF-8", TransMan.getCurrentCharset().c_str(), text.encode().c_str(), text.size() + 1); + char *utf8_text = (char *)text.encode().c_str(); if (utf8_text) { int status = SDL_SetClipboardText(utf8_text); - SDL_free(utf8_text); return status == 0; } return SDL_SetClipboardText(text.encode().c_str()) == 0; diff --git a/backends/text-to-speech/linux/linux-text-to-speech.cpp b/backends/text-to-speech/linux/linux-text-to-speech.cpp index a7777f1a500..8825296ee7f 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.cpp +++ b/backends/text-to-speech/linux/linux-text-to-speech.cpp @@ -226,6 +226,10 @@ bool SpeechDispatcherManager::say(const Common::U32String &str, Action action, C return false; } +bool SpeechDispatcherManager::say(const Common::String &str, Action action, Common::String charset) { + return say(Common::U32String(str), action, charset); +} + bool SpeechDispatcherManager::stop() { if (_speechState == READY || _speechState == BROKEN) return true; diff --git a/backends/text-to-speech/linux/linux-text-to-speech.h b/backends/text-to-speech/linux/linux-text-to-speech.h index 77b790509d0..906d0ada8f9 100644 --- a/backends/text-to-speech/linux/linux-text-to-speech.h +++ b/backends/text-to-speech/linux/linux-text-to-speech.h @@ -61,6 +61,7 @@ public: virtual ~SpeechDispatcherManager() override; virtual bool say(const Common::U32String &str, Action action, Common::String charset = "") override; + virtual bool say(const Common::String &str, Action action, Common::String charset = "") override; virtual bool stop() override; virtual bool pause() override; diff --git a/backends/text-to-speech/macosx/macosx-text-to-speech.h b/backends/text-to-speech/macosx/macosx-text-to-speech.h index b3e96c228b2..35bb723f7dc 100644 --- a/backends/text-to-speech/macosx/macosx-text-to-speech.h +++ b/backends/text-to-speech/macosx/macosx-text-to-speech.h @@ -37,6 +37,7 @@ public: virtual ~MacOSXTextToSpeechManager() override; virtual bool say(const Common::U32String &str, Action action, Common::String charset = "") override; + virtual bool say(const Common::String &str, Action action, Common::String charset = "") override; virtual bool stop() override; virtual bool pause() override; diff --git a/backends/text-to-speech/macosx/macosx-text-to-speech.mm b/backends/text-to-speech/macosx/macosx-text-to-speech.mm index ddf4a4fab74..ff205390884 100644 --- a/backends/text-to-speech/macosx/macosx-text-to-speech.mm +++ b/backends/text-to-speech/macosx/macosx-text-to-speech.mm @@ -119,6 +119,10 @@ bool MacOSXTextToSpeechManager::say(const Common::U32String &text, Action action return true; } +bool MacOSXTextToSpeechManager::say(const Common::String &text, Action action, Common::String encoding) { + return say(Common::U32String(text), action, encoding); +} + bool MacOSXTextToSpeechManager::startNextSpeech() { _currentSpeech.clear(); if (_messageQueue.empty()) diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 8e264f148e6..1607319c587 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -961,7 +961,7 @@ static void listAudioDevices() { const MusicPluginObject &musicObject = (*i)->get(); MusicDevices deviceList = musicObject.getDevices(); for (MusicDevices::iterator j = deviceList.begin(), jend = deviceList.end(); j != jend; ++j) { - printf("%-30s %s\n", Common::String::format("\"%s\"", j->getCompleteId().encode().c_str()).c_str(), j->getCompleteName().encode().c_str()); + printf("%-30s %s\n", Common::String::format("\"%s\"", j->getCompleteId().c_str()).c_str(), j->getCompleteName().c_str()); } } } diff --git a/common/ustr.cpp b/common/ustr.cpp index ceaa1ca52b4..d7b9d0c1391 100644 --- a/common/ustr.cpp +++ b/common/ustr.cpp @@ -579,6 +579,7 @@ int U32String::vformat(U32String::const_iterator fmt, const U32String::const_ite output.insertString(buffer, pos); pos += len - 1; + break; case 'i': int_temp = va_arg(args, uint16); itoa(int_temp, buffer, 10); @@ -587,6 +588,7 @@ int U32String::vformat(U32String::const_iterator fmt, const U32String::const_ite output.insertString(buffer, pos); pos += len - 1; + break; default: warning("Unexpected formatting type for U32String::Format."); break; diff --git a/gui/about.cpp b/gui/about.cpp index bfef4f1a39f..448fe73cfbf 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -147,8 +147,7 @@ void AboutDialog::addLine(const U32String &str) { if (*strBeginItr == 0) { _lines.push_back(U32String("")); } else { - U32String dupliStr = str; - Common::U32String format(dupliStr.encode().c_str(), 2); + Common::U32String format(str.begin(), str.begin() + 2); strBeginItr += 2; U32String renderStr(strBeginItr, str.end()); diff --git a/gui/browser.cpp b/gui/browser.cpp index 6284e63e984..b77bff83005 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -72,7 +72,7 @@ BrowserDialog::BrowserDialog(const Common::U32String &title, bool dirBrowser) _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain; // Checkbox for the "show hidden files" state. - _showHiddenWidget = new CheckboxWidget(this, "Browser.Hidden", (_("Show hidden files")), _("Show files marked with the hidden attribute"), kHiddenCmd); + _showHiddenWidget = new CheckboxWidget(this, "Browser.Hidden", _("Show hidden files"), _("Show files marked with the hidden attribute"), kHiddenCmd); // Buttons if (g_system->getOverlayWidth() > 320) diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp index a10357676ca..8ec1563a69a 100644 --- a/gui/editgamedialog.cpp +++ b/gui/editgamedialog.cpp @@ -88,7 +88,7 @@ enum { */ class DomainEditTextWidget : public EditTextWidget { public: - DomainEditTextWidget(GuiObject *boss, const String &name, const String &text, U32String tooltip = U32String("")) + DomainEditTextWidget(GuiObject *boss, const String &name, const U32String &text, const U32String &tooltip = U32String("")) : EditTextWidget(boss, name, text, tooltip) {} protected: @@ -152,11 +152,11 @@ EditGameDialog::EditGameDialog(const String &domain) _langPopUpDesc = new StaticTextWidget(tab, "GameOptions_Game.LangPopupDesc", _("Language:"), _("Language of the game. This will not turn your Spanish game version into English")); _langPopUp = new PopUpWidget(tab, "GameOptions_Game.LangPopup", _("Language of the game. This will not turn your Spanish game version into English")); _langPopUp->appendEntry(_(""), (uint32)Common::UNK_LANG); - _langPopUp->appendEntry(Common::U32String(""), (uint32)Common::UNK_LANG); + _langPopUp->appendEntry("", (uint32)Common::UNK_LANG); const Common::LanguageDescription *l = Common::g_languages; for (; l->code; ++l) { if (checkGameGUIOptionLanguage(l->id, _guioptionsString)) - _langPopUp->appendEntry(Common::convertToU32String(l->description), l->id); + _langPopUp->appendEntry(l->description, l->id); } // Platform popup @@ -166,10 +166,10 @@ EditGameDialog::EditGameDialog(const String &domain) _platformPopUpDesc = new StaticTextWidget(tab, "GameOptions_Game.PlatformPopupDesc", _c("Platform:", "lowres"), _("Platform the game was originally designed for")); _platformPopUp = new PopUpWidget(tab, "GameOptions_Game.PlatformPopup", _("Platform the game was originally designed for")); _platformPopUp->appendEntry(_("")); - _platformPopUp->appendEntry(Common::U32String("")); + _platformPopUp->appendEntry(""); const Common::PlatformDescription *p = Common::g_platforms; for (; p->code; ++p) { - _platformPopUp->appendEntry(Common::convertToU32String(p->description), p->id); + _platformPopUp->appendEntry(p->description, p->id); } // @@ -237,7 +237,7 @@ EditGameDialog::EditGameDialog(const String &domain) // // 4) The audio tab // - tab->addTab((_("Audio")), "GameOptions_Audio"); + tab->addTab(_("Audio"), "GameOptions_Audio"); if (g_system->getOverlayWidth() > 320) _globalAudioOverride = new CheckboxWidget(tab, "GameOptions_Audio.EnableTabCheckbox", _("Override global audio settings"), Common::U32String(""), kCmdGlobalAudioOverride); @@ -307,9 +307,9 @@ EditGameDialog::EditGameDialog(const String &domain) // GUI: Button + Label for the game path if (g_system->getOverlayWidth() > 320) - new ButtonWidget(tab, "GameOptions_Paths.Gamepath", (_("Game Path:")), Common::U32String(""), kCmdGameBrowser); + new ButtonWidget(tab, "GameOptions_Paths.Gamepath", _("Game Path:"), Common::U32String(""), kCmdGameBrowser); else - new ButtonWidget(tab, "GameOptions_Paths.Gamepath", (_c("Game Path:", "lowres")), Common::U32String(""), kCmdGameBrowser); + new ButtonWidget(tab, "GameOptions_Paths.Gamepath", _c("Game Path:", "lowres"), Common::U32String(""), kCmdGameBrowser); _gamePathWidget = new StaticTextWidget(tab, "GameOptions_Paths.GamepathText", gamePath); // GUI: Button + Label for the additional path @@ -337,7 +337,7 @@ EditGameDialog::EditGameDialog(const String &domain) const MetaEngine &metaEngine = plugin->get(); Common::AchievementsInfo achievementsInfo = metaEngine.getAchievementsInfo(domain); if (achievementsInfo.descriptions.size() > 0) { - tab->addTab((_("Achievements")), "GameOptions_Achievements"); + tab->addTab(_("Achievements"), "GameOptions_Achievements"); addAchievementsControls(tab, "GameOptions_Achievements.", achievementsInfo); } } @@ -438,7 +438,7 @@ void EditGameDialog::open() { } void EditGameDialog::apply() { - ConfMan.set("description", Common::convertFromU32String(_descriptionWidget->getEditString()), _domain); + ConfMan.set("description", _descriptionWidget->getEditString(), _domain); Common::Language lang = (Common::Language)_langPopUp->getSelectedTag(); if (lang < 0) @@ -448,17 +448,17 @@ void EditGameDialog::apply() { U32String gamePath(_gamePathWidget->getLabel()); if (!gamePath.empty()) - ConfMan.set("path", gamePath.encode(), _domain); + ConfMan.set("path", gamePath, _domain); U32String extraPath(_extraPathWidget->getLabel()); if (!extraPath.empty() && (extraPath != _c("None", "path"))) - ConfMan.set("extrapath", extraPath.encode(), _domain); + ConfMan.set("extrapath", extraPath, _domain); else ConfMan.removeKey("extrapath", _domain); U32String savePath(_savePathWidget->getLabel()); if (!savePath.empty() && (savePath != _("Default"))) - ConfMan.set("savepath", savePath.encode(), _domain); + ConfMan.set("savepath", savePath, _domain); else ConfMan.removeKey("savepath", _domain); diff --git a/gui/error.cpp b/gui/error.cpp index 3cfc0ef020b..ca7c487027d 100644 --- a/gui/error.cpp +++ b/gui/error.cpp @@ -33,7 +33,7 @@ void displayErrorDialog(const Common::U32String &text) { alert.runModal(); } -void displayErrorDialog(const Common::Error &error, Common::U32String extraText) { +void displayErrorDialog(const Common::Error &error, const Common::U32String &extraText) { Common::U32String errorText(extraText); errorText += Common::U32String(" "); errorText += _(error.getDesc()); diff --git a/gui/error.h b/gui/error.h index 1da53d9e19c..f97faafbe9a 100644 --- a/gui/error.h +++ b/gui/error.h @@ -33,7 +33,7 @@ namespace GUI { * @param error error code * @param extraText extra text to be displayed in addition to default string description(optional) */ -void displayErrorDialog(const Common::Error &error, Common::U32String = Common::U32String("")); +void displayErrorDialog(const Common::Error &error, const Common::U32String &extraText = Common::U32String("")); /** * Displays an error dialog for a given message. diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 7dc35edd973..c48c00faa77 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -163,7 +163,7 @@ void LauncherDialog::build() { new ButtonWidget(this, "Launcher.RemoveGameButton", _("~R~emove Game"), _("Remove game from the list. The game data files stay intact"), kRemoveGameCmd); } else { DropdownButtonWidget *addButton = - new DropdownButtonWidget(this, "Launcher.AddGameButton", (_c("~A~dd Game...", "lowres")), _("Add games to the list"), kAddGameCmd); + new DropdownButtonWidget(this, "Launcher.AddGameButton", _c("~A~dd Game...", "lowres"), _("Add games to the list"), kAddGameCmd); addButton->appendEntry(_c("Mass Add...", "lowres"), kMassAddGameCmd); _addButton = addButton; diff --git a/gui/massadd.cpp b/gui/massadd.cpp index cee29071c44..956f5f24a63 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -73,10 +73,10 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir) // new StaticTextWidget(this, "massadddialog_caption", "Mass Add Dialog"); _dirProgressText = new StaticTextWidget(this, "MassAdd.DirProgressText", - _("... progress ...")); + _("... progress ...")); _gameProgressText = new StaticTextWidget(this, "MassAdd.GameProgressText", - _("... progress ...")); + _("... progress ...")); _dirProgressText->setAlign(Graphics::kTextAlignCenter); _gameProgressText->setAlign(Graphics::kTextAlignCenter); @@ -86,10 +86,10 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir) _list->setNumberingMode(kListNumberingOff); _list->setList(l); - _okButton = new ButtonWidget(this, "MassAdd.Ok", Common::U32String("Ok"), Common::U32String(""), kOkCmd, Common::ASCII_RETURN); + _okButton = new ButtonWidget(this, "MassAdd.Ok", _("OK"), Common::U32String(""), kOkCmd, Common::ASCII_RETURN); _okButton->setEnabled(false); - new ButtonWidget(this, "MassAdd.Cancel", Common::U32String("Cancel"), Common::U32String(""), kCancelCmd, Common::ASCII_ESCAPE); + new ButtonWidget(this, "MassAdd.Cancel", _("Cancel"), Common::U32String(""), kCancelCmd, Common::ASCII_ESCAPE); // Build a map from all configured game paths to the targets using them const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains(); diff --git a/gui/message.cpp b/gui/message.cpp index 401cb30ce0f..827a0d05116 100644 --- a/gui/message.cpp +++ b/gui/message.cpp @@ -39,7 +39,7 @@ enum { // TODO: The default button should be visibly distinct from the alternate button -MessageDialog::MessageDialog(const Common::U32String &message, Common::U32String defaultButton, Common::U32String altButton, Graphics::TextAlign alignment, const char *url) +MessageDialog::MessageDialog(const Common::U32String &message, const Common::U32String &defaultButton, const Common::U32String &altButton, Graphics::TextAlign alignment, const char *url) : Dialog(30, 20, 260, 124) { _url = url; @@ -93,11 +93,15 @@ MessageDialog::MessageDialog(const Common::U32String &message, Common::U32String okButtonPos = cancelButtonPos = (_w - buttonWidth) / 2; } - if (!defaultButton.empty()) - new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, defaultButton, Common::U32String(""), kOkCmd, Common::ASCII_RETURN); // Confirm dialog + if (!defaultButton.empty()) { + // Confirm dialog + new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, defaultButton, Common::U32String(""), kOkCmd, Common::ASCII_RETURN); + } - if (!altButton.empty()) - new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, altButton, Common::U32String(""), kCancelCmd, Common::ASCII_ESCAPE); // Cancel dialog + if (!altButton.empty()) { + // Cancel dialog + new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, altButton, Common::U32String(""), kCancelCmd, Common::ASCII_ESCAPE); + } } MessageDialog::MessageDialog(const char *message, const char *defaultButton, const char *altButton, Graphics::TextAlign alignment) diff --git a/gui/message.h b/gui/message.h index 89ccd8ff257..80ad8216e48 100644 --- a/gui/message.h +++ b/gui/message.h @@ -41,7 +41,7 @@ enum { */ class MessageDialog : public Dialog { public: - MessageDialog(const Common::U32String &message, Common::U32String defaultButton = Common::U32String("OK"), Common::U32String altButton = Common::U32String(""), Graphics::TextAlign alignment = Graphics::kTextAlignCenter, const char *url = nullptr); + MessageDialog(const Common::U32String &message, const Common::U32String &defaultButton = Common::U32String("OK"), const Common::U32String &altButton = Common::U32String(""), Graphics::TextAlign alignment = Graphics::kTextAlignCenter, const char *url = nullptr); MessageDialog(const char *message, const char *defaultButton = "OK", const char *altButton = "", Graphics::TextAlign alignment = Graphics::kTextAlignCenter, const char *url = nullptr); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override; diff --git a/gui/options.cpp b/gui/options.cpp index 68b60e4a826..ecd48842fc2 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1155,13 +1155,13 @@ void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::Strin } CheckboxWidget *checkBox; - checkBox = new CheckboxWidget(scrollContainer, lineHeight, yPos, width, yStep, Common::convertToU32String(info.descriptions[idx].title)); + checkBox = new CheckboxWidget(scrollContainer, lineHeight, yPos, width, yStep, Common::U32String(info.descriptions[idx].title)); checkBox->setEnabled(false); checkBox->setState(isAchieved); yPos += yStep; if (info.descriptions[idx].comment && strlen(info.descriptions[idx].comment) > 0) { - new StaticTextWidget(scrollContainer, lineHeight + descrDelta, yPos, width - descrDelta, yStep, Common::convertToU32String(info.descriptions[idx].comment), Graphics::kTextAlignStart, Common::U32String(""), ThemeEngine::kFontStyleNormal); + new StaticTextWidget(scrollContainer, lineHeight + descrDelta, yPos, width - descrDelta, yStep, Common::U32String(info.descriptions[idx].comment), Graphics::kTextAlignStart, Common::U32String(""), ThemeEngine::kFontStyleNormal); yPos += yStep; } @@ -1486,7 +1486,7 @@ bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String se return true; if (_domain != Common::ConfigManager::kApplicationDomain || ConfMan.hasKey(setting, _domain) || preferredType) { - const Common::U32String drv = ConfMan.get(setting, (_domain != Common::ConfigManager::kApplicationDomain && !ConfMan.hasKey(setting, _domain)) ? Common::ConfigManager::kApplicationDomain : _domain); + const Common::String drv = ConfMan.get(setting, (_domain != Common::ConfigManager::kApplicationDomain && !ConfMan.hasKey(setting, _domain)) ? Common::ConfigManager::kApplicationDomain : _domain); const PluginList p = MusicMan.getPlugins(); for (PluginList::const_iterator m = p.begin(); m != p.end(); ++m) { @@ -1513,7 +1513,7 @@ void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String se MusicDevices i = (*m)->get().getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { if (d->getHandle() == popup->getSelectedTag()) { - ConfMan.set(setting, d->getCompleteId().encode().c_str(), _domain); + ConfMan.set(setting, d->getCompleteId(), _domain); found = true; break; } @@ -1851,24 +1851,24 @@ void GlobalOptionsDialog::build() { #if !defined(__DC__) // Set _savePath to the current save path - Common::U32String savePath(ConfMan.get("savepath", _domain)); - Common::U32String themePath(ConfMan.get("themepath", _domain)); - Common::U32String extraPath(ConfMan.get("extrapath", _domain)); + Common::String savePath(ConfMan.get("savepath", _domain)); + Common::String themePath(ConfMan.get("themepath", _domain)); + Common::String extraPath(ConfMan.get("extrapath", _domain)); if (savePath.empty() || !ConfMan.hasKey("savepath", _domain)) { - _savePath->setLabel((_("Default"))); + _savePath->setLabel(_("Default")); } else { _savePath->setLabel(savePath); } if (themePath.empty() || !ConfMan.hasKey("themepath", _domain)) { - _themePath->setLabel((_c("None", "path"))); + _themePath->setLabel(_c("None", "path")); } else { _themePath->setLabel(themePath); } if (extraPath.empty() || !ConfMan.hasKey("extrapath", _domain)) { - _extraPath->setLabel((_c("None", "path"))); + _extraPath->setLabel(_c("None", "path")); } else { _extraPath->setLabel(extraPath); } @@ -1900,7 +1900,7 @@ void GlobalOptionsDialog::build() { #ifdef USE_SDL_NET Common::String rootPath(ConfMan.get("rootpath", "cloud")); if (rootPath.empty() || !ConfMan.hasKey("rootpath", "cloud")) { - _rootPath->setLabel((_c("None", "path"))); + _rootPath->setLabel(_c("None", "path")); } else { _rootPath->setLabel(rootPath); } @@ -1982,10 +1982,10 @@ void GlobalOptionsDialog::addMiscControls(GuiObject *boss, const Common::String if (!lowres) { for (uint i = 1; i < GUI::ThemeEngine::_rendererModesSize; ++i) - _rendererPopUp->appendEntry((_(GUI::ThemeEngine::_rendererModes[i].name)), GUI::ThemeEngine::_rendererModes[i].mode); + _rendererPopUp->appendEntry(_(GUI::ThemeEngine::_rendererModes[i].name), GUI::ThemeEngine::_rendererModes[i].mode); } else { for (uint i = 1; i < GUI::ThemeEngine::_rendererModesSize; ++i) - _rendererPopUp->appendEntry((_(GUI::ThemeEngine::_rendererModes[i].shortname)), GUI::ThemeEngine::_rendererModes[i].mode); + _rendererPopUp->appendEntry(_(GUI::ThemeEngine::_rendererModes[i].shortname), GUI::ThemeEngine::_rendererModes[i].mode); } if (!lowres) @@ -2011,12 +2011,12 @@ void GlobalOptionsDialog::addMiscControls(GuiObject *boss, const Common::String #ifdef USE_DETECTLANG _guiLanguagePopUp->appendEntry(_(""), Common::kTranslationAutodetectId); #endif // USE_DETECTLANG - _guiLanguagePopUp->appendEntry(Common::U32String("English"), Common::kTranslationBuiltinId); - _guiLanguagePopUp->appendEntry(Common::U32String(""), 0); + _guiLanguagePopUp->appendEntry("English", Common::kTranslationBuiltinId); + _guiLanguagePopUp->appendEntry("", 0); Common::TLangArray languages = TransMan.getSupportedLanguageNames(); Common::TLangArray::iterator lang = languages.begin(); while (lang != languages.end()) { - _guiLanguagePopUp->appendEntry(Common::convertToU32String(lang->name), lang->id); + _guiLanguagePopUp->appendEntry(lang->name, lang->id); lang++; } @@ -2168,7 +2168,7 @@ void GlobalOptionsDialog::addNetworkControls(GuiObject *boss, const Common::Stri #ifdef USE_TTS void GlobalOptionsDialog::addAccessibilityControls(GuiObject *boss, const Common::String &prefix) { _ttsCheckbox = new CheckboxWidget(boss, prefix + "TTSCheckbox", - _("Use Text to speech"), _("Will read text in gui on mouse over.")); + _("Use Text to speech"), _("Will read text in gui on mouse over.")); if (ConfMan.hasKey("tts_enabled")) _ttsCheckbox->setState(ConfMan.getBool("tts_enabled", _domain)); else @@ -2486,7 +2486,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 Common::FSNode file(browser.getResult()); _soundFont->setLabel(file.getPath()); - if (!file.getPath().empty() && (Common::convertToU32String(file.getPath().c_str()) != _c("None", "path"))) + if (!file.getPath().empty() && (file.getPath().decode() != _c("None", "path"))) _soundFontClearButton->setEnabled(true); else _soundFontClearButton->setEnabled(false); @@ -2572,9 +2572,9 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 break; } case kConnectStorageCmd: { - Common::U32String code(""); + Common::String code = ""; if (_storageWizardCodeBox) - code = _storageWizardCodeBox->getEditString(); + code = _storageWizardCodeBox->getEditString().encode(); if (code.size() == 0) return; @@ -2605,7 +2605,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 if (_storageWizardConnectionStatusHint) _storageWizardConnectionStatusHint->setLabel(_("Connecting...")); CloudMan.connectStorage( - _selectedStorageIndex, Common::convertFromU32String(code), + _selectedStorageIndex, code, new Common::Callback(this, &GlobalOptionsDialog::storageConnectionCallback) ); _connectingStorage = true; diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp index 3abedb7d237..add657b6471 100644 --- a/gui/predictivedialog.cpp +++ b/gui/predictivedialog.cpp @@ -70,8 +70,8 @@ enum { PredictiveDialog::PredictiveDialog() : Dialog("Predictive") { new StaticTextWidget(this, "Predictive.Headline", Common::U32String("Enter Text")); - _button[kCancelAct] = new ButtonWidget(this, "Predictive.Cancel", (_("Cancel")) , Common::U32String(""), kCancelCmd); - _button[kOkAct] = new ButtonWidget(this, "Predictive.OK", (_("Ok")) , Common::U32String(""), kOkCmd); + _button[kCancelAct] = new ButtonWidget(this, "Predictive.Cancel", _("Cancel") , Common::U32String(""), kCancelCmd); + _button[kOkAct] = new ButtonWidget(this, "Predictive.OK", _("Ok") , Common::U32String(""), kOkCmd); if (g_gui.useRTL()) { /** If using RTL, swap the internal name of odd columns, to be flipped again when drawing. @@ -103,8 +103,8 @@ PredictiveDialog::PredictiveDialog() : Dialog("Predictive") { } // I18N: You must leave "#" as is, only word 'next' is translatable - _button[kNextAct] = new ButtonWidget(this, "Predictive.Next", (_("# next")) , Common::U32String(""), kNextCmd); - _button[kAddAct] = new ButtonWidget(this, "Predictive.Add", (_("add")) , Common::U32String(""), kAddCmd); + _button[kNextAct] = new ButtonWidget(this, "Predictive.Next", _("# next") , Common::U32String(""), kNextCmd); + _button[kAddAct] = new ButtonWidget(this, "Predictive.Add", _("add") , Common::U32String(""), kAddCmd); _button[kAddAct]->setEnabled(false); #ifndef DISABLE_FANCY_THEMES @@ -114,7 +114,7 @@ PredictiveDialog::PredictiveDialog() : Dialog("Predictive") { ((PicButtonWidget *)_button[kDelAct])->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageDelButton)); } else #endif - _button[kDelAct] = new ButtonWidget(this, "Predictive.Delete" , (_("<")) , Common::U32String(""), kDelCmd); + _button[kDelAct] = new ButtonWidget(this, "Predictive.Delete" , _("<") , Common::U32String(""), kDelCmd); // I18N: Pre means 'Predictive', leave '*' as is _button[kModeAct] = new ButtonWidget(this, "Predictive.Pre", _("* Pre"), Common::U32String(""), kModeCmd); _editText = new EditTextWidget(this, "Predictive.Word", _search, Common::U32String(""), 0, 0); @@ -190,7 +190,7 @@ void PredictiveDialog::reflowLayout() { ((PicButtonWidget *)_button[kDelAct])->useThemeTransparency(true); ((PicButtonWidget *)_button[kDelAct])->setGfx(g_gui.theme()->getImageSurface(ThemeEngine::kImageDelButton)); } else { - _button[kDelAct] = new ButtonWidget(this, "Predictive.Delete" , (_("<")) , Common::U32String(""), kDelCmd); + _button[kDelAct] = new ButtonWidget(this, "Predictive.Delete" , _("<") , Common::U32String(""), kDelCmd); } #endif diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 58112a4726f..c4a28b7da51 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -49,7 +49,7 @@ enum { }; SaveLoadCloudSyncProgressDialog::SaveLoadCloudSyncProgressDialog(bool canRunInBackground): Dialog("SaveLoadCloudSyncProgress"), _close(false) { - _label = new StaticTextWidget(this, "SaveLoadCloudSyncProgress.TitleText", Common::U32String("Downloading saves...")); + _label = new StaticTextWidget(this, "SaveLoadCloudSyncProgress.TitleText", _("Downloading saves...")); uint32 progress = (uint32)(100 * CloudMan.getSyncDownloadingProgress()); _progressBar = new SliderWidget(this, "SaveLoadCloudSyncProgress.ProgressBar"); _progressBar->setMinValue(0); @@ -57,8 +57,8 @@ SaveLoadCloudSyncProgressDialog::SaveLoadCloudSyncProgressDialog(bool canRunInBa _progressBar->setValue(progress); _progressBar->setEnabled(false); _percentLabel = new StaticTextWidget(this, "SaveLoadCloudSyncProgress.PercentText", Common::String::format("%u %%", progress)); - new ButtonWidget(this, "SaveLoadCloudSyncProgress.Cancel", Common::U32String("Cancel"), Common::U32String(""), kCancelSyncCmd, Common::ASCII_ESCAPE); // Cancel dialog - ButtonWidget *backgroundButton = new ButtonWidget(this, "SaveLoadCloudSyncProgress.Background", Common::U32String("Run in background"), Common::U32String(""), kBackgroundSyncCmd, Common::ASCII_RETURN); // Confirm dialog + new ButtonWidget(this, "SaveLoadCloudSyncProgress.Cancel", _("Cancel"), Common::U32String(""), kCancelSyncCmd, Common::ASCII_ESCAPE); // Cancel dialog + ButtonWidget *backgroundButton = new ButtonWidget(this, "SaveLoadCloudSyncProgress.Background", _("Run in background"), Common::U32String(""), kBackgroundSyncCmd, Common::ASCII_RETURN); // Confirm dialog backgroundButton->setEnabled(canRunInBackground); g_gui.scheduleTopDialogRedraw(); } @@ -348,7 +348,7 @@ void SaveLoadChooserDialog::addChooserButtons() { } } -ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &name, Common::U32String desc, Common::U32String tooltip, const char *image, uint32 cmd) { +ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &name, const Common::U32String &desc, const Common::U32String &tooltip, const char *image, uint32 cmd) { ButtonWidget *button; #ifndef DISABLE_FANCY_THEMES @@ -683,7 +683,7 @@ void SaveLoadChooserSimple::updateSaveList() { saveSlot = x->getSaveSlot(); if (curSlot < saveSlot) { while (curSlot < saveSlot) { - SaveStateDescriptor dummySave(curSlot, Common::U32String("")); + SaveStateDescriptor dummySave(curSlot, ""); _saveList.insert_at(curSlot, dummySave); saveNames.push_back(dummySave.getDescription()); colors.push_back(ThemeEngine::kFontColorNormal); @@ -727,7 +727,7 @@ void SaveLoadChooserSimple::updateSaveList() { Common::String emptyDesc; for (int i = curSlot; i <= maximumSaveSlots; i++) { saveNames.push_back(emptyDesc); - SaveStateDescriptor dummySave(i, Common::U32String("")); + SaveStateDescriptor dummySave(i, ""); _saveList.push_back(dummySave); colors.push_back(ThemeEngine::kFontColorNormal); } @@ -1102,7 +1102,7 @@ void SaveLoadChooserGrid::updateSaves() { } else { curButton.button->setGfx(kThumbnailWidth, kThumbnailHeight2, 0, 0, 0); } - curButton.description->setLabel(Common::String::format("%d. %s", saveSlot, desc.getDescription().encode().c_str())); + curButton.description->setLabel(Common::U32String(Common::String::format("%d. ", saveSlot)) + desc.getDescription()); Common::U32String tooltip(_("Name: ")); tooltip += desc.getDescription(); @@ -1165,7 +1165,7 @@ SavenameDialog::SavenameDialog() new ButtonWidget(this, "SavenameDialog.Cancel", _("Cancel"), Common::U32String(""), kCloseCmd); new ButtonWidget(this, "SavenameDialog.Ok", _("OK"), Common::U32String(""), kOKCmd); - _description = new EditTextWidget(this, "SavenameDialog.Description", Common::String(), Common::U32String(""), 0, kOKCmd); + _description = new EditTextWidget(this, "SavenameDialog.Description", Common::U32String(), Common::U32String(""), 0, kOKCmd); _targetSlot = 0; } diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index de517a8caff..aaea785b230 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -126,7 +126,7 @@ protected: ButtonWidget *_gridButton; void addChooserButtons(); - ButtonWidget *createSwitchButton(const Common::String &name, Common::U32String desc, Common::U32String tooltip, const char *image, uint32 cmd = 0); + ButtonWidget *createSwitchButton(const Common::String &name, const Common::U32String &desc, const Common::U32String &tooltip, const char *image, uint32 cmd = 0); #endif // !DISABLE_SAVELOADCHOOSER_GRID }; diff --git a/gui/widget.cpp b/gui/widget.cpp index f886e10e1a6..da2f8406d96 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -812,13 +812,13 @@ int SliderWidget::posToValue(int pos) { #pragma mark - -GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, Common::U32String tooltip) +GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip) : Widget(boss, x, y, w, h, tooltip), _gfx(), _alpha(255), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } -GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name, Common::U32String tooltip) +GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip) : Widget(boss, name, tooltip), _gfx(), _alpha(255), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; diff --git a/gui/widget.h b/gui/widget.h index a27e53ce78f..9c4810df396 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -172,6 +172,7 @@ public: bool hasTooltip() const { return !_tooltip.empty(); } const Common::U32String &getTooltip() const { return _tooltip; } void setTooltip(const Common::U32String &tooltip) { _tooltip = tooltip; } + void setTooltip(const Common::String &tooltip) { _tooltip = Common::U32String(tooltip); } virtual bool containsWidget(Widget *) const { return false; } @@ -413,8 +414,8 @@ protected: /* GraphicsWidget */ class GraphicsWidget : public Widget { public: - GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, Common::U32String tooltip = Common::U32String("")); - GraphicsWidget(GuiObject *boss, const Common::String &name, Common::U32String tooltip = Common::U32String("")); + GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const Common::U32String &tooltip = Common::U32String("")); + GraphicsWidget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String("")); ~GraphicsWidget() override; void setGfx(const Graphics::Surface *gfx); diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index da480d7ddaf..7c13d54d4c5 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -28,7 +28,7 @@ namespace GUI { -EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &text, U32String tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font) +EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &text, const U32String &tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font) : EditableWidget(boss, x, y - 1, w, h + 2, tooltip, cmd) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE); _type = kEditTextWidget; @@ -40,7 +40,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, cons _leftPadding = _rightPadding = 0; } -EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const U32String &text, U32String tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font) +EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const U32String &text, const U32String &tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font) : EditableWidget(boss, name, tooltip, cmd) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE); _type = kEditTextWidget; diff --git a/gui/widgets/edittext.h b/gui/widgets/edittext.h index fa9b84cc570..da4e6de90f0 100644 --- a/gui/widgets/edittext.h +++ b/gui/widgets/edittext.h @@ -41,8 +41,8 @@ protected: int _rightPadding; public: - EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &text, Common::U32String tooltip = Common::U32String(""), uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal); - EditTextWidget(GuiObject *boss, const String &name, const U32String &text, Common::U32String tooltip = Common::U32String(""), uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal); + EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &text, const U32String &tooltip = Common::U32String(""), uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal); + EditTextWidget(GuiObject *boss, const String &name, const U32String &text, const U32String &tooltip = Common::U32String(""), uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal); void setEditString(const U32String &str) override;