GUI: U32: More issue fixes and general improvements

- Use the fake constructor for message dialog less often
- solve errors regarding comparision between string and u32string in midi
- solve errors in testbed/speech related to ttsMan->say
- fix unsigned comparision warning in tab.cpp
- fix issue with static strings and translations in sdl-graphics
This commit is contained in:
aryanrawlani28 2020-06-22 23:29:25 +05:30 committed by Eugene Sandulenko
parent da380a9002
commit a9bfe35216
20 changed files with 31 additions and 30 deletions

View File

@ -177,7 +177,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
if ((flags & MDT_PREFER_FLUID) && selDevStr == "auto") {
selDevStr = "fluidsynth";
}
DeviceHandle hdl = getDeviceHandle(selDevStr.empty() ? Common::String("auto") : selDevStr);
DeviceHandle hdl = getDeviceHandle(selDevStr.empty() ? Common::U32String("auto") : selDevStr);
DeviceHandle reslt = 0;
_forceTypeMT32 = false;
@ -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::String("null") : devStr);
hdl = getDeviceHandle(devStr.empty() ? Common::U32String("null") : devStr);
const MusicType type = getMusicType(hdl);
// If we have a "Don't use GM/MT-32" setting we skip this part and jump

View File

@ -419,7 +419,7 @@ Common::Keymap *SdlGraphicsManager::getKeymap() {
#ifdef USE_SCALERS
struct ActionEntry {
const char *id;
U32String description;
const char *description;
};
static const ActionEntry filters[] = {
{ "FLT1", _s("Switch to nearest neighbour scaling") },
@ -435,7 +435,7 @@ Common::Keymap *SdlGraphicsManager::getKeymap() {
};
for (uint i = 0; i < ARRAYSIZE(filters); i++) {
act = new Action(filters[i].id, filters[i].description);
act = new Action(filters[i].id, _(filters[i].description));
act->addDefaultInputMapping(String::format("C+A+%d", i + 1));
act->addDefaultInputMapping(String::format("C+A+KP%d", i + 1));
act->setCustomBackendActionEvent(kActionSetScaleFilter1 + i);

View File

@ -126,8 +126,7 @@ String::String(char c)
}
String::String(const U32String &str) {
String internString = str.encode();
String::String(internString);
*this = String(str.encode());
}
String::~String() {

View File

@ -115,7 +115,7 @@ U32String TranslationManager::getTranslation(const char *message) const {
U32String TranslationManager::getTranslation(const char *message, const char *context) const {
// If no language is set or message is empty, return msgid as is
if (_currentTranslationMessages.empty() || *message == '\0')
return message;
return U32String(message);
// Binary-search for the msgid
int leftIndex = 0;

View File

@ -21,6 +21,7 @@
*/
#include "common/ustr.h"
#include "common/str.h"
#include "common/memorypool.h"
#include "common/util.h"
#include "unicode-bidi.h"
@ -550,7 +551,7 @@ int U32String::vformat(U32String &output, U32String::iterator fmt, va_list args)
char buffer[512];
while (fmt != output.end() && pos < output.size()) {
while (fmt != output.end() && pos < (int)output.size()) {
ch = *fmt++;
if (ch == '%') {
switch (ch = *fmt++)

View File

@ -139,11 +139,12 @@ int MidiPlayer::open(int gameType, bool isDemo) {
case MT_GM:
if (!ConfMan.getBool("native_mt32")) {
// Not a real MT32 / no MUNT
::GUI::MessageDialog dialog(("You appear to be using a General MIDI device,\n"
::GUI::MessageDialog dialog(Common::convertToU32String((
"You appear to be using a General MIDI device,\n"
"but your game only supports Roland MT32 MIDI.\n"
"We try to map the Roland MT32 instruments to\n"
"General MIDI ones. It is still possible that\n"
"some tracks sound incorrect."));
"some tracks sound incorrect.")));
dialog.runModal();
}
// Switch to MT32 driver in any case

View File

@ -319,7 +319,7 @@ void initGraphics(int width, int height, const Graphics::PixelFormat *format) {
_("Could not switch to resolution '%dx%d'."), width, height);
GUIErrorMessage(message);
error("%s", message.c_str());
error("%s", message.encode().c_str());
}
// Just show warnings then these occur:

View File

@ -1494,7 +1494,7 @@ void Script::o_checkvalidsaves() {
while (it != list.end()) {
int8 slot = it->getSaveSlot();
if (SaveLoad::isSlotValid(slot)) {
debugC(2, kDebugScript, " Found valid savegame: %s", it->getDescription().c_str());
debugC(2, kDebugScript, " Found valid savegame: %s", it->getDescription().encode().c_str());
// Mark this slot as used
setVariable(slot, 1);

View File

@ -435,7 +435,7 @@ bool HugoEngine::loadHugoDat() {
if (!in.isOpen()) {
Common::U32String errorMessage = Common::U32String::format(_("Unable to locate the '%s' engine data file."), filename.c_str());
GUIErrorMessage(errorMessage);
warning("%s", errorMessage.c_str());
warning("%s", errorMessage.encode().c_str());
return false;
}

View File

@ -122,7 +122,7 @@ void LabEngine::handleTrialWarning() {
// Wyrmkeep trial version
_extraGameFeatures = GF_WINDOWS_TRIAL;
GUI::MessageDialog trialMessage(_("This is a trial Windows version of the game. To play the full version, you will need to use the original interpreter and purchase a key from Wyrmkeep"));
GUI::MessageDialog trialMessage(Common::convertToU32String("This is a trial Windows version of the game. To play the full version, you will need to use the original interpreter and purchase a key from Wyrmkeep"));
trialMessage.runModal();
}
else {

View File

@ -327,7 +327,7 @@ void LabEngine::doActions(const ActionList &actionList) {
// This is a Wyrmkeep Windows trial version, thus stop at this
// point, since we can't check for game payment status
_graphics->readPict(getPictName(true));
GUI::MessageDialog trialMessage(_("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep"));
GUI::MessageDialog trialMessage(Common::convertToU32String("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep"));
trialMessage.runModal();
break;
}

View File

@ -146,7 +146,7 @@ void SpecialLocks::changeTile(uint16 col, uint16 row) {
if (scrolltype != -1) {
if (_vm->getFeatures() & GF_WINDOWS_TRIAL) {
GUI::MessageDialog trialMessage(_("This puzzle is not available in the trial version of the game"));
GUI::MessageDialog trialMessage(Common::convertToU32String("This puzzle is not available in the trial version of the game"));
trialMessage.runModal();
return;
}

View File

@ -86,7 +86,7 @@ void Preview::o_fadeFromBlack(uint16 var, const ArgumentsArray &args) {
void Preview::o_stayHere(uint16 var, const ArgumentsArray &args) {
// Nuh-uh! No leaving the library in the demo!
GUI::MessageDialog dialog("You can't leave the library in the demo.");
GUI::MessageDialog dialog(Common::convertToU32String("You can't leave the library in the demo."));
dialog.runModal();
}

View File

@ -164,11 +164,11 @@ TestExitStatus Speechtests::testStopAndSpeak() {
return kTestSkipped;
}
ttsMan->say("Testing text to speech, the speech should stop after approximately a second after it started, so it shouldn't have the time to read this.");
ttsMan->say(Common::convertToU32String("Testing text to speech, the speech should stop after approximately a second after it started, so it shouldn't have the time to read this."));
g_system->delayMillis(1000);
ttsMan->stop();
ttsMan->say("Now starting the second sentence.", Common::TextToSpeechManager::QUEUE);
ttsMan->say("You should hear that one in totality.", Common::TextToSpeechManager::QUEUE);
ttsMan->say(Common::convertToU32String("Now starting the second sentence."), Common::TextToSpeechManager::QUEUE);
ttsMan->say(Common::convertToU32String("You should hear that one in totality."), Common::TextToSpeechManager::QUEUE);
if (!ttsMan->isSpeaking()) {
Testsuite::logDetailedPrintf("Male TTS failed\n");
return kTestFailed;

View File

@ -215,11 +215,11 @@ bool TonyEngine::loadTonyDat() {
int minVer = in.readByte();
if ((majVer != TONY_DAT_VER_MAJ) || (minVer != TONY_DAT_VER_MIN)) {
msg = Common::String::format(
_("Incorrect version of the '%s' engine data file found. Expected %d.%d but got %d.%d.").encode().c_str(),
msg = Common::U32String::format(
_("Incorrect version of the '%s' engine data file found. Expected %d.%d but got %d.%d."),
filename.c_str(), TONY_DAT_VER_MAJ, TONY_DAT_VER_MIN, majVer, minVer);
GUIErrorMessage(msg);
warning("%s", msg.c_str());
warning("%s", msg.encode().c_str());
return false;
}

View File

@ -308,7 +308,7 @@ Common::Error ZVision::run() {
}
if (!foundAllFonts) {
GUI::MessageDialog dialog(
GUI::MessageDialog dialog(Common::convertToU32String(
"Before playing this game, you'll need to copy the required "
"fonts into ScummVM's extras directory, or into the game directory. "
"On Windows, you'll need the following font files from the Windows "
@ -318,7 +318,7 @@ Common::Error ZVision::run() {
"fonts from the font package you choose, i.e., LiberationMono, "
"LiberationSans and LiberationSerif, or FreeMono, FreeSans and "
"FreeSerif respectively."
);
));
dialog.runModal();
quitGame();
return Common::kUnknownError;

View File

@ -103,7 +103,7 @@ MessageDialog::MessageDialog(const Common::U32String &message, Common::U32String
MessageDialog::MessageDialog(const char *message, const char *defaultButton, const char *altButton, Graphics::TextAlign alignment)
: Dialog(30, 20, 260, 124) {
MessageDialog::MessageDialog(Common::U32String(message), Common::U32String(defaultButton), Common::U32String(altButton), alignment);
MessageDialog(Common::U32String(message), Common::U32String(defaultButton), Common::U32String(altButton), alignment);
}
void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {

View File

@ -2572,7 +2572,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
case kConnectStorageCmd: {
Common::U32String code = "";
Common::U32String code("");
if (_storageWizardCodeBox)
code = _storageWizardCodeBox->getEditString();
if (code.size() == 0)
@ -2976,7 +2976,7 @@ void GlobalOptionsDialog::reflowNetworkTabLayout() {
#ifdef USE_LIBCURL
void GlobalOptionsDialog::storageConnectionCallback(Networking::ErrorResponse response) {
Common::U32String message = "...";
Common::U32String message("...");
if (!response.failed && !response.interrupted) {
// success
g_system->displayMessageOnOSD(_("Storage connected."));

View File

@ -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().c_str()));
curButton.description->setLabel(Common::String::format("%d. %s", saveSlot, desc.getDescription().encode().c_str()));
Common::U32String tooltip(_("Name: "));
tooltip += desc.getDescription();

View File

@ -268,7 +268,7 @@ uint8 Widget::parseHotkey(const Common::U32String &label) {
}
Common::U32String Widget::cleanupHotkey(const Common::U32String &label) {
Common::U32String res = "";
Common::U32String res("");
for (Common::U32String::const_iterator itr = label.begin(); itr != label.end(); itr++) {
if (*itr != '~') {