ScummVM API documentation
animscript.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 STARK_RESOURCES_ANIM_SCRIPT_H
23 #define STARK_RESOURCES_ANIM_SCRIPT_H
24 
25 #include "common/str.h"
26 
27 #include "engines/stark/resources/object.h"
28 
29 namespace Stark {
30 
31 namespace Formats {
32 class XRCReadStream;
33 }
34 
35 namespace Resources {
36 
37 class Anim;
38 class AnimScriptItem;
39 
49 class AnimScript : public Object {
50 public:
51  static const Type::ResourceType TYPE = Type::kAnimScript;
52 
53  AnimScript(Object *parent, byte subType, uint16 index, const Common::String &name);
54  virtual ~AnimScript();
55 
56  // Resource API
57  void onAllLoaded() override;
58  void onGameLoop() override;
59  void saveLoad(ResourceSerializer *serializer) override;
60 
62  void goToScriptItem(AnimScriptItem *item);
63 
65  bool hasReached(AnimScriptItem *item);
66 
68  bool isDone() const;
69 
70 protected:
71  void goToNextItem();
72  int32 findItemIndex(AnimScriptItem *item);
73 
74  Anim *_anim;
76 
77  int32 _nextItemIndex;
78  int32 _msecsToNextUpdate;
79  bool _done;
80 };
81 
88 class AnimScriptItem : public Object {
89 public:
90  static const Type::ResourceType TYPE = Type::kAnimScriptItem;
91 
92  enum Opcodes {
93  kDisplayFrame = 0,
94  kPlayAnimSound = 1,
95  kGoToItem = 2,
96  kDisplayRandomFrame = 3,
97  kSleepRandomDuration = 4,
98  kPlayStockSound = 5
99  };
100 
101  AnimScriptItem(Object *parent, byte subType, uint16 index, const Common::String &name);
102  virtual ~AnimScriptItem();
103 
104  // Resource API
105  void readData(Formats::XRCReadStream *stream) override;
106 
108  uint32 getOpcode() const { return _opcode; }
109 
111  uint32 getOperand() const { return _operand; }
112 
114  uint32 getDuration() const { return _duration; }
115 
116 protected:
117  void printData() override;
118 
119  uint32 _opcode;
120  uint32 _operand;
121  uint32 _duration;
122 };
123 
124 } // End of namespace Resources
125 } // End of namespace Stark
126 
127 #endif // STARK_RESOURCES_ANIM_SCRIPT_H
Definition: animscript.h:49
Definition: str.h:59
uint32 getOpcode() const
Definition: animscript.h:108
uint32 getDuration() const
Definition: animscript.h:114
Definition: array.h:52
Definition: anim.h:58
uint32 getOperand() const
Definition: animscript.h:111
Definition: console.h:27
Definition: object.h:143
Definition: animscript.h:88
Definition: xrc.h:45
Definition: stateprovider.h:51