[Scummvm-cvs-logs] SF.net SVN: scummvm: [23011] scummvm/trunk/engines/agi

ender at users.sourceforge.net ender at users.sourceforge.net
Sat Jun 10 15:20:47 CEST 2006


Revision: 23011
Author:   ender
Date:     2006-06-10 06:20:29 -0700 (Sat, 10 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23011&view=rev

Log Message:
-----------
Pop AGIs text.cpp into a class, for later cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agi/cycle.cpp
    scummvm/trunk/engines/agi/inv.cpp
    scummvm/trunk/engines/agi/keyboard.cpp
    scummvm/trunk/engines/agi/menu.cpp
    scummvm/trunk/engines/agi/op_cmd.cpp
    scummvm/trunk/engines/agi/savegame.cpp
    scummvm/trunk/engines/agi/sprite.cpp
    scummvm/trunk/engines/agi/text.cpp
    scummvm/trunk/engines/agi/text.h
Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/agi.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -523,6 +523,7 @@
 	game.hires = (uint8 *) calloc(_WIDTH * 2, _HEIGHT);
 
 	_sprites = new SpritesMan;
+	_text = new TextMan;
 	init_video();
 
 	tick_timer = 0;

Modified: scummvm/trunk/engines/agi/cycle.cpp
===================================================================
--- scummvm/trunk/engines/agi/cycle.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/cycle.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -98,8 +98,8 @@
 
 	game.exit_all_logics = true;
 
-	write_status();
-	write_prompt();
+	_text->write_status();
+	_text->write_prompt();
 }
 
 static void reset_controllers() {
@@ -138,7 +138,7 @@
 	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 @@
 	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 @@
 
 	if (key == KEY_STATUSLN) {
 		debug_.statusline = !debug_.statusline;
-		write_status();
+		_text->write_status();
 		key = 0;
 	}
 
@@ -332,11 +332,11 @@
 		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;
 			}
 

Modified: scummvm/trunk/engines/agi/inv.cpp
===================================================================
--- scummvm/trunk/engines/agi/inv.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/inv.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -57,7 +57,7 @@
 
 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 @@
 	}
 
 	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 @@
 	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 @@
 	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 @@
 		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

Modified: scummvm/trunk/engines/agi/keyboard.cpp
===================================================================
--- scummvm/trunk/engines/agi/keyboard.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/keyboard.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -293,8 +293,8 @@
 		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:

Modified: scummvm/trunk/engines/agi/menu.cpp
===================================================================
--- scummvm/trunk/engines/agi/menu.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/menu.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -78,13 +78,13 @@
 }
 
 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_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 @@
 	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 @@
 	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 @@
 exit_menu:
 	button_used = 0;
 	show_pic();
-	write_status();
+	_text->write_status();
 
 	setvar(V_key, 0);
 	game.keypress = 0;

Modified: scummvm/trunk/engines/agi/op_cmd.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_cmd.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/op_cmd.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -386,17 +386,17 @@
 }
 
 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(load_game) {
+	assert(1);
 	game.simple_save ? loadgame_simple() : loadgame_dialog();
 }
 
@@ -460,7 +461,7 @@
 }
 
 cmd(show_mem) {
-	message_box("Enough memory");
+	_text->message_box("Enough memory");
 }
 
 cmd(init_joy) { /* do nothing */ ;
@@ -532,7 +533,7 @@
 	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 @@
 	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 @@
 
 	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 @@
 		game.gfx_mode = true;
 		clear_screen(0);
 		show_pic();
-		write_status();
-		write_prompt();
+		_text->write_status();
+		_text->write_prompt();
 	}
 }
 
@@ -962,7 +963,7 @@
 	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 @@
 
 	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 @@
 
 	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 @@
 
 	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 @@
 
 	_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(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 @@
 	/* 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) {

Modified: scummvm/trunk/engines/agi/savegame.cpp
===================================================================
--- scummvm/trunk/engines/agi/savegame.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/savegame.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -412,7 +412,7 @@
 		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 @@
 
 	/* Clear input line */
 	clear_screen(0);
-	write_status();
+	_text->write_status();
 
 	/* Recreate background from saved image stack */
 	clear_image_stack();
@@ -606,7 +606,7 @@
 		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 @@
 	debugC(8, kDebugLevelMain | kDebugLevelInput, "Button pressed: %d", rc);
 
 getout:
-	close_window();
+	_text->close_window();
 	return rc;
 }
 
@@ -671,10 +671,10 @@
 
 	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 @@
 		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 @@
 	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 @@
 
 	save_game(path, desc);
 
-	message_box("Game saved.");
+	_text->message_box("Game saved.");
 
 	return err_OK;
 }
@@ -727,14 +727,14 @@
 
 	_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 @@
 	_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;

Modified: scummvm/trunk/engines/agi/sprite.cpp
===================================================================
--- scummvm/trunk/engines/agi/sprite.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/sprite.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -746,7 +746,7 @@
 	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);
 

Modified: scummvm/trunk/engines/agi/text.cpp
===================================================================
--- scummvm/trunk/engines/agi/text.cpp	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/text.cpp	2006-06-10 13:20:29 UTC (rev 23011)
@@ -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 @@
 
 /* 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 @@
 	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 @@
 /**
  * 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 @@
 /**
  * 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 @@
  * @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 @@
 /**
  * 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 @@
  * 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 @@
  * @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 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 @@
 /**
  *
  */
-static void print_status(const char *message, ...) {
+void TextMan::print_status(const char *message, ...) {
 	char x[42];
 	va_list args;
 
@@ -467,7 +469,7 @@
 	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 @@
  * @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 @@
 /**
  * Write the status line.
  */
-void write_status() {
+void TextMan::write_status() {
 	char x[64];
 
 	if (debug_.statusline) {
@@ -593,7 +595,7 @@
 /**
  * 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 @@
  * @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 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 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;

Modified: scummvm/trunk/engines/agi/text.h
===================================================================
--- scummvm/trunk/engines/agi/text.h	2006-06-10 12:05:27 UTC (rev 23010)
+++ scummvm/trunk/engines/agi/text.h	2006-06-10 13:20:29 UTC (rev 23011)
@@ -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 */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list