[Scummvm-cvs-logs] CVS: scummex scummex.cpp,1.20,1.21 scummex.h,1.12,1.13 wxwindows.cpp,1.19,1.20 wxwindows.h,1.8,1.9

Max Horn fingolfin at users.sourceforge.net
Tue Sep 23 05:27:02 CEST 2003


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

Modified Files:
	scummex.cpp scummex.h wxwindows.cpp wxwindows.h 
Log Message:
some more cleanup

Index: scummex.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- scummex.cpp	23 Sep 2003 01:28:14 -0000	1.20
+++ scummex.cpp	23 Sep 2003 12:26:09 -0000	1.21
@@ -37,7 +37,7 @@
 	delete _image;
 }
 
-void ScummEX::getFileType(const char *filename) {
+void ScummEX::loadFile(const char *filename) {
 	uint32 tag;
 	_encbyte = 0;
 	char buf[256];
@@ -115,24 +115,24 @@
 	_gui->DisplayDialog("Unknown file type!", "Error");
 }
 
-void ScummEX::Descumm() {
+void ScummEX::Descumm(int blockid) {
 	
-	_input.seek(_blockTable[_blockId].offset, SEEK_SET);
+	_input.seek(_blockTable[blockid].offset, SEEK_SET);
 	_scummVersion = _gui->getScummVersionDialog();
 	if (_scummVersion != 0) {
-		DeScumm(_input, _blockTable[_blockId].blockSize, _scummVersion);
+		DeScumm(_input, _blockTable[blockid].blockSize, _scummVersion);
 	}
 }
 
-void ScummEX::FileDump(const char *filename) {
+void ScummEX::FileDump(int blockid, const char *filename) {
 
 	uint32 size = 0, tot_size = 0;
 	char fbuf2[2048];
 
 	_output.open(filename, 2, 0);
-	_input.seek(_blockTable[_blockId].offset, SEEK_SET);
+	_input.seek(_blockTable[blockid].offset, SEEK_SET);
 
-	while (tot_size < _blockTable[_blockId].blockSize) {
+	while (tot_size < _blockTable[blockid].blockSize) {
 		size = _input.read(fbuf2, 1);
 		tot_size += size;
 		_output.write(fbuf2, 1);
@@ -140,7 +140,7 @@
 	_output.close();
 }
 
-void ScummEX::fileView() {
+void ScummEX::fileView(int blockid) {
 	int j, i;
 	char *text;
 	char title[256];
@@ -150,8 +150,8 @@
 	int len, offset, nlines, bytes_per_line;
 	byte c;
 	
-	len = _blockTable[_blockId].blockSize;
-	offset = _blockTable[_blockId].offset;
+	len = _blockTable[blockid].blockSize;
+	offset = _blockTable[blockid].offset;
 	bytes_per_line = 16;
 	nlines = len / bytes_per_line;
 	
@@ -160,16 +160,16 @@
 	if (text == NULL)
 		return;
 
-	sprintf(title, "%s Block at offset %d", _blockTable[_blockId].blockName, _blockTable[_blockId].offset);
+	sprintf(title, "%s Block at offset %d", _blockTable[blockid].blockName, _blockTable[blockid].offset);
 	
-	_input.seek(_blockTable[_blockId].offset, SEEK_SET);
+	_input.seek(_blockTable[blockid].offset, SEEK_SET);
 
-	dataorg = data = (byte*) malloc(_blockTable[_blockId].blockSize);
+	dataorg = data = (byte*) malloc(_blockTable[blockid].blockSize);
 
 	if (data == NULL)
 		return;
 
-	_input.read(data, _blockTable[_blockId].blockSize);
+	_input.read(data, _blockTable[blockid].blockSize);
 
 	while (len >= bytes_per_line) {
 		sprintf(buf, "%06X: ", offset);
@@ -244,62 +244,49 @@
 
 }
 
-void ScummEX::iMUSEPlay()
+void ScummEX::iMUSEPlay(int blockid)
 {
-	_sound->playiMUSE(_input, _blockTable, _blockId, _input);
+	_sound->playiMUSE(_input, _blockTable, blockid, _input);
 }
 
-void ScummEX::iMUSEDump(const char *filename)
+void ScummEX::iMUSEDump(int blockid, const char *filename)
 {
 	_output.open(filename, 2, 0);
 
-	_sound->playiMUSE(_input, _blockTable, _blockId, _output, 1);
+	_sound->playiMUSE(_input, _blockTable, blockid, _output, 1);
 }
 
-void ScummEX::SOUPlay()
+void ScummEX::SOUPlay(int blockid)
 {
-	_sound->playSOU(_blockTable, _input, _blockId, _input);
+	_sound->playSOU(_blockTable, _input, blockid, _input);
 }
 
-void ScummEX::paletteDraw()
+void ScummEX::paletteDraw(int blockid)
 {
-	_image->drawPalette(_blockTable, _blockId, _input);
+	_image->drawPalette(_blockTable, blockid, _input);
 }
 
-void ScummEX::bgDraw()
+void ScummEX::bgDraw(int blockid)
 {
-	_image->drawBG(_input, _blockTable, _blockId);
+	_image->drawBG(_input, _blockTable, blockid);
 }
 
-void ScummEX::SmushFrameDraw()
+void ScummEX::SmushFrameDraw(int blockid)
 {
-	_image->drawSmushFrame(_blockTable, _blockId, _input);
+	_image->drawSmushFrame(_blockTable, blockid, _input);
 }
 
-void ScummEX::objectDraw()
+void ScummEX::objectDraw(int blockid)
 {
-	_image->drawObject(_input, _blockTable, _blockId);
+	_image->drawObject(_input, _blockTable, blockid);
 }
 
-void ScummEX::boxesDraw()
+void ScummEX::boxesDraw(int blockid)
 {
-	_image->drawBoxes(_blockTable, _blockId, _input);
+	_image->drawBoxes(_blockTable, blockid, _input);
 }
 
-void ScummEX::boxesDrawOverlay()
+void ScummEX::boxesDrawOverlay(int blockid)
 {
-	_image->drawBoxes(_blockTable, _blockId, _input, 0);
-}
-
-void ScummEX::FileInfo() {
-	int fsize;
-	fsize = _input.size();
-	_gui->FileInfoDialog(fsize, _encbyte);
-}
-	
-void ScummEX::UpdateInfosFromTree(int blockid) {
-	// TODO: This method should eventuall be removed, likewise _blockId.
-	// Instead pass the proper block id, or even the BlockTable struct,
-	// as a paramter to the methods using it.
-	_blockId = blockid;
+	_image->drawBoxes(_blockTable, blockid, _input, 0);
 }

Index: scummex.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/scummex.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- scummex.h	23 Sep 2003 01:28:15 -0000	1.12
+++ scummex.h	23 Sep 2003 12:26:09 -0000	1.13
@@ -32,7 +32,6 @@
 private:
 	File _input;
 	File _output;
-	uint32 _blockId;
 		
 	BlockTable _blockTable[60000];
 	
@@ -48,29 +47,30 @@
 	ScummEX();
 	~ScummEX();
 
-	void fileView();
-	void FileInfo();
-	void UpdateInfosFromTree(int blockid); 
-	void getFileType(const char *filename);
-	void updateLabel(char *label, char *title, uint32 text);
-	void add_tree_elements(char *itemName, int blockid, int level);
+	void loadFile(const char *filename);
+
 	void warning(const char *s, ...);
 	void debug(int level, const char *s, ...);
 	void error(const char *s, ...);
-	void FileDump(const char *filename);
-	void iMUSEDump(const char *filename);
 
-	void Descumm();
-	void iMUSEPlay();
-	void SOUPlay();
-	void paletteDraw();
-	void bgDraw();
-	void SmushFrameDraw();
-	void objectDraw();
-	void boxesDraw();
-	void boxesDrawOverlay();
+	void fileView(int blockid);
+	void FileDump(int blockid, const char *filename);
+	void iMUSEDump(int blockid, const char *filename);
+
+	void Descumm(int blockid);
+	void iMUSEPlay(int blockid);
+	void SOUPlay(int blockid);
+	void paletteDraw(int blockid);
+	void bgDraw(int blockid);
+	void SmushFrameDraw(int blockid);
+	void objectDraw(int blockid);
+	void boxesDraw(int blockid);
+	void boxesDrawOverlay(int blockid);
 	
 	const BlockTable &getBlockTable(int blockid) const { return _blockTable[blockid]; }
+	
+	int getInputFileSize() { return _input.size(); }
+	byte getEncByte() const { return _encbyte; }
 };
 
 #endif

Index: wxwindows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- wxwindows.cpp	23 Sep 2003 11:55:45 -0000	1.19
+++ wxwindows.cpp	23 Sep 2003 12:26:09 -0000	1.20
@@ -25,11 +25,8 @@
 #include "scummex.h"
 #include "icons.h"
 
-wxTreeItemId iter[11];
-wxTreeCtrl *tree = 0;
 ScummEX *g_scummex = 0;
 wxImage *image = 0;
-const char *g_filename = 0;
 wxTextCtrl *hexdata = 0;
 wxToolBar *ToolBar = 0;
 
@@ -127,25 +124,6 @@
 	return 0;
 }
 
-void GUI_wxWindows::FileInfoDialog(int size, int encbyte) {
-	char buf[256];
-	char msg[512];
-	const char *fname;
-	const char *fpath;
-	wxFileName *filename = new wxFileName(g_filename);
-	
-	fname = filename->GetFullName();
-	fpath = filename->GetFullPath();
-	sprintf(msg, "Filename: \t\t %s\n", fname);
-	sprintf(buf, "Full Path: \t\t %s\n", fpath);
-	strcat(msg, buf);
-	sprintf(buf, "Size: \t\t %d\n", size);
-	strcat(msg, buf);
-	sprintf(buf, "XOR byte: \t %d (0x%02X)\n", encbyte, encbyte);
-	strcat(msg, buf);
-	wxMessageBox(msg, "File Info", wxOK, _mainWindow);
-}
-
 void GUI_wxWindows::PutPixel(int x, int y, int red, int green, int blue) {
 	image->SetRGB(x, y, (unsigned char) red, (unsigned char) green, (unsigned char) blue);
 }
@@ -227,8 +205,15 @@
 }
 
 void ImageWindow::boxesDrawOverlay(wxEvent& event) {
-	g_scummex->boxesDrawOverlay();
+// FIXME: need to pass the current block ID here. I could add a hack to do
+// that, however, the truth is that ImageWindow and Image are not quite nice
+// anyway... We probably should just rewrite them in a cleaner fashion.
+// Also it feels odd to reuse a single ImageWindow for everything, after all
+// one may want to compare multiple palettes/rooms etc. side-by-side.
+// 
+//	g_scummex->boxesDrawOverlay();
 }
+
 void GUI_wxWindows::DisplayViewer(char *title, int width, int height, char *text) {
 
 	ViewerWindow *viewerFrame = new ViewerWindow(_mainWindow, title, text, wxPoint(50,50), wxSize(width, height));
@@ -281,6 +266,10 @@
 	ToolBar->EnableTool(tool, FALSE);
 }
 
+void GUI_wxWindows::add_tree_elements(char *itemName, int blockid, int level, int type) {
+	_mainWindow->add_tree_elements(itemName, blockid, level, type);
+}
+
 void MainWindow::SetButton(int blocktype) {
 	SpecButton1->Enable(TRUE);
 	SpecButton2->Enable(TRUE);
@@ -372,7 +361,7 @@
 
 }
 
-void GUI_wxWindows::add_tree_elements(char *itemName, int blockid, int level, int type) {
+void MainWindow::add_tree_elements(char *itemName, int blockid, int level, int type) {
 
 	wxTreeItemId itemid;
 	assert(level <= 10);
@@ -532,7 +521,8 @@
 
 
 MainWindow::MainWindow(const wxString& title, const wxPoint& pos, const wxSize& size)
-	: wxFrame((wxFrame*)NULL,-1,title,pos,size)
+	: wxFrame((wxFrame*)NULL,-1,title,pos,size),
+	_filename(0), _blockId(0)
 {
 	htmlflag = 0;
 	
@@ -930,9 +920,9 @@
 		"Directory Files|*.000;*.la0;*.lfl;*.sm0",
 		wxOPEN);
 	if (dialog->ShowModal() == wxID_OK) {
-		g_filename = (const char*)dialog->GetPath();
+		_filename = (const char*)dialog->GetPath();
 		tree->DeleteChildren(iter[0]);
-		g_scummex->getFileType(g_filename);
+		g_scummex->loadFile(_filename);
 	}
 }
 
@@ -1229,26 +1219,46 @@
 		
 	BigIcon->SetBitmap(bigIconBitmap);
 	
-	updateLabels(item->_blockId);
-	g_scummex->UpdateInfosFromTree(item->_blockId);
+	_blockId = item->_blockId;
+	updateLabels(_blockId);
 	event.Skip();
 }
 
 void MainWindow::FileView(wxEvent& event) {
-	g_scummex->fileView();
+	g_scummex->fileView(_blockId);
 }
 
 void MainWindow::FileInfo(wxEvent& event) {
-	g_scummex->FileInfo();
+	FileInfoDialog(g_scummex->getInputFileSize(), g_scummex->getEncByte());
+}
+
+void MainWindow::FileInfoDialog(int size, int encbyte) {
+	char buf[256];
+	char msg[512];
+	const char *fname;
+	const char *fpath;
+	wxFileName *filename = new wxFileName(_filename);
+	
+	fname = filename->GetFullName();
+	fpath = filename->GetFullPath();
+	sprintf(msg, "Filename: \t\t %s\n", fname);
+	sprintf(buf, "Full Path: \t\t %s\n", fpath);
+	strcat(msg, buf);
+	sprintf(buf, "Size: \t\t %d\n", size);
+	strcat(msg, buf);
+	sprintf(buf, "XOR byte: \t %d (0x%02X)\n", encbyte, encbyte);
+	strcat(msg, buf);
+	wxMessageBox(msg, "File Info", wxOK, this);
 }
 
+
 void MainWindow::BlockDump(wxEvent& event) {
 	wxFileDialog *dialog = new wxFileDialog(this, "Please select an output file.", "", "",
 		"*",
 		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
 		const char *filename = (const char*)dialog->GetPath();
-		g_scummex->FileDump(filename);
+		g_scummex->FileDump(_blockId, filename);
 	}
 	
 }
@@ -1259,7 +1269,7 @@
 		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
 		const char *filename = (const char*)dialog->GetPath();
-		g_scummex->iMUSEDump(filename);
+		g_scummex->iMUSEDump(_blockId, filename);
 	}
 	
 }
@@ -1270,32 +1280,32 @@
 		wxSAVE);
 	if (dialog->ShowModal() == wxID_OK) {
 		const char *filename = (const char*)dialog->GetPath();
-		g_scummex->iMUSEDump(filename);
+		g_scummex->iMUSEDump(_blockId, filename);
 	}
 	
 }
 
 void MainWindow::Descumm(wxEvent& event) {
-	g_scummex->Descumm();
+	g_scummex->Descumm(_blockId);
 }
 void MainWindow::iMUSEPlay(wxEvent& event) {
-	g_scummex->iMUSEPlay();
+	g_scummex->iMUSEPlay(_blockId);
 }
 void MainWindow::SOUPlay(wxEvent& event) {
-	g_scummex->SOUPlay();
+	g_scummex->SOUPlay(_blockId);
 }
 void MainWindow::paletteDraw(wxEvent& event) {
-	g_scummex->paletteDraw();
+	g_scummex->paletteDraw(_blockId);
 }
 void MainWindow::bgDraw(wxEvent& event) {
-	g_scummex->bgDraw();
+	g_scummex->bgDraw(_blockId);
 }
 void MainWindow::SmushFrameDraw(wxEvent& event) {
-	g_scummex->SmushFrameDraw();
+	g_scummex->SmushFrameDraw(_blockId);
 }
 void MainWindow::objectDraw(wxEvent& event) {
-	g_scummex->objectDraw();
+	g_scummex->objectDraw(_blockId);
 }
 void MainWindow::boxesDraw(wxEvent& event) {
-	g_scummex->boxesDraw();
+	g_scummex->boxesDraw(_blockId);
 }

Index: wxwindows.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- wxwindows.h	23 Sep 2003 11:55:45 -0000	1.8
+++ wxwindows.h	23 Sep 2003 12:26:09 -0000	1.9
@@ -57,11 +57,18 @@
 	wxStaticText *TypeLabel, *OffsetLabel, *SizeLabel, *DescriptionLabel;
 	wxStaticText *SpecLabel[6];
 	wxButton *SpecButton1, *SpecButton2;
+	wxTreeItemId iter[11];
+	wxTreeCtrl *tree;
+
+	const char *_filename;
+
+	uint32 _blockId;
 
 public:
 	MainWindow(const wxString& title, const wxPoint& pos, const wxSize& size);
 
 	void SetButton(int blocktype);
+	void add_tree_elements(char *itemName, int blockid, int level, int type);
 
 protected:
 	void OnQuit(wxCommandEvent& event);
@@ -88,6 +95,8 @@
 	void updateLabels(int blockid);
 	void updateLabel(wxStaticText *label, const char *title, uint32 text);
 
+	void FileInfoDialog(int size, int encbyte);
+
 	DECLARE_EVENT_TABLE()
 };
 
@@ -129,7 +138,6 @@
 	void EnableToolbarTool(int tool);
 	void DisableToolbarTool(int tool);
 	void AppendText(char *text);
-	void FileInfoDialog(int size, int encbyte);
 	void DrawImage();
 	void UpdateImage();
 	void DisplayHelp();





More information about the Scummvm-git-logs mailing list