ScummVM API documentation
tangrampuzzle.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 NANCY_ACTION_TANGRAMPUZZLE_H
23 #define NANCY_ACTION_TANGRAMPUZZLE_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 #include "engines/nancy/misc/mousefollow.h"
27 
28 namespace Nancy {
29 namespace Action {
30 
31 // Handles a specific type of puzzle where clicking an object rotates it,
32 // as well as several other objects linked to it. Examples are the sun/moon
33 // and staircase spindle puzzles in nancy3
35 public:
37  virtual ~TangramPuzzle();
38 
39  void init() override;
40  void registerGraphics() override;
41 
42  void readData(Common::SeekableReadStream &stream) override;
43  void execute() override;
44  void handleInput(NancyInput &input) override;
45 
46 protected:
47  Common::String getRecordTypeName() const override { return "TangramPuzzle"; }
48  bool isViewportRelative() const override { return true; }
49 
50  class Tile : public Misc::MouseFollowObject {
51  friend class TangramPuzzle;
52  public:
53  Tile();
54  virtual ~Tile();
55 
56  void drawMask();
57  void setHighlighted(bool highlighted);
58 
59  Graphics::ManagedSurface _srcImage;
60  Graphics::ManagedSurface _highlightedSrcImage;
61  byte *_mask;
62  byte _id;
63  byte _rotation;
64  bool _isHighlighted;
65 
66  protected:
67  bool isViewportRelative() const override { return true; }
68  };
69 
70  void drawToBuffer(const Tile &tile, Common::Rect subRect = Common::Rect());
71 
72  void pickUpTile(uint id);
73  void putDownTile(uint id);
74  void rotateTile(uint id);
75 
76  void moveToTop(uint id);
77  void redrawBuffer(const Common::Rect &rect);
78 
79  bool checkBuffer(const Tile &tile) const;
80 
81  Common::Path _tileImageName;
82  Common::Path _maskImageName;
83 
85  Common::Array<Common::Rect> _tileDests;
86 
87  Common::Rect _maskSolveBounds;
88 
89  SoundDescription _pickUpSound;
90  SoundDescription _putDownSound;
91  SoundDescription _rotateSound;
92 
93  SceneChangeWithFlag _solveScene;
94  SoundDescription _solveSound;
95 
96  SceneChangeWithFlag _exitScene;
97  Common::Rect _exitHotspot;
98 
99  Graphics::ManagedSurface _tileImage;
100  Graphics::ManagedSurface _maskImage;
101  byte *_zBuffer = nullptr;
102 
103  Common::Array<Tile> _tiles;
104 
105  int16 _pickedUpTile = -1;
106  bool _shouldCheck = false;
107  bool _solved = false;
108 
109  uint _pixelAdjustment = 5;
110 };
111 
112 } // End of namespace Action
113 } // End of namespace Nancy
114 
115 #endif // NANCY_ACTION_TANGRAMPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: tangrampuzzle.h:50
Definition: mousefollow.h:42
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: tangrampuzzle.h:34
Definition: commontypes.h:171
Definition: actionrecord.h:149
Definition: commontypes.h:254
Definition: actionmanager.h:32