[Scummvm-cvs-logs] SF.net SVN: scummvm: [28148] scummex/branches/gsoc2007-gameresbrowser
zbychs at users.sourceforge.net
zbychs at users.sourceforge.net
Thu Jul 19 21:58:19 CEST 2007
Revision: 28148
http://scummvm.svn.sourceforge.net/scummvm/?rev=28148&view=rev
Author: zbychs
Date: 2007-07-19 12:58:19 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
Added more descriptive chunk names in the ExplorationTree (for LFLFs, ROOMs, LSCRs, OBCDs and OBNAs).
Fixed RNAM presenter. Added NLSC and OBNA presenters.
Added single click activation in ExplorationTree.
Some other changes in ScummBlockFactory, CustomScummBlocks and presenters.
Modified Paths:
--------------
scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp
scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h
scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.cpp
scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.h
scummex/branches/gsoc2007-gameresbrowser/src/browserapp/DefaultPlugin.cpp
scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.cpp
scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.wxform
scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainFormCommands.cpp
scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/BinaryPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/DirectoryPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/BlockyBlockPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockFactory.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummParser.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummPresenterBase.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.cpp
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.h
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters2.cpp
scummex/branches/gsoc2007-gameresbrowser/vc8/scumm_plugin/scumm_plugin.vcproj
scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout
Added Paths:
-----------
scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.inl
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -19,6 +19,7 @@
#include <wx/wx.h>
#include <wx/imaglist.h>
+#include <wx/wupdlock.h>
#include "debugmem.h"
@@ -132,6 +133,8 @@
_rootObjectChain = new ObjectChain();
_panelMap = new PanelMap();
_dirMap = new DirMap();
+
+ _noActivationsHack = false;
}
ExplorationTree::~ExplorationTree() {
@@ -146,6 +149,9 @@
void ExplorationTree::cleanup() {
nodeDeactivate();
+ wxWindowUpdateLocker noTreeUpdates(_explorationTree);
+ wxWindowUpdateLocker noNotebookUpdates(_panelNotebook);
+
_dirMap->cleanup();
_panelMap->cleanup();
@@ -218,6 +224,8 @@
data->setCompleted(true);
}
+ wxWindowUpdateLocker noTreeUpdates(_explorationTree);
+
if (!kidchain->getObjectWithFlags(IS_DIRECTORY_CONTROLLER))
ExplorationTree::get()->deleteChildren(item); //delete the Dummy added by the ExplorationTree
@@ -330,8 +338,10 @@
void ExplorationTree::deleteChildren(const wxTreeItemId& parent) {
ASSERT_VALID_TREE_ITEM(parent);
- //FIXME: does not deactivate panels
+ //FIXME: does not deactivate panels (so use it only from DirectoryPresenter::deleteKidChains())
+ _noActivationsHack = true;
_explorationTree->DeleteChildren(parent); //CAUTION: after deleting every child updates selection! (on MSW at least)
+ _noActivationsHack = false;
}
void ExplorationTree::setItemData(const wxTreeItemId& item, wxTreeItemData* data) {
@@ -391,6 +401,8 @@
if (!node)
return;
+ wxWindowUpdateLocker noNotebookUpdates(_panelNotebook);
+
std::list<PanelInfo*> pinfos = _panelMap->getPanelsFor(node);
std::list<PanelInfo*>::iterator i;
for (i = pinfos.begin(); i != pinfos.end(); ++i) {
@@ -405,6 +417,8 @@
//deactivate currently activated node, and all other attached panels
void ExplorationTree::nodeDeactivate() {
+ wxWindowUpdateLocker noNotebookUpdates(_panelNotebook);
+
nodeDeactivate(_activeNode, false); //don't deactivate detached panels
_activeNode = NULL;
@@ -421,6 +435,8 @@
}
void ExplorationTree::nodeActivated(VirtualNode* activatedNode) {
+ wxWindowUpdateLocker noNotebookUpdates(_panelNotebook);
+
if (activatedNode != _activeNode)
nodeDeactivate();
_activeNode = activatedNode;
@@ -436,6 +452,14 @@
}
void ExplorationTree::itemActivated(const wxTreeItemId& item) {
+ if (_noActivationsHack)
+ return; //FIXME:
+ // This is specificaly to workaround treeItem selection events while
+ // deleting child items during cleanup. The child items are first
+ // unrealized. They're treeItems are deleted later. During the deletion
+ // a lot of SelChanged events fly, that might want to activate those
+ // already unrealized child nodes.
+
VirtualNode* node = getNode(item);
if (node)
nodeActivated(node);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/ExplorationTree.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -93,6 +93,8 @@
friend class PanelInfo;
+ bool _noActivationsHack; //see itemActivated() method for details
+
private:
ExplorationTree();
~ExplorationTree();
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -48,6 +48,21 @@
write(str.c_str(), str.size());
}*/
+wxString ReadStream::readString() {
+ char buf[2048 + 1];
+ int idx = 0;
+ while (idx < 2048) {
+ byte c = readByte();
+ if (c == 0)
+ break;
+ buf[idx] = (char)c;
+ idx++;
+ }
+ buf[idx] = '\0';
+ return Core::toString(buf);
+}
+
+
MemoryReadStream *ReadStream::readStream(uint32 dataSize) {
void *buf = malloc(dataSize);
dataSize = read(buf, dataSize);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browser/streams/stream.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -285,6 +285,10 @@
*/
MemoryReadStream *readStream(uint32 dataSize);
+ /**
+ * Reads a NULL-terminated string (max 2048 chars).
+ */
+ wxString readString();
};
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browserapp/DefaultPlugin.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browserapp/DefaultPlugin.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browserapp/DefaultPlugin.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -91,10 +91,13 @@
PLUGGED_OBJECT(ScummOFFSBlockPresenter)
PLUGGED_OBJECT(ScummRMHDBlockPresenter)
PLUGGED_OBJECT(ScummTRNSBlockPresenter)
+ PLUGGED_OBJECT(ScummNLSCBlockPresenter)
+
PLUGGED_OBJECT(ScummPALBlockPresenter)
PLUGGED_OBJECT(ScummIMGBlockPresenter)
PLUGGED_OBJECT(ScummScriptBlockPresenter)
+ PLUGGED_OBJECT(ScummStringBlockPresenter)
PLUGGED_OBJECT(ScummRNAMBlockPresenter)
PLUGGED_OBJECT(ScummMAXSBlockPresenter)
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -89,21 +89,21 @@
this->SetSizer(WxBoxSizer1);
this->SetAutoLayout(true);
- WxSplitterWindow1 = new wxSplitterWindow(this, ID_WXSPLITTERWINDOW1, wxPoint(0,0), wxSize(578,392));
+ WxSplitterWindow1 = new wxSplitterWindow(this, ID_WXSPLITTERWINDOW1, wxPoint(0,0), wxSize(578,392), wxCLIP_CHILDREN);
WxSplitterWindow1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
WxBoxSizer1->Add(WxSplitterWindow1,1,wxEXPAND | wxALL,0);
browserTree = new wxTreeCtrl(WxSplitterWindow1, ID_BROWSERTREE, wxPoint(5,5), wxSize(185,382), wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT);
browserTree->SetFont(wxFont(10, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
- mainPanel = new wxPanel(WxSplitterWindow1, ID_MAINPANEL, wxPoint(200,8), wxSize(363,376));
+ mainPanel = new wxPanel(WxSplitterWindow1, ID_MAINPANEL, wxPoint(200,8), wxSize(363,376), wxCLIP_CHILDREN);
mainPanel->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
mainPanel->SetSizer(WxBoxSizer2);
mainPanel->SetAutoLayout(true);
- browserNotebook = new wxNotebook(mainPanel, ID_BROWSERNOTEBOOK, wxPoint(5,5),wxSize(309,337));
+ browserNotebook = new wxNotebook(mainPanel, ID_BROWSERNOTEBOOK, wxPoint(5,5),wxSize(309,337), wxCLIP_CHILDREN);
browserNotebook->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
WxBoxSizer2->Add(browserNotebook,1,wxEXPAND | wxALL,5);
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.wxform
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.wxform 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainForm.wxform 2007-07-19 19:58:19 UTC (rev 28148)
@@ -62,7 +62,7 @@
Wx_IDName = 'ID_WXSPLITTERWINDOW1'
Wx_IDValue = 1014
Wx_SashPosition = 185
- Wx_GeneralStyle = []
+ Wx_GeneralStyle = [wxCLIP_CHILDREN]
Wx_SplitterStyle = []
Wx_Border = 0
Wx_Alignment = [wxEXPAND]
@@ -110,7 +110,7 @@
Wx_EventList.Strings = (
'EVT_UPDATE_UI:OnUpdateUI')
Wx_FGColor = clBlack
- Wx_GeneralStyle = []
+ Wx_GeneralStyle = [wxCLIP_CHILDREN]
Wx_Hidden = False
Wx_IDName = 'ID_MAINPANEL'
Wx_IDValue = 1017
@@ -146,7 +146,7 @@
Wx_IDValue = 1021
Wx_Hidden = False
Wx_NoteBookStyle = []
- Wx_GeneralStyle = []
+ Wx_GeneralStyle = [wxCLIP_CHILDREN]
Wx_Alignment = [wxEXPAND]
Wx_StretchFactor = 1
end
Modified: scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainFormCommands.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainFormCommands.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/browserapp/MainFormCommands.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -184,7 +184,7 @@
*/
void MainForm::browserTreeItemActivated(wxTreeEvent& event) {
//move to browserTreeSelChanged
- ExplorationTree::get()->itemActivated(event.GetItem());
+ //ExplorationTree::get()->itemActivated(event.GetItem());
}
/*
@@ -207,8 +207,8 @@
*/
void MainForm::browserTreeSelChanged(wxTreeEvent& event)
{
- //if (event.GetItem().IsOk())
- //ExplorationTree::get()->itemActivated(event.GetItem());
+ if (event.GetItem().IsOk())
+ ExplorationTree::get()->itemActivated(event.GetItem());
}
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/core/tostring.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -95,6 +95,11 @@
return wxString(wxConvCurrent->cWC2WX(str));
}
+inline
+wxString toHex(unsigned int num, int digits = 8) {
+ return wxString::Format(wxString::Format(wxT("%%0%dX"), digits), num);
+}
+
#ifndef streamout
#error streamout not defined
#endif
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/BinaryPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/BinaryPresenter.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/BinaryPresenter.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -162,11 +162,6 @@
//infoout << wxT("BinaryPresenter::panelDeactivate()") << std::endl;
}
-inline
-wxString toHex(uint32 num, int digits = 8) {
- return wxString::Format(wxString::Format(wxT("%%0%dX"), digits), num);
-}
-
void DumpBinaryEvtHandler::hexeditChanged(wxCommandEvent& event) {
long offs = event.GetExtraLong();
int val = event.GetInt();
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/DirectoryPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/DirectoryPresenter.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/DirectoryPresenter.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -48,13 +48,14 @@
//wxTreeItemId dummyTreeItem = ExplorationTree::get()->appendItem(
// node->getTreeItem(), wxT("Dummy"));
+ _created = false;
_expanded = false;
return true;
}
void DirectoryPresenter::doUnrealize(ObjectChain* ochain) {
- ASSERT(_inodeprovider && _inodeprovider->getNode());
+ //ASSERT(_inodeprovider && _inodeprovider->getNode());
/*infoout << wxT("DirectoryPresenter::unrealize(): ")
//<< (_inodeprovider ? _inodeprovider->getNode()->getTreeItemName().c_str() : wxT("<error>")) << wxT(" ")
<< (_idirectory ? _idirectory->getName().c_str() : wxT("<not expanded>")) << wxT(" ")
@@ -64,6 +65,7 @@
deleteKidChains();
+ _created = false;
_expanded = false;
_idirectory = NULL;
_inodeprovider = NULL;
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -234,6 +234,10 @@
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND));
}
+wxPaintBox::~wxPaintBox() {
+ delete m_buffer;
+}
+
void wxPaintBox::OnPaint(wxPaintEvent& WXUNUSED(event))
{
if (!m_buffer->Ok())
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/basic/ImageBox.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -20,7 +20,7 @@
{
public:
wxPaintBox(wxWindow *parent, wxWindowID id = -1);
- ~wxPaintBox() {}
+ virtual ~wxPaintBox();
wxBitmap& GetBuffer() { return *m_buffer; }
virtual void Update() {}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/BlockyBlockPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/BlockyBlockPresenter.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/BlockyBlockPresenter.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -130,7 +130,8 @@
ScummBlock::scumm_blocks::const_iterator i;
for (i = subblocks.begin(); i != subblocks.end(); ++i) {
ScummBlock* block = *i;
- addBlock(block->getTag()->toString(), block);
+ wxString friendlyName = block->getFriendlyName();
+ addBlock(friendlyName, block);
}
IVirtualBlocksDirectoryImpl::create();
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -1,223 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// CustomScummBlocks.h
-// This file holds implementations of ScummBlocks that can parse particular
-// scumm chunks. (Normally a ScummBlock is enough to parse a scumm chunk, but
-// some chunks have a weird format - so the customized ScummBlocks for them
-// are here.)
+#ifndef _CUSTOM_SCUMM_BLOCKS_H_
+#define _CUSTOM_SCUMM_BLOCKS_H_
-// To be included in ScummBlockFactory.cpp
+#include "ScummBlock.h"
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// A ScummBlock that doesn't have a normal scumm chunk header.
-// It has only a block tag + data, no size field.
+namespace Browser {
-class RawScummBlock : public ScummBlock {
-public:
- RawScummBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummBlock(tag, size, stream) {}
+using namespace Core;
- virtual bool parse() {
- _parsed = true;
- ASSERT(_sizeMode == TILL_END);
- ASSERT(!ifReadData());
- ASSERT(!ifParseSubBlocks());
- return true;
- }
+namespace Scumm {
-protected:
+// This file holds interfaces of ScummBlocks that can parse particular
+// scumm chunks. See CustomScummBlocks.inl
- virtual bool readHeader() {
- ASSERT(false); //we don't have a standard header
- return false;
- }
-
- virtual bool determineHeaderSize(uint32& outSize) {
- outSize = (_tag->isNewTag() ? 4 : 2);
- return true;
- }
-};
-
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// A generic ScummBlocks that exposes width and height (for whatever purpose).
+// A ScummBlock that consists of one null-terminated string.
+// It uses it as it's friendlyName.
-ScummWidthHeightBlock::ScummWidthHeightBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummBlock(tag, size, stream) {}
-
-uint32 ScummWidthHeightBlock::getWidth() {
- parse();
- return _width;
-}
-
-uint32 ScummWidthHeightBlock::getHeight() {
- parse();
- return _height;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// A ScummBlock that is able to parse RMHD chunk.
-// It exposes the determined width and height of the room's image.
-
-class ScummRMHDBlock : public ScummWidthHeightBlock {
- uint32 _objs;
+class ScummStringBlock : public ScummBlock {
+protected:
+ wxString _string;
public:
- ScummRMHDBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummWidthHeightBlock(tag, size, stream) {}
-
- virtual uint32 getNumObjs() {
- parse();
- return _objs;
- }
-
- virtual bool readData() {
- Common::SeekableReadStream& _input = *_mineStream;
- _width = _input.readUint16LE();
- _height = _input.readUint16LE();
- _objs = _input.readUint16LE();
- return true;
- }
+ ScummStringBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream);
+ virtual const wxString& getString();
+ virtual bool readData();
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// A ScummBlock that is able to parse IMHD chunk.
-// It exposes the determined width and height of the image.
+// A ScummBlock that is able to parse LOFF chunk.
-class ScummIMHDBlock : public ScummWidthHeightBlock {
- uint32 _numFiles;
+class ScummLOFFBlock : public ScummBlock {
public:
- ScummIMHDBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummWidthHeightBlock(tag, size, stream) {}
+ struct LOFFEntry {
+ byte roomNumber;
+ uint32 offset;
+ };
- virtual uint32 getNumFiles() {
- parse();
- return _numFiles;
- }
-
- virtual bool readData() {
- Common::SeekableReadStream& _input = *_mineStream;
-
- uint32 mark = _input.readUint32LE();
-
- if (mark == 730) {
- _input.readUint16LE();
- _numFiles = _input.readUint16LE(); // Number of images
- _input.readUint16LE(); // X Position
- _input.readUint16LE(); // Y Position
- _width = _input.readUint16LE();
- _height = _input.readUint16LE();
- } else {
- bool read = false;
-
- ScummBlock* im00 = this->getNext();
- ScummBlock* bomp = im00 ? im00->getNext() : NULL;
- if (bomp && bomp->getTag()->equals("BOMP")) { //FIXME: it shouldn't be a BOMP test, almost 100%
- Common::SeekableReadStream& _bompinput = *bomp->_mineStream;
- _bompinput.seek(0, SEEK_SET);
- _bompinput.seek(8 + 2, SEEK_SET);
- uint32 mark = _bompinput.readUint32LE();
- if (mark == 801) {
- _numFiles = _bompinput.readUint32LE(); // Number of images
- _bompinput.readUint32LE(); // X Position
- _bompinput.readUint32LE(); // Y Position
- _width = _bompinput.readUint32LE();
- _height = _bompinput.readUint32LE();
- read = true;
- }
- }
-
- if (!read) {
- _input.seek(10, SEEK_SET);
- _numFiles = _input.readUint16LE();
- _input.readUint32BE(); // Number of Z-Buffers per Image
- _input.readUint16LE(); // X Position
- _input.readUint16LE(); // Y Position
- _width = _input.readUint16LE();
- _height = _input.readUint16LE();
- }
- }
- return true;
- }
+protected:
+ std::vector<LOFFEntry> _offsets;
+public:
+ ScummLOFFBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream);
+ virtual const std::vector<LOFFEntry>& getOffsets();
+ virtual int getRoomNumberByOffset(uint32 offset); //-1 if not found
+ virtual bool readData();
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// A generic ScummBlocks that is able to parse palette chunks.
+// A ScummBlock that is able to parse LFLF chunk.
+// It takes it's room number from LOFF chunk, adds it to it's friendlyName, and
+// to it's room friendly name.
-ScummPALBlock::ScummPALBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
-: ScummBlock(tag, size, stream), _count(256), _palData(NULL) {}
-
-int ScummPALBlock::getColCount() {
- parse();
- return _count;
-}
-
-byte* ScummPALBlock::getPAL() {
- parse();
- ASSERT(_palData);
- return _palData;
-}
-
-bool ScummPALBlock::parse() {
- ASSERT(ifReadData());
- ASSERT(!ifParseSubBlocks());
- bool res = ScummBlock::parse();
- if (!res)
- return false;
- _palData = _data;
- return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-// Custom ScummBlocks that are able to parse AHDR and RGBS palettes.
-
-class ScummAHDRBlock : public ScummPALBlock {
+class ScummLFLFBlock : public ScummBlock {
+ int _roomNumber;
+ friend class ScummLOFFBlock;
public:
- ScummAHDRBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummPALBlock(tag, size, stream) {}
-
- virtual byte* getPAL() {
- parse();
- ASSERT(_palData);
- return _palData + 6;
- }
+ ScummLFLFBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream);
+ virtual int getRoomNumber(); //-1 if not found
+ virtual bool parse();
};
-class ScummRGBSBlock : public ScummPALBlock {
-public:
- ScummRGBSBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummPALBlock(tag, size, stream) {}
-
- virtual int getColCount() {
- parse();
- return _dsize / 3;
- }
-};
-
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// Dummy ScummBlock that holds an EGA palette
-class ScummEGABlock : public ScummPALBlock {
-public:
- ScummEGABlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : ScummPALBlock(tag, size, stream) {
- _count = 16;
- _palData = egaPal;
- _parsed = true;
- }
-};
+} // namespace Scumm
-ScummPALBlock* getEGAPalette() {
- ASSERT_STATICS_ALLOWED();
- static ScummEGABlock ega(NULL, 0, NULL);
- return &ega;
-}
+} // namespace Browser
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
+#endif // _CUSTOM_SCUMM_BLOCKS_H_
Added: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.inl
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.inl (rev 0)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.inl 2007-07-19 19:58:19 UTC (rev 28148)
@@ -0,0 +1,439 @@
+/////////////////////////////////////////////////////////////////////////////
+// CustomScummBlocks.inl
+
+// This file holds implementations of ScummBlocks that can parse particular
+// scumm chunks. (Normally a ScummBlock is enough to parse a scumm chunk, but
+// some chunks have a weird format - so the customized ScummBlocks for them
+// are here.)
+
+// To be included in ScummBlockFactory.cpp
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// This file defines blocks specific for the following scumm chunks:
+// RMHD
+// IMHD
+// PAL's (various, plus dummy ScummEGABlock)
+// OBNA
+// LFLF
+// LOFF
+//
+// Plus: RawScummBlock, ScummStringBlock
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that doesn't have a normal scumm chunk header.
+// It has only a block tag + data, no size field.
+
+class RawScummBlock : public ScummBlock {
+public:
+ RawScummBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummBlock(tag, size, stream) {}
+
+ virtual bool parse() {
+ _parsed = true;
+ ASSERT(_sizeMode == TILL_END);
+ ASSERT(!ifReadData());
+ ASSERT(!ifParseSubBlocks());
+ return true;
+ }
+
+protected:
+
+ virtual bool readHeader() {
+ ASSERT(false); //we don't have a standard header
+ return false;
+ }
+
+ virtual bool determineHeaderSize(uint32& outSize) {
+ outSize = (_tag->isNewTag() ? 4 : 2);
+ return true;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A generic ScummBlocks that exposes width and height (for whatever purpose).
+
+ScummWidthHeightBlock::ScummWidthHeightBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummBlock(tag, size, stream) {}
+
+uint32 ScummWidthHeightBlock::getWidth() {
+ parse();
+ return _width;
+}
+
+uint32 ScummWidthHeightBlock::getHeight() {
+ parse();
+ return _height;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that is able to parse RMHD chunk.
+// It exposes the determined width and height of the room's image.
+
+class ScummRMHDBlock : public ScummWidthHeightBlock {
+ uint32 _objs;
+public:
+ ScummRMHDBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummWidthHeightBlock(tag, size, stream) {
+ _flags = READ_DATA;
+ }
+
+ virtual uint32 getNumObjs() {
+ parse();
+ return _objs;
+ }
+
+ virtual bool readData() {
+ Common::SeekableReadStream& _input = *_mineStream;
+ _width = _input.readUint16LE();
+ _height = _input.readUint16LE();
+ _objs = _input.readUint16LE();
+ return true;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that is able to parse IMHD chunk.
+// It exposes the determined width and height of the image.
+
+class ScummIMHDBlock : public ScummWidthHeightBlock {
+ uint32 _numFiles;
+public:
+ ScummIMHDBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummWidthHeightBlock(tag, size, stream) {
+ _flags = READ_DATA;
+ }
+
+ virtual uint32 getNumFiles() {
+ parse();
+ return _numFiles;
+ }
+
+ virtual bool readData() {
+ Common::SeekableReadStream& _input = *_mineStream;
+
+ uint32 mark = _input.readUint32LE();
+
+ if (mark == 730) {
+ _input.readUint16LE();
+ _numFiles = _input.readUint16LE(); // Number of images
+ _input.readUint16LE(); // X Position
+ _input.readUint16LE(); // Y Position
+ _width = _input.readUint16LE();
+ _height = _input.readUint16LE();
+ } else {
+ bool read = false;
+
+ ScummBlock* im00 = this->getNext();
+ ScummBlock* bomp = im00 ? im00->getNext() : NULL;
+ if (bomp && bomp->getTag()->equals("BOMP")) { //FIXME: it shouldn't be a BOMP test, almost 100%
+ Common::SeekableReadStream& _bompinput = *bomp->_mineStream;
+ _bompinput.seek(0, SEEK_SET);
+ _bompinput.seek(8 + 2, SEEK_SET);
+ uint32 mark = _bompinput.readUint32LE();
+ if (mark == 801) {
+ _numFiles = _bompinput.readUint32LE(); // Number of images
+ _bompinput.readUint32LE(); // X Position
+ _bompinput.readUint32LE(); // Y Position
+ _width = _bompinput.readUint32LE();
+ _height = _bompinput.readUint32LE();
+ read = true;
+ }
+ }
+
+ if (!read) {
+ _input.seek(10, SEEK_SET);
+ _numFiles = _input.readUint16LE();
+ _input.readUint32BE(); // Number of Z-Buffers per Image
+ _input.readUint16LE(); // X Position
+ _input.readUint16LE(); // Y Position
+ _width = _input.readUint16LE();
+ _height = _input.readUint16LE();
+ }
+ }
+ return true;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A generic ScummBlocks that is able to parse palette chunks.
+
+ScummPALBlock::ScummPALBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+: ScummBlock(tag, size, stream), _count(256), _palData(NULL) {
+ _flags = READ_DATA;
+}
+
+int ScummPALBlock::getColCount() {
+ parse();
+ return _count;
+}
+
+byte* ScummPALBlock::getPAL() {
+ parse();
+ ASSERT(_palData);
+ return _palData;
+}
+
+bool ScummPALBlock::parse() {
+ ASSERT(ifReadData());
+ ASSERT(!ifParseSubBlocks());
+ bool res = ScummBlock::parse();
+ if (!res)
+ return false;
+ _palData = _data;
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Custom ScummBlocks that are able to parse AHDR and RGBS palettes.
+
+class ScummAHDRBlock : public ScummPALBlock {
+public:
+ ScummAHDRBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummPALBlock(tag, size, stream) {}
+
+ virtual byte* getPAL() {
+ parse();
+ ASSERT(_palData);
+ return _palData + 6;
+ }
+};
+
+class ScummRGBSBlock : public ScummPALBlock {
+public:
+ ScummRGBSBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummPALBlock(tag, size, stream) {}
+
+ virtual int getColCount() {
+ parse();
+ return _dsize / 3;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// Dummy ScummBlock that holds an EGA palette
+
+class ScummEGABlock : public ScummPALBlock {
+public:
+ ScummEGABlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummPALBlock(tag, size, stream) {
+ _count = 16;
+ _palData = egaPal;
+ _parsed = true;
+ }
+};
+
+ScummPALBlock* getEGAPalette() {
+ ASSERT_STATICS_ALLOWED();
+ static ScummEGABlock ega(NULL, 0, NULL);
+ return &ega;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that consists of one null-terminated string.
+// It adds it to it's friendlyName.
+
+ScummStringBlock::ScummStringBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+: ScummBlock(tag, size, stream) {
+ _flags = READ_DATA | PARSE_BEFORE_NAME;
+}
+
+const wxString& ScummStringBlock::getString() {
+ parse();
+ return _string;
+}
+
+bool ScummStringBlock::readData() {
+ _string = _mineStream->readString();
+ _friendlyName << wxT(": ") << _string;
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that can parse OBNA chunk.
+// It adds parsed Object Name to it's own and it's parent's (OBCD) _friendlyName.
+
+class ScummOBNABlock : public ScummStringBlock {
+public:
+ ScummOBNABlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummStringBlock(tag, size, stream) {
+ _flags |= EAGER_PARSE; //PARSE_BEFORE_NAME is not enough, cause we need to set name for OBCD, our parent
+ }
+ virtual bool readData() {
+ bool res = ScummStringBlock::readData();
+ if (!res)
+ return false;
+
+ ScummBlock* obcdBlock = getParent();
+
+ if (!obcdBlock || !obcdBlock->getTag()->equals("OBCD")) //if we are standalone, or not OBCD's child
+ return true;
+
+ obcdBlock->_friendlyName << wxT(": ") << _string;
+
+ return true;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that is able to parse LFLF chunk.
+// It takes it's room number from LOFF chunk, adds it to it's friendlyName, and
+// to it's room friendly name.
+
+ScummLFLFBlock::ScummLFLFBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummBlock(tag, size, stream), _roomNumber(-1) {
+ _flags = PARSE_SUB_BLOCKS | IS_STOPPER;
+}
+
+int ScummLFLFBlock::getRoomNumber() {
+ //parse();
+ return _roomNumber;
+}
+
+bool ScummLFLFBlock::parse() {
+ if (_parsed)
+ return true;
+ bool res = ScummBlock::parse();
+ if (!res)
+ return false;
+
+ if (_roomNumber == -1)
+ return true;
+
+ ScummBlock* roomBlock = findChild("ROOM");
+ if (!roomBlock)
+ return true;
+
+ wxString suffix(wxT(" #"));
+ suffix << _roomNumber;
+ roomBlock->setFriendlyName(roomBlock->getFriendlyName() + suffix);
+
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that is able to parse LOFF chunk.
+// It exposes the determined width and height of the room's image.
+
+ScummLOFFBlock::ScummLOFFBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummBlock(tag, size, stream) {
+ _flags = READ_DATA | EAGER_PARSE;
+}
+
+const std::vector<ScummLOFFBlock::LOFFEntry>& ScummLOFFBlock::getOffsets() {
+ parse();
+ return _offsets;
+}
+
+bool ScummLOFFBlock::readData() {
+ byte numLFLFs = _mineStream->readByte();
+
+ LOFFEntry entry;
+ for (int i = 0; i < numLFLFs; ++i ) {
+ entry.roomNumber = _mineStream->readByte();
+ entry.offset = _mineStream->readUint32LE();
+ _offsets.push_back(entry);
+ }
+
+ if (!getParent()) //if we are standalone
+ return true;
+
+ scumm_blocks& siblings = getParent()->_subblocks;
+
+ scumm_blocks::iterator i;
+ for (i = siblings.begin(); i != siblings.end(); ++i) {
+ ScummBlock* sibling = *i;
+ if (!sibling->getTag()->equals("LFLF"))
+ continue;
+
+ ScummLFLFBlock* lflfBlock = dynamic_cast<ScummLFLFBlock*>(sibling);
+ ASSERT(lflfBlock);
+
+ //FIXME: is this correct? maybe it should be contained ROOM's offset?
+ uint32 hsize;
+ lflfBlock->determineHeaderSize(hsize);
+ int roomNumber = getRoomNumberByOffset(lflfBlock->_rootOffs + hsize);
+ if (roomNumber == -1)
+ continue;
+
+ lflfBlock->_roomNumber = roomNumber;
+ lflfBlock->_friendlyName << wxT(" #") << roomNumber;
+ }
+
+ return true;
+}
+
+int ScummLOFFBlock::getRoomNumberByOffset(uint32 offset) {
+ parse();
+
+ for (size_t i = 0; i < _offsets.size(); ++i )
+ if (_offsets[i].offset == offset)
+ return _offsets[i].roomNumber;
+
+ return -1;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// A ScummBlock that is able to parse NLSC chunk.
+// It assigns ordinal numbers to all local scripts following it (adds it to
+// their friendly name.
+
+class ScummNLSCBlock : public ScummBlock {
+ int16 _numScripts;
+public:
+ ScummNLSCBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
+ : ScummBlock(tag, size, stream) {
+ _flags = READ_DATA | EAGER_PARSE;
+ }
+
+ virtual int16 getNumScripts() {
+ parse();
+ return _numScripts;
+ }
+
+ virtual bool readData() {
+ _numScripts = _mineStream->readSint16LE();
+ return true;
+ }
+
+ virtual bool parse() {
+ if (_parsed)
+ return true;
+ bool res = ScummBlock::parse();
+ if (!res)
+ return false;
+
+ ScummBlock* block = this;
+ int idx = 0;
+ while (true) {
+ block = block->getNextSibling();
+ if (!block || !block->getTag()->equals("LSCR"))
+ break;
+ wxString suffix;
+ suffix << wxT(" #") << idx;
+ block->setFriendlyName(block->getFriendlyName() + suffix);
+ idx++;
+ }
+ if (idx != _numScripts)
+ errout << wxT("ScummNLSCBlock::parse(): not enough LSCR chunks found") << std::endl;
+
+ return true;
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
Property changes on: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/CustomScummBlocks.inl
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -22,12 +22,14 @@
// chunk. It can be subclassed to parse even most weird chunks.
ScummBlock::ScummBlock(ScummTag* tag, uint32 size, Common::SeekableReadStream* stream)
- : _tag(tag), _sizeMode(INVALID_SIZE_MODE),
- _ownStream(true), _mineStream(stream),
- _flags(0), _parsed(false), _size(size), _dsize(-1), _data(NULL),
- _subblocks(),
- _parent(NULL), _myId(), _rootOffs(-1),
- _level(0) {}
+: _tag(tag), _sizeMode(INVALID_SIZE_MODE),
+ _friendlyName(tag ? tag->toString() : wxString()), //ScummEGABlock uses NULL tag
+ _ownStream(true), _mineStream(stream),
+ _flags(0), _parsed(false), _size(size), _dsize(-1), _data(NULL),
+ _subblocks(),
+ _parent(NULL), _myId(), _rootOffs(-1),
+ _level(0) {
+}
ScummBlock::~ScummBlock() {
if(_tag)
@@ -45,6 +47,16 @@
return _tag;
}
+const wxString& ScummBlock::getFriendlyName() {
+ if (_flags & PARSE_BEFORE_NAME)
+ parse();
+ return _friendlyName;
+}
+
+void ScummBlock::setFriendlyName(wxString friendlyName) {
+ _friendlyName = friendlyName;
+}
+
const ScummBlock::scumm_blocks& ScummBlock::getSubBlocks() {
return _subblocks;
}
@@ -73,6 +85,42 @@
return _parent->getRootScummBlock();
}
+ScummBlock* ScummBlock::getNextSibling() {
+ if (!getParent())
+ return NULL;
+ scumm_blocks& siblings = getParent()->_subblocks;
+
+ scumm_blocks::iterator i;
+ for (i = siblings.begin(); i != siblings.end(); ++i) {
+ if ((*i) == this) {
+ ++i;
+ break;
+ }
+ }
+
+ if (i != siblings.end())
+ return *i;
+ return NULL;
+}
+
+ScummBlock* ScummBlock::getPrevSibling() {
+ if (!getParent())
+ return NULL;
+ scumm_blocks& siblings = getParent()->_subblocks;
+
+ scumm_blocks::reverse_iterator i;
+ for (i = siblings.rbegin(); i != siblings.rend(); ++i) {
+ if ((*i) == this) {
+ ++i;
+ break;
+ }
+ }
+
+ if (i != siblings.rend())
+ return *i;
+ return NULL;
+}
+
ScummBlock* ScummBlock::getNext() {
parse();
scumm_blocks::iterator i = _myId;
@@ -112,15 +160,27 @@
return NULL;
}
-ScummBlock* ScummBlock::findChild(const char* tag) {
- ScummBlock* prev = this;
- while (true) {
- prev = prev->getNext();
- if (!prev || (prev->_level <= this->_level))
- return NULL;
- if (prev->getTag()->equals(tag))
- return prev;
+ScummBlock* ScummBlock::findChild(const char* tag, bool recursive /*= false*/) {
+ parse();
+
+ scumm_blocks::iterator i;
+ for (i = _subblocks.begin(); i != _subblocks.end(); ++i) {
+ ScummBlock* child = *i;
+ if (child->getTag()->equals(tag))
+ return child;
}
+
+ if (!recursive)
+ return NULL;
+
+ //FIXME: the recursive order is neither BFS, nor DFS - it's weird.
+ for (i = _subblocks.begin(); i != _subblocks.end(); ++i) {
+ ScummBlock* child = *i;
+ ScummBlock* found = child->findChild(tag, recursive);
+ if (found)
+ return found;
+ }
+
return NULL;
}
@@ -353,6 +413,14 @@
return false;
}
+ //parse all child blocks with EAGER_PARSE set
+ scumm_blocks::iterator i;
+ for (i = _subblocks.begin(); i != _subblocks.end(); ++i) {
+ ScummBlock* block = *i;
+ if (block->_flags & EAGER_PARSE)
+ block->parse();
+ }
+
return true;
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlock.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -39,11 +39,16 @@
// chunk. It can be subclassed to parse even most weird chunks.
enum ScummBlockFlags {
+ INVALID_FLAGS = -1, //"flags not set" marker
READ_DATA = 1, //if we want the raw data to be read from the chunk (and stored in _data)
PARSE_SUB_BLOCKS = 2, //if we want the sub blocks to be parsed (and stored in _subblocks)
IS_STOPPER = 4, //if this is set, the getNext()/getPrev() functions
//don't go beyond this block - use this for ROOMs, LFLFs etc.
//so that searching is constrained to the ROOM/LFLF scope
+ EAGER_PARSE = 8, //if we want the block to be parsed when it's indexed by it's
+ //parent (to be precise: right after the parent indexes all it's
+ //children)
+ PARSE_BEFORE_NAME = 16, //parse() before returning _friendlyName
};
class RootScummBlock;
@@ -55,6 +60,7 @@
ScummTag* _tag;
ScummChunkSizeMode _sizeMode;
+ wxString _friendlyName; //something we'd like to see in the ExplorationTree
bool _ownStream;
Common::SeekableReadStream* _mineStream;
@@ -83,6 +89,8 @@
//accessors
ScummTag* getTag();
+ virtual const wxString& getFriendlyName(); //virtual, cause some blocks might require to parse() themselves first.
+ void setFriendlyName(wxString friendlyName);
const scumm_blocks& getSubBlocks();
Common::SeekableReadStream* getStream();
ScummBlock* getParent();
@@ -98,13 +106,15 @@
//scumm_id getBlockId();
//void setBlockId(scumm_id id);
- ScummBlock* findBlock(const char* tag, int dir); //find a block with a given tag
- ScummBlock* findChild(const char* tag); //find a child
+ ScummBlock* findBlock(const char* tag, int dir); //find a block with given tag
+ ScummBlock* findChild(const char* tag, bool recursive = false); //find a child with given tag
//void setParent(ScummBlock* parent);
//ScummBlock* getScummBlock(scumm_id id);
ScummBlock* getNext(); //get next block in the list of all scumm blocks in the scumm file
ScummBlock* getPrev(); //like above, but previous
+ ScummBlock* getNextSibling(); //get next block in the list of my siblings
+ ScummBlock* getPrevSibling(); //like above, but previous
virtual bool parse(); //parse the input stream: it is a "template method"
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockFactory.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockFactory.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockFactory.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -6,11 +6,14 @@
#include "scumm/ScummResource.h"
#include "scumm/ScummBlock.h"
#include "scumm/ScummFileTypes.h"
+#include "scumm/CustomScummBlocks.h"
#include "CoreFileTypes.h"
#include <list>
#include <algorithm>
+#include <iostream>
+
#include "safe_static.h"
#include "debugmem.h"
@@ -25,7 +28,7 @@
/////////////////////////////////////////////////////////////////////////////
// Include specialized ScummBlocks for various scumm chunks.
-#include "scumm/CustomScummBlocks.h"
+#include "scumm/CustomScummBlocks.inl"
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -88,10 +91,13 @@
ASSERT(stream);
ASSERT(_size == (uint32)(-1) || _size == size);
T* block = new T(tag, size, stream);
- block->_sizeMode = _sizeMode;
+ if (_sizeMode != INVALID_SIZE_MODE)
+ block->_sizeMode = _sizeMode;
//block->_size = _size;
- block->_dsize = _dsize;
- block->_flags = _flags;
+ if (_dsize != (uint32)(-1))
+ block->_dsize = _dsize;
+ if (_flags != INVALID_FLAGS)
+ block->_flags = _flags;
return block;
}
};
@@ -135,14 +141,20 @@
static ret_pair GENERATE_UNIQUE_IDENTIFIER_SUB(insert) = creators.insert( \
the_pair( wxString(wxT(tag)), &GENERATE_UNIQUE_IDENTIFIER_SUB(creator)) );
+#define SCUMM_BLOCK_EX(blocktype, tag, sizeMode, size, dsize, flags, presenterGUID) \
+ SCUMM_BLOCK(blocktype, tag, sizeMode, size, dsize, flags) \
+ static int GENERATE_UNIQUE_IDENTIFIER_SUB(parser) = \
+ GENERATE_UNIQUE_IDENTIFIER_SUB(creator).addParser(presenterGUID); \
+ USE_VAR(GENERATE_UNIQUE_IDENTIFIER_SUB(parser));
+
#define DATA_BLOCK(blocktype, tag, presenterGUID) \
SCUMM_BLOCK(blocktype, tag, INVALID_SIZE_MODE, -1, -1, READ_DATA) \
- static int GENERATE_UNIQUE_IDENTIFIER_SUB(parser) = \
+ static int GENERATE_UNIQUE_IDENTIFIER_SUB(parser) = \
GENERATE_UNIQUE_IDENTIFIER_SUB(creator).addParser(presenterGUID); \
- USE_VAR(GENERATE_UNIQUE_IDENTIFIER_SUB(parser));
+ USE_VAR(GENERATE_UNIQUE_IDENTIFIER_SUB(parser));
#define CUSTOM_BLOCK_EX(blocktype, tag, presenterGUID) \
- SCUMM_BLOCK(blocktype, tag, INVALID_SIZE_MODE, -1, -1, 0) \
+ SCUMM_BLOCK(blocktype, tag, INVALID_SIZE_MODE, -1, -1, INVALID_FLAGS) \
static int GENERATE_UNIQUE_IDENTIFIER_SUB(parser) = \
GENERATE_UNIQUE_IDENTIFIER_SUB(creator).addParser(presenterGUID); \
USE_VAR(GENERATE_UNIQUE_IDENTIFIER_SUB(parser));
@@ -160,7 +172,7 @@
CUSTOM_BLOCK_EX(ScummBlock, tag, presenterGUID)
#define BASIC_BLOCK(tag) \
- SCUMM_BLOCK(ScummBlock, tag, INVALID_SIZE_MODE, -1, -1, 0) \
+ SCUMM_BLOCK(ScummBlock, tag, INVALID_SIZE_MODE, -1, -1, INVALID_FLAGS) \
static int GENERATE_UNIQUE_IDENTIFIER_SUB(parser) = \
GENERATE_UNIQUE_IDENTIFIER_SUB(creator).addParser(CoreFileTypes::binaryParserGUID()); \
USE_VAR(GENERATE_UNIQUE_IDENTIFIER_SUB(parser));
@@ -271,7 +283,7 @@
CUSTOM_BLOCK("DCHR", scummDIRBlockPresenterGUID())
CUSTOM_BLOCK("DRSC", scummDIRBlockPresenterGUID())
- CUSTOM_BLOCK("LOFF", scummLOFFBlockPresenterGUID())
+ CUSTOM_BLOCK_EX(ScummLOFFBlock, "LOFF", scummLOFFBlockPresenterGUID())
CUSTOM_BLOCK("OFFS", scummOFFSBlockPresenterGUID())
//Infos
@@ -282,23 +294,23 @@
//Other
BASIC_BLOCK("ADL ")
BASIC_BLOCK("AMI ")
- SCUMM_BLOCK(ScummBlock, "DATA", TILL_END, -1, -1, 0) //TODO: probably not correct
+ SCUMM_BLOCK(ScummBlock, "DATA", TILL_END, -1, -1, INVALID_FLAGS) //TODO: probably not correct
BASIC_BLOCK("FRMT")
BASIC_BLOCK("GMD ")
SCUMM_BLOCK(ScummBlock, "iMUS", TILL_END, -1, -1, PARSE_SUB_BLOCKS) //TODO: probably not correct
BASIC_BLOCK("JUMP")
- SCUMM_BLOCK(RawScummBlock, "LABN", TILL_END, -1, -1, 0) //TODO: parse it properly
- SCUMM_BLOCK(RawScummBlock, "LB83", TILL_END, -1, -1, 0) //TODO: parse it properly
+ SCUMM_BLOCK(RawScummBlock, "LABN", TILL_END, -1, -1, INVALID_FLAGS) //TODO: parse it properly
+ SCUMM_BLOCK(RawScummBlock, "LB83", TILL_END, -1, -1, INVALID_FLAGS) //TODO: parse it properly
BLOCKY_STOPPER("LECF")
- BLOCKY_STOPPER("LFLF")
+ CUSTOM_BLOCK_EX(ScummLFLFBlock, "LFLF", blockyBlockPresenterGUID())
BASIC_BLOCK("MAP ")
- SCUMM_BLOCK(RawScummBlock, "MCMP", TILL_END, -1, -1, 0) //TODO: parse it properly
+ SCUMM_BLOCK(RawScummBlock, "MCMP", TILL_END, -1, -1, INVALID_FLAGS) //TODO: parse it properly
BASIC_BLOCK("MIDI")
BLOCKY_BLOCK("PALS")
- SCUMM_BLOCK(RawScummBlock, "RIFF", TILL_END, -1, -1, 0) //TODO: parse it properly
+ SCUMM_BLOCK(RawScummBlock, "RIFF", TILL_END, -1, -1, INVALID_FLAGS) //TODO: parse it properly
BASIC_BLOCK("ROL ")
BLOCKY_STOPPER("ROOM")
DATA_BLOCK(ScummIMHDBlock, "IMHD", CoreFileTypes::binaryParserGUID())
@@ -308,12 +320,16 @@
BASIC_BLOCK("STOP")
CUSTOM_BLOCK("TRNS", scummTRNSBlockPresenterGUID())
+ CUSTOM_BLOCK_EX(ScummNLSCBlock, "NLSC", scummNLSCBlockPresenterGUID())
+ CUSTOM_BLOCK_EX(ScummOBNABlock, "OBNA", scummStringBlockPresenterGUID())
+ SCUMM_BLOCK_EX(ScummBlock, "OBCD", INVALID_SIZE_MODE, -1, -1,
+ EAGER_PARSE | PARSE_SUB_BLOCKS, //EAGER_PARSE to parse OBNA block and set _friendlyName
+ blockyBlockPresenterGUID())
BLOCKY_BLOCK("WRAP") //FIXME: Is this ok? Shouldn't the OFFS subblock be used here?
//BLOCKY_BLOCK("SOUN") //This not ok.
BLOCKY_BLOCK("PALS")
- BLOCKY_BLOCK("OBCD")
//FIXME: files
//BLOCKY_BLOCK(".IMC")
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -22,6 +22,7 @@
SLOT_DESCS(ScummBlockPresenter)
SLOT_DESC(_fileSlot, SLOT_DEFAULT)
+ //SLOT_DESC(_nodeSlot, SLOT_DEFAULT)
END_DESCS
PIN_DESCS(ScummBlockPresenter)
@@ -38,10 +39,24 @@
if (!res)
return false;
+ /*_inodeprovider = _nodeSlot->getInterface();
+ if (!_inodeprovider) {
+ errout << wxT("ScummBlockPresenter::doRealize(): could not get INodeProvider interface") << std::endl;
+ _realized = false;
+ return false;
+ }
+
+ //Register myself in the ExploartionTree as a... something maybe
+ VirtualNode* node = _inodeprovider->getNode();
+ ASSERT(node);
+ ExplorationTree::get()->registerSomething...(node, this);*/
+
return true;
}
void ScummBlockPresenter::doUnrealize(ObjectChain* ochain) {
+ //ExplorationTree::get()->unregisterSomething...(this);
+
if (_ownBlock && _block)
delete _block;
_block = NULL;
@@ -49,7 +64,10 @@
_ownBlock = false;
_ifile = NULL;
+ //_inodeprovider = NULL;
+
_fileSlot->releaseInterface();
+ //_nodeSlot->releaseInterface();
BObject::doUnrealize(ochain);
}
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummBlockPresenter.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -63,9 +63,12 @@
protected:
Slot<IFile>* _fileSlot;
+ //Slot<INodeProvider>* _nodeSlot;
Pin< IProvider<FileNScummBlock> >* _blockPin;
IFile* _ifile;
+ //INodeProvider* _inodeprovider;
+
bool _created;
bool _ownBlock;
ScummBlock* _block;
@@ -77,7 +80,7 @@
SLOTS_DECL
ScummBlockPresenter()
- : _ifile(NULL), _created(false), _ownBlock(false), _block(NULL) {}
+ : _ifile(NULL), /*_inodeprovider(NULL),*/ _created(false), _ownBlock(false), _block(NULL) {}
~ScummBlockPresenter();
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -6,6 +6,7 @@
#include "scumm/ScummCommonPresenters.h"
#include "scumm/ScummResource.h"
#include "scumm/descumm.h"
+#include "scumm/CustomScummBlocks.h"
#include "CoreInterfaces.h"
#include "PluginUtil.h"
@@ -35,6 +36,7 @@
_text = wxT("");
_text << wxT("Block type: ") << _title << wxEndl();
+ _text << wxT("Friendly name: ") << block->getFriendlyName() << wxEndl();
_text << wxT("Offset in file: ") << toHex(block->_rootOffs) << wxEndl();
_text << wxT("Size: ") << block->_size << wxEndl();
_text << wxT("Data Size: ") << block->_dsize << wxEndl();
@@ -99,6 +101,9 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+//FIXME: VERB scripts not decompilled correctly
+// (Max: "At least it doesn't show the "verb entry header" of the script.")
+
void ScummScriptBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
//infoout << wxT("ScummScriptBlockPresenter::doCreate(): ") << std::endl;
@@ -126,6 +131,18 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+void ScummStringBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummStringBlockPresenter::doCreate(): ") << std::endl;
+
+ ScummStringBlock* stringBlock = dynamic_cast<ScummStringBlock*>(block);
+ ASSERT(stringBlock);
+
+ _text = stringBlock->getString();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
void ScummPALBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
//infoout << wxT("ScummPALBlockPresenter::doCreate(): ") << std::endl;
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummCommonPresenters.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -18,6 +18,7 @@
// This file declares some "generic" presenters:
// - ScummBlockInfoPresenter (general info about the block)
// - ScummScriptBlockPresenter (descumm)
+// - ScummStringBlockPresenter (a chunk with one null-terminated string)
// - ScummPALBlockPresenter (displays various palletes)
// - ScummIMGBlockPresenter (displays various images)
//
@@ -64,6 +65,18 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+class SCUMM_PLUGIN_API ScummStringBlockPresenter : public ScummBlockTextPresenter {
+ DECLARE_BOBJECT_CLASS(ScummStringBlockPresenter, ScummBlockTextPresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
class SCUMM_PLUGIN_API ScummPALBlockPresenter : public ScummBlockImagePresenter {
DECLARE_BOBJECT_CLASS(ScummPALBlockPresenter, ScummBlockImagePresenter)
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -32,10 +32,13 @@
SAFE_LOCAL_STATIC(scummOFFSBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummOFFSBlockPresenter"), 1) )
SAFE_LOCAL_STATIC(scummRMHDBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummRMHDBlockPresenter"), 1) )
SAFE_LOCAL_STATIC(scummTRNSBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummTRNSBlockPresenter"), 1) )
+SAFE_LOCAL_STATIC(scummNLSCBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummNLSCBlockPresenter"), 1) )
+
SAFE_LOCAL_STATIC(scummPALBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummPALBlockPresenter"), 1) )
SAFE_LOCAL_STATIC(scummIMGBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummIMGBlockPresenter"), 1) )
SAFE_LOCAL_STATIC(scummScriptBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummScriptBlockPresenter"), 1) )
+SAFE_LOCAL_STATIC(scummStringBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummStringBlockPresenter"), 1) )
SAFE_LOCAL_STATIC(scummRNAMBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummRNAMBlockPresenter"), 1) )
SAFE_LOCAL_STATIC(scummMAXSBlockPresenterGUID, BGUID, (wxT("ScummObjects"), wxT("ScummMAXSBlockPresenter"), 1) )
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummFileTypes.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -34,10 +34,13 @@
SAFE_LOCAL_STATIC_DECL(scummOFFSBlockPresenterGUID, BGUID)
SAFE_LOCAL_STATIC_DECL(scummRMHDBlockPresenterGUID, BGUID)
SAFE_LOCAL_STATIC_DECL(scummTRNSBlockPresenterGUID, BGUID)
+SAFE_LOCAL_STATIC_DECL(scummNLSCBlockPresenterGUID, BGUID)
+
SAFE_LOCAL_STATIC_DECL(scummPALBlockPresenterGUID, BGUID)
SAFE_LOCAL_STATIC_DECL(scummIMGBlockPresenterGUID, BGUID)
SAFE_LOCAL_STATIC_DECL(scummScriptBlockPresenterGUID, BGUID)
+SAFE_LOCAL_STATIC_DECL(scummStringBlockPresenterGUID, BGUID)
SAFE_LOCAL_STATIC_DECL(scummRNAMBlockPresenterGUID, BGUID)
SAFE_LOCAL_STATIC_DECL(scummMAXSBlockPresenterGUID, BGUID)
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummImageDetail.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -179,7 +179,7 @@
ScummBlock* dataID;
if (version > 4) {
- dataID = block->findChild("SMAP");
+ dataID = block->findChild("SMAP", true);
if (!dataID) {
errout << wxT("Image::drawBG(): unknown image format (smap)") << std::endl;
return false;
@@ -333,7 +333,7 @@
ScummBlock* dataID;
uint32 plusOffs = 0;
if (version > 4) {
- dataID = block->findChild("SMAP");
+ dataID = block->findChild("SMAP", true);
if (!dataID) {
errout << wxT("Image::drawObject(): unknown image format (smap)") << std::endl;
return false;
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummParser.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummParser.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummParser.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -25,6 +25,7 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+int _getScummVersionByFileName(wxString fileName);
int _getScummVersionDialog();
void ScummParser::create() {
@@ -64,43 +65,124 @@
}
int scummVersion = rootBlock->getScummVersion();
- if (scummVersion == -1) {
+ if (scummVersion == -1)
+ scummVersion = _getScummVersionByFileName(_ifile->getName());
+ if (scummVersion == -1)
scummVersion = _getScummVersionDialog();
- rootBlock->setScummVersion(scummVersion);
- }
+ rootBlock->setScummVersion(scummVersion);
_block = block;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Silly scumm version recognition:
+
+/*
+int _getScummVersionByFileNameAndStream(wxString fileName, Common::SeekableReadStream* stream) {
+ ASSERT(stream);
+
+ fileName.UpperCase();
+ if (fileName.EndsWith(wxT(".LFL"))) //v3/4 not supported yet
+ return -1;
+
+ int scV = -1;
+ if (fileName.EndsWith(wxT(".000"))) //v5/6
+ scV = 5;
+ if (fileName.EndsWith(wxT(".001"))) //v5/6
+ scV = 5;
+ if (fileName.EndsWith(wxT(".LA0"))) //v7/8
+ scV = 7;
+ if (fileName.EndsWith(wxT(".LA1"))) //v7/8
+ scV = 7;
+
+ if (scV == -1)
+ return -1;
+
+ return scV;
+}
+*/
+
+int _getScummVersionByFileName(wxString fileName) {
+ fileName.UpperCase();
+ if (fileName == wxT("SAMNMAX.SM0"))
+ return 6;
+ if (fileName == wxT("SAMNMAX.SM1"))
+ return 6;
+ if (fileName == wxT("SAMDEMO.000"))
+ return 6;
+ if (fileName == wxT("SAMDEMO.001"))
+ return 6;
+ if (fileName == wxT("ATLANTIS.000"))
+ return 5;
+ if (fileName == wxT("ATLANTIS.001"))
+ return 5;
+ if (fileName == wxT("MONKEY.000"))
+ return 4;
+ if (fileName == wxT("MONKEY.001"))
+ return 4;
+ if (fileName == wxT("MONKEY2.000"))
+ return 5;
+ if (fileName == wxT("MONKEY2.001"))
+ return 5;
+ if (fileName == wxT("TENTACLE.000"))
+ return 6;
+ if (fileName == wxT("TENTACLE.001"))
+ return 6;
+ if (fileName == wxT("DOTTDEMO.000"))
+ return 6;
+ if (fileName == wxT("DOTTDEMO.001"))
+ return 6;
+ if (fileName == wxT("FT.000"))
+ return 7;
+ if (fileName == wxT("FT.001"))
+ return 7;
+ if (fileName == wxT("FT.LA0"))
+ return 7;
+ if (fileName == wxT("FT.LA1"))
+ return 7;
+ if (fileName == wxT("DIG.LA0"))
+ return 7;
+ if (fileName == wxT("DIG.LA1"))
+ return 7;
+ if (fileName == wxT("COMI.LA0"))
+ return 8;
+ if (fileName == wxT("COMI.LA1"))
+ return 8;
+ if (fileName == wxT("COMI.LA2"))
+ return 8;
+ return -1;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
// taken from ScummEX
int _getScummVersionDialog() {
int choice;
wxString games[22] = {
- wxT("Maniac Mansion (C64)"),
- wxT("Maniac Mansion (PC)"),
- wxT("Zak McKracken"),
- wxT("Zak McKracken (FM Towns)"),
- wxT("Indiana Jones & The Last Crusade"),
- wxT("Sampler (Loom, Indy3, SOMI)"),
- wxT("The Secret of Monkey Island (Demo)"),
- wxT("The Secret of Monkey Island (EGA)"),
- wxT("The Secret of Monkey Island"),
- wxT("Loom"),
- wxT("Loom (CD)"),
- wxT("Monkey Island 2: LeChuck's Revenge"),
- wxT("Indiana Jones & The Fate of Atlantis"),
- wxT("Day of the Tentacle"),
- wxT("Sam & Max Hit The Road (Demo)"),
- wxT("Sam & Max Hit The Road (Mac demo)"),
- wxT("Sam & Max Hit The Road (Disk)"),
- wxT("Sam & Max Hit The Road (CD)"),
- wxT("Full Throttle"),
- wxT("The Dig"),
- wxT("The Dig (Win95)"),
- wxT("The Curse of Monkey Island")
+ /* 0 */ wxT("Maniac Mansion (C64)"),
+ /* 1 */ wxT("Maniac Mansion (PC)"),
+ /* 2 */ wxT("Zak McKracken"),
+ /* 3 */ wxT("Zak McKracken (FM Towns)"),
+ /* 4 */ wxT("Indiana Jones & The Last Crusade"),
+ /* 5 */ wxT("Sampler (Loom, Indy3, SOMI)"),
+ /* 6 */ wxT("The Secret of Monkey Island (Demo)"),
+ /* 7 */ wxT("The Secret of Monkey Island (EGA)"),
+ /* 8 */ wxT("The Secret of Monkey Island"),
+ /* 9 */ wxT("Loom"),
+ /* 10 */ wxT("Loom (CD)"),
+ /* 11 */ wxT("Monkey Island 2: LeChuck's Revenge"),
+ /* 12 */ wxT("Indiana Jones & The Fate of Atlantis"),
+ /* 13 */ wxT("Day of the Tentacle"),
+ /* 14 */ wxT("Sam & Max Hit The Road (Demo)"),
+ /* 15 */ wxT("Sam & Max Hit The Road (Mac demo)"),
+ /* 16 */ wxT("Sam & Max Hit The Road (Disk)"),
+ /* 17 */ wxT("Sam & Max Hit The Road (CD)"),
+ /* 18 */ wxT("Full Throttle"),
+ /* 19 */ wxT("The Dig"),
+ /* 20 */ wxT("The Dig (Win95)"),
+ /* 21 */ wxT("The Curse of Monkey Island")
};
wxSingleChoiceDialog *dialog = new wxSingleChoiceDialog(PluginUtil::getMainForm(), wxT("Please select the correct game"), wxT("Scumm version selection"), 22, games, NULL, wxOK|wxCANCEL|wxCENTRE, wxDefaultPosition);
@@ -134,9 +216,9 @@
case 13:
case 14:
case 16:
+ case 17:
ret = 6;
break;
- case 17:
case 18:
case 19:
ret = 7;
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummPresenterBase.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummPresenterBase.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummPresenterBase.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -19,7 +19,8 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
-// This file contains abstract base classes for ScummBlockPresenters.
+// This file contains abstract base classes for ScummBlockPresenters, and
+// some helpers (READ_STRING(), etc.)
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -149,12 +150,25 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Helpers
-inline
-wxString toHex(uint32 num, int digits = 8) {
- return wxString::Format(wxString::Format(wxT("%%0%dX"), digits), num);
-}
+#define DEF_STRING(varName, len) \
+ char varName[len + 1]
+#define READ_STRING(varName, stream) \
+ do { \
+ int len = sizeof(varName) - 1; \
+ stream->read(varName, len); \
+ varName[len] = '\0'; \
+ } while(false)
+
+#define XOR_STRING(varName, xorbyte) \
+ do { \
+ int len = sizeof(varName) - 1; \
+ for (int i = 0; i < len; ++i) \
+ varName[i] ^= xorbyte; \
+ } while(false)
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -5,6 +5,7 @@
#include "scumm/ScummSpecificPresenters.h"
#include "scumm/ScummResource.h"
+#include "scumm/CustomScummBlocks.h"
#include "CoreInterfaces.h"
#include "PluginUtil.h"
@@ -20,25 +21,6 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-wxString ScummLOFFBlockPresenter::doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream) {
- return wxString::Format(wxT("Number of rooms: %d\n\n"), _numEntries);
-}
-
-wxString ScummLOFFBlockPresenter::doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream) {
- //infoout << wxT("ScummLOFFBlockPresenter::doReadEntry(): ") << std::endl;
-
- byte roomNumber = stream->readByte();
- uint32 offset = stream->readUint32LE();
-
- wxString txt;
- txt << wxT("Room Number: ") << roomNumber << wxEndl();
- txt << wxT("Offset: ") << toHex(offset) << wxEndl();
- return txt;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
wxString ScummOFFSBlockPresenter::doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream) {
return wxString::Format(wxT("Number of offsets: %d\n\n"), _numEntries);
}
@@ -49,6 +31,7 @@
uint32 offset = stream->readUint32LE();
wxString txt;
+ txt << idx << wxT(": ");
txt << wxT("Offset: ") << toHex(offset) << wxEndl();
return txt;
}
@@ -86,4 +69,57 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+void ScummNLSCBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummNLSCBlockPresenter::doCreate(): ") << std::endl;
+
+ uint32 numberOfLocalScripts = stream->readUint16LE();
+
+ wxString txt;
+ txt << wxT("Number of local scripts: ") << numberOfLocalScripts << wxEndl();
+ _text = txt;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+void ScummLOFFBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummNLSCBlockPresenter::doCreate(): ") << std::endl;
+
+ ScummLOFFBlock* loffBlock = dynamic_cast<ScummLOFFBlock*>(block);
+ ASSERT(loffBlock);
+
+ const std::vector<ScummLOFFBlock::LOFFEntry>& offsets = loffBlock->getOffsets();
+
+ wxString txt;
+ txt << wxT("Number of rooms: ") << offsets.size() << wxEndl() << wxEndl();
+ for (int i = 0; i < offsets.size(); ++i) {
+ ScummLOFFBlock::LOFFEntry entry = offsets[i];
+ txt << i << wxT(": ");
+ txt << wxT("Room Number: ") << entry.roomNumber;
+ txt << wxT(" Offset: ") << toHex(entry.offset) << wxEndl();
+ }
+ _text = txt;
+}
+
+/*
+wxString ScummLOFFBlockPresenter::doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream) {
+ return wxString::Format(wxT("Number of rooms: %d\n\n"), _numEntries);
+}
+
+wxString ScummLOFFBlockPresenter::doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream) {
+ //infoout << wxT("ScummLOFFBlockPresenter::doReadEntry(): ") << std::endl;
+
+ byte roomNumber = stream->readByte();
+ uint32 offset = stream->readUint32LE();
+
+ wxString txt;
+ txt << idx << wxT(": ");
+ txt << wxT("Room Number: ") << roomNumber << wxEndl();
+ txt << wxT("Offset: ") << toHex(offset) << wxEndl();
+ return txt;
+}
+*/
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
} // namespace Browser
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.h
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.h 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters.h 2007-07-19 19:58:19 UTC (rev 28148)
@@ -16,21 +16,25 @@
/////////////////////////////////////////////////////////////////////////////
//
// This file declares presenters specific for the following scumm chunks:
-// LOFF
// OFFS
// RMHD
// TRNS
+// NLSC
+// LOFF
// They are pretty self explanatory.
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-class SCUMM_PLUGIN_API ScummLOFFBlockPresenter : public ScummEntryBlockPresenter {
- DECLARE_BOBJECT_CLASS(ScummLOFFBlockPresenter, ScummEntryBlockPresenter)
+class SCUMM_PLUGIN_API ScummOFFSBlockPresenter : public ScummEntryBlockPresenter {
+ DECLARE_BOBJECT_CLASS(ScummOFFSBlockPresenter, ScummEntryBlockPresenter)
public:
ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+ ScummOFFSBlockPresenter()
+ : ScummEntryBlockPresenter(ENTRY_COUNT_MODE_CUSTOM, 4) {}
+
virtual wxString doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream);
virtual wxString doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream);
};
@@ -38,24 +42,32 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-class SCUMM_PLUGIN_API ScummOFFSBlockPresenter : public ScummEntryBlockPresenter {
- DECLARE_BOBJECT_CLASS(ScummOFFSBlockPresenter, ScummEntryBlockPresenter)
+class SCUMM_PLUGIN_API ScummRMHDBlockPresenter : public ScummBlockTextPresenter {
+ DECLARE_BOBJECT_CLASS(ScummRMHDBlockPresenter, ScummBlockTextPresenter)
public:
ASSIGN_DESC(0,wxT("ScummObjects"), 1)
- ScummOFFSBlockPresenter()
- : ScummEntryBlockPresenter(ENTRY_COUNT_MODE_CUSTOM, 4) {}
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
+};
- virtual wxString doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream);
- virtual wxString doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream);
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SCUMM_PLUGIN_API ScummTRNSBlockPresenter : public ScummBlockTextPresenter {
+ DECLARE_BOBJECT_CLASS(ScummTRNSBlockPresenter, ScummBlockTextPresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-class SCUMM_PLUGIN_API ScummRMHDBlockPresenter : public ScummBlockTextPresenter {
- DECLARE_BOBJECT_CLASS(ScummRMHDBlockPresenter, ScummBlockTextPresenter)
+class SCUMM_PLUGIN_API ScummNLSCBlockPresenter : public ScummBlockTextPresenter {
+ DECLARE_BOBJECT_CLASS(ScummNLSCBlockPresenter, ScummBlockTextPresenter)
public:
ASSIGN_DESC(0,wxT("ScummObjects"), 1)
@@ -66,8 +78,8 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-class SCUMM_PLUGIN_API ScummTRNSBlockPresenter : public ScummBlockTextPresenter {
- DECLARE_BOBJECT_CLASS(ScummTRNSBlockPresenter, ScummBlockTextPresenter)
+class SCUMM_PLUGIN_API ScummLOFFBlockPresenter : public ScummBlockTextPresenter {
+ DECLARE_BOBJECT_CLASS(ScummLOFFBlockPresenter, ScummBlockTextPresenter)
public:
ASSIGN_DESC(0,wxT("ScummObjects"), 1)
@@ -75,6 +87,17 @@
virtual void doCreate(ScummBlock* block, Common::SeekableReadStream* stream);
};
+
+/*class SCUMM_PLUGIN_API ScummLOFFBlockPresenter : public ScummEntryBlockPresenter {
+ DECLARE_BOBJECT_CLASS(ScummLOFFBlockPresenter, ScummEntryBlockPresenter)
+
+public:
+ ASSIGN_DESC(0,wxT("ScummObjects"), 1)
+
+ virtual wxString doPreEntries(ScummBlock* block, Common::SeekableReadStream* stream);
+ virtual wxString doReadEntry(ScummBlock* block, uint32 idx, Common::SeekableReadStream* stream);
+};*/
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Modified: scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters2.cpp
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters2.cpp 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/src/plugins/scumm/ScummSpecificPresenters2.cpp 2007-07-19 19:58:19 UTC (rev 28148)
@@ -46,25 +46,18 @@
/////////////////////////////////////////////////////////////////////////////
void ScummRNAMBlockPresenter::doCreate(ScummBlock* block, Common::SeekableReadStream* stream) {
- byte roomNo = stream->readByte();
-
- int scV = _guess_scumm_version(block);
- if (scV >= 6) {
+ _text << wxT("Rooms: ") << wxEndl() << wxEndl();
+ while (true) {
+ byte roomNo = stream->readByte();
if (roomNo == 0)
- _text << wxT("No room names are stored in this scumm version.") << wxEndl();
- else
- _text << wxT("ERROR") << wxEndl();
- return;
- }
+ break;
- char roomName[10];
- stream->read(roomName, 9);
- roomName[9] = '\0';
- for (int i = 0; i < 9; ++i)
- roomName[i] ^= 0xFF;
+ DEF_STRING(roomName, 9);
+ READ_STRING(roomName, stream);
+ XOR_STRING(roomName, 0xFF);
- _text << wxT("Room number: ") << roomNo << wxEndl();
- _text << wxT("Room name: ") << toString(roomName) << wxEndl();
+ _text << roomNo << wxT(": ") << toString(roomName) << wxEndl();
+ }
}
/////////////////////////////////////////////////////////////////////////////
@@ -186,7 +179,8 @@
byte state = ownerNState & 0x0F;
wxString txt;
- txt << wxT("Owner: ") << owner;
+ txt << idx << wxT(": ");
+ txt << wxT(" Owner: ") << owner;
txt << wxT(" State: ") << toHex(state, 1) << wxEndl();
return txt;
}
@@ -255,6 +249,7 @@
_text << wxT("Items: ") << numberOfItems << wxEndl();
for (int i = 0; i < numberOfItems; ++i) {
+ _text << i << wxT(": ");
_text << wxT("Item number: ") << itemNumbers[i] << wxEndl();
_text << wxT("Item offset: ") << toHex(itemOffsets[i]) << wxEndl();
}
Modified: scummex/branches/gsoc2007-gameresbrowser/vc8/scumm_plugin/scumm_plugin.vcproj
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/vc8/scumm_plugin/scumm_plugin.vcproj 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/vc8/scumm_plugin/scumm_plugin.vcproj 2007-07-19 19:58:19 UTC (rev 28148)
@@ -276,7 +276,7 @@
>
</File>
<File
- RelativePath="..\..\src\plugins\scumm\CustomScummBlocks.h"
+ RelativePath="..\..\src\plugins\scumm\CustomScummBlocks.inl"
>
</File>
<File
@@ -386,6 +386,10 @@
>
</File>
<File
+ RelativePath="..\..\src\plugins\scumm\CustomScummBlocks.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\plugins\scumm\descumm.h"
>
</File>
Modified: scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout
===================================================================
--- scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout 2007-07-19 12:19:36 UTC (rev 28147)
+++ scummex/branches/gsoc2007-gameresbrowser/wxdev/Browser.layout 2007-07-19 19:58:19 UTC (rev 28148)
@@ -25,7 +25,7 @@
TopLine=1
LeftChar=1
Open=1
-Top=1
+Top=0
[Editor_1]
CursorCol=1
CursorRow=1
@@ -45,11 +45,11 @@
LeftChar=1
[Editor_7]
CursorCol=1
-CursorRow=170
-TopLine=140
+CursorRow=171
+TopLine=141
LeftChar=1
Open=1
-Top=0
+Top=1
[Editor_6]
CursorCol=1
CursorRow=57
@@ -60,7 +60,7 @@
[Editor_8]
CursorCol=1
CursorRow=114
-TopLine=114
+TopLine=106
LeftChar=1
Open=1
Top=0
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