2021-12-26 20:19:38 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2008-06-13 14:57:47 +00:00
|
|
|
*
|
2021-12-26 20:19:38 +00:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
2008-06-13 14:57:47 +00:00
|
|
|
* file distributed with this source distribution.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-04-05 16:18:42 +00:00
|
|
|
*
|
2012-12-19 22:15:43 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2006-04-02 14:20:45 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-19 22:15:43 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-04-05 16:18:42 +00:00
|
|
|
*
|
2012-12-19 22:15:43 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
|
|
|
*/
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2009-05-26 09:39:42 +00:00
|
|
|
#ifndef GRIM_RESOURCE_H
|
|
|
|
#define GRIM_RESOURCE_H
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2009-04-05 14:48:54 +00:00
|
|
|
#include "common/archive.h"
|
2012-03-27 03:12:00 +00:00
|
|
|
#include "common/array.h"
|
2009-04-05 14:48:54 +00:00
|
|
|
|
2011-03-20 21:16:27 +00:00
|
|
|
#include "engines/grim/object.h"
|
2005-01-01 12:27:57 +00:00
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
namespace Grim {
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2012-01-30 21:24:09 +00:00
|
|
|
class AnimationEmi;
|
2003-10-05 17:45:46 +00:00
|
|
|
class CMap;
|
2003-08-15 18:00:22 +00:00
|
|
|
class Costume;
|
2005-03-18 19:54:40 +00:00
|
|
|
class Font;
|
2003-08-15 18:00:22 +00:00
|
|
|
class KeyframeAnim;
|
|
|
|
class Material;
|
|
|
|
class Model;
|
2011-12-30 11:39:45 +00:00
|
|
|
class EMIModel;
|
2009-04-21 18:04:24 +00:00
|
|
|
class LipSync;
|
2011-03-20 21:16:27 +00:00
|
|
|
class TrackedObject;
|
|
|
|
class SaveGame;
|
2011-12-30 14:10:32 +00:00
|
|
|
class Skeleton;
|
2013-07-08 00:18:30 +00:00
|
|
|
class Sprite;
|
2013-07-08 00:23:27 +00:00
|
|
|
class EMICostume;
|
2011-05-14 00:55:14 +00:00
|
|
|
class Lab;
|
2014-06-09 15:41:01 +00:00
|
|
|
class Actor;
|
2015-01-29 04:44:27 +00:00
|
|
|
class Overlay;
|
2011-03-20 21:16:27 +00:00
|
|
|
|
|
|
|
typedef ObjectPtr<Material> MaterialPtr;
|
|
|
|
typedef ObjectPtr<Model> ModelPtr;
|
|
|
|
typedef ObjectPtr<CMap> CMapPtr;
|
|
|
|
typedef ObjectPtr<KeyframeAnim> KeyframeAnimPtr;
|
|
|
|
typedef ObjectPtr<Font> FontPtr;
|
|
|
|
typedef ObjectPtr<LipSync> LipSyncPtr;
|
2014-05-28 11:49:11 +00:00
|
|
|
typedef ObjectPtr<AnimationEmi> AnimationEmiPtr;
|
2003-08-15 18:00:22 +00:00
|
|
|
|
|
|
|
class ResourceLoader {
|
|
|
|
public:
|
2009-06-26 18:48:13 +00:00
|
|
|
ResourceLoader();
|
|
|
|
~ResourceLoader();
|
2004-02-24 22:43:32 +00:00
|
|
|
|
2011-05-22 23:40:56 +00:00
|
|
|
CMap *loadColormap(const Common::String &fname);
|
2014-06-09 15:41:01 +00:00
|
|
|
Costume *loadCostume(const Common::String &fname, Actor *owner, Costume *prevCost);
|
2011-05-22 23:40:56 +00:00
|
|
|
Font *loadFont(const Common::String &fname);
|
|
|
|
KeyframeAnim *loadKeyframe(const Common::String &fname);
|
2014-06-18 01:58:21 +00:00
|
|
|
Material *loadMaterial(const Common::String &fname, CMap *c, bool clamp);
|
2011-07-18 21:43:01 +00:00
|
|
|
Model *loadModel(const Common::String &fname, CMap *c, Model *parent = NULL);
|
2013-12-22 20:29:58 +00:00
|
|
|
EMIModel *loadModelEMI(const Common::String &fname, EMICostume *costume);
|
2011-05-22 23:40:56 +00:00
|
|
|
LipSync *loadLipSync(const Common::String &fname);
|
2011-12-30 14:10:32 +00:00
|
|
|
Skeleton *loadSkeleton(const Common::String &fname);
|
2013-07-08 00:23:27 +00:00
|
|
|
Sprite *loadSprite(const Common::String &fname, EMICostume *costume);
|
2012-01-30 21:24:09 +00:00
|
|
|
AnimationEmi *loadAnimationEmi(const Common::String &filename);
|
2015-01-29 04:44:27 +00:00
|
|
|
Overlay *loadOverlay(const Common::String &filename);
|
2012-04-11 12:23:08 +00:00
|
|
|
Common::SeekableReadStream *openNewStreamFile(Common::String fname, bool cache = false) const;
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-05-22 23:40:56 +00:00
|
|
|
ModelPtr getModel(const Common::String &fname, CMap *c);
|
|
|
|
CMapPtr getColormap(const Common::String &fname);
|
|
|
|
KeyframeAnimPtr getKeyframe(const Common::String &fname);
|
|
|
|
LipSyncPtr getLipSync(const Common::String &fname);
|
2014-05-28 11:49:11 +00:00
|
|
|
AnimationEmiPtr getAnimationEmi(const Common::String &fname);
|
2011-03-20 21:16:27 +00:00
|
|
|
void uncacheModel(Model *m);
|
|
|
|
void uncacheColormap(CMap *c);
|
|
|
|
void uncacheKeyframe(KeyframeAnim *kf);
|
|
|
|
void uncacheLipSync(LipSync *l);
|
2014-05-28 11:49:11 +00:00
|
|
|
void uncacheAnimationEmi(AnimationEmi *a);
|
2011-03-20 21:16:27 +00:00
|
|
|
|
2009-05-12 14:31:48 +00:00
|
|
|
struct ResourceCache {
|
|
|
|
char *fname;
|
2011-12-21 10:00:08 +00:00
|
|
|
byte *resPtr;
|
|
|
|
uint32 len;
|
2009-05-12 14:31:48 +00:00
|
|
|
};
|
|
|
|
|
2012-08-12 16:00:23 +00:00
|
|
|
static Common::String fixFilename(const Common::String &filename, bool append = true);
|
|
|
|
|
2009-06-26 18:48:13 +00:00
|
|
|
private:
|
2012-04-11 12:23:08 +00:00
|
|
|
Common::SeekableReadStream *loadFile(const Common::String &filename) const;
|
|
|
|
Common::SeekableReadStream *getFileFromCache(const Common::String &filename) const;
|
|
|
|
ResourceLoader::ResourceCache *getEntryFromCache(const Common::String &filename) const;
|
|
|
|
void putIntoCache(const Common::String &fname, byte *res, uint32 len) const;
|
2012-04-11 18:41:32 +00:00
|
|
|
void uncache(const char *fname) const;
|
2012-04-11 12:23:08 +00:00
|
|
|
|
|
|
|
mutable Common::Array<ResourceCache> _cache;
|
|
|
|
mutable bool _cacheDirty;
|
|
|
|
mutable int32 _cacheMemorySize;
|
2011-03-20 21:16:27 +00:00
|
|
|
|
2011-12-30 11:39:45 +00:00
|
|
|
Common::List<EMIModel *> _emiModels;
|
2011-03-20 21:16:27 +00:00
|
|
|
Common::List<Model *> _models;
|
|
|
|
Common::List<CMap *> _colormaps;
|
|
|
|
Common::List<KeyframeAnim *> _keyframeAnims;
|
|
|
|
Common::List<LipSync *> _lipsyncs;
|
2014-05-28 11:49:11 +00:00
|
|
|
Common::List<AnimationEmi *> _emiAnims;
|
2003-08-15 18:00:22 +00:00
|
|
|
};
|
|
|
|
|
2004-12-31 21:35:04 +00:00
|
|
|
extern ResourceLoader *g_resourceloader;
|
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
} // end of namespace Grim
|
|
|
|
|
2003-08-15 18:00:22 +00:00
|
|
|
#endif
|