aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2009-09-27 01:50:26 +0000
committerWillem Jan Palenstijn2009-09-27 01:50:26 +0000
commitd3c19163847de0dbfc28972b91f43a7b4c0ded7f (patch)
treee7163f4ebb6b92fca49e712eac369a86d05fcdc7 /engines/sci/gfx
parent5d2d8c580a902c97b201f2e012a7888f94e44581 (diff)
downloadscummvm-rg350-d3c19163847de0dbfc28972b91f43a7b4c0ded7f.tar.gz
scummvm-rg350-d3c19163847de0dbfc28972b91f43a7b4c0ded7f.tar.bz2
scummvm-rg350-d3c19163847de0dbfc28972b91f43a7b4c0ded7f.zip
SCI: Major string handling update.
All string access to segments should now work with both raw and non-raw (reg_t) segments, using the new utility functions in segMan. There will likely be regressions. svn-id: r44388
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r--engines/sci/gfx/gfx_gui.cpp2
-rw-r--r--engines/sci/gfx/gfx_state_internal.h2
-rw-r--r--engines/sci/gfx/gfx_widgets.cpp1
-rw-r--r--engines/sci/gfx/menubar.cpp24
-rw-r--r--engines/sci/gfx/menubar.h2
5 files changed, 16 insertions, 15 deletions
diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp
index b4479b7341..6deb01b1c2 100644
--- a/engines/sci/gfx/gfx_gui.cpp
+++ b/engines/sci/gfx/gfx_gui.cpp
@@ -175,7 +175,7 @@ GfxPort *sciw_new_window(EngineState *s,
win = new GfxPort(visual, area, color, bgcolor);
win->_font = font;
- win->title_text = title;
+ win->_title_text = title;
win->port_flags = flags;
win->_flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS;
diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h
index 1bff83e713..aeb3b05cd4 100644
--- a/engines/sci/gfx/gfx_state_internal.h
+++ b/engines/sci/gfx/gfx_state_internal.h
@@ -382,7 +382,7 @@ struct GfxPort : public GfxContainer {
gfxw_snapshot_t *restore_snap; /**< Snapshot to be restored automagically,
experimental feature used in the PQ3 interpreter */
int port_flags; /**< interpreter-dependant flags */
- const char *title_text;
+ Common::String _title_text;
byte gray_text; /**< Whether text is 'grayed out' (dithered) */
public:
diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp
index 3d94bf1342..1d737e9eb2 100644
--- a/engines/sci/gfx/gfx_widgets.cpp
+++ b/engines/sci/gfx/gfx_widgets.cpp
@@ -1581,7 +1581,6 @@ GfxPort::GfxPort(GfxVisual *visual_, rect_t area, gfx_color_t fgcolor, gfx_color
port_bg = NULL;
_parent = NULL;
_decorations = NULL;
- title_text = NULL;
draw_pos = Common::Point(0, 0);
gray_text = 0;
_color = fgcolor;
diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp
index 1c04486d4d..283b233477 100644
--- a/engines/sci/gfx/menubar.cpp
+++ b/engines/sci/gfx/menubar.cpp
@@ -122,7 +122,7 @@ int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const ch
return total_left_size + width;
}
-void Menubar::addMenu(GfxState *state, const char *title, const char *entries, int font, reg_t entries_base) {
+void Menubar::addMenu(GfxState *state, const Common::String &title, const Common::String &entries, int font, reg_t entries_base) {
char tracker;
char *left = NULL;
reg_t left_origin = entries_base;
@@ -134,17 +134,19 @@ void Menubar::addMenu(GfxState *state, const char *title, const char *entries, i
menu._title = title;
- gfxop_get_text_params(state, font, title, SIZE_INF, &(menu._titleWidth), &height, 0, NULL, NULL, NULL);
+ gfxop_get_text_params(state, font, title.c_str(), SIZE_INF, &(menu._titleWidth), &height, 0, NULL, NULL, NULL);
+
+ const char *entries_p = entries.c_str();
do {
- tracker = *entries++;
+ tracker = *entries_p++;
entries_base.offset++;
if (!left) { // Left string not finished?
if (tracker == '=') { // Hit early-SCI tag assignment?
- left = sci_strndup(entries - string_len - 1, string_len);
- tag = atoi(entries++);
- tracker = *entries++;
+ left = sci_strndup(entries_p - string_len - 1, string_len);
+ tag = atoi(entries_p++);
+ tracker = *entries_p++;
}
if ((tracker == 0 && string_len > 0) || (tracker == '=') || (tracker == ':')) { // End of entry
MenuType entrytype = MENU_TYPE_NORMAL;
@@ -152,7 +154,7 @@ void Menubar::addMenu(GfxState *state, const char *title, const char *entries, i
reg_t beginning;
if (!left)
- left = sci_strndup(entries - string_len - 1, string_len);
+ left = sci_strndup(entries_p - string_len - 1, string_len);
inleft = left;
while (isspace(*inleft))
@@ -179,7 +181,7 @@ void Menubar::addMenu(GfxState *state, const char *title, const char *entries, i
if (!left) {
left_origin = entries_base;
left_origin.offset -= string_len + 1;
- left = sci_strndup(entries - string_len - 1, string_len);
+ left = sci_strndup(entries_p - string_len - 1, string_len);
}
string_len = 0; // Continue with the right string
} else
@@ -189,7 +191,7 @@ void Menubar::addMenu(GfxState *state, const char *title, const char *entries, i
if ((tracker == ':') || (tracker == 0)) { // End of entry
int key, modifiers = 0;
- char *right = sci_strndup(entries - string_len - 1, string_len);
+ char *right = sci_strndup(entries_p - string_len - 1, string_len);
if (right[0] == '#') {
right[0] = SCI_SPECIAL_CHAR_FUNCTION; // Function key
@@ -294,7 +296,7 @@ int Menubar::setAttribute(EngineState *s, int menu_nr, int item_nr, int attribut
case MENU_ATTRIBUTE_SAID:
if (value.segment) {
item->_saidPos = value;
- memcpy(item->_said, s->segMan->derefBulkPtr(value, 0), MENU_SAID_SPEC_SIZE); // Copy Said spec
+ s->segMan->memcpy(item->_said, value, MENU_SAID_SPEC_SIZE); // Copy Said spec
item->_flags |= MENU_ATTRIBUTE_FLAGS_SAID;
} else
@@ -304,7 +306,7 @@ int Menubar::setAttribute(EngineState *s, int menu_nr, int item_nr, int attribut
case MENU_ATTRIBUTE_TEXT:
assert(value.segment);
- item->_text = s->segMan->derefString(value);
+ item->_text = s->segMan->getString(value);
item->_textPos = value;
break;
diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h
index 44ecd8f1bb..029af5923b 100644
--- a/engines/sci/gfx/menubar.h
+++ b/engines/sci/gfx/menubar.h
@@ -171,7 +171,7 @@ public:
* @param[in] font The font which is to be used for drawing
* @param[in] entries_base Segmented VM address of the entries string
*/
- void addMenu(GfxState *state, const char *title, const char *entries, int font, reg_t entries_base);
+ void addMenu(GfxState *state, const Common::String &title, const Common::String &entries, int font, reg_t entries_base);
/**