ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

resource.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_RESOURCE_H
00024 #define GRIM_RESOURCE_H
00025 
00026 #include "common/archive.h"
00027 #include "common/array.h"
00028 
00029 #include "engines/grim/object.h"
00030 
00031 namespace Grim {
00032 
00033 class AnimationEmi;
00034 class CMap;
00035 class Costume;
00036 class Font;
00037 class KeyframeAnim;
00038 class Material;
00039 class Model;
00040 class EMIModel;
00041 class LipSync;
00042 class TrackedObject;
00043 class SaveGame;
00044 class Skeleton;
00045 class Sprite;
00046 class EMICostume;
00047 class Lab;
00048 class Actor;
00049 
00050 typedef ObjectPtr<Material> MaterialPtr;
00051 typedef ObjectPtr<Model> ModelPtr;
00052 typedef ObjectPtr<CMap> CMapPtr;
00053 typedef ObjectPtr<KeyframeAnim> KeyframeAnimPtr;
00054 typedef ObjectPtr<Font> FontPtr;
00055 typedef ObjectPtr<LipSync> LipSyncPtr;
00056 typedef ObjectPtr<AnimationEmi> AnimationEmiPtr;
00057 
00058 class ResourceLoader {
00059 public:
00060     ResourceLoader();
00061     ~ResourceLoader();
00062 
00063     CMap *loadColormap(const Common::String &fname);
00064     Costume *loadCostume(const Common::String &fname, Actor *owner, Costume *prevCost);
00065     Font *loadFont(const Common::String &fname);
00066     KeyframeAnim *loadKeyframe(const Common::String &fname);
00067     Material *loadMaterial(const Common::String &fname, CMap *c, bool clamp);
00068     Model *loadModel(const Common::String &fname, CMap *c, Model *parent = NULL);
00069     EMIModel *loadModelEMI(const Common::String &fname, EMICostume *costume);
00070     LipSync *loadLipSync(const Common::String &fname);
00071     Skeleton *loadSkeleton(const Common::String &fname);
00072     Sprite *loadSprite(const Common::String &fname, EMICostume *costume);
00073     AnimationEmi *loadAnimationEmi(const Common::String &filename);
00074     Common::SeekableReadStream *openNewStreamFile(Common::String fname, bool cache = false) const;
00075 
00076     ModelPtr getModel(const Common::String &fname, CMap *c);
00077     CMapPtr getColormap(const Common::String &fname);
00078     KeyframeAnimPtr getKeyframe(const Common::String &fname);
00079     LipSyncPtr getLipSync(const Common::String &fname);
00080     AnimationEmiPtr getAnimationEmi(const Common::String &fname);
00081     void uncacheModel(Model *m);
00082     void uncacheColormap(CMap *c);
00083     void uncacheKeyframe(KeyframeAnim *kf);
00084     void uncacheLipSync(LipSync *l);
00085     void uncacheAnimationEmi(AnimationEmi *a);
00086 
00087     struct ResourceCache {
00088         char *fname;
00089         byte *resPtr;
00090         uint32 len;
00091     };
00092 
00093     static Common::String fixFilename(const Common::String &filename, bool append = true);
00094 
00095 private:
00096     Common::SeekableReadStream *loadFile(const Common::String &filename) const;
00097     Common::SeekableReadStream *getFileFromCache(const Common::String &filename) const;
00098     ResourceLoader::ResourceCache *getEntryFromCache(const Common::String &filename) const;
00099     void putIntoCache(const Common::String &fname, byte *res, uint32 len) const;
00100     void uncache(const char *fname) const;
00101 
00102     mutable Common::Array<ResourceCache> _cache;
00103     mutable bool _cacheDirty;
00104     mutable int32 _cacheMemorySize;
00105 
00106     Common::List<EMIModel *> _emiModels;
00107     Common::List<Model *> _models;
00108     Common::List<CMap *> _colormaps;
00109     Common::List<KeyframeAnim *> _keyframeAnims;
00110     Common::List<LipSync *> _lipsyncs;
00111     Common::List<AnimationEmi *> _emiAnims;
00112 };
00113 
00114 extern ResourceLoader *g_resourceloader;
00115 
00116 } // end of namespace Grim
00117 
00118 #endif


Generated on Sat Apr 20 2019 05:03:48 for ResidualVM by doxygen 1.7.1
curved edge   curved edge