BACKENDS: Use Common::U32String for OSystem::setWindowCaption

This commit is contained in:
Cameron Cawley 2020-11-01 21:15:34 +00:00 committed by Thierry Crozat
parent ce39fcbf8b
commit 01b4432825
23 changed files with 34 additions and 92 deletions

View file

@ -555,9 +555,7 @@ void OSystem_Android::quit() {
pthread_join(_timer_thread, 0);
}
void OSystem_Android::setWindowCaption(const char *caption) {
ENTER("%s", caption);
void OSystem_Android::setWindowCaption(const Common::U32String &caption) {
JNI::setWindowCaption(caption);
}

View file

@ -128,7 +128,7 @@ public:
virtual void quit() override;
virtual void setWindowCaption(const char *caption) override;
virtual void setWindowCaption(const Common::U32String &caption) override;
virtual Audio::Mixer *getMixer() override;
virtual void getTimeAndDate(TimeDate &t) const override;

View file

@ -340,9 +340,9 @@ bool JNI::isConnectionLimited() {
return limited;
}
void JNI::setWindowCaption(const Common::String &caption) {
void JNI::setWindowCaption(const Common::U32String &caption) {
JNIEnv *env = JNI::getEnv();
jstring java_caption = convertToJString(env, caption.decode(Common::kISO8859_1));
jstring java_caption = convertToJString(env, caption);
env->CallVoidMethod(_jobj, _MID_setWindowCaption, java_caption);

View file

@ -58,7 +58,7 @@ public:
static void setReadyForEvents(bool ready);
static void setWindowCaption(const Common::String &caption);
static void setWindowCaption(const Common::U32String &caption);
static void getDPI(float *values);
static void displayMessageOnOSD(const Common::U32String &msg);
static bool openUrl(const Common::String &url);

View file

@ -490,9 +490,7 @@ void OSystem_Android::quit() {
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
}
void OSystem_Android::setWindowCaption(const char *caption) {
ENTER("%s", caption);
void OSystem_Android::setWindowCaption(const Common::U32String &caption) {
JNI::setWindowCaption(caption);
}

View file

@ -175,7 +175,7 @@ public:
virtual void quit();
virtual void setWindowCaption(const char *caption);
virtual void setWindowCaption(const Common::U32String &caption);
virtual void showVirtualKeyboard(bool enable);
virtual Audio::Mixer *getMixer();

View file

@ -170,7 +170,7 @@ public:
// Set a window caption or any other comparable status display to the
// given value.
void setWindowCaption(const char *caption);
void setWindowCaption(const Common::U32String &caption);
// Modulatized backend
Audio::Mixer *getMixer() { return _mixer; }

View file

@ -37,7 +37,7 @@
Icon icon;
const char *gGameName;
const char gGameName[32];
OSystem_Dreamcast::OSystem_Dreamcast()
@ -143,9 +143,9 @@ bool DCCDManager::isPlaying() const {
return getCdState() == 3;
}
void OSystem_Dreamcast::setWindowCaption(const char *caption)
void OSystem_Dreamcast::setWindowCaption(const Common::U32String &caption)
{
gGameName = caption;
Common::strlcpy(gGameName, cap.encode(Common::kISO8859_1).c_str(), 32);
}
void OSystem_Dreamcast::quit() {

View file

@ -340,7 +340,7 @@ public:
void OutVMSave::finalize()
{
extern const char *gGameName;
extern const char gGameName[32];
extern Icon icon;
if (committed >= _pos)

View file

@ -99,21 +99,8 @@ void OSystem_SDL_Maemo::setXWindowName(const char *caption) {
}
}
void OSystem_SDL_Maemo::setWindowCaption(const char *caption) {
Common::String cap;
byte c;
// The string caption is supposed to be in LATIN-1 encoding.
// SDL expects UTF-8. So we perform the conversion here.
while ((c = *(const byte *)caption++)) {
if (c < 0x80)
cap += c;
else {
cap += 0xC0 | (c >> 6);
cap += 0x80 | (c & 0x3F);
}
}
void OSystem_SDL_Maemo::setWindowCaption(const Common::U32String &caption) {
Common::String cap = caption.encode();
_window->setWindowCaption(cap);
Common::String cap2("ScummVM - "); // 2 lines in OS2008 task switcher, set first line

View file

@ -40,7 +40,7 @@ public:
virtual void initBackend() override;
virtual void quit() override;
virtual void fatalError() override;
virtual void setWindowCaption(const char *caption) override;
virtual void setWindowCaption(const Common::U32String &caption) override;
virtual Common::HardwareInputSet *getHardwareInputSet() override;
virtual Common::KeymapArray getGlobalKeymaps() override;
virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() override;

View file

@ -470,21 +470,8 @@ void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority)
}
void OSystem_SDL::setWindowCaption(const char *caption) {
Common::String cap;
byte c;
// The string caption is supposed to be in LATIN-1 encoding.
// SDL expects UTF-8. So we perform the conversion here.
while ((c = *(const byte *)caption++)) {
if (c < 0x80)
cap += c;
else {
cap += 0xC0 | (c >> 6);
cap += 0x80 | (c & 0x3F);
}
}
void OSystem_SDL::setWindowCaption(const Common::U32String &caption) {
Common::String cap = caption.encode();
_window->setWindowCaption(cap);
}

View file

@ -78,7 +78,7 @@ public:
virtual bool setTextInClipboard(const Common::U32String &text) override;
#endif
virtual void setWindowCaption(const char *caption) override;
virtual void setWindowCaption(const Common::U32String &caption) override;
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
virtual uint32 getMillis(bool skipRecord = false) override;
virtual void delayMillis(uint msecs) override;

View file

@ -257,10 +257,6 @@ void OSystem_Wii::deleteMutex(MutexRef mutex) {
free(mutex);
}
void OSystem_Wii::setWindowCaption(const char *caption) {
printf("window caption: %s\n", caption);
}
Audio::Mixer *OSystem_Wii::getMixer() {
assert(_mixer);
return _mixer;

View file

@ -206,8 +206,6 @@ public:
virtual void quit() override;
virtual void setWindowCaption(const char *caption) override;
virtual Audio::Mixer *getMixer() override;
virtual FilesystemFactory *getFilesystemFactory() override;
virtual void getTimeAndDate(TimeDate &t) const override;

View file

@ -237,7 +237,7 @@ static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common
if (caption.empty())
caption = target;
if (!caption.empty()) {
system.setWindowCaption(caption.c_str());
system.setWindowCaption(caption.decode());
}
//
@ -364,7 +364,7 @@ static void setupGraphics(OSystem &system) {
GUI::GuiManager::instance();
// Set initial window caption
system.setWindowCaption(gScummVMFullVersion);
system.setWindowCaption(Common::U32String(gScummVMFullVersion));
// Clear the main screen
system.fillScreen(0);

View file

@ -1472,13 +1472,9 @@ public:
* Set a window caption or any other comparable status display to the
* given value.
*
* The caption must be a pure ISO LATIN 1 string. Passing a string
* with a different encoding may lead to unexpected behavior,
* even crashes.
*
* @param caption The window caption to use, as an ISO LATIN 1 string.
* @param caption The window caption to use.
*/
virtual void setWindowCaption(const char *caption) {}
virtual void setWindowCaption(const Common::U32String &caption) {}
/**
* Display a message in an 'on-screen display'.

View file

@ -417,7 +417,7 @@ void GUIErrorMessage(const Common::String &msg, const char *url) {
}
void GUIErrorMessage(const Common::U32String &msg, const char *url) {
g_system->setWindowCaption("Error");
g_system->setWindowCaption(_("Error"));
g_system->beginGFXTransaction();
initCommonGFX();
g_system->initSize(320, 200);

View file

@ -192,7 +192,7 @@ unsigned int _surface_manager::Init_direct_draw() {
// Debug info
Zdebug("*SURFACE_MANAGER* Initalizing the SDL video interface");
g_system->setWindowCaption("In Cold Blood (C)2000 Revolution Software Ltd");
g_system->setWindowCaption(Common::U32String("In Cold Blood (C)2000 Revolution Software Ltd"));
initGraphics(640, 480, nullptr);
_zb = new TinyGL::FrameBuffer(640, 480, g_system->getScreenFormat()); // TODO: delete

View file

@ -1721,18 +1721,12 @@ void ScummEngine_v100he::o100_setSystemMessage() {
switch (subOp) {
case 80: // Set Window Caption
// TODO: The 'name' string can contain non-ASCII data. This can lead to
// problems, because (a) the encoding used for "name" is not clear,
// (b) OSystem::setWindowCaption only supports ASCII. As a result, odd
// behavior can occur, from strange wrong titles, up to crashes (happens
// under Mac OS X).
// problems, because the encoding used for "name" is not clear,
//
// Possible fixes/workarounds:
// - Simply stop using this. It's a rather unimportant "feature" anyway.
// - Try to translate the text to ASCII.
// - Refine OSystem to accept window captions that are non-ASCII, e.g.
// by enhancing all backends to deal with UTF-8 data. Of course, then
// one still would have to convert 'name' to the correct encoding.
//_system->setWindowCaption((const char *)name);
// - Try to translate the text to UTF-32.
//_system->setWindowCaption(Common::U32String((const char *)name));
break;
case 131: // Set Version
debug(1,"o100_setSystemMessage: (%d) %s", subOp, name);

View file

@ -490,18 +490,12 @@ void ScummEngine_v70he::o70_setSystemMessage() {
break;
case 243: // Set Window Caption
// TODO: The 'name' string can contain non-ASCII data. This can lead to
// problems, because (a) the encoding used for "name" is not clear,
// (b) OSystem::setWindowCaption only supports ASCII. As a result, odd
// behavior can occur, from strange wrong titles, up to crashes (happens
// under Mac OS X).
// problems, because the encoding used for "name" is not clear.
//
// Possible fixes/workarounds:
// - Simply stop using this. It's a rather unimportant "feature" anyway.
// - Try to translate the text to ASCII.
// - Refine OSystem to accept window captions that are non-ASCII, e.g.
// by enhancing all backends to deal with UTF-8 data. Of course, then
// one still would have to convert 'name' to the correct encoding.
//_system->setWindowCaption((const char *)name);
// - Try to translate the text to UTF-32.
//_system->setWindowCaption(Common::U32String((const char *)name));
break;
default:
error("o70_setSystemMessage: default case %d", subOp);

View file

@ -1993,18 +1993,12 @@ void ScummEngine_v72he::o72_setSystemMessage() {
break;
case 243: // Set Window Caption
// TODO: The 'name' string can contain non-ASCII data. This can lead to
// problems, because (a) the encoding used for "name" is not clear,
// (b) OSystem::setWindowCaption only supports ASCII. As a result, odd
// behavior can occur, from strange wrong titles, up to crashes (happens
// under Mac OS X).
// problems, because the encoding used for "name" is not clear.
//
// Possible fixes/workarounds:
// - Simply stop using this. It's a rather unimportant "feature" anyway.
// - Try to translate the text to ASCII.
// - Refine OSystem to accept window captions that are non-ASCII, e.g.
// by enhancing all backends to deal with UTF-8 data. Of course, then
// one still would have to convert 'name' to the correct encoding.
//_system->setWindowCaption((const char *)name);
// - Try to translate the text to UTF-32.
//_system->setWindowCaption(Common::U32String((const char *)name));
break;
default:
error("o72_setSystemMessage: default case %d", subOp);

View file

@ -674,7 +674,7 @@ void Sword2Engine::initializeFontResourceFlags() {
else
textLine = (char *)fetchTextLine(textFile, 54) + 2;
_system->setWindowCaption(textLine);
_system->setWindowCaption(Common::U32String(textLine));
_resman->closeResource(TEXT_RES);
}