ScummVM API documentation
animationtemplate.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_ANIMATION_TEMPLATE_H
32 #define SWORD25_ANIMATION_TEMPLATE_H
33 
34 // -----------------------------------------------------------------------------
35 // Includes
36 // -----------------------------------------------------------------------------
37 
38 #include "sword25/kernel/common.h"
39 #include "sword25/kernel/persistable.h"
40 #include "sword25/gfx/animationdescription.h"
41 
42 namespace Sword25 {
43 
44 class AnimationResource;
45 
47 public:
48  static uint create(const Common::String &sourceAnimation);
49  static uint create(const AnimationTemplate &other);
50  static uint create(InputPersistenceBlock &reader, uint handle);
51  AnimationTemplate *resolveHandle(uint handle) const;
52 
53 private:
54  AnimationTemplate(const Common::String &sourceAnimation);
56  AnimationTemplate(InputPersistenceBlock &reader, uint handle);
57 
58 public:
59  ~AnimationTemplate() override;
60 
61  const Frame &getFrame(uint index) const override {
62  assert(index < _frames.size());
63  return _frames[index];
64  }
65  uint getFrameCount() const override {
66  return _frames.size();
67  }
68  void unlock() override {
69  delete this;
70  }
71 
72  bool isValid() const {
73  return _valid;
74  }
75 
83  void addFrame(int index);
84 
90  void setFrame(int destIndex, int srcIndex);
91 
96  void setAnimationType(Animation::ANIMATION_TYPES type) {
97  _animationType = type;
98  }
99 
104  void setFPS(int FPS);
105 
106  bool persist(OutputPersistenceBlock &writer) override;
107  bool unpersist(InputPersistenceBlock &reader) override;
108 
109 private:
110  Common::Array<Frame> _frames;
111  AnimationResource *_sourceAnimationPtr;
112  bool _valid;
113 
114  AnimationResource *requestSourceAnimation(const Common::String &sourceAnimation) const;
115  bool validateSourceIndex(uint index) const;
116  bool validateDestIndex(uint index) const;
117 };
118 
119 } // End of namespace Sword25
120 
121 #endif
void setAnimationType(Animation::ANIMATION_TYPES type)
Setzt den Animationstyp.
Definition: animationtemplate.h:96
Definition: str.h:59
void setFrame(int destIndex, int srcIndex)
Ändert einen bereits in der Animation vorhandenen Frame.
Definition: animationdescription.h:52
void setFPS(int FPS)
Setzt die Abspielgeschwindigkeit.
Definition: console.h:27
void addFrame(int index)
Fügt einen neuen Frame zur Animation hinzu.
Definition: animationdescription.h:40
Definition: animationtemplate.h:46
size_type size() const
Definition: array.h:315
Definition: animationresource.h:45
Definition: inputpersistenceblock.h:40
Definition: outputpersistenceblock.h:39