aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2002-09-28 19:25:09 +0000
committerMax Horn2002-09-28 19:25:09 +0000
commit94b55db8215e709a40cc562df3d8e1540e6b5174 (patch)
tree27c59541d7f9dc98f8af3635aff2fbe6ffe5c51e
parent9dc5fe2a1dc4196d5785b484bfb1a96d33d732e8 (diff)
downloadscummvm-rg350-94b55db8215e709a40cc562df3d8e1540e6b5174.tar.gz
scummvm-rg350-94b55db8215e709a40cc562df3d8e1540e6b5174.tar.bz2
scummvm-rg350-94b55db8215e709a40cc562df3d8e1540e6b5174.zip
patch #612722: MI2 NewGui title fix
svn-id: r5030
-rw-r--r--common/str.cpp11
-rw-r--r--gui/dialog.cpp2
-rw-r--r--gui/dialog.h2
-rw-r--r--scumm/dialogs.cpp135
-rw-r--r--scumm/dialogs.h8
5 files changed, 120 insertions, 38 deletions
diff --git a/common/str.cpp b/common/str.cpp
index 874b99938e..7b33b29c30 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -20,13 +20,10 @@
#include "stdafx.h"
#include "str.h"
-#include "util.h"
#ifdef _MSC_VER
-
# pragma warning( disable : 4068 ) // unknown pragmas
-
#endif
@@ -39,7 +36,7 @@ String::String(const char *str, int len)
if (len > 0)
_capacity = _len = len;
else
- _capacity = _len = resStrLen(str);
+ _capacity = _len = strlen(str);
_str = (char *)calloc(1, _capacity+1);
memcpy(_str, str, _len);
_str[_len] = 0;
@@ -54,7 +51,7 @@ String::String(const ConstString &str)
printf("String::String(const ConstString &str)\n");
_refCount = new int(1);
if (str._str) {
- _capacity = _len = resStrLen(str._str);
+ _capacity = _len = strlen(str._str);
_str = (char *)calloc(1, _capacity+1);
memcpy(_str, str._str, _len+1);
} else {
@@ -90,7 +87,7 @@ void String::decRefCount()
String& String::operator =(const char* str)
{
- int len = resStrLen(str);
+ int len = strlen(str);
if (len > 0) {
ensureCapacity(len, false);
@@ -123,7 +120,7 @@ String& String::operator =(const String& str)
String& String::operator +=(const char* str)
{
- int len = resStrLen(str);
+ int len = strlen(str);
if (len > 0) {
ensureCapacity(_len + len, true);
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index d9c25d15bb..bfddcd81cb 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -243,7 +243,7 @@ Widget *Dialog::findWidget(int x, int y)
return w;
}
-void Dialog::addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey)
+void Dialog::addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey)
{
new ButtonWidget(this, x, y, w, h, label, cmd, hotkey);
}
diff --git a/gui/dialog.h b/gui/dialog.h
index a530a79075..c6793129ee 100644
--- a/gui/dialog.h
+++ b/gui/dialog.h
@@ -70,7 +70,7 @@ public:
protected:
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
- void addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey);
+ void addButton(int x, int y, int w, int h, const ScummVM::String &label, uint32 cmd, char hotkey);
};
#endif
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp
index 34e0d3e54a..ddbb37a93f 100644
--- a/scumm/dialogs.cpp
+++ b/scumm/dialogs.cpp
@@ -30,16 +30,11 @@
#include "common/config-file.h"
-
#ifdef _MSC_VER
-
# pragma warning( disable : 4068 )
-
#endif
-
-
struct ResString {
int num;
char string[80];
@@ -153,20 +148,17 @@ static ResString string_map_table_v5[] = {
void ScummDialog::addResText(int x, int y, int w, int h, int resID)
{
// Get the string
- const char *str = queryResString(resID);
- if (!str)
- str = "Dummy!";
- new StaticTextWidget(this, x, y, w, h, str, kTextAlignCenter);
+ new StaticTextWidget(this, x, y, w, h, queryResString(resID), kTextAlignCenter);
}
-const char *ScummDialog::queryResString(int stringno)
+const ScummVM::String ScummDialog::queryResString(int stringno)
{
char *result;
int string;
if (stringno == 0)
- return NULL;
+ return String();
if (_scumm->_features & GF_AFTER_V7)
string = _scumm->_vars[string_map_table_v7[stringno - 1].num];
@@ -183,12 +175,105 @@ const char *ScummDialog::queryResString(int stringno)
if (!result) { // Gracelessly degrade to english :)
if (_scumm->_features & GF_AFTER_V6)
- return string_map_table_v6[stringno - 1].string;
+ result = string_map_table_v6[stringno - 1].string;
else
- return string_map_table_v5[stringno - 1].string;
+ result = string_map_table_v5[stringno - 1].string;
}
- return result;
+ // Convert to a proper string (take care of FF codes)
+ int value;
+ byte chr;
+ String tmp;
+
+ while ((chr = *result++)) {
+ if (chr == 0xFF) {
+ chr = *result++;
+ switch (chr) {
+ case 4: { // add value
+ value = _scumm->readVar(READ_LE_UINT16(result));
+ if (value < 0) {
+ tmp += '-';
+ value = -value;
+ }
+
+ int flag = 0;
+ int max = 10000;
+ do {
+ if (value >= max || flag) {
+ tmp += value / max + '0';
+ value %= max;
+ flag = 1;
+ }
+ max /= 10;
+ if (max == 1)
+ flag = 1;
+ } while (max);
+ result += 2;
+ break;
+ }
+
+ case 5: { //add verb
+ value = _scumm->readVar(READ_LE_UINT16(result));
+ int i;
+ if (!value)
+ break;
+
+ for (i = 1; i < _scumm->_maxVerbs; i++) {
+ if (value == _scumm->_verbs[i].verbid && !_scumm->_verbs[i].type && !_scumm->_verbs[i].saveid) {
+ char* verb = (char*)_scumm->getResourceAddress(rtVerb, i);
+ if (verb) {
+ tmp += verb;
+ }
+ break;
+ }
+ }
+ result += 2;
+ break;
+ }
+
+ case 6: { // add object or actor name
+ value = _scumm->readVar(READ_LE_UINT16(result));
+ if (!value)
+ break;
+
+ char* name = (char*)_scumm->getObjOrActorName(value);
+ if (name) {
+ tmp += name;
+ }
+ result += 2;
+ break;
+ }
+ case 7: { // add string
+ value = READ_LE_UINT16(result);
+ if (_scumm->_features & GF_AFTER_V6 || _scumm->_gameId == GID_INDY3_256)
+ value = _scumm->readVar(value);
+
+ if (value) {
+ char *str = (char*)_scumm->getStringAddress(value);
+ if (str) {
+ tmp += str;
+ }
+ }
+ result += 2;
+ break;
+ }
+ // Do these ever occur in the Gui?
+ case 9:
+ case 10:
+ case 12:
+ case 13:
+ case 14:
+ result += 2;
+ default:
+ warning("Ignoring unknown resource string of type %d", (int)chr);
+ }
+ } else {
+ if (chr != '@') {
+ tmp += chr;
+ }
+ }
+ }
+ return tmp;
}
const char *ScummDialog::queryCustomString(int stringno)
@@ -224,11 +309,11 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm)
// addResText(10, 7, 240, 16, 2);
// addResText(10, 7, 240, 16, 3);
- addButton(200, 20, 54, 16, RES_STRING(4), kSaveCmd, 'S'); // Save
- addButton(200, 40, 54, 16, RES_STRING(5), kLoadCmd, 'L'); // Load
- addButton(200, 60, 54, 16, RES_STRING(6), kPlayCmd, 'P'); // Play
- addButton(200, 80, 54, 16, CUSTOM_STRING(17), kOptionsCmd, 'O'); // Options
- addButton(200, 100, 54, 16, RES_STRING(8), kQuitCmd, 'Q'); // Quit
+ addButton(200, 20, 54, 16, queryResString(4), kSaveCmd, 'S'); // Save
+ addButton(200, 40, 54, 16, queryResString(5), kLoadCmd, 'L'); // Load
+ addButton(200, 60, 54, 16, queryResString(6), kPlayCmd, 'P'); // Play
+ addButton(200, 80, 54, 16, queryCustomString(17), kOptionsCmd, 'O'); // Options
+ addButton(200, 100, 54, 16, queryResString(8), kQuitCmd, 'Q'); // Quit
_savegameList = new ListWidget(this, 10, 20, 180, 90);
_savegameList->setNumberingMode(kListNumberingZero);
@@ -294,11 +379,11 @@ enum {
OptionsDialog::OptionsDialog(NewGui *gui, Scumm *scumm)
: ScummDialog(gui, scumm, 50, 80, 210, 60)
{
- addButton( 10, 10, 40, 16, CUSTOM_STRING(5), kSoundCmd, 'S'); // Sound
- addButton( 80, 10, 40, 16, CUSTOM_STRING(6), kKeysCmd, 'K'); // Keys
- addButton(150, 10, 40, 16, CUSTOM_STRING(7), kAboutCmd, 'A'); // About
- addButton( 10, 35, 40, 16, CUSTOM_STRING(18), kMiscCmd, 'M'); // Misc
- addButton(150, 35, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C'); // Close dialog - FIXME
+ addButton( 10, 10, 40, 16, queryCustomString(5), kSoundCmd, 'S'); // Sound
+ addButton( 80, 10, 40, 16, queryCustomString(6), kKeysCmd, 'K'); // Keys
+ addButton(150, 10, 40, 16, queryCustomString(7), kAboutCmd, 'A'); // About
+ addButton( 10, 35, 40, 16, queryCustomString(18), kMiscCmd, 'M'); // Misc
+ addButton(150, 35, 40, 16, queryCustomString(23), kCloseCmd, 'C'); // Close dialog - FIXME
_aboutDialog = new AboutDialog(gui, scumm);
_soundDialog = new SoundDialog(gui, scumm);
@@ -333,7 +418,7 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
AboutDialog::AboutDialog(NewGui *gui, Scumm *scumm)
: ScummDialog(gui, scumm, 30, 20, 260, 124)
{
- addButton(110, 100, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C'); // Close dialog - FIXME
+ addButton(110, 100, 40, 16, queryCustomString(23), kCloseCmd, 'C'); // Close dialog - FIXME
new StaticTextWidget(this, 10, 10, 240, 16, "ScummVM " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", kTextAlignCenter);
new StaticTextWidget(this, 10, 30, 240, 16, "http://scummvm.sourceforge.net", kTextAlignCenter);
new StaticTextWidget(this, 10, 50, 240, 16, "All games (c) LucasArts", kTextAlignCenter);
diff --git a/scumm/dialogs.h b/scumm/dialogs.h
index bc8111ea8b..f6f925b988 100644
--- a/scumm/dialogs.h
+++ b/scumm/dialogs.h
@@ -21,26 +21,26 @@
#ifndef SCUMM_DIALOGS_H
#define SCUMM_DIALOGS_H
+#include "common/str.h"
#include "gui/dialog.h"
class ListWidget;
class Scumm;
-#define RES_STRING(id) queryResString(id)
-#define CUSTOM_STRING(id) queryCustomString(id)
-
class ScummDialog : public Dialog {
public:
ScummDialog(NewGui *gui, Scumm *scumm, int x, int y, int w, int h)
: Dialog(gui, x, y, w, h), _scumm(scumm) {}
protected:
+ typedef ScummVM::String String;
+
Scumm *_scumm;
void addResText(int x, int y, int w, int h, int resID);
// Query a string from the resources
- const char *queryResString(int stringno);
+ const String queryResString(int stringno);
// Query a custom string. This is in a seperate method so that we
// can easily localize the messages in the future if we want to.