24 #ifndef SAGA_RESOURCE_H 25 #define SAGA_RESOURCE_H 27 #include "common/array.h" 28 #include "common/file.h" 29 #include "common/list.h" 34 #define RSC_TABLEINFO_SIZE 8 35 #define RSC_TABLEENTRY_SIZE 8 37 #define RSC_MIN_FILESIZE (RSC_TABLEINFO_SIZE + RSC_TABLEENTRY_SIZE + 1) 45 const char *_fileName;
46 bool _deletePatchFile;
47 bool _patchFileOpened;
50 PatchData(
const char *fileName): _fileName(fileName), _deletePatchFile(
true), _patchFile(
nullptr), _patchFileOpened(
false) {
60 _patchFileOpened =
true;
61 if (!file->
open(_fileName)) {
71 if (_deletePatchFile && _patchFileOpened) {
74 _patchFileOpened =
false;
79 if (_deletePatchFile) {
92 offset(0), size(0), patchData(NULL), diskNum(-1) {
110 _fileName(NULL), _fileType(0), _isCompressed(
false), _serial(0),
112 _fileSize(0), _tombstone(
false) {
117 bool isCompressed()
const {
return _isCompressed; }
118 uint16 fileType()
const {
return _fileType; }
119 int32 fileSize()
const {
return _fileSize; }
120 int serial()
const {
return _serial; }
121 bool isBigEndian()
const {
return _isBigEndian; }
122 const char * fileName()
const {
return _fileName; }
125 if (resourceData && resourceData->patchData != NULL) {
126 return resourceData->patchData->getStream();
128 if (!_file && !_tombstone)
137 bool validResourceId(uint32 resourceId)
const {
138 return (resourceId < _table.size());
142 if (resourceId >= _table.size()) {
143 error(
"ResourceContext::getResourceData() wrong resourceId %d", resourceId);
145 return &_table[resourceId];
153 const char *_fileName;
159 ResourceDataArray _table;
167 bool loadResIteAmiga(
SagaEngine *_vm,
int type,
bool isFloppy);
168 bool loadResIteAmigaSound(
SagaEngine *_vm,
int type);
170 virtual bool loadRes(
SagaEngine *_vm,
int type) = 0;
179 int32 objectsStringsResourceID;
180 int32 inventorySpritesID;
182 int32 objectsResourceID;
184 int32 actorsStringsResourceID;
185 int32 actorsResourceID;
186 int32 protagFaceSpritesID;
189 int16 protagStatesCount;
190 int32 protagStatesResourceID;
191 int32 cutawayListResourceID;
195 memset(
this, 0,
sizeof(*
this));
203 bool createContexts();
204 void clearContexts();
207 virtual uint32 convertResourceId(uint32 resourceId) = 0;
208 virtual void loadGlobalResources(
int chapter,
int actorsEntrance) = 0;
214 ResourceContextList _contexts;
215 char _voicesFileName[8][256];
216 char _musicFileName[256];
217 char _soundFileName[256];
219 void addContext(
const char *fileName, uint16 fileType,
bool isCompressed =
false,
int serial = 0);
226 bool loadRes(
SagaEngine *_vm,
int type)
override {
237 bool loadRes(
SagaEngine *_vm,
int type)
override {
238 return loadResIteAmiga(_vm, type, _isFloppy);
247 uint32 convertResourceId(uint32 resourceId)
override {
248 return _vm->isMacResources() ? resourceId - 2 : resourceId;
250 void loadGlobalResources(
int chapter,
int actorsEntrance)
override {}
257 if (_vm->getPlatform() == Common::kPlatformAmiga && _vm->getGameId() == GID_ITE) {
268 bool loadRes(
SagaEngine *_vm,
int type)
override {
278 bool loadRes(
SagaEngine *_vm,
int type)
override {
283 _fileType = GAME_VOICEFILE;
288 class Resource_RES :
public Resource {
291 uint32 convertResourceId(uint32 resourceId)
override {
return resourceId; }
292 void loadGlobalResources(
int chapter,
int actorsEntrance)
override;
293 MetaResource* getMetaResource()
override {
return &_metaResource; }
296 return new ResourceContext_RES();
Definition: resource.h:105
Definition: resource.h:244
virtual bool open(const Path &filename)
Definition: resource.h:232
Definition: resource.h:199
Definition: resource.h:85
Definition: resource.h:224
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: resource.h:42
static SeekableReadStream * openFileOrDataFork(const Path &fileName, Archive &archive)