ScummVM API documentation
resource.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef RESOURCE_H
23 #define RESOURCE_H
24 
25 #include "common/memstream.h"
26 #include "common/platform.h"
27 #include "common/str.h"
28 #include "common/stream.h"
29 
30 #include "startrek/iwfile.h"
31 
32 namespace Common {
33 class MacResManager;
34 }
35 
36 namespace StarTrek {
37 
38 struct ResourceIndex {
39  uint32 indexOffset;
40  bool foundData;
41  uint16 fileCount;
42  uint16 uncompressedSize; // used in the demo
43  Common::String fileName;
44 
45  ResourceIndex() {
46  indexOffset = 0;
47  foundData = 0;
48  fileCount = 0;
49  uncompressedSize = 0;
50  fileName = "";
51  }
52 };
53 
54 class Resource {
55 public:
56  Resource(Common::Platform platform, bool isDemo);
57  virtual ~Resource();
58 
59  Common::List<ResourceIndex> searchIndex(Common::String filename);
60  Common::MemoryReadStreamEndian *loadFile(Common::String filename, int fileIndex = 0, bool errorOnNotFound = true);
61  Common::MemoryReadStreamEndian *loadBitmapFile(Common::String baseName);
62 
66  Common::MemoryReadStreamEndian *loadFileWithParams(Common::String filename, bool unk1, bool unk2, bool unk3);
67 
72  Common::String getLoadedText(int textIndex);
73 
74  void setTxtFileName(Common::String txtFileName) {
75  _txtFilename = txtFileName;
76  }
77 
78  Common::List<ResourceIndex> _resources;
79 
80 private:
81  void readIndexFile();
82  ResourceIndex getIndex(Common::String filename);
83  ResourceIndex getIndexEntry(Common::SeekableReadStream *indexFile);
84  Common::MemoryReadStreamEndian *loadSequentialFile(Common::String filename, int fileIndex = 0);
85  uint32 getSequentialFileOffset(uint32 offset, int fileIndex);
86 
87  //IWFile *_iwFile;
88  Common::MacResManager *_macResFork;
89  Common::Platform _platform;
90  bool _isDemo;
91  Common::String _txtFilename;
92  //Common::List<ResourceIndex> _resources;
93 };
94 
95 } // End of namespace StarTrek
96 
97 #endif
Definition: macresman.h:125
Definition: str.h:59
Definition: list.h:44
Definition: stream.h:745
Definition: memstream.h:103
Definition: resource.h:54
Definition: algorithm.h:29
Definition: action.h:27
Definition: resource.h:38
Platform
Definition: platform.h:46