Added a walkboxes viewer

This commit is contained in:
yoshizf
2003-09-22 15:23:57 +00:00
parent 581d2f0a16
commit e42ace0c0f
7 changed files with 128 additions and 10 deletions
+76 -1
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/image.cpp,v 1.6 2003/09/21 23:50:28 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/image.cpp,v 1.7 2003/09/22 15:23:56 yoshizf Exp $
*
*/
@@ -74,6 +74,81 @@ int Image::drawPalette(BlockTable *_blockTable, int id, File& _input)
return 0;
}
void Image::drawLine(int xStart, int yStart, int xEnd, int yEnd, int red, int green, int blue) {
int i, len, xlen, ylen;
double x, xinc, y, yinc;
if (xStart == xEnd && yStart == yEnd) {
_gui->PutPixel(xEnd, yEnd, red, green, blue);
return;
}
xlen = xEnd - xStart;
ylen = yEnd - yStart;
if (abs(xlen) > abs(ylen)) {
len = abs(xlen);
} else {
len = abs(ylen);
}
xinc = xlen / (double) len;
yinc = ylen / (double) len;
x = xStart + 0.5;
y = yStart + 0.5;
for (i=0; i<=len; ++i) {
_gui->PutPixel((int)x, (int)y, red, green, blue);
x += xinc;
y += yinc;
}
}
int Image::drawBoxes(BlockTable *_blockTable, int id, File& _input, int newWindow) {
int nBox, RMHDindex, width, height;
RMHDindex = _resource->findBlock(0, _blockTable, _input, id, "RMHD", "-1");
width = _blockTable[RMHDindex].width;
height = _blockTable[RMHDindex].height;
_input.seek(_blockTable[id].offset + 10, SEEK_SET);
nBox = _blockTable[id].numFiles;
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();
_input.readUint16LE();
_input.readUint16LE();
}
if (newWindow == 1) {
_gui->DisplayImage("Boxes", width, height);
}
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);
}
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();
} else {
_gui->UpdateImage();
}
return 0;
}
int Image::drawSmushFrame(BlockTable *_blockTable, int id, File& _input) {
int index;
int x = 0, y = 0;
+10 -1
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/image.h,v 1.5 2003/09/21 23:50:28 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/image.h,v 1.6 2003/09/22 15:23:56 yoshizf Exp $
*
*/
@@ -34,9 +34,15 @@ struct rgbtable {
int blue;
};
struct points {
int x;
int y;
};
class Image {
private:
struct rgbtable _rgbTable[256];
struct points _points[40][4];
uint32 _palette[256];
int _transp;
uint32 *_offsets;
@@ -47,6 +53,8 @@ private:
Codec37Decoder _codec37;
Codec47Decoder _codec47;
void drawLine(int xStart, int yStart, int xEnd, int yEnd, int red, int green, int blue);
public:
Image();
~Image();
@@ -54,6 +62,7 @@ public:
int drawBG(File& _input, BlockTable *_blockTable, int id, char* filename);
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);
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);
+9 -1
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/resource.cpp,v 1.12 2003/09/22 08:31:59 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/resource.cpp,v 1.13 2003/09/22 15:23:56 yoshizf Exp $
*
*/
@@ -824,6 +824,14 @@ int Resource::parseBlocks(char *blockName, BlockTable *_blockTable, File& _input
index++;
break;
case BOXD:
_blockTable[index].blockSize = _input.readUint32BE();
_blockTable[index].numFiles = _input.readUint16LE(); // Number of walkboxes
_input.seek(_blockTable[index].offset + _blockTable[index].blockSize, SEEK_SET);
_gui->add_tree_elements(_blockTable[index].blockName, index, level, _blockTable[index].blockTypeID);
index++;
break;
default:
_blockTable[index].blockSize = _input.readUint32BE();
_input.seek(_blockTable[index].offset + _blockTable[index].blockSize, SEEK_SET);
+12 -1
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/scummex.cpp,v 1.13 2003/09/21 23:50:28 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/scummex.cpp,v 1.14 2003/09/22 15:23:57 yoshizf Exp $
*
*/
@@ -285,6 +285,12 @@ void ScummEX::objectDraw()
_image->drawObject(_input, _blockTable, _blockId);
}
void ScummEX::boxesDraw()
{
_image = new Image();
_image->drawBoxes(_blockTable, _blockId, _input);
}
void ScummEX::FileInfo() {
int fsize;
fsize = _input.size();
@@ -391,6 +397,11 @@ void ScummEX::UpdateInfosFromTree(int blockid) {
_gui->updateLabel("SpecLabel3", "Codec", _blockTable[blockid].variables);
_gui->SetButton(_blockTable[blockid].blockTypeID);
break;
case BOXD:
_gui->updateLabel("SpecLabel1", "No. of Boxes", _blockTable[blockid].numFiles);
_gui->SetButton(_blockTable[blockid].blockTypeID);
break;
}
}
+2 -2
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/scummex.h,v 1.6 2003/09/21 23:50:28 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/scummex.h,v 1.7 2003/09/22 15:23:57 yoshizf Exp $
*
*/
@@ -42,7 +42,6 @@ public:
File _output;
uint32 _blockId;
int _scummVersion;
ScummEX();
void fileView();
@@ -63,6 +62,7 @@ public:
void bgDraw();
void SmushFrameDraw();
void objectDraw();
void boxesDraw();
};
#endif
+15 -3
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/wxwindows.cpp,v 1.11 2003/09/21 23:50:28 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/wxwindows.cpp,v 1.12 2003/09/22 15:23:57 yoshizf Exp $
*
*/
@@ -227,6 +227,12 @@ void GUI_wxWindows::DrawImage() {
imageFrame->DrawImage();
}
void GUI_wxWindows::UpdateImage() {
wxBitmap bitmap = wxBitmap(image);
imageFrame->_sbmp->SetBitmap(bitmap);
imageFrame->Refresh();
}
ImageWindow::ImageWindow(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(frame,ID_ImageWindow,title,pos,size, wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION))
{
@@ -251,9 +257,9 @@ void ImageWindow::DrawImage() {
wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBitmap *sbmp = new wxStaticBitmap(this, -1, bitmap);
_sbmp = new wxStaticBitmap(this, -1, bitmap);
vertSizer->Add(sbmp, 0, wxALL, 0 );
vertSizer->Add(_sbmp, 0, wxALL, 0 );
Show(TRUE);
}
@@ -392,6 +398,12 @@ void GUI_wxWindows::SetButton(int blocktype) {
(wxObjectEventFunction) &ScummEX::Descumm );
break;
case BOXD:
SpecButton1->SetLabel("View Boxes...");
SpecButton1->Show(TRUE);
SpecButton1->Connect( ID_SpecButton1, wxEVT_COMMAND_BUTTON_CLICKED,
(wxObjectEventFunction) &ScummEX::boxesDraw );
break;
}
}
+4 -1
View File
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/wxwindows.h,v 1.3 2003/09/19 19:57:07 yoshizf Exp $
* $Header: /Users/sev/projects/sc/s/scummvm/scummex/wxwindows.h,v 1.4 2003/09/22 15:23:57 yoshizf Exp $
*
*/
@@ -60,6 +60,8 @@ public:
class ImageWindow : public wxFrame {
public:
wxStaticBitmap *_sbmp;
void DrawImage();
void OnQuit(wxCommandEvent& event);
ImageWindow(const wxString& title, const wxPoint& pos, const wxSize& size);
@@ -84,6 +86,7 @@ public:
void AppendText(char *text);
void FileInfoDialog(int size, int encbyte);
void DrawImage();
void UpdateImage();
void DisplayHelp();
void SetTitle(char *title);
void SaveImage();