[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.12,1.13 dialog.h,1.3,1.4 newgui.cpp,1.6,1.7 newgui.h,1.3,1.4 widget.cpp,1.3,1.4

Max Horn fingolfin at users.sourceforge.net
Thu Sep 19 09:07:10 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv18083/gui

Modified Files:
	dialog.cpp dialog.h newgui.cpp newgui.h widget.cpp 
Log Message:
Added overlay to OSystem interface; implemented overlay in SDL backend (all other backends, including SDL_gl, still need to implement this!); changed NewGUI to make use of the overlay; added Cmd-Q as a shortcut for Quit on MacOS X

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dialog.cpp	17 Sep 2002 12:52:53 -0000	1.12
+++ dialog.cpp	19 Sep 2002 16:06:50 -0000	1.13
@@ -45,33 +45,6 @@
  * ...
  */
 
-Dialog::~Dialog()
-{
-	teardownScreenBuf();
-}
-
-void Dialog::setupScreenBuf()
-{
-	// Create _screenBuf if it doesn't already exist
-	if (!_screenBuf)
-		_screenBuf = new byte[g_scumm->_realWidth * g_scumm->_realHeight];
-	
-	// Draw the fixed parts of the dialog: background and border.
-	_gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor);
-	_gui->box(_x, _y, _w, _h);
-	
-	// Finally blit this to _screenBuf
-	_gui->blitTo(_screenBuf, _x, _y, _w, _h); 
-}
-
-void Dialog::teardownScreenBuf()
-{
-	if (_screenBuf) {
-		delete [] _screenBuf;
-		_screenBuf = 0;
-	}
-}
-
 void Dialog::open()
 {
 	Widget *w = _firstWidget;
@@ -112,18 +85,15 @@
 	if (!isVisible())
 		return;
 
-	if (_screenBuf) {
-		_gui->blitFrom(_screenBuf, _x, _y, _w, _h); 
-	} else {
-		_gui->fillRect(_x, _y, _w, _h, _gui->_bgcolor);
-		_gui->box(_x, _y, _w, _h);
-	}
-	_gui->addDirtyRect(_x, _y, _w, _h);
+	_gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor);
+	_gui->box(_x, _y, _w, _h);
 
 	while (w) {
 		w->draw();
 		w = w->_next;
 	}
+
+	_gui->addDirtyRect(_x, _y, _w, _h);
 }
 
 void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
@@ -314,8 +284,8 @@
  *   method to Dialog for that.
  */
 
-SaveLoadDialog::SaveLoadDialog(NewGui *gui)
-	: Dialog (gui, 30, 20, 260, 124)
+SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm)
+	: Dialog (gui, 30, 20, 260, 124), _scumm(scumm)
 {
 	addResText(10, 7, 240, 16, 1);
 //  addResText(10, 7, 240, 16, 2);
@@ -333,10 +303,9 @@
 	// Get savegame names
 	ScummVM::StringList l;
 	char name[32];
-	Scumm *s = _gui->getScumm();
 
 	for (int i = 0; i <= 80; i++) {		// 80 - got this value from the old GUI
-		s->getSavegameName(i, name);
+		_scumm->getSavegameName(i, name);
 		l.push_back(name);
 	}
 
@@ -349,7 +318,7 @@
 	case kListItemChangedCmd:
 	case kSaveCmd:
 		if (_savegameList->getSelected() >= 1 && !_savegameList->getSelectedString().isEmpty()) {
-			Scumm *s = _gui->getScumm();
+			Scumm *s = _scumm;
 			s->_saveLoadSlot = _savegameList->getSelected();
 			s->_saveLoadCompatible = false;
 			s->_saveLoadFlag = 1;		// 1 for save, I assume (Painelf)
@@ -360,7 +329,7 @@
 	case kListItemDoubleClickedCmd:
 	case kLoadCmd:
 		if (_savegameList->getSelected() >= 0 && !_savegameList->getSelectedString().isEmpty()) {
-			Scumm *s = _gui->getScumm();
+			Scumm *s = _scumm;
 			s->_saveLoadSlot = _savegameList->getSelected();
 			s->_saveLoadCompatible = false;
 			s->_saveLoadFlag = 2;		// 2 for load. Magic number anyone?
@@ -374,8 +343,7 @@
 		_gui->optionsDialog();
 		break;
 	case kQuitCmd: {
-			Scumm *s = _gui->getScumm();
-			s->_system->quit();
+			_scumm->_system->quit();
 		}
 		break;
 	default:
@@ -441,8 +409,8 @@
 	addResText(4, 4, 220, 16, 10);
 }
 
-SoundDialog::SoundDialog(NewGui *gui)
-	: Dialog (gui, 30, 20, 260, 110)
+SoundDialog::SoundDialog(NewGui *gui, Scumm *scumm)
+	: Dialog (gui, 30, 20, 260, 110), _scumm(scumm)
 {
 
 	// set up dialog
@@ -471,14 +439,12 @@
 
 void SoundDialog::open()
 {
-	Scumm	*scumm = _gui->getScumm();
-	
 	Dialog::open();
 
 	// get current variables
-	_soundVolumeMaster = scumm->_sound->_sound_volume_master;
-	_soundVolumeMusic = scumm->_sound->_sound_volume_music;
-	_soundVolumeSfx = scumm->_sound->_sound_volume_sfx;
+	_soundVolumeMaster = _scumm->_sound->_sound_volume_master;
+	_soundVolumeMusic = _scumm->_sound->_sound_volume_music;
+	_soundVolumeSfx = _scumm->_sound->_sound_volume_sfx;
 
 	masterVolumeSlider->setValue(_soundVolumeMaster);
 	musicVolumeSlider->setValue(_soundVolumeMusic);
@@ -509,17 +475,15 @@
 		sfxVolumeLabel->draw();
 		break;
 	case kOKCmd: {
-		Scumm	*scumm = _gui->getScumm();
-		
 		// FIXME: Look at Fingolfins comments in Gui::handleSoundDialogCommand(), gui.cpp 
-		scumm->_sound->_sound_volume_master = _soundVolumeMaster;	// Master
-		scumm->_sound->_sound_volume_music = _soundVolumeMusic;	// Music
-		scumm->_sound->_sound_volume_sfx = _soundVolumeSfx;	// SFX
+		_scumm->_sound->_sound_volume_master = _soundVolumeMaster;	// Master
+		_scumm->_sound->_sound_volume_music = _soundVolumeMusic;	// Music
+		_scumm->_sound->_sound_volume_sfx = _soundVolumeSfx;	// SFX
 		
-		scumm->_imuse->set_music_volume(_soundVolumeMusic);
-		scumm->_imuse->set_master_volume(_soundVolumeMaster);
-		scumm->_mixer->setVolume(_soundVolumeSfx);
-		scumm->_mixer->setMusicVolume(_soundVolumeMusic);
+		_scumm->_imuse->set_music_volume(_soundVolumeMusic);
+		_scumm->_imuse->set_master_volume(_soundVolumeMaster);
+		_scumm->_mixer->setVolume(_soundVolumeSfx);
+		_scumm->_mixer->setMusicVolume(_soundVolumeMusic);
 		
 		scummcfg->setInt("master_volume", _soundVolumeMaster);
 		scummcfg->setInt("music_volume", _soundVolumeMusic);

Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dialog.h	8 Sep 2002 16:00:12 -0000	1.3
+++ dialog.h	19 Sep 2002 16:06:50 -0000	1.4
@@ -26,6 +26,7 @@
 #include "ListWidget.h"
 
 class NewGui;
+class Scumm;
 
 #define RES_STRING(id)		_gui->queryResString(id)
 #define CUSTOM_STRING(id)	_gui->queryCustomString(id)
@@ -45,15 +46,14 @@
 	Widget	*_firstWidget;
 	Widget	*_mouseWidget;
 	Widget  *_focusedWidget;
-	byte	*_screenBuf;
 	bool	_visible;
 
 public:
 	Dialog(NewGui *gui, int x, int y, int w, int h)
 		: _gui(gui), _x(x), _y(y), _w(w), _h(h), _firstWidget(0),
-		  _mouseWidget(0), _focusedWidget(0), _screenBuf(0), _visible(false)
+		  _mouseWidget(0), _focusedWidget(0), _visible(false)
 		{}
-	virtual ~Dialog();
+	virtual ~Dialog() {};
 
 	virtual void open();
 	virtual void close();
@@ -70,9 +70,6 @@
 	
 	NewGui	*getGui()	{ return _gui; }
 	
-	virtual void	setupScreenBuf();
-	virtual void	teardownScreenBuf();
-
 	bool isVisible() const		{ return _visible; }
 
 protected:
@@ -85,24 +82,25 @@
 
 class SaveLoadDialog : public Dialog {
 public:
-	SaveLoadDialog(NewGui *gui);
+	SaveLoadDialog(NewGui *gui, Scumm *scumm);
 
 	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
 
 protected:
+	Scumm *_scumm;
 	ListWidget	*_savegameList;
 };
 
 
-class SoundDialog;
-class KeysDialog;
-class MiscDialog;
-
 class AboutDialog : public Dialog {
 public:
 	AboutDialog(NewGui *gui);
 };
 
+class SoundDialog;
+class KeysDialog;
+class MiscDialog;
+
 class OptionsDialog : public Dialog {
 protected:
 	SoundDialog		*_soundDialog;
@@ -138,7 +136,7 @@
 
 class SoundDialog : public Dialog {
 public:
-	SoundDialog(NewGui *gui);
+	SoundDialog(NewGui *gui, Scumm *scumm);
 
 	enum {
 		kMasterVolumeChanged	= 'mavc',
@@ -153,6 +151,8 @@
 	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
 
 protected:
+	Scumm *_scumm;
+	
 	int _soundVolumeMaster;
 	int _soundVolumeMusic;
 	int _soundVolumeSfx;

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- newgui.cpp	17 Sep 2002 16:12:16 -0000	1.6
+++ newgui.cpp	19 Sep 2002 16:06:50 -0000	1.7
@@ -37,11 +37,24 @@
  * - ...
  */
 
-NewGui::NewGui(Scumm *s) : _s(s), _use_alpha_blending(false),
-	_need_redraw(false),_prepare_for_gui(true),
+// FIXME - this macro assumes that we use 565 mode. But what if we are in 555 mode?
+#define RGB_TO_16(r,g,b)	(((((r)>>3)&0x1F) << 11) | ((((g)>>2)&0x3F) << 5) | (((b)>>3)&0x1F))
+//#define RGB_TO_16(r,g,b)	(((((r)>>3)&0x1F) << 10) | ((((g)>>3)&0x1F) << 5) | (((b)>>3)&0x1F))
+
+#define RED_FROM_16(x)		((((x)>>11)&0x1F) << 3)
+#define GREEN_FROM_16(x)	((((x)>>5)&0x3F) << 2)
+#define BLUE_FROM_16(x)		(((x)&0x1F) << 3)
+
+//#define RED_FROM_16(x)	((((x)>>10)&0x1F) << 3)
+//#define GREEN_FROM_16(x)	((((x)>>5)&0x1F) << 3)
+//#define BLUE_FROM_16(x)	(((x)&0x1F) << 3)
+
+
+NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0),
+	_use_alpha_blending(true), _need_redraw(false),_prepare_for_gui(true),
 	_pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0),
 	_currentKeyDown(0)
-{	
+{
 }
 
 void NewGui::pauseDialog()
@@ -54,7 +67,7 @@
 void NewGui::saveloadDialog()
 {
 	if (!_saveLoadDialog)
-		_saveLoadDialog = new SaveLoadDialog(this);
+		_saveLoadDialog = new SaveLoadDialog(this, _s);
 	_saveLoadDialog->open();
 }
 
@@ -75,7 +88,7 @@
 void NewGui::soundDialog()
 {
 	if (!_soundDialog)
-		_soundDialog = new SoundDialog(this);
+		_soundDialog = new SoundDialog(this, _s);
 	_soundDialog->open();
 }
 
@@ -85,22 +98,14 @@
 	int i;
 	
 	if (_prepare_for_gui) {
-		ClearBlendCache(_s->_currentPalette, 128);
 		saveState();
-		if (_use_alpha_blending)
-			activeDialog->setupScreenBuf();
-#if 1
-		// FIXME - hack to encode our own custom GUI colors. Since we have to live
-		// with a given 8 bit palette, the result is not always as nice as one
-		// would wish, but this is just an experiment after all.
-		_bgcolor = RGBMatch(_s->_currentPalette, 0, 0, 0);
-	
-		_color = RGBMatch(_s->_currentPalette, 80, 80, 80);
-		_shadowcolor = RGBMatch(_s->_currentPalette, 64, 64, 64);
-	
-		_textcolor = RGBMatch(_s->_currentPalette, 32, 192, 32);
-		_textcolorhi = RGBMatch(_s->_currentPalette, 0, 256, 0);
-#endif
+
+		// Setup some default GUI colors
+		_bgcolor = RGB_TO_16(0, 0, 0);
+		_color = RGB_TO_16(80, 80, 80);
+		_shadowcolor = RGB_TO_16(64, 64, 64);
+		_textcolor = RGB_TO_16(32, 192, 32);
+		_textcolorhi = RGB_TO_16(0, 255, 0);
 
 		_eventList.clear();
 		_currentKeyDown = 0;
@@ -115,6 +120,10 @@
 	activeDialog->handleTickle();
 
 	if (_need_redraw) {
+		// Restore the overlay to its initial state, then draw all dialogs.
+		// This is necessary to get the blending right.
+		_system->clear_overlay();
+		_system->grab_overlay(_screen, _screen_pitch);
 		for (i = 0; i < _dialogStack.size(); i++)
 			_dialogStack[i]->draw();
 		_need_redraw = false;
@@ -152,7 +161,7 @@
 				// We don't distinguish between mousebuttons (for now at least)
 				case OSystem::EVENT_LBUTTONDOWN:
 				case OSystem::EVENT_RBUTTONDOWN: {
-					uint32 time = _s->_system->get_msecs();
+					uint32 time = _system->get_msecs();
 					if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay)
 					      && ABS(_lastClick.x - t.mouse.x) < 3
 					      && ABS(_lastClick.y - t.mouse.y) < 3) {
@@ -208,10 +217,16 @@
 	_old_cursorHeight = _s->_cursorHeight;
 	_old_cursorHotspotX = _s->_cursorHotspotX;
 	_old_cursorHotspotY = _s->_cursorHotspotY;
-	_old_cursor_mode = _s->_system->show_mouse(true);
+	_old_cursor_mode = _system->show_mouse(true);
 
 	_s->_cursorAnimate++;
 	_s->gdi._cursorActive = 1;
+	
+	// TODO - add getHeight & getWidth methods to OSystem
+	_system->show_overlay();
+	_screen = new int16[_s->_realWidth * _s->_realHeight];
+	_screen_pitch = _s->_realWidth;
+	_system->grab_overlay(_screen, _screen_pitch);
 }
 
 void NewGui::restoreState()
@@ -228,17 +243,21 @@
 	_s->_cursorHotspotY = _old_cursorHotspotY;
 	_s->updateCursor();
 
-	_s->_system->show_mouse(_old_cursor_mode);
+	_system->show_mouse(_old_cursor_mode);
 
 	_s->_sound->pauseSounds(_old_soundsPaused);
+
+	_system->hide_overlay();
+	if (_screen) {
+		delete _screen;
+		_screen = 0;
+	}
 }
 
 void NewGui::openDialog(Dialog *dialog)
 {
 	if (_dialogStack.empty())
 		_prepare_for_gui = true;
-	else if (_use_alpha_blending)
-		dialog->setupScreenBuf();
 
 	_dialogStack.push(dialog);
 	_need_redraw = true;
@@ -250,10 +269,6 @@
 	if (_dialogStack.empty())
 		return;
 	
-	// Tear down its screenBuf
-	if (_use_alpha_blending)
-		_dialogStack.top()->teardownScreenBuf();
-	
 	// Remove the dialog from the stack
 	_dialogStack.pop();
 	if (_dialogStack.empty())
@@ -304,15 +319,9 @@
 #pragma mark -
 
 
-byte *NewGui::getBasePtr(int x, int y)
+int16 *NewGui::getBasePtr(int x, int y)
 {
-	VirtScreen *vs = _s->findVirtScreen(y);
-
-	if (vs == NULL)
-		return NULL;
-
-	return vs->screenPtr + x + (y - vs->topline) * _s->_realWidth +
-		_s->_screenStartStrip * 8 + (_s->camera._cur.y - (_s->_realHeight / 2)) * _s->_realWidth;
+	return _screen + x + y * _screen_pitch;
 }
 
 void NewGui::box(int x, int y, int width, int height)
@@ -328,9 +337,9 @@
 	vline(x + width - 2, y + 1, y + height - 1, _shadowcolor);
 }
 
-void NewGui::line(int x, int y, int x2, int y2, byte color)
+void NewGui::line(int x, int y, int x2, int y2, int16 color)
 {
-	byte *ptr;
+	int16 *ptr;
 
 	if (x2 < x)
 		x2 ^= x ^= x2 ^= x;					// Swap x2 and x
@@ -347,7 +356,7 @@
 		/* vertical line */
 		while (y++ <= y2) {
 			*ptr = color;
-			ptr += _s->_realWidth;
+			ptr += _screen_pitch;
 		}
 	} else if (y == y2) {
 		/* horizontal line */
@@ -357,53 +366,61 @@
 	}
 }
 
-void NewGui::blendRect(int x, int y, int w, int h, byte color)
+void NewGui::blendRect(int x, int y, int w, int h, int16 color)
 {
-	byte *ptr = getBasePtr(x, y);
+	int r = RED_FROM_16(color);
+	int g = GREEN_FROM_16(color);
+	int b = BLUE_FROM_16(color);
+	int16 *ptr = getBasePtr(x, y);
 	if (ptr == NULL)
 		return;
 
 	while (h--) {
 		for (int i = 0; i < w; i++) {
-			ptr[i] = Blend(ptr[i], color, _s->_currentPalette);
+			ptr[i] = RGB_TO_16((RED_FROM_16(ptr[i])+r)/2,
+			                   (GREEN_FROM_16(ptr[i])+g)/2,
+			                   (BLUE_FROM_16(ptr[i])+b)/2);
+//			ptr[i] = color;
 		}
-		ptr += _s->_realWidth;
+		ptr += _screen_pitch;
 	}
 }
 
-void NewGui::fillRect(int x, int y, int w, int h, byte color)
+void NewGui::fillRect(int x, int y, int w, int h, int16 color)
 {
-	byte *ptr = getBasePtr(x, y);
+	int i;
+	int16 *ptr = getBasePtr(x, y);
 	if (ptr == NULL)
 		return;
 
 	while (h--) {
-		for (int i = 0; i < w; i++) {
+		for (i = 0; i < w; i++) {
 			ptr[i] = color;
 		}
-		ptr += _s->_realWidth;
+		ptr += _screen_pitch;
 	}
 }
 
-void NewGui::checkerRect(int x, int y, int w, int h, byte color)
+void NewGui::checkerRect(int x, int y, int w, int h, int16 color)
 {
-	byte *ptr = getBasePtr(x, y);
+	int i;
+	int16 *ptr = getBasePtr(x, y);
 	if (ptr == NULL)
 		return;
 
 	while (h--) {
-		for (int i = 0; i < w; i++) {
+		for (i = 0; i < w; i++) {
 			if ((h ^ i) & 1)
 				ptr[i] = color;
 		}
-		ptr += _s->_realWidth;
+		ptr += _screen_pitch;
 	}
 }
 
-void NewGui::frameRect(int x, int y, int w, int h, byte color)
+void NewGui::frameRect(int x, int y, int w, int h, int16 color)
 {
 	int i;
-	byte *ptr, *basePtr = getBasePtr(x, y);
+	int16 *ptr, *basePtr = getBasePtr(x, y);
 	if (basePtr == NULL)
 		return;
 
@@ -411,57 +428,57 @@
 	for (i = 0; i < w; i++, ptr++)
 		*ptr = color;
 	ptr--;
-	for (i = 0; i < h; i++, ptr += _s->_realWidth)
+	for (i = 0; i < h; i++, ptr += _screen_pitch)
 		*ptr = color;
 	ptr = basePtr;
-	for (i = 0; i < h; i++, ptr += _s->_realWidth)
+	for (i = 0; i < h; i++, ptr += _screen_pitch)
 		*ptr = color;
-	ptr -= _s->_realWidth;
+	ptr -= _screen_pitch;
 	for (i = 0; i < w; i++, ptr++)
 		*ptr = color;
 }
 
 void NewGui::addDirtyRect(int x, int y, int w, int h)
 {
-	VirtScreen *vs = _s->findVirtScreen(y);
-
-	if (vs != NULL)
-		_s->setVirtscreenDirty(vs, x, y, x + w, y + h);
+	// For now we don't keep yet another list of dirty rects but simply
+	// blit the affected area directly to the overlay. At least for our current
+	// GUI/widget/dialog code that is just fine.
+	int16 *buf = getBasePtr(x, y);
+	_system->copy_rect_overlay(buf, _screen_pitch, x, y, w, h);
 }
 
-void NewGui::drawChar(const char str, int xx, int yy)
+void NewGui::drawChar(const char str, int xx, int yy, int16 color)
 {
 	unsigned int buffer = 0, mask = 0, x, y;
 	byte *tmp;
-	int tempc = _color;
-	_color = _textcolor;
 
 	tmp = &guifont[0];
 	tmp += 224 + (str + 1) * 8;
 
-	byte *ptr = getBasePtr(xx, yy);
+	int16 *ptr = getBasePtr(xx, yy);
 	if (ptr == NULL)
 		return;
 
 	for (y = 0; y < 8; y++) {
 		for (x = 0; x < 8; x++) {
-			unsigned char color;
+			unsigned char c;
 			if ((mask >>= 1) == 0) {
 				buffer = *tmp++;
 				mask = 0x80;
 			}
-			color = ((buffer & mask) != 0);
-			if (color)
-				ptr[x] = _color;
+			c = ((buffer & mask) != 0);
+			if (c)
+				ptr[x] = color;
 		}
-		ptr += _s->_realWidth;
+		ptr += _screen_pitch;
 	}
-	_color = tempc;
-
 }
 
-void NewGui::drawString(const char *str, int x, int y, int w, byte color, int align)
+void NewGui::drawString(const char *str, int x, int y, int w, int16 color, int align)
 {
+#if 1
+	if (0) {
+#else
 	if (_s->_gameId) {						/* If a game is active.. */
 		StringTab *st = &_s->string[5];
 		st->charset = 1;
@@ -480,22 +497,23 @@
 	
 		_s->_messagePtr = (byte *)str;
 		_s->drawString(5);
+#endif
 	} else {
 		// FIXME - support center/right align, use nicer custom font.
 		// Ultimately, we might want to *always* draw our messages this way,
 		// but only if we have a nice font.
 		uint len = strlen(str);
 		for (uint letter = 0; letter < len; letter++)
-			drawChar(str[letter], x + (letter * 8), y);
+			drawChar(str[letter], x + (letter * 8), y, color);
 	}
 }
 
 /*
  * Draw an 8x8 bitmap at location (x,y)
  */
-void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, byte color)
+void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, int16 color)
 {
-	byte *ptr = getBasePtr(x, y);
+	int16 *ptr = getBasePtr(x, y);
 	if (ptr == NULL)
 		return;
 
@@ -506,39 +524,6 @@
 				ptr[x2] = color;
 			mask >>= 4;
 		}
-		ptr += _s->_realWidth;
-	}
-}
-
-void NewGui::blitTo(byte buffer[320*200], int x, int y, int w, int h)
-{
-	byte *dstPtr = buffer + x + y * _s->_realWidth;
-	byte *srcPtr = getBasePtr(x, y);
-	if (srcPtr == NULL)
-		return;
-
-	while (h--) {
-		for (int i = 0; i < w; i++) {
-			*dstPtr++ = *srcPtr++;
-		}
-		dstPtr += _s->_realWidth - w;
-		srcPtr += _s->_realWidth - w;
-	}
-}
-
-void NewGui::blitFrom(byte buffer[320*200], int x, int y, int w, int h)
-{
-	byte *srcPtr = buffer + x + y * _s->_realWidth;
-	byte *dstPtr = getBasePtr(x, y);
-	if (dstPtr == NULL)
-		return;
-
-	while (h--) {
-		for (int i = 0; i < w; i++) {
-			*dstPtr++ = *srcPtr++;
-		}
-		dstPtr += _s->_realWidth - w;
-		srcPtr += _s->_realWidth - w;
+		ptr += _screen_pitch;
 	}
 }
-

Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- newgui.h	8 Sep 2002 12:56:44 -0000	1.3
+++ newgui.h	19 Sep 2002 16:06:51 -0000	1.4
@@ -63,10 +63,10 @@
 class NewGui {
 	friend class Dialog;
 public:
-	byte _color, _shadowcolor;
-	byte _bgcolor;
-	byte _textcolor;
-	byte _textcolorhi;
+	int16 _color, _shadowcolor;
+	int16 _bgcolor;
+	int16 _textcolor;
+	int16 _textcolorhi;
 
 	// Dialogs
 	void pauseDialog();
@@ -82,11 +82,13 @@
 	NewGui(Scumm *s);
 
 	void handleEvent(const OSystem::Event &event) { _eventList.push_back(event); }
-	
-	Scumm *getScumm() { return _s; }
 
 protected:
 	Scumm		*_s;
+	OSystem		*_system;
+	int16		*_screen;
+	int			_screen_pitch;
+	
 	bool		_use_alpha_blending;
 	bool		_need_redraw;
 	bool		_prepare_for_gui;
@@ -129,20 +131,18 @@
 
 public:
 	// Drawing
-	byte *getBasePtr(int x, int y);
+	int16 *getBasePtr(int x, int y);
 	void box(int x, int y, int width, int height);
-	void line(int x, int y, int x2, int y2, byte color);
-	void blendRect(int x, int y, int w, int h, byte color);
-	void fillRect(int x, int y, int w, int h, byte color);
-	void checkerRect(int x, int y, int w, int h, byte color);
-	void frameRect(int x, int y, int w, int h, byte color);
+	void line(int x, int y, int x2, int y2, int16 color);
+	void blendRect(int x, int y, int w, int h, int16 color);
+	void fillRect(int x, int y, int w, int h, int16 color);
+	void checkerRect(int x, int y, int w, int h, int16 color);
+	void frameRect(int x, int y, int w, int h, int16 color);
 	void addDirtyRect(int x, int y, int w, int h);
-	void drawChar(const char c, int x, int y);
-	void drawString(const char *str, int x, int y, int w, byte color, int align = kTextAlignLeft);
+	void drawChar(const char c, int x, int y, int16 color);
+	void drawString(const char *str, int x, int y, int w, int16 color, int align = kTextAlignLeft);
 
-	void drawBitmap(uint32 bitmap[8], int x, int y, byte color);
-	void blitTo(byte buffer[320*200], int x, int y, int w, int h);
-	void blitFrom(byte buffer[320*200], int x, int y, int w, int h);
+	void drawBitmap(uint32 bitmap[8], int x, int y, int16 color);
 
 	// Query a string from the resources
 	const char *queryResString(int stringno);

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- widget.cpp	8 Sep 2002 16:00:12 -0000	1.3
+++ widget.cpp	19 Sep 2002 16:06:51 -0000	1.4
@@ -58,9 +58,6 @@
 	
 	// Now perform the actual widget draw
 	drawWidget(_flags & WIDGET_HILITED);
-	
-	// Flag the draw area as dirty
-	gui->addDirtyRect(_x, _y, _w, _h);
 
 	// Restore x/y
 	if (_flags & WIDGET_BORDER) {
@@ -68,6 +65,10 @@
 		_y -= 4;
 		_w += 8;
 	}
+	
+	// Flag the draw area as dirty
+	gui->addDirtyRect(_x, _y, _w, _h);
+
 	_x -= _boss->_x;
 	_y -= _boss->_y;
 }





More information about the Scummvm-git-logs mailing list