aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agi/agi.cpp1
-rw-r--r--engines/agi/cycle.cpp14
-rw-r--r--engines/agi/inv.cpp14
-rw-r--r--engines/agi/keyboard.cpp4
-rw-r--r--engines/agi/menu.cpp16
-rw-r--r--engines/agi/op_cmd.cpp47
-rw-r--r--engines/agi/savegame.cpp44
-rw-r--r--engines/agi/sprite.cpp2
-rw-r--r--engines/agi/text.cpp38
-rw-r--r--engines/agi/text.h39
10 files changed, 117 insertions, 102 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index fffa4217f3..d259e9ecc5 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -523,6 +523,7 @@ void AgiEngine::initialize() {
game.hires = (uint8 *) calloc(_WIDTH * 2, _HEIGHT);
_sprites = new SpritesMan;
+ _text = new TextMan;
init_video();
tick_timer = 0;
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 49ed883c65..4df9bc910c 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -98,8 +98,8 @@ void new_room(int n) {
game.exit_all_logics = true;
- write_status();
- write_prompt();
+ _text->write_status();
+ _text->write_prompt();
}
static void reset_controllers() {
@@ -138,7 +138,7 @@ static void interpret_cycle() {
game.view_table[0].direction = game.vars[V_ego_dir];
if (game.vars[V_score] != old_score || getflag(F_sound_on) != old_sound)
- write_status();
+ _text->write_status();
game.vars[V_border_touch_obj] = 0;
game.vars[V_border_code] = 0;
@@ -203,7 +203,7 @@ int main_cycle() {
update_timer();
if (game.ver == 0) {
- message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
+ _text->message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
game.ver = -1;
}
@@ -228,7 +228,7 @@ int main_cycle() {
if (key == KEY_STATUSLN) {
debug_.statusline = !debug_.statusline;
- write_status();
+ _text->write_status();
key = 0;
}
@@ -332,11 +332,11 @@ static int play_game() {
if (getvar(V_time_delay) == 0 ||
(1 + clock_count) % getvar(V_time_delay) == 0) {
if (!game.has_prompt && game.input_mode == INPUT_NORMAL) {
- write_prompt();
+ _text->write_prompt();
game.has_prompt = 1;
} else
if (game.has_prompt && game.input_mode == INPUT_NONE) {
- write_prompt();
+ _text->write_prompt();
game.has_prompt = 0;
}
diff --git a/engines/agi/inv.cpp b/engines/agi/inv.cpp
index bf9de04d74..4c1f524638 100644
--- a/engines/agi/inv.cpp
+++ b/engines/agi/inv.cpp
@@ -57,7 +57,7 @@ static uint8 *intobj = NULL;
static void print_item(int n, int fg, int bg)
{
- print_text(object_name(intobj[n]), 0, n % 2 ? 39 - strlen(object_name(intobj[n])) : 1,
+ _text->print_text(object_name(intobj[n]), 0, n % 2 ? 39 - strlen(object_name(intobj[n])) : 1,
(n / 2) + 2, 40, fg, bg);
}
@@ -88,7 +88,7 @@ static int show_items() {
}
if (i == 0) {
- print_text(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
+ _text->print_text(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
}
return i;
@@ -166,7 +166,7 @@ void inventory() {
game.color_bg = 15;
clear_screen(game.color_bg);
- print_text(YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG);
+ _text->print_text(YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG);
/* FIXME: doesn't check if objects overflow off screen... */
@@ -176,9 +176,9 @@ void inventory() {
n = show_items();
if (getflag(F_status_selects_items)) {
- print_text(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG);
+ _text->print_text(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG);
} else {
- print_text(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG);
+ _text->print_text(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG);
}
flush_screen();
@@ -197,12 +197,12 @@ void inventory() {
wait_any_key();
clear_screen(0);
- write_status();
+ _text->write_status();
show_pic();
game.color_fg = old_fg;
game.color_bg = old_bg;
game.has_prompt = 0;
- flush_lines(game.line_user_input, 24);
+ _text->flush_lines(game.line_user_input, 24);
}
} // End of namespace Agi
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index bdac3953f8..a35fe8a547 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -293,8 +293,8 @@ void handle_keys(int key) {
game.has_prompt = 0;
game.input_buffer[game.cursor_pos = 0] = 0;
debugC(3, kDebugLevelInput, "clear lines");
- clear_lines(l, l + 1, bg);
- flush_lines(l, l + 1);
+ _text->clear_lines(l, l + 1, bg);
+ _text->flush_lines(l, l + 1);
break;
case KEY_ESCAPE:
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index 71f1928f94..3b6021986f 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -78,13 +78,13 @@ agi_menu_option *Menu::get_menu_option(int i, int j) {
}
void Menu::draw_menu_bar() {
- clear_lines(0, 0, MENU_BG);
- flush_lines(0, 0);
+ _text->clear_lines(0, 0, MENU_BG);
+ _text->flush_lines(0, 0);
MenuList::iterator iter;
for (iter = menubar.begin(); iter != menubar.end(); ++iter) {
agi_menu *m = *iter;
- print_text(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
+ _text->print_text(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
}
}
@@ -92,8 +92,8 @@ void Menu::draw_menu_bar() {
void Menu::draw_menu_hilite(int cur_menu) {
agi_menu *m = get_menu(cur_menu);
debugC(6, kDebugLevelMenu, "[%s]", m->text);
- print_text(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
- flush_lines(0, 0);
+ _text->print_text(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
+ _text->flush_lines(0, 0);
}
/* draw box and pulldowns. */
@@ -107,7 +107,7 @@ void Menu::draw_menu_option(int h_menu) {
MenuOptionList::iterator iter;
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
agi_menu_option* d = *iter;
- print_text(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
+ _text->print_text(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
d->enabled ? MENU_FG : MENU_DISABLED, MENU_BG);
}
}
@@ -116,7 +116,7 @@ void Menu::draw_menu_option_hilite(int h_menu, int v_menu) {
agi_menu *m = get_menu(h_menu);
agi_menu_option *d = get_menu_option(h_menu, v_menu);
- print_text(d->text, 0, m->wincol + 1, v_menu + 2, m->width + 2,
+ _text->print_text(d->text, 0, m->wincol + 1, v_menu + 2, m->width + 2,
MENU_BG, d->enabled ? MENU_FG : MENU_DISABLED);
}
@@ -412,7 +412,7 @@ bool Menu::keyhandler(int key) {
exit_menu:
button_used = 0;
show_pic();
- write_status();
+ _text->write_status();
setvar(V_key, 0);
game.keypress = 0;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 267adb5c3f..caa97950dd 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -386,17 +386,17 @@ cmd(close_dialogue) {
}
cmd(close_window) {
- close_window();
+ _text->close_window();
}
cmd(status_line_on) {
game.status_line = true;
- write_status();
+ _text->write_status();
}
cmd(status_line_off) {
game.status_line = false;
- write_status();
+ _text->write_status();
}
cmd(show_obj) {
@@ -444,6 +444,7 @@ cmd(save_game) {
}
cmd(load_game) {
+ assert(1);
game.simple_save ? loadgame_simple() : loadgame_dialog();
}
@@ -460,7 +461,7 @@ cmd(trace_info) { /* do nothing */
}
cmd(show_mem) {
- message_box("Enough memory");
+ _text->message_box("Enough memory");
}
cmd(init_joy) { /* do nothing */ ;
@@ -532,7 +533,7 @@ cmd(parse) {
setflag(F_entered_cli, false);
setflag(F_said_accepted_input, false);
- dictionary_words(agi_sprintf(game.strings[p0]));
+ dictionary_words(_text->agi_sprintf(game.strings[p0]));
}
cmd(call) {
@@ -867,7 +868,7 @@ cmd(pause) {
const char *b[] = { "Continue", NULL };
game.clock_enabled = false;
- selection_box(" Game is paused. \n\n\n", b);
+ _text->selection_box(" Game is paused. \n\n\n", b);
game.clock_enabled = tmp;
}
@@ -907,7 +908,7 @@ cmd(version) {
strncpy(q + 1 + ((r - q > 0 ? r - q : 1) / 4), ver_msg, strlen(ver_msg));
sprintf(msg, q, maj, min);
- message_box(msg);
+ _text->message_box(msg);
}
cmd(configure_screen) {
@@ -934,8 +935,8 @@ cmd(graphics) {
game.gfx_mode = true;
clear_screen(0);
show_pic();
- write_status();
- write_prompt();
+ _text->write_status();
+ _text->write_prompt();
}
}
@@ -962,7 +963,7 @@ cmd(quit) {
if (p0) {
game.quit_prog_now = true;
} else {
- if (selection_box
+ if (_text->selection_box
(" Quit the game, or continue? \n\n\n", buttons) == 0) {
game.quit_prog_now = true;
}
@@ -975,7 +976,7 @@ cmd(restart_game) {
stop_sound();
sel = getflag(F_auto_restart) ? 1 :
- selection_box(" Restart game, or continue? \n\n\n", buttons);
+ _text->selection_box(" Restart game, or continue? \n\n\n", buttons);
if (sel == 0) {
game.quit_prog_now = 0xff;
@@ -1036,7 +1037,7 @@ cmd(get_string) {
if (cur_logic->texts != NULL && cur_logic->num_texts >= tex) {
int len = strlen(cur_logic->texts[tex]);
- print_text(cur_logic->texts[tex], 0, col, row, len, game.color_fg, game.color_bg);
+ _text->print_text(cur_logic->texts[tex], 0, col, row, len, game.color_fg, game.color_bg);
get_string(col + len - 1, row, p4, p0);
/* SGEO: display input char */
@@ -1054,7 +1055,7 @@ cmd(get_num) {
if (cur_logic->texts != NULL && cur_logic->num_texts >= (p0 - 1)) {
int len = strlen(cur_logic->texts[p0 - 1]);
- print_text(cur_logic->texts[p0 - 1], 0, 0, 22, len, game.color_fg, game.color_bg);
+ _text->print_text(cur_logic->texts[p0 - 1], 0, 0, 22, len, game.color_fg, game.color_bg);
get_string(len - 1, 22, 3, MAX_STRINGS);
/* CM: display input char */
@@ -1067,8 +1068,8 @@ cmd(get_num) {
_v[p1] = atoi(game.strings[MAX_STRINGS]);
debugC(4, kDebugLevelScripts, "[%s] -> %d", game.strings[MAX_STRINGS], _v[p1]);
- clear_lines(22, 22, game.color_bg);
- flush_lines(22, 22);
+ _text->clear_lines(22, 22, game.color_bg);
+ _text->flush_lines(22, 22);
}
cmd(set_cursor_char) {
@@ -1101,12 +1102,12 @@ cmd(set_string) {
}
cmd(display) {
- print_text(cur_logic->texts[p2 - 1], p1, 0, p0, 40, game.color_fg, game.color_bg);
+ _text->print_text(cur_logic->texts[p2 - 1], p1, 0, p0, 40, game.color_fg, game.color_bg);
}
cmd(display_f) {
debugC(4, kDebugLevelScripts, "p0 = %d", p0);
- print_text(cur_logic->texts[_v[p2] - 1], _v[p1], 0, _v[p0], 40, game.color_fg, game.color_bg);
+ _text->print_text(cur_logic->texts[_v[p2] - 1], _v[p1], 0, _v[p0], 40, game.color_fg, game.color_bg);
}
cmd(clear_text_rect) {
@@ -1149,29 +1150,29 @@ cmd(clear_lines) {
/* Residence 44 calls clear.lines(24,0,0), see bug #558423 */
l = p1 ? p1 : p0;
- clear_lines(p0, l, p2);
- flush_lines(p0, l);
+ _text->clear_lines(p0, l, p2);
+ _text->flush_lines(p0, l);
}
cmd(print) {
int n = p0 < 1 ? 1 : p0;
- print(cur_logic->texts[n - 1], 0, 0, 0);
+ _text->print(cur_logic->texts[n - 1], 0, 0, 0);
}
cmd(print_f) {
int n = _v[p0] < 1 ? 1 : _v[p0];
- print(cur_logic->texts[n - 1], 0, 0, 0);
+ _text->print(cur_logic->texts[n - 1], 0, 0, 0);
}
cmd(print_at) {
int n = p0 < 1 ? 1 : p0;
debugC(4, kDebugLevelScripts, "%d %d %d %d", p0, p1, p2, p3);
- print(cur_logic->texts[n - 1], p1, p2, p3);
+ _text->print(cur_logic->texts[n - 1], p1, p2, p3);
}
cmd(print_at_v) {
int n = _v[p0] < 1 ? 1 : _v[p0];
- print(cur_logic->texts[n - 1], p1, p2, p3);
+ _text->print(cur_logic->texts[n - 1], p1, p2, p3);
}
cmd(push_script) {
diff --git a/engines/agi/savegame.cpp b/engines/agi/savegame.cpp
index 4e466d9b5d..f996443a81 100644
--- a/engines/agi/savegame.cpp
+++ b/engines/agi/savegame.cpp
@@ -412,7 +412,7 @@ int load_game(char *s) {
game.pri_table[i] = read_uint8(&f);
if (game.has_window)
- close_window();
+ _text->close_window();
game.msg_box_ticks = 0;
game.block.active = false;
/* game.window - fixed by close_window() */
@@ -548,7 +548,7 @@ int load_game(char *s) {
/* Clear input line */
clear_screen(0);
- write_status();
+ _text->write_status();
/* Recreate background from saved image stack */
clear_image_stack();
@@ -606,7 +606,7 @@ static int select_slot() {
char dstr[64];
for (i = 0; i < NUM_SLOTS; i++) {
sprintf(dstr, "[%-32.32s]", desc[i]);
- print_text(dstr, 0, hm + 1, vm + 4 + i,
+ _text->print_text(dstr, 0, hm + 1, vm + 4 + i,
(40 - 2 * hm) - 1, i == active ? MSG_BOX_COLOUR : MSG_BOX_TEXT,
i == active ? MSG_BOX_TEXT : MSG_BOX_COLOUR);
@@ -641,7 +641,7 @@ press:
debugC(8, kDebugLevelMain | kDebugLevelInput, "Button pressed: %d", rc);
getout:
- close_window();
+ _text->close_window();
return rc;
}
@@ -671,10 +671,10 @@ int savegame_dialog() {
sprintf(path, "%s/%05X_%s_%02d.sav", _savePath, game.crc, game.id, slot);
- draw_window(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
- print_text("Select a slot in which you wish to save the game:",
+ _text->draw_window(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
+ _text->print_text("Select a slot in which you wish to save the game:",
0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
- print_text("Press ENTER to select, ESC cancels",
+ _text->print_text("Press ENTER to select, ESC cancels",
0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
slot = select_slot();
@@ -682,9 +682,9 @@ int savegame_dialog() {
return err_OK;
/* Get savegame description */
- draw_window(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
+ _text->draw_window(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
GFX_HEIGHT - vp - 9 * CHAR_LINES);
- print_text("Enter a description for this game:",
+ _text->print_text("Enter a description for this game:",
0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
draw_rectangle(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
@@ -696,16 +696,16 @@ int savegame_dialog() {
do {
main_cycle();
} while (game.input_mode == INPUT_GETSTRING);
- close_window();
+ _text->close_window();
desc = game.strings[MAX_STRINGS];
sprintf(dstr, "Are you sure you want to save the game "
"described as:\n\n%s\n\nin slot %d?\n\n\n", desc, slot);
- rc = selection_box(dstr, buttons);
+ rc = _text->selection_box(dstr, buttons);
if (rc != 0) {
- message_box("Game NOT saved.");
+ _text->message_box("Game NOT saved.");
return err_OK;
}
@@ -714,7 +714,7 @@ int savegame_dialog() {
save_game(path, desc);
- message_box("Game saved.");
+ _text->message_box("Game saved.");
return err_OK;
}
@@ -727,14 +727,14 @@ int loadgame_simple() {
_sprites->erase_both();
stop_sound();
- close_window();
+ _text->close_window();
if ((rc = load_game(path)) == err_OK) {
- message_box("Game restored.");
+ _text->message_box("Game restored.");
game.exit_all_logics = 1;
menu->enable_all();
} else {
- message_box("Error restoring game.");
+ _text->message_box("Error restoring game.");
}
return rc;
@@ -757,27 +757,27 @@ int loadgame_dialog() {
_sprites->erase_both();
stop_sound();
- draw_window(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
- print_text("Select a game which you wish to\nrestore:",
+ _text->draw_window(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
+ _text->print_text("Select a game which you wish to\nrestore:",
0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
- print_text("Press ENTER to select, ESC cancels",
+ _text->print_text("Press ENTER to select, ESC cancels",
0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
slot = select_slot();
if (slot < 0) {
- message_box("Game NOT restored.");
+ _text->message_box("Game NOT restored.");
return err_OK;
}
sprintf(path, "%s/%05X_%s_%02d.sav", _savePath, game.crc, game.id, slot);
if ((rc = load_game(path)) == err_OK) {
- message_box("Game restored.");
+ _text->message_box("Game restored.");
game.exit_all_logics = 1;
menu->enable_all();
} else {
- message_box("Error restoring game.");
+ _text->message_box("Error restoring game.");
}
return rc;
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index 99f9d6e0a4..4653093c77 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -746,7 +746,7 @@ void SpritesMan::show_obj(int n) {
objs_savearea(&s);
blit_cel(x1, y1, s.x_size, c);
commit_block(x1, y1, x2, y2);
- message_box(game.views[n].descr);
+ _text->message_box(game.views[n].descr);
objs_restorearea(&s);
commit_block(x1, y1, x2, y2);
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index b0d0c9d727..1b93f361cf 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -30,7 +30,9 @@
namespace Agi {
-static void print_text2(int l, const char *msg, int foff, int xoff, int yoff,
+TextMan *_text;
+
+void TextMan::print_text2(int l, const char *msg, int foff, int xoff, int yoff,
int len, int fg, int bg) {
int x1, y1;
int maxx, minx, ofoff;
@@ -113,7 +115,7 @@ static void print_text2(int l, const char *msg, int foff, int xoff, int yoff,
/* len is in characters, not pixels!!
*/
-static void blit_textbox(const char *p, int y, int x, int len) {
+void TextMan::blit_textbox(const char *p, int y, int x, int len) {
/* if x | y = -1, then centre the box */
int xoff, yoff, lin, h, w;
char *msg, *m;
@@ -164,7 +166,7 @@ static void blit_textbox(const char *p, int y, int x, int len) {
do_update();
}
-static void erase_textbox() {
+void TextMan::erase_textbox() {
if (!game.window.active) {
debugC(3, kDebugLevelText, "no window active");
return;
@@ -189,7 +191,7 @@ static void erase_textbox() {
/**
* Print text in the AGI engine screen.
*/
-void print_text(const char *msg, int f, int x, int y, int len, int fg, int bg) {
+void TextMan::print_text(const char *msg, int f, int x, int y, int len, int fg, int bg) {
f *= CHAR_COLS;
x *= CHAR_COLS;
y *= CHAR_LINES;
@@ -201,7 +203,7 @@ void print_text(const char *msg, int f, int x, int y, int len, int fg, int bg) {
/**
* Print text in the AGI engine console.
*/
-void print_text_console(const char *msg, int x, int y, int len, int fg, int bg) {
+void TextMan::print_text_console(const char *msg, int x, int y, int len, int fg, int bg) {
x *= CHAR_COLS;
y *= 10;
@@ -213,7 +215,7 @@ void print_text_console(const char *msg, int x, int y, int len, int fg, int bg)
* @param str String to wrap.
* @param len Length of line.
*/
-char *word_wrap_string(char *str, int *len) {
+char *TextMan::word_wrap_string(char *str, int *len) {
/* If the message has a long word (longer than 31 character) then
* loop in line 239 (for (; *v != ' '; v--, c--);) can wrap
* around 0 and write large number in c. This causes returned
@@ -275,7 +277,7 @@ char *word_wrap_string(char *str, int *len) {
/**
* Remove existing window, if any.
*/
-void close_window() {
+void TextMan::close_window() {
debugC(4, kDebugLevelText, "close window");
_sprites->erase_both();
erase_textbox(); /* remove window, if any */
@@ -290,7 +292,7 @@ void close_window() {
* centered in the screen and waits until a key is pressed.
* @param p The text to be displayed
*/
-int message_box(const char *s) {
+int TextMan::message_box(const char *s) {
int k;
_sprites->erase_both();
@@ -310,7 +312,7 @@ int message_box(const char *s) {
* @param p The text to be displayed
* @param b NULL-terminated list of button labels
*/
-int selection_box(const char *m, const char **b) {
+int TextMan::selection_box(const char *m, const char **b) {
int x, y, i, s;
int key, active = 0;
int rc = -1;
@@ -393,7 +395,7 @@ int selection_box(const char *m, const char **b) {
/**
*
*/
-int print(const char *p, int lin, int col, int len) {
+int TextMan::print(const char *p, int lin, int col, int len) {
if (p == NULL)
return 0;
@@ -449,7 +451,7 @@ int print(const char *p, int lin, int col, int len) {
/**
*
*/
-static void print_status(const char *message, ...) {
+void TextMan::print_status(const char *message, ...) {
char x[42];
va_list args;
@@ -467,7 +469,7 @@ static void print_status(const char *message, ...) {
print_text(x, 0, 0, game.line_status, 40, STATUS_FG, STATUS_BG);
}
-static char *safe_strcat(char *s, const char *t) {
+char *TextMan::safe_strcat(char *s, const char *t) {
if (t != NULL)
strcat(s, t);
@@ -482,7 +484,7 @@ static char *safe_strcat(char *s, const char *t) {
* @param n logic number
*/
#define MAX_LEN 768
-char *agi_sprintf(const char *s) {
+char *TextMan::agi_sprintf(const char *s) {
static char y[MAX_LEN];
char x[MAX_LEN];
char z[16], *p;
@@ -568,7 +570,7 @@ char *agi_sprintf(const char *s) {
/**
* Write the status line.
*/
-void write_status() {
+void TextMan::write_status() {
char x[64];
if (debug_.statusline) {
@@ -593,7 +595,7 @@ void write_status() {
/**
* Print user input prompt.
*/
-void write_prompt() {
+void TextMan::write_prompt() {
int l, fg, bg, pos;
if (!game.input_enabled || game.input_mode != INPUT_NORMAL)
@@ -622,7 +624,7 @@ void write_prompt() {
* @param l2 end line
* @param c color
*/
-void clear_lines(int l1, int l2, int c) {
+void TextMan::clear_lines(int l1, int l2, int c) {
/* do we need to adjust for +8 on topline?
* inc for endline so it matches the correct num
* ie, from 22 to 24 is 3 lines, not 2 lines.
@@ -638,7 +640,7 @@ void clear_lines(int l1, int l2, int c) {
/**
*
*/
-void flush_lines(int l1, int l2) {
+void TextMan::flush_lines(int l1, int l2) {
l1 *= CHAR_LINES;
l2 *= CHAR_LINES;
l2 += CHAR_LINES - 1;
@@ -649,7 +651,7 @@ void flush_lines(int l1, int l2) {
/**
*
*/
-void draw_window(int x1, int y1, int x2, int y2) {
+void TextMan::draw_window(int x1, int y1, int x2, int y2) {
game.window.active = true;
game.window.x1 = x1;
game.window.y1 = y1;
diff --git a/engines/agi/text.h b/engines/agi/text.h
index d683b1669e..28324fc005 100644
--- a/engines/agi/text.h
+++ b/engines/agi/text.h
@@ -29,20 +29,31 @@
namespace Agi {
-int message_box(const char *);
-int selection_box(const char *, const char **);
-void close_window(void);
-void draw_window(int, int, int, int);
-void print_text(const char *, int, int, int, int, int, int);
-void print_text_console(const char *, int, int, int, int, int);
-int print(const char *, int, int, int);
-char *word_wrap_string(char *, int *);
-char *agi_sprintf(const char *);
-void write_status(void);
-void write_prompt(void);
-void clear_lines(int, int, int);
-void flush_lines(int, int);
-
+class TextMan {
+public:
+ int message_box(const char *);
+ int selection_box(const char *, const char **);
+ void close_window(void);
+ void draw_window(int, int, int, int);
+ void print_text(const char *, int, int, int, int, int, int);
+ void print_text_console(const char *, int, int, int, int, int);
+ int print(const char *, int, int, int);
+ char *word_wrap_string(char *, int *);
+ char *agi_sprintf(const char *);
+ void write_status(void);
+ void write_prompt(void);
+ void clear_lines(int, int, int);
+ void flush_lines(int, int);
+
+private:
+ void print_status(const char *message, ...);
+ void print_text2(int l, const char *msg, int foff, int xoff, int yoff, int len, int fg, int bg);
+ void blit_textbox(const char *p, int y, int x, int len);
+ void erase_textbox();
+ char *safe_strcat(char *s, const char *t);
+};
+
+extern TextMan *_text;
} // End of namespace Agi
#endif /* AGI_TEXT_H */