PINK: add loadTxt to ResourceMgr

This commit is contained in:
whiterandrek 2018-06-02 22:22:56 +03:00 committed by Eugene Sandulenko
parent b682ecb0ea
commit 442f725a5d
2 changed files with 28 additions and 18 deletions

View File

@ -48,14 +48,37 @@ void ResourceMgr::init(PinkEngine *game, Page *page) {
_resDescTable = orb->getResDescTable(objDesc);
}
void ResourceMgr::clear() {
delete[] _resDescTable;
_resDescTable = nullptr;
}
CelDecoder *ResourceMgr::loadCEL(Common::String &name) {
CelDecoder *decoder = new CelDecoder();
decoder->loadStream(getResourceStream(name));
return decoder;
}
Sound *ResourceMgr::loadSound(Common::String &name) {
return new Sound(_game->_mixer, getResourceStream(name));
}
Common::String ResourceMgr::loadText(Common::String &name) {
Common::SeekableReadStream *stream = getResourceStream(name);
char *txt = new char[stream->size()];
Common::String str(txt, stream->size());
delete txt;
return str;
}
static int resDescComp(const void *a, const void *b) {
return scumm_stricmp((char *) a, (char *) b);
}
PinkEngine *ResourceMgr::getGame() const {
return _game;
}
Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(Common::String &name) {
Common::SeekableReadStream *stream;
@ -69,22 +92,7 @@ Common::SafeSeekableSubReadStream *ResourceMgr::getResourceStream(Common::String
stream->seek(desc->offset);
return new Common::SafeSeekableSubReadStream(stream, desc->offset,
desc->offset + desc->size);
}
PinkEngine *ResourceMgr::getGame() const {
return _game;
}
CelDecoder *ResourceMgr::loadCEL(Common::String &name) {
CelDecoder *decoder = new CelDecoder();
decoder->loadStream(getResourceStream(name));
return decoder;
}
void ResourceMgr::clear() {
delete[] _resDescTable;
_resDescTable = nullptr;
desc->offset + desc->size);
}
} // End of namespace Pink

View File

@ -47,11 +47,13 @@ public:
~ResourceMgr();
void init(PinkEngine *game, Page *page);
void clear();
//Common::String loadText(Common::String &name);
Sound *loadSound(Common::String &name);
CelDecoder *loadCEL(Common::String &name);
Sound *loadSound(Common::String &name);
Common::String loadText(Common::String &name);
PinkEngine *getGame() const;
private: