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/baglib/object.h"
28 
29 namespace Bagel {
30 
32 protected:
33  Video::SmackerDecoder *_smacker = nullptr;
34  CBofBitmap *_bmpBuf = nullptr;
35  int _charTransColor = 0;
36 
37  char *_binBuf = nullptr;
38  int32 _binBufLen = 0;
39 
40  int _playbackSpeed = 0;
41  int _numOfLoops = 0;
42  int _startFrame = 0;
43  int _endFrame = 0;
44 
45  bool _exitAtEnd : 1;
46  bool _firstFrame : 1;
47 
48  bool _saveState : 1; // Flag to save the state/frame of the character
49  bool _pAnim : 1; // If affected by Panimations On/Off setting
50 
51  int _prevFrame = 0;
52 
53  void setFrame(int n);
54 
55  // Keep track of the PDA wand and the number of frames it has
56  static CBagCharacterObject *_pdaWand;
57  static bool _pdaAnimating;
58 
59 public:
61  virtual ~CBagCharacterObject();
62  static void initialize();
63 
64  // Return ERR_NONE if the Object had members that are properly initialized/de-initialized
65  ErrorCode attach() override;
66  ErrorCode detach() override;
67 
68  CBofRect getRect() override;
69 
70  ErrorCode update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcRect = nullptr, int maskColor = -1) override;
71 
72  bool doAdvance();
73  void updatePosition();
74  bool refreshCurrentFrame();
75 
76  bool runObject() override;
77  bool isInside(const CBofPoint &point) override;
78 
79  void arrangeFrames();
80 
81  int getNumberOfLoops() const {
82  return _numOfLoops;
83  }
84  int getPlaybackSpeed() const {
85  return _playbackSpeed;
86  }
87  int getStartFrame() const {
88  return _startFrame;
89  }
90  int getEndFrame() const {
91  return _endFrame;
92  }
93  int getCurrentFrame() const {
94  return (_smacker != nullptr) ? _smacker->getCurFrame() : -1;
95  }
96 
97  bool isModalDone() override {
98  return !_numOfLoops;
99  }
100 
101  bool isPanim() const {
102  return _pAnim;
103  }
104 
105  void setNumOfLoops(int n);
106  void setPlaybackSpeed(int n);
107  void setStartFrame(int n);
108  void setEndFrame(int n);
109  void setCurrentFrame(int n);
110 
111  ParseCodes setInfo(CBagIfstream &istr) override;
112 
113  void setProperty(const CBofString &prop, int val) override;
114  int getProperty(const CBofString &prop) override;
115 
116  // Remember the pda wand, we'll need to know about it and
117  // it's total number of frames.
118  static void setPdaWand(CBagCharacterObject *pdaWand);
119  static bool pdaWandAnimating();
120 
121  bool isStationary() const {
122  return _binBuf != nullptr;
123  }
124 };
125 
126 } // namespace Bagel
127 
128 #endif
int getCurFrame() const
Definition: bitmap.h:55
Definition: rect.h:36
Definition: smk_decoder.h:76
Definition: object.h:85
Definition: ifstream.h:31
Definition: string.h:38
Definition: bagel.h:31
Definition: point.h:34
Definition: character_object.h:31