scummvm/engines/grim/resource.h

120 lines
3.8 KiB
C
Raw Normal View History

2021-12-26 20:19:38 +00:00
/* ScummVM - Graphic Adventure Engine
*
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
* file distributed with this source distribution.
2006-04-02 14:20:45 +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
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2014-04-05 16:18:42 +00:00
*
* You should have received a copy of the GNU General Public License
* 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
#include "common/archive.h"
#include "common/array.h"
#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
class AnimationEmi;
class CMap;
2003-08-15 18:00:22 +00:00
class Costume;
class Font;
2003-08-15 18:00:22 +00:00
class KeyframeAnim;
class Material;
class Model;
class EMIModel;
2009-04-21 18:04:24 +00:00
class LipSync;
class TrackedObject;
class SaveGame;
2011-12-30 14:10:32 +00:00
class Skeleton;
2013-07-08 00:18:30 +00:00
class Sprite;
class EMICostume;
2011-05-14 00:55:14 +00:00
class Lab;
class Actor;
class Overlay;
typedef ObjectPtr<Material> MaterialPtr;
typedef ObjectPtr<Model> ModelPtr;
typedef ObjectPtr<CMap> CMapPtr;
typedef ObjectPtr<KeyframeAnim> KeyframeAnimPtr;
typedef ObjectPtr<Font> FontPtr;
typedef ObjectPtr<LipSync> LipSyncPtr;
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();
CMap *loadColormap(const Common::String &fname);
Costume *loadCostume(const Common::String &fname, Actor *owner, Costume *prevCost);
Font *loadFont(const Common::String &fname);
KeyframeAnim *loadKeyframe(const Common::String &fname);
Material *loadMaterial(const Common::String &fname, CMap *c, bool clamp);
Model *loadModel(const Common::String &fname, CMap *c, Model *parent = NULL);
EMIModel *loadModelEMI(const Common::String &fname, EMICostume *costume);
LipSync *loadLipSync(const Common::String &fname);
2011-12-30 14:10:32 +00:00
Skeleton *loadSkeleton(const Common::String &fname);
Sprite *loadSprite(const Common::String &fname, EMICostume *costume);
AnimationEmi *loadAnimationEmi(const Common::String &filename);
Overlay *loadOverlay(const Common::String &filename);
Common::SeekableReadStream *openNewStreamFile(Common::String fname, bool cache = false) const;
2003-08-15 18:00:22 +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);
AnimationEmiPtr getAnimationEmi(const Common::String &fname);
void uncacheModel(Model *m);
void uncacheColormap(CMap *c);
void uncacheKeyframe(KeyframeAnim *kf);
void uncacheLipSync(LipSync *l);
void uncacheAnimationEmi(AnimationEmi *a);
2009-05-12 14:31:48 +00:00
struct ResourceCache {
char *fname;
byte *resPtr;
uint32 len;
2009-05-12 14:31:48 +00:00
};
static Common::String fixFilename(const Common::String &filename, bool append = true);
2009-06-26 18:48:13 +00:00
private:
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;
void uncache(const char *fname) const;
mutable Common::Array<ResourceCache> _cache;
mutable bool _cacheDirty;
mutable int32 _cacheMemorySize;
Common::List<EMIModel *> _emiModels;
Common::List<Model *> _models;
Common::List<CMap *> _colormaps;
Common::List<KeyframeAnim *> _keyframeAnims;
Common::List<LipSync *> _lipsyncs;
Common::List<AnimationEmi *> _emiAnims;
2003-08-15 18:00:22 +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