NEVERHOOD: Add StaticData class
This commit is contained in:
parent
9d0e90bcd2
commit
ae4ef4e66d
6 changed files with 209 additions and 9 deletions
|
@ -18,7 +18,8 @@ MODULE_OBJS = \
|
||||||
screen.o \
|
screen.o \
|
||||||
smackerscene.o \
|
smackerscene.o \
|
||||||
smackerplayer.o \
|
smackerplayer.o \
|
||||||
sprite.o
|
sprite.o \
|
||||||
|
staticdata.o
|
||||||
|
|
||||||
# This module can be built as a plugin
|
# This module can be built as a plugin
|
||||||
ifdef BUILD_PLUGINS
|
ifdef BUILD_PLUGINS
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "neverhood/resourceman.h"
|
#include "neverhood/resourceman.h"
|
||||||
#include "neverhood/resource.h"
|
#include "neverhood/resource.h"
|
||||||
#include "neverhood/screen.h"
|
#include "neverhood/screen.h"
|
||||||
|
#include "neverhood/staticdata.h"
|
||||||
|
|
||||||
namespace Neverhood {
|
namespace Neverhood {
|
||||||
|
|
||||||
|
@ -62,6 +63,9 @@ Common::Error NeverhoodEngine::run() {
|
||||||
|
|
||||||
_isSaveAllowed = false;
|
_isSaveAllowed = false;
|
||||||
|
|
||||||
|
_staticData = new StaticData();
|
||||||
|
_staticData->load("neverhood.dat");
|
||||||
|
|
||||||
_screen = new Screen(this);
|
_screen = new Screen(this);
|
||||||
|
|
||||||
_res = new ResourceMan();
|
_res = new ResourceMan();
|
||||||
|
@ -176,9 +180,10 @@ Common::Error NeverhoodEngine::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete _gameModule;
|
delete _gameModule;
|
||||||
|
|
||||||
delete _res;
|
delete _res;
|
||||||
delete _screen;
|
delete _screen;
|
||||||
|
|
||||||
|
delete _staticData;
|
||||||
|
|
||||||
debug("Ok.");
|
debug("Ok.");
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct NeverhoodGameDescription;
|
||||||
class GameModule;
|
class GameModule;
|
||||||
class ResourceMan;
|
class ResourceMan;
|
||||||
class Screen;
|
class Screen;
|
||||||
|
class StaticData;
|
||||||
|
|
||||||
struct GameState {
|
struct GameState {
|
||||||
int sceneNum;
|
int sceneNum;
|
||||||
|
@ -74,6 +75,7 @@ public:
|
||||||
Screen *_screen;
|
Screen *_screen;
|
||||||
ResourceMan *_res;
|
ResourceMan *_res;
|
||||||
GameModule *_gameModule;
|
GameModule *_gameModule;
|
||||||
|
StaticData *_staticData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,10 @@
|
||||||
#include "neverhood/palette.h"
|
#include "neverhood/palette.h"
|
||||||
#include "neverhood/smackerplayer.h"
|
#include "neverhood/smackerplayer.h"
|
||||||
#include "neverhood/sprite.h"
|
#include "neverhood/sprite.h"
|
||||||
|
#include "neverhood/staticdata.h"
|
||||||
|
|
||||||
namespace Neverhood {
|
namespace Neverhood {
|
||||||
|
|
||||||
struct MessageListItem {
|
|
||||||
uint32 messageNum;
|
|
||||||
uint32 messageValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Scene : public Entity {
|
class Scene : public Entity {
|
||||||
public:
|
public:
|
||||||
Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects);
|
Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects);
|
||||||
|
@ -58,7 +54,7 @@ protected:
|
||||||
Common::Array<Entity*> _entities;
|
Common::Array<Entity*> _entities;
|
||||||
Common::Array<BaseSurface*> _surfaces;
|
Common::Array<BaseSurface*> _surfaces;
|
||||||
bool _systemCallbackFlag;
|
bool _systemCallbackFlag;
|
||||||
MessageListItem *_messageList;
|
MessageList *_messageList;
|
||||||
int _messageListIndex;
|
int _messageListIndex;
|
||||||
int _messageListCount;
|
int _messageListCount;
|
||||||
bool _messageListFlag1;
|
bool _messageListFlag1;
|
||||||
|
@ -77,7 +73,7 @@ protected:
|
||||||
Background *_background;
|
Background *_background;
|
||||||
bool _surfaceFlag;
|
bool _surfaceFlag;
|
||||||
bool _messageListFlag;
|
bool _messageListFlag;
|
||||||
MessageListItem *_messageList2;
|
MessageList *_messageList2;
|
||||||
int _messageListStatus;
|
int _messageListStatus;
|
||||||
SmackerPlayer *_smackerPlayer;
|
SmackerPlayer *_smackerPlayer;
|
||||||
void (Entity::*_savedUpdateHandlerCb)();
|
void (Entity::*_savedUpdateHandlerCb)();
|
||||||
|
|
121
engines/neverhood/staticdata.cpp
Normal file
121
engines/neverhood/staticdata.cpp
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "neverhood/staticdata.h"
|
||||||
|
|
||||||
|
namespace Neverhood {
|
||||||
|
|
||||||
|
StaticData::StaticData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticData::~StaticData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticData::load(const char *filename) {
|
||||||
|
|
||||||
|
Common::File fd;
|
||||||
|
|
||||||
|
if (!fd.open(filename))
|
||||||
|
error("StaticData::load() Could not open %s", filename);
|
||||||
|
|
||||||
|
fd.readUint32LE(); // magic
|
||||||
|
fd.readUint32LE(); // version
|
||||||
|
|
||||||
|
// Load message lists
|
||||||
|
uint32 messageListsCount = fd.readUint32LE();
|
||||||
|
debug("messageListsCount: %d", messageListsCount);
|
||||||
|
for (uint32 i = 0; i < messageListsCount; i++) {
|
||||||
|
MessageList *messageList = new MessageList();
|
||||||
|
uint32 id = fd.readUint32LE();
|
||||||
|
uint32 itemCount = fd.readUint32LE();
|
||||||
|
for (uint32 itemIndex = 0; itemIndex < itemCount; itemIndex++) {
|
||||||
|
MessageItem messageItem;
|
||||||
|
messageItem.messageNum = fd.readUint16LE();
|
||||||
|
messageItem.messageValue = fd.readUint32LE();
|
||||||
|
messageList->push_back(messageItem);
|
||||||
|
}
|
||||||
|
_messageLists[id] = messageList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load rect lists
|
||||||
|
uint32 rectListsCount = fd.readUint32LE();
|
||||||
|
debug("rectListsCount: %d", rectListsCount);
|
||||||
|
for (uint32 i = 0; i < rectListsCount; i++) {
|
||||||
|
RectList *rectList = new RectList();
|
||||||
|
uint32 id = fd.readUint32LE();
|
||||||
|
uint32 itemCount = fd.readUint32LE();
|
||||||
|
for (uint32 itemIndex = 0; itemIndex < itemCount; itemIndex++) {
|
||||||
|
RectItem rectItem;
|
||||||
|
rectItem.rect.x1 = fd.readUint16LE();
|
||||||
|
rectItem.rect.y1 = fd.readUint16LE();
|
||||||
|
rectItem.rect.x2 = fd.readUint16LE();
|
||||||
|
rectItem.rect.y2 = fd.readUint16LE();
|
||||||
|
uint32 subItemCount = fd.readUint32LE();
|
||||||
|
rectItem.subRects.reserve(subItemCount);
|
||||||
|
for (uint32 subItemIndex = 0; subItemIndex < subItemCount; subItemIndex++) {
|
||||||
|
SubRectItem subRectItem;
|
||||||
|
subRectItem.rect.x1 = fd.readUint16LE();
|
||||||
|
subRectItem.rect.y1 = fd.readUint16LE();
|
||||||
|
subRectItem.rect.x2 = fd.readUint16LE();
|
||||||
|
subRectItem.rect.y2 = fd.readUint16LE();
|
||||||
|
subRectItem.messageListId = fd.readUint32LE();
|
||||||
|
rectItem.subRects.push_back(subRectItem);
|
||||||
|
}
|
||||||
|
rectList->push_back(rectItem);
|
||||||
|
}
|
||||||
|
_rectLists[id] = rectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load hit rects
|
||||||
|
uint32 hitRectListsCount = fd.readUint32LE();
|
||||||
|
debug("hitRectListsCount: %d", hitRectListsCount);
|
||||||
|
for (uint32 i = 0; i < hitRectListsCount; i++) {
|
||||||
|
HitRectList *hitRectList = new HitRectList();
|
||||||
|
uint32 id = fd.readUint32LE();
|
||||||
|
uint32 itemCount = fd.readUint32LE();
|
||||||
|
for (uint32 itemIndex = 0; itemIndex < itemCount; itemIndex++) {
|
||||||
|
HitRect hitRect;
|
||||||
|
hitRect.rect.x1 = fd.readUint16LE();
|
||||||
|
hitRect.rect.y1 = fd.readUint16LE();
|
||||||
|
hitRect.rect.x2 = fd.readUint16LE();
|
||||||
|
hitRect.rect.y2 = fd.readUint16LE();
|
||||||
|
hitRect.type = fd.readUint16LE();
|
||||||
|
hitRectList->push_back(hitRect);
|
||||||
|
}
|
||||||
|
_hitRectLists[id] = hitRectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HitRectList *StaticData::getHitRectList(uint32 id) {
|
||||||
|
return _hitRectLists[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
RectList *StaticData::getRectList(uint32 id) {
|
||||||
|
return _rectLists[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageList *StaticData::getMessageList(uint32 id) {
|
||||||
|
return _messageLists[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End of namespace Neverhood
|
75
engines/neverhood/staticdata.h
Normal file
75
engines/neverhood/staticdata.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NEVERHOOD_STATICDATA_H
|
||||||
|
#define NEVERHOOD_STATICDATA_H
|
||||||
|
|
||||||
|
#include "common/array.h"
|
||||||
|
#include "common/hashmap.h"
|
||||||
|
#include "neverhood/neverhood.h"
|
||||||
|
#include "neverhood/graphics.h"
|
||||||
|
|
||||||
|
namespace Neverhood {
|
||||||
|
|
||||||
|
struct HitRect {
|
||||||
|
NRect rect;
|
||||||
|
uint16 type;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Common::Array<HitRect> HitRectList;
|
||||||
|
|
||||||
|
struct SubRectItem {
|
||||||
|
NRect rect;
|
||||||
|
uint32 messageListId;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RectItem {
|
||||||
|
NRect rect;
|
||||||
|
Common::Array<SubRectItem> subRects;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Common::Array<RectItem> RectList;
|
||||||
|
|
||||||
|
struct MessageItem {
|
||||||
|
uint16 messageNum;
|
||||||
|
uint32 messageValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Common::Array<MessageItem> MessageList;
|
||||||
|
|
||||||
|
class StaticData {
|
||||||
|
public:
|
||||||
|
StaticData();
|
||||||
|
~StaticData();
|
||||||
|
void load(const char *filename);
|
||||||
|
HitRectList *getHitRectList(uint32 id);
|
||||||
|
RectList *getRectList(uint32 id);
|
||||||
|
MessageList *getMessageList(uint32 id);
|
||||||
|
protected:
|
||||||
|
Common::HashMap<uint32, HitRectList*> _hitRectLists;
|
||||||
|
Common::HashMap<uint32, RectList*> _rectLists;
|
||||||
|
Common::HashMap<uint32, MessageList*> _messageLists;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End of namespace Neverhood
|
||||||
|
|
||||||
|
#endif /* NEVERHOOD_STATICDATA_H */
|
Loading…
Add table
Add a link
Reference in a new issue