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 GRIM_RESOURCE_H
23 #define GRIM_RESOURCE_H
24 
25 #include "common/archive.h"
26 #include "common/array.h"
27 
28 #include "engines/grim/object.h"
29 
30 namespace Grim {
31 
32 class AnimationEmi;
33 class CMap;
34 class Costume;
35 class Font;
36 class KeyframeAnim;
37 class Material;
38 class Model;
39 class EMIModel;
40 class LipSync;
41 class TrackedObject;
42 class SaveGame;
43 class Skeleton;
44 class Sprite;
45 class EMICostume;
46 class Lab;
47 class Actor;
48 class Overlay;
49 
50 typedef ObjectPtr<Material> MaterialPtr;
51 typedef ObjectPtr<Model> ModelPtr;
52 typedef ObjectPtr<CMap> CMapPtr;
53 typedef ObjectPtr<KeyframeAnim> KeyframeAnimPtr;
54 typedef ObjectPtr<Font> FontPtr;
55 typedef ObjectPtr<LipSync> LipSyncPtr;
56 typedef ObjectPtr<AnimationEmi> AnimationEmiPtr;
57 
59 public:
61  ~ResourceLoader();
62 
63  CMap *loadColormap(const Common::String &fname);
64  Costume *loadCostume(const Common::String &fname, Actor *owner, Costume *prevCost);
65  Font *loadFont(const Common::String &fname);
66  KeyframeAnim *loadKeyframe(const Common::String &fname);
67  Material *loadMaterial(const Common::String &fname, CMap *c, bool clamp);
68  Model *loadModel(const Common::String &fname, CMap *c, Model *parent = NULL);
69  EMIModel *loadModelEMI(const Common::String &fname, EMICostume *costume);
70  LipSync *loadLipSync(const Common::String &fname);
71  Skeleton *loadSkeleton(const Common::String &fname);
72  Sprite *loadSprite(const Common::String &fname, EMICostume *costume);
73  AnimationEmi *loadAnimationEmi(const Common::String &filename);
74  Overlay *loadOverlay(const Common::String &filename);
75  Common::SeekableReadStream *openNewStreamFile(const Common::String &fname, bool cache = false) const;
76 
77  ModelPtr getModel(const Common::String &fname, CMap *c);
78  CMapPtr getColormap(const Common::String &fname);
79  KeyframeAnimPtr getKeyframe(const Common::String &fname);
80  LipSyncPtr getLipSync(const Common::String &fname);
81  AnimationEmiPtr getAnimationEmi(const Common::String &fname);
82  void uncacheModel(Model *m);
83  void uncacheColormap(CMap *c);
84  void uncacheKeyframe(KeyframeAnim *kf);
85  void uncacheLipSync(LipSync *l);
86  void uncacheAnimationEmi(AnimationEmi *a);
87 
88  struct ResourceCache {
89  char *fname;
90  byte *resPtr;
91  uint32 len;
92  };
93 
94  static Common::String fixFilename(const Common::String &filename, bool append = true);
95 
96 private:
97  Common::SeekableReadStream *loadFile(const Common::Path &filename) const;
98  Common::SeekableReadStream *getFileFromCache(const Common::Path &filename) const;
99  ResourceLoader::ResourceCache *getEntryFromCache(const Common::Path &filename) const;
100  void putIntoCache(const Common::Path &fname, byte *res, uint32 len) const;
101  void uncache(const Common::Path &fname) const;
102 
103  mutable Common::Array<ResourceCache> _cache;
104  mutable bool _cacheDirty;
105  mutable int32 _cacheMemorySize;
106 
107  Common::List<EMIModel *> _emiModels;
108  Common::List<Model *> _models;
109  Common::List<CMap *> _colormaps;
110  Common::List<KeyframeAnim *> _keyframeAnims;
111  Common::List<LipSync *> _lipsyncs;
113 };
114 
115 extern ResourceLoader *g_resourceloader;
116 
117 } // end of namespace Grim
118 
119 #endif
Definition: str.h:59
Definition: modelemi.h:82
Definition: overlay.h:33
Definition: array.h:52
Definition: list.h:44
Definition: path.h:52
Definition: resource.h:88
Definition: stream.h:745
Definition: actor.h:33
Definition: material.h:64
Definition: skeleton.h:68
Definition: sprite.h:38
Definition: anim.h:33
Definition: lipsync.h:35
Definition: keyframe.h:38
Definition: colormap.h:35
Definition: costumeemi.h:40
Definition: model.h:43
Definition: default_display_client.h:65
Definition: font.h:38
Actor represents a 3D character on screen.
Definition: actor.h:72
Definition: animationemi.h:60
Definition: resource.h:58
Definition: costume.h:45