ScummVM API documentation
character_object.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BAGLIB_BAG_CHARACTER_OBJECT_H
24 #define BAGEL_BAGLIB_BAG_CHARACTER_OBJECT_H
25 
26 #include "video/smk_decoder.h"
27 #include "bagel/spacebar/baglib/object.h"
28 
29 namespace Bagel {
30 namespace SpaceBar {
31 
33 protected:
34  Video::SmackerDecoder *_smacker = nullptr;
35  CBofBitmap *_bmpBuf = nullptr;
36  int _charTransColor = 0;
37 
38  char *_binBuf = nullptr;
39  int32 _binBufLen = 0;
40 
41  int _playbackSpeed = 0;
42  int _numOfLoops = 0;
43  int _startFrame = 0;
44  int _endFrame = 0;
45 
46  bool _exitAtEnd : 1;
47  bool _firstFrame : 1;
48 
49  bool _saveState : 1; // Flag to save the state/frame of the character
50  bool _pAnim : 1; // If affected by Panimations On/Off setting
51 
52  int _prevFrame = 0;
53 
54  void setFrame(int n);
55 
56  // Keep track of the PDA wand and the number of frames it has
57  static CBagCharacterObject *_pdaWand;
58  static bool _pdaAnimating;
59 
60 public:
62  virtual ~CBagCharacterObject();
63  static void initialize();
64 
65  // Return ERR_NONE if the Object had members that are properly initialized/de-initialized
66  ErrorCode attach() override;
67  ErrorCode detach() override;
68 
69  CBofRect getRect() override;
70 
71  ErrorCode update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcRect = nullptr, int maskColor = -1) override;
72 
73  bool doAdvance();
74  void updatePosition();
75  bool refreshCurrentFrame();
76 
77  bool runObject() override;
78  bool isInside(const CBofPoint &point) override;
79 
80  void arrangeFrames();
81 
82  int getNumberOfLoops() const {
83  return _numOfLoops;
84  }
85  int getPlaybackSpeed() const {
86  return _playbackSpeed;
87  }
88  int getStartFrame() const {
89  return _startFrame;
90  }
91  int getEndFrame() const {
92  return _endFrame;
93  }
94  int getCurrentFrame() const {
95  return (_smacker != nullptr) ? _smacker->getCurFrame() : -1;
96  }
97 
98  bool isModalDone() override {
99  return !_numOfLoops;
100  }
101 
102  bool isPanim() const {
103  return _pAnim;
104  }
105 
106  void setNumOfLoops(int n);
107  void setPlaybackSpeed(int n);
108  void setStartFrame(int n);
109  void setEndFrame(int n);
110  void setCurrentFrame(int n);
111 
112  ParseCodes setInfo(CBagIfstream &istr) override;
113 
114  void setProperty(const CBofString &prop, int val) override;
115  int getProperty(const CBofString &prop) override;
116 
117  // Remember the pda wand, we'll need to know about it and
118  // it's total number of frames.
119  static void setPdaWand(CBagCharacterObject *pdaWand);
120  static bool pdaWandAnimating();
121 
122  bool isStationary() const {
123  return _binBuf != nullptr;
124  }
125 };
126 
127 } // namespace SpaceBar
128 } // namespace Bagel
129 
130 #endif
Definition: ifstream.h:32
Definition: character_object.h:32
int getCurFrame() const
Definition: object.h:86
Definition: rect.h:35
Definition: smk_decoder.h:77
Definition: string.h:38
Definition: afxwin.h:27
Definition: point.h:32
Definition: bitmap.h:57