[Scummvm-cvs-logs] CVS: scummex image.cpp,1.18,1.19 image.h,1.12,1.13 resource.h,1.11,1.12 scummex.cpp,1.25,1.26 scummex.h,1.14,1.15 wxwindows.cpp,1.24,1.25 wxwindows.h,1.12,1.13

Adrien Mercier yoshizf at users.sourceforge.net
Sat Sep 27 08:40:02 CEST 2003


Update of /cvsroot/scummvm/scummex
In directory sc8-pr-cvs1:/tmp/cvs-serv21941

Modified Files:
	image.cpp image.h resource.h scummex.cpp scummex.h 
	wxwindows.cpp wxwindows.h 
Log Message:
Rewrote Image/ImageWindow according to Fingolfing tips, removed all those ugly wrapper methods, and added scaler support, although I still have to add a dialog to choose it

Index: image.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/image.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- image.cpp	25 Sep 2003 15:26:26 -0000	1.18
+++ image.cpp	27 Sep 2003 14:56:11 -0000	1.19
@@ -23,6 +23,7 @@
 #include "file.h"
 #include "resource.h"
 #include "image.h"
+#include "scaler.h"
 
 uint32 offset;
 
@@ -62,13 +63,16 @@
 	_rgbTable[idx].blue = b;
 }
 
-int Image::drawPalette(BlockTable *_blockTable, int id, File& _input)
+void Image::drawPalette(BlockTable *_blockTable, int id, File& _input)
 {
 	int addindex = 0;
 	int index = 0;
 	unsigned int h;
 
-	_imageWindowId = _gui->DisplayImage("Block Palette", 384, 384, id);
+	if (_blockTable[id].image == NULL)
+		_image = _blockTable[id].image = new ImageWindow("Block Palette", wxSize(384, 384), id);
+	else
+		_image = _blockTable[id].image;
 
 	_input.seek(_blockTable[id].offset + 8, SEEK_SET);
 
@@ -100,7 +104,7 @@
 			for (int l = 0; l < 16; l++) {
 				for (int j = 0; j < 384 / 16; j++) {
 					index = l + addindex;
-					_gui->PutPixel(_imageWindowId, x++, y, _rgbTable[index].red, _rgbTable[index].green, _rgbTable[index].blue);
+					_image->PutPixel(x++, y, _rgbTable[index].red, _rgbTable[index].green, _rgbTable[index].blue);
 				}
 			}
 			y++;
@@ -109,8 +113,7 @@
 		addindex += 16;
 	}
 
-	_gui->DrawImage(_imageWindowId);
-	return 0;
+	_image->DrawImage();
 }
 
 void Image::drawLine(int xStart, int yStart, int xEnd, int yEnd, int red, int green, int blue) {
@@ -119,7 +122,7 @@
 	double x, xinc, y, yinc;
 
 	if (xStart == xEnd && yStart == yEnd) {
-		_gui->PutPixel(_imageWindowId, xEnd, yEnd, red, green, blue);
+		_image->PutPixel(xEnd, yEnd, red, green, blue);
 		return;
 	}
 
@@ -138,14 +141,14 @@
 	y = yStart + 0.5;
 
 	for (i=0; i<=len; ++i) { 
-		_gui->PutPixel(_imageWindowId, (int)x, (int)y, red, green, blue);
+		_image->PutPixel((int)x, (int)y, red, green, blue);
 		x += xinc;
 		y += yinc;
 	}
 
 }
 
-int Image::drawBoxes(BlockTable *_blockTable, int id, File& _input, int newWindow, int imageWindowId) {
+void Image::drawBoxes(BlockTable *_blockTable, int id, File& _input) {
 	int nBox, RMHDindex, width, height, version = 5;
 
 	if (_blockTable[id].blockTypeID == BM || _blockTable[id].blockTypeID == BX) {
@@ -163,9 +166,13 @@
 	} else if ( version > 3 && _resource->findBlock(0, _blockTable, id, "PALS", NULL) != -1) {
 		version = 7;
 	}
-			
-	if (newWindow == 0) {
-		_imageWindowId = imageWindowId;
+
+	if (_blockTable[id].image == NULL)
+		_image = _blockTable[id].image = new ImageWindow("Boxes", wxSize(_width, _height), id);
+	else
+		_image = _blockTable[id].image;
+
+	if (_blockTable[id].blockTypeID != BOXD && _blockTable[id].blockTypeID != BX) {
 		if (version > 5) {
 			id = _resource->findBlock(1, _blockTable, id, "BOXD", NULL);
 		} else {
@@ -185,35 +192,44 @@
 
 	if (version == 8) {
 		for (int i=0; i<nBox; i++) {
-			_points[i][0].x = (short)_input.readUint32LE();
-			_points[i][0].y = (short)_input.readUint32LE();
-			_points[i][1].x = (short)_input.readUint32LE();
-			_points[i][1].y = (short)_input.readUint32LE();
-			_points[i][2].x = (short)_input.readUint32LE();
-			_points[i][2].y = (short)_input.readUint32LE();
-			_points[i][3].x = (short)_input.readUint32LE();
-			_points[i][3].y = (short)_input.readUint32LE();
+			_points[i][0].x = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][0].y = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][1].x = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][1].y = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][2].x = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][2].y = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][3].x = (short)_input.readUint32LE() * _image->_scaleFactor;
+			_points[i][3].y = (short)_input.readUint32LE() * _image->_scaleFactor;
 			_input.seek(20, SEEK_CUR);
 		}
+
+	} else if (version == 3 && _resource->findBlock(0, _blockTable, id, "LF", NULL) == -1 && _resource->findBlock(1, _blockTable, id, "PA", NULL) != -1) {
+		for (int i=0; i<nBox; i++) {
+			_points[i][0].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][0].y = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][1].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][1].y = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][2].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][2].y = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][3].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][3].y = _input.readUint16LE() * _image->_scaleFactor;
+			_input.readUint16LE();
+		}
 	} else {
 		for (int i=0; i<nBox; i++) {
-			_points[i][0].x = _input.readUint16LE();
-			_points[i][0].y = _input.readUint16LE();
-			_points[i][1].x = _input.readUint16LE();
-			_points[i][1].y = _input.readUint16LE();
-			_points[i][2].x = _input.readUint16LE();
-			_points[i][2].y = _input.readUint16LE();
-			_points[i][3].x = _input.readUint16LE();
-			_points[i][3].y = _input.readUint16LE();
+			_points[i][0].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][0].y = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][1].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][1].y = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][2].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][2].y = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][3].x = _input.readUint16LE() * _image->_scaleFactor;
+			_points[i][3].y = _input.readUint16LE() * _image->_scaleFactor;
 			_input.readUint16LE();
 			_input.readUint16LE();
 		}
 	}
-	
 
-	if (newWindow == 1)
-		_imageWindowId = _gui->DisplayImage("Boxes", width, height, id);
-	
 	for (int i=0; i<nBox; i++) {
 		for (int j=0; j<3; j++) {
 			drawLine(_points[i][j].x, _points[i][j].y, _points[i][j+1].x, _points[i][j+1].y, 255, 255, 255);
@@ -221,18 +237,13 @@
 		drawLine(_points[i][3].x, _points[i][3].y, _points[i][0].x, _points[i][0].y, 255, 255, 255);
 	}
 	
-	if (newWindow == 1) {
-		_gui->DrawImage(_imageWindowId);
-	} else {
-		_gui->UpdateImage(_imageWindowId);
-	}
-	return 0;
+	_image->DrawImage();
 }
 
-int Image::drawSmushFrame(BlockTable *_blockTable, int id, File& _input) {
+void Image::drawSmushFrame(BlockTable *_blockTable, int id, File& _input) {
 	int index;
 	int x = 0, y = 0;
-	byte *dst, *dstorg, *chunk_buffer;
+	byte *dst, *dstorg, *chunk_buffer, *dstFinal;
 
 	index = _resource->findBlock(0, _blockTable, id, "NPAL", "AHDR", NULL);
 	if (_blockTable[index].blockTypeID == AHDR) {
@@ -247,16 +258,24 @@
 		_rgbTable[j].blue = _input.readByte();	// blue
 	}
 
+	_width = _blockTable[id].width;
+	_height = _blockTable[id].height;
+
+	if (_blockTable[id].image == NULL)
+		_image = _blockTable[id].image = new ImageWindow("SMUSH Frame", wxSize(_width, _height), id);
+	else
+		_image = _blockTable[id].image;
+
 	_input.seek(_blockTable[id].offset + 22, SEEK_SET);
-	_codec37.init(_blockTable[id].width, _blockTable[id].height);
-	_codec47.init(_blockTable[id].width, _blockTable[id].height);
+	_codec37.init(_width, _height);
+	_codec47.init(_width, _height);
 	chunk_buffer = (byte *)malloc(_blockTable[id].blockSize - 22);
-	dstorg = dst = (byte *)malloc(_blockTable[id].width * _blockTable[id].height + 1000);
+	dstorg = dst = (byte *)malloc(_width * _height + 1000);
 	_input.read(chunk_buffer, _blockTable[id].blockSize - 22);
 
 	switch (_blockTable[id].variables) {
 		case 1:
-			decodeCodec1(dst, chunk_buffer, _blockTable[id].height);
+			decodeCodec1(dst, chunk_buffer, _height);
 			break;
 
 		case 37:
@@ -272,28 +291,33 @@
 			_codec47.decode(dst, chunk_buffer);
 			break;
 	}
+	free(chunk_buffer);
 
-	_imageWindowId = _gui->DisplayImage("SMUSH Frame", _blockTable[id].width, _blockTable[id].height, id);
-	
-	for (y=0; y<_blockTable[id].height; y++) {
-		for (x=0; x<_blockTable[id].width; x++) {
-			int color = *dst++;
-			_gui->PutPixel(_imageWindowId, x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
+	if (_image->_scaleFactor > 1) {
+		dstorg = dstFinal = (byte *)malloc((_width * _image->_scaleFactor) * (_height * _image->_scaleFactor));
+		scale(_image->_scaleFactor, dst, _width, dstFinal, _width * _image->_scaleFactor, _width, _height);
+		free(dst);
+	} else {
+		dstFinal = dst;
+	}
+
+	for (y=0; y<_height * _image->_scaleFactor; y++) {
+		for (x=0; x<_width * _image->_scaleFactor; x++) {
+			int color = *dstFinal++;
+			_image->PutPixel(x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
 		}
 	}
 	
-	free(chunk_buffer);
 	free(dstorg);
-	_gui->DrawImage(_imageWindowId);
-	return 0;
+	_image->DrawImage();
 }
 
-int Image::drawBG(File& _input, BlockTable *_blockTable, int id, int newWindow, int imageWindowId)
+void Image::drawBG(File& _input, BlockTable *_blockTable, int id)
 {
 	int RMHDindex, CLUTindex, SMAPindex, TRNSindex, version;
 	int32 blockSize;
-	byte *dst, *dstorg, *src;
-	
+	byte *dst, *dstorg, *src, *dstFinal;
+
 	if (_blockTable[id].blockTypeID == BM) {
 		version = 3;
 		RMHDindex = _resource->findBlock(0, _blockTable, id, "HD", NULL);
@@ -308,12 +332,11 @@
 	_width = _blockTable[RMHDindex].width;
 	_height = _blockTable[RMHDindex].height;
 
-	if (newWindow) {
-		_imageWindowId = _gui->DisplayImage("Room Image", _width, _height, id, IMAGE_BOXES);
-	} else {
-		_imageWindowId = imageWindowId;
-	}
-	
+	if (_blockTable[id].image == NULL)
+		_image = _blockTable[id].image = new ImageWindow("Room Image", wxSize(_width, _height), id, IMAGE_BOXES);
+	else
+		_image = _blockTable[id].image;
+
 	if (version > 4) {
 		TRNSindex = _resource->findBlock(0, _blockTable, id, "TRNS", NULL);
 		_transp = _blockTable[TRNSindex].trans;
@@ -384,36 +407,46 @@
 			GetStrip(dst + (8 * x), src + _offsets[x], _height);
 	}
 	free(src);
+
+	if (_image->_scaleFactor > 1) {
+		dstorg = dstFinal = (byte *)malloc((_width * _image->_scaleFactor) * (_height * _image->_scaleFactor));
+		scale(_image->_scaleFactor, dst, _width, dstFinal, _width * _image->_scaleFactor, _width, _height);
+		free(dst);
+	} else {
+		dstFinal = dst;
+	}
 	
-	for (int y=0; y<_height; y++) {
-		for (int x=0; x<_width; x++) {
-			int color = *dst++;
-			_gui->PutPixel(_imageWindowId, x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
+	for (int y=0; y<_height * _image->_scaleFactor; y++) {
+		for (int x=0; x<_width * _image->_scaleFactor; x++) {
+			int color = *dstFinal++;
+			_blockTable[id].image->PutPixel(x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
 		}
 	}
+
 	free(dstorg);
 		
-	if (newWindow) {
-		_gui->DrawImage(_imageWindowId);
-	} else {
-		_gui->UpdateImage(_imageWindowId);
-	}
-
-	return 0;
+	_image->DrawImage();
 }
 
-int Image::drawObject(File& _input, BlockTable *_blockTable, int id)
+void Image::drawObject(File& _input, BlockTable *_blockTable, int id)
 {
 	int RMHDindex, CLUTindex, SMAPindex, TRNSindex;
-	byte *dst, *dstorg, *src;
+	byte *dst, *dstorg, *src, *dstFinal;
 
-	RMHDindex = _resource->findBlock(1, _blockTable, id, "IMHD", NULL);
+	if (_blockTable[id].blockTypeID == OBIM) {
+		RMHDindex = _resource->findBlock(1, _blockTable, id, "IMHD", NULL);
+	} else {
+		RMHDindex = _resource->findBlock(0, _blockTable, id, "IMHD", NULL);
+	}
 	
 	_width = _blockTable[RMHDindex].width;
 	_height = _blockTable[RMHDindex].height;
-	
-	_imageWindowId = _gui->DisplayImage("Object", _width, _height, id);
-	
+
+	if (_blockTable[id].image == NULL)
+		_image = _blockTable[id].image = new ImageWindow("Object", wxSize(_width, _height), id);
+	else
+		_image = _blockTable[id].image;
+
 	TRNSindex = _resource->findBlock(0, _blockTable, id, "TRNS", NULL);
 
 	_transp = _blockTable[TRNSindex].trans;
@@ -445,17 +478,24 @@
 		GetStrip(dst + (8 * x), src + _offsets[x], _height);
 	}
 	free(src);
-	
-	for (int y=0; y<_height; y++) {
-		for (int x=0; x<_width; x++) {
-			int color = *dst++;
-			_gui->PutPixel(_imageWindowId, x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
+
+	if (_image->_scaleFactor > 1) {
+		dstorg = dstFinal = (byte *)malloc((_width * _image->_scaleFactor) * (_height * _image->_scaleFactor));
+		scale(_image->_scaleFactor, dst, _width, dstFinal, _width * _image->_scaleFactor, _width, _height);
+		free(dst);
+	} else {
+		dstFinal = dst;
+	}
+
+	for (int y=0; y<_height * _image->_scaleFactor; y++) {
+		for (int x=0; x<_width * _image->_scaleFactor; x++) {
+			int color = *dstFinal++;
+			_image->PutPixel(x, y, _rgbTable[color].red, _rgbTable[color].green, _rgbTable[color].blue);
 		}
 	}
 	free(dstorg);
 	
-	_gui->DrawImage(_imageWindowId);
-	return 0;
+	_image->DrawImage();
 }
 
 void Image::GetStrip(byte *dst, const byte *src, int numLinesToProcess)

Index: image.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/image.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- image.h	25 Sep 2003 15:26:26 -0000	1.12
+++ image.h	27 Sep 2003 14:56:11 -0000	1.13
@@ -35,8 +35,8 @@
 };
 
 struct points {
-	int x;
-	int y;
+	uint x;
+	uint y;
 };
 
 class Image {
@@ -55,26 +55,11 @@
 	Resource *_resource;
 	Codec37Decoder _codec37;
 	Codec47Decoder _codec47;
+	ImageWindow *_image;
 
 	void drawLine(int xStart, int yStart, int xEnd, int yEnd, int red, int green, int blue);
 	void setupEGAPalette();
 	void setPalColor(int idx, int r, int g, int b);
-
-public:
-	Image();
-	~Image();
-	int drawPalette(BlockTable *_blockTable, int id, File& _input);
-	int drawBG(File& _input, BlockTable *_blockTable, int id, int newWindow = 1, int imageWindowId = 0);
-	int drawObject(File& _input, BlockTable *_blockTable, int id);
-	int drawSmushFrame(BlockTable *_blockTable, int id, File& _input);
-	int drawBoxes(BlockTable *_blockTable, int id, File& _input, int newWindow = 1, int imageWindowId = 0);
-	void decode_uncompressed(uint16 height, File& _input);
-	void decode_horiz(uint16 height, uint8 compr, File& _input);
-	void decode_vert(uint16 height, uint8 compr, File& _input);
-	void decode_horiz_transp(uint16 height, uint8 compr, File& _input);
-	void decode_vert_transp(uint16 height, uint8 compr, File& _input);
-	void decode2(uint16 height, uint8 compr, File& _input);
-	void decode2transp(uint16 height, uint8 compr, File& _inpuit);
 	void GetStrip(byte *dst, const byte *src, int numLinesToProcess);
 	void decodeCodec44(byte *dst, const byte *src, uint32 length);
 	void decodeCodec1(byte *dst, byte *src, int height);
@@ -87,6 +72,15 @@
 	void unkDecode9(byte *dst, const byte *src, int height);
 	void unkDecode10(byte *dst, const byte *src, int height);
 	void unkDecode11(byte *dst, const byte *src, int height);
+
+public:
+	Image();
+	~Image();
+	void drawPalette(BlockTable *_blockTable, int id, File& _input);
+	void drawBG(File& _input, BlockTable *_blockTable, int id);
+	void drawObject(File& _input, BlockTable *_blockTable, int id);
+	void drawSmushFrame(BlockTable *_blockTable, int id, File& _input);
+	void drawBoxes(BlockTable *_blockTable, int id, File& _input);
 };
 
 #endif

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/resource.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- resource.h	26 Sep 2003 23:51:36 -0000	1.11
+++ resource.h	27 Sep 2003 14:56:11 -0000	1.12
@@ -44,6 +44,7 @@
 	int32 width;
 	int trans;
 	int32 height;
+	ImageWindow *image;
 };
 
 struct RoomTable {

Index: scummex.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- scummex.cpp	26 Sep 2003 00:39:50 -0000	1.25
+++ scummex.cpp	27 Sep 2003 14:56:11 -0000	1.26
@@ -255,11 +255,6 @@
 	_image->drawBG(_input, _blockTable, blockid);
 }
 
-void ScummEX::bgReDraw(int imageWindowId, int blockid)
-{
-	_image->drawBG(_input, _blockTable, blockid, 0, imageWindowId);
-}
-
 void ScummEX::SmushFrameDraw(int blockid)
 {
 	_image->drawSmushFrame(_blockTable, blockid, _input);
@@ -273,9 +268,4 @@
 void ScummEX::boxesDraw(int blockid)
 {
 	_image->drawBoxes(_blockTable, blockid, _input);
-}
-
-void ScummEX::boxesDrawOverlay(int imageWindowId, int blockid)
-{
-	_image->drawBoxes(_blockTable, blockid, _input, 0, imageWindowId);
 }

Index: scummex.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- scummex.h	24 Sep 2003 11:49:30 -0000	1.14
+++ scummex.h	27 Sep 2003 14:56:11 -0000	1.15
@@ -65,10 +65,8 @@
 	void SmushFrameDraw(int blockid);
 	void objectDraw(int blockid);
 	void boxesDraw(int blockid);
-	void boxesDrawOverlay(int imageWindowId, int blockid);
-	void bgReDraw(int imageWindowId, int blockid);
 	
-	const BlockTable &getBlockTable(int blockid) const { return _blockTable[blockid]; }
+	BlockTable &getBlockTable(int blockid) { return _blockTable[blockid]; }
 	
 	int getInputFileSize() { return _input.size(); }
 	byte getEncByte() const { return _encbyte; }

Index: wxwindows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- wxwindows.cpp	26 Sep 2003 23:47:59 -0000	1.24
+++ wxwindows.cpp	27 Sep 2003 14:56:11 -0000	1.25
@@ -28,9 +28,7 @@
 ScummEX *g_scummex = 0;
 wxTextCtrl *hexdata = 0;
 wxToolBar *ToolBar = 0;
-
 GUI_wxWindows *_gui = 0;
-int imageWindowId;
 
 IMPLEMENT_APP(GUI_wxWindows)
 
@@ -125,24 +123,6 @@
 	return 0;
 }
 
-void GUI_wxWindows::PutPixel(int imgWindowId, int x, int y, int red, int green, int blue) {
-	_imageWindow[imgWindowId]->PutPixel(x, y, red, green, blue);
-}
-
-int GUI_wxWindows::DisplayImage(char* title, int width, int height, int blockId, byte flags) {
-	_imageWindow[imageWindowId] = new ImageWindow(_mainWindow, imageWindowId + 150, title, wxPoint(-1,-1), wxSize(width, height), blockId, flags);
-	imageWindowId++;
-	return imageWindowId - 1;
-}
-
-void GUI_wxWindows::DrawImage(int imgWindowId) {
-	_imageWindow[imgWindowId]->DrawImage();
-}
-
-void GUI_wxWindows::UpdateImage(int imgWindowId) {
-	_imageWindow[imgWindowId]->UpdateImage();
-}
-
 bool GUI_wxWindows::readConfigValue(const char* key, int* string) {
 	bool result;
 	result = config->Read(key, string);
@@ -176,8 +156,8 @@
 	EVT_MENU(ID_Boxes, ImageWindow::boxesDrawOverlay)
 END_EVENT_TABLE()
 
-ImageWindow::ImageWindow(MainWindow *parent, int imgWindowId, const wxString& title, const wxPoint& pos, const wxSize& size, int blockId, byte flags)
-	: wxFrame(parent, imgWindowId, title, pos, size, wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION))
+ImageWindow::ImageWindow(const wxString& title, const wxSize& size, int blockId, byte flags)
+	: wxFrame(_gui->_mainWindow, -1, title, wxPoint(-1,-1), size, wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION))
 {
 	wxMenuBar *menuBar = new wxMenuBar;
 	wxMenu *menuFile = new wxMenu;
@@ -201,26 +181,33 @@
 	}
 	
 	SetMenuBar(menuBar);
-	SetClientSize(size.GetWidth(), size.GetHeight());
-	_image = new wxImage(size.GetWidth(), size.GetHeight());
+	
+	_scaleFactor = 1;
+	_gui->readConfigValue("Scaler", &_scaleFactor);
+	SetClientSize(size.GetWidth() * _scaleFactor, size.GetHeight() * _scaleFactor);
+	_image = new wxImage(size.GetWidth() * _scaleFactor, size.GetHeight() * _scaleFactor);
+	_sbmp = NULL;
 }
 
 void ImageWindow::DrawImage() {
 	wxBitmap bitmap = wxBitmap(_image);
-		
-	wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
-
-	_sbmp = new wxStaticBitmap(this, -1, bitmap);
-	
-	vertSizer->Add(_sbmp, 0, wxALL, 0 );
 	
-	Show(TRUE);
+	if (_sbmp == NULL) {
+		wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
+
+		_sbmp = new wxStaticBitmap(this, -1, bitmap);
+		vertSizer->Add(_sbmp, 0, wxALL, 0 );
+		Show(TRUE);
+	} else {
+		_sbmp->SetBitmap(bitmap);
+		Refresh();
+	}
 }
 
 void ImageWindow::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
 	delete _image;
-	imageWindowId--;
+	g_scummex->getBlockTable(_blockId).image = NULL;
 	Destroy();
 }
 
@@ -235,13 +222,12 @@
 }
 
 void ImageWindow::boxesDrawOverlay(wxEvent& event) {
-	int windowId = this->GetId() - 150;
 	if (!_boxesDisplayed) {
 		_boxesDisplayed = 1;
-		g_scummex->boxesDrawOverlay(windowId, _blockId);
+		g_scummex->boxesDraw(_blockId);
 	} else {
 		_boxesDisplayed = 0;
-		g_scummex->bgReDraw(windowId, _blockId);
+		g_scummex->bgDraw(_blockId);
 	}
 }
 

Index: wxwindows.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- wxwindows.h	26 Sep 2003 23:47:59 -0000	1.12
+++ wxwindows.h	27 Sep 2003 14:56:11 -0000	1.13
@@ -104,7 +104,9 @@
 
 class ImageWindow : public wxFrame {
 public:
-	ImageWindow(MainWindow *parent, int imgWindowId, const wxString& title, const wxPoint& pos, const wxSize& size, int blockId, byte flags);
+	int _scaleFactor;
+	
+	ImageWindow(const wxString& title, const wxSize& size, int blockId, byte flags = FLAG_NONE);
 	void DrawImage();
 	void PutPixel(int x, int y, int red, int green, int blue);
 	void UpdateImage();
@@ -135,24 +137,19 @@
 
 class GUI_wxWindows : public wxApp {
 private:
-	MainWindow *_mainWindow;
-	ImageWindow *_imageWindow[10];
 	wxConfig *config;
 
 public:
 	GUI_wxWindows();
 	~GUI_wxWindows();
 	
+	MainWindow *_mainWindow;
 	void EnableToolbarTool(int tool);
 	void DisableToolbarTool(int tool);
 	void AppendText(char *text);
-	void DrawImage(int imgWindowId);
-	void UpdateImage(int imgWindowId);
 	void DisplayHelp();
 	void SetTitle(char *title);
 	void DisplayViewer(char *title, int width, int height, char *text);
-	void PutPixel(int imgWindowId, int x, int y, int red, int green, int blue);
-	int DisplayImage(char* title, int width, int height, int blockID, byte flags = FLAG_NONE);
 	void DisplayDialog(char *message, char *title);
 	virtual bool OnInit();
 	void add_tree_elements(char *itemName, int blockid, int level, int type);





More information about the Scummvm-git-logs mailing list