ScummVM API documentation
animationresource.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 /*
23  * This code is based on Broken Sword 2.5 engine
24  *
25  * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26  *
27  * Licensed under GNU GPL v2
28  *
29  */
30 
31 #ifndef SWORD25_ANIMATIONRESOURCE_H
32 #define SWORD25_ANIMATIONRESOURCE_H
33 
34 #include "common/formats/xmlparser.h"
35 #include "sword25/kernel/common.h"
36 #include "sword25/kernel/resource.h"
37 #include "sword25/gfx/animationdescription.h"
38 #include "sword25/gfx/animation.h"
39 
40 namespace Sword25 {
41 
42 class Kernel;
43 class PackageManager;
44 
46 public:
47  AnimationResource(const Common::String &filename);
48  ~AnimationResource() override;
49 
50  const Frame &getFrame(uint index) const override {
51  return _frames[index];
52  }
53  uint getFrameCount() const override {
54  return _frames.size();
55  }
56  void unlock() override {
57  release();
58  }
59 
60  Animation::ANIMATION_TYPES getAnimationType() const {
61  return _animationType;
62  }
63  int getFPS() const {
64  return _FPS;
65  }
66  int getMillisPerFrame() const {
67  return _millisPerFrame;
68  }
69  bool isScalingAllowed() const {
70  return _scalingAllowed;
71  }
72  bool isAlphaAllowed() const {
73  return _alphaAllowed;
74  }
75  bool isColorModulationAllowed() const {
76  return _colorModulationAllowed;
77  }
78  bool isValid() const {
79  return _valid;
80  }
81 
82 private:
83  bool _valid;
84 
85  Common::Array<Frame> _frames;
86 
87  PackageManager *_pPackage;
88 
89 
90  bool computeFeatures();
91  bool precacheAllFrames() const;
92 
93  // Parser
94  CUSTOM_XML_PARSER(AnimationResource) {
95  XML_KEY(animation)
96  XML_PROP(fps, true)
97  XML_PROP(type, true)
98 
99  XML_KEY(frame)
100  XML_PROP(file, true)
101  XML_PROP(hotspotx, true)
102  XML_PROP(hotspoty, true)
103  XML_PROP(fliph, false)
104  XML_PROP(flipv, false)
105  KEY_END()
106  KEY_END()
107  } PARSER_END()
108 
109  bool parseBooleanKey(Common::String s, bool &result);
110 
111  // Parser callback methods
112  bool parserCallback_animation(ParserNode *node);
113  bool parserCallback_frame(ParserNode *node);
114 };
115 
116 } // End of namespace Sword25
117 
118 #endif
Definition: str.h:59
Definition: packagemanager.h:71
Definition: animationdescription.h:52
Definition: xmlparser.h:145
Definition: resource.h:43
Definition: xmlparser.h:98
Definition: console.h:27
Definition: animationdescription.h:40
size_type size() const
Definition: array.h:315
Definition: animationresource.h:45