ScummVM API documentation
peepholepuzzle.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_PEEPHOLEPUZZLE_H
23 #define NANCY_ACTION_PEEPHOLEPUZZLE_H
24 
25 #include "engines/nancy/action/autotext.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // Action record that, despite what its name suggests, is mostly used
31 // to render Nancy's diary in nancy6 and up.
33 public:
35  virtual ~PeepholePuzzle() {}
36 
37  void init() override;
38 
39  void readData(Common::SeekableReadStream &stream) override;
40  void execute() override;
41  void handleInput(NancyInput &input) override;
42 
43  bool isViewportRelative() const override { return true; }
44 
45 protected:
46  Common::String getRecordTypeName() const override { return "PeepholePuzzle"; }
47 
48  void drawInner();
49  void checkButtons();
50 
51  Common::Path _innerImageName;
52  Common::Path _buttonsImageName;
53 
54  uint16 _transparency = 0;
55 
56  Common::Rect _innerBounds;
57  Common::Rect _startSrc;
58  Common::Rect _dest;
59 
60  // Order: up, down, left, right
61  Common::Array<Common::Rect> _buttonDests;
62  Common::Array<Common::Rect> _buttonSrcs;
63  Common::Array<Common::Rect> _buttonDisabledSrcs;
64 
65  byte _pixelsToScroll = 0;
66 
67  SceneChangeWithFlag _exitScene;
68  Common::Rect _exitHotspot;
69 
70  Graphics::ManagedSurface _innerImage;
71  Graphics::ManagedSurface _buttonsImage;
72 
73  Common::Rect _currentSrc;
74  int _pressedButton = -1;
75  uint32 _pressStart = 0;
76  Common::Array<bool> _disabledButtons = Common::Array<bool>(4, false);
77 };
78 
79 // Combines the Peephole with the Autotext used to supply its text data
80 // Implementing this with diamond-shaped multiple inheritance is bad,
81 // but so is the original design, where a Peephole is constructed
82 // on the fly and replaces the TextScroll/AutotextEntryList
83 class TextScroll : public Autotext, public PeepholePuzzle {
84 public:
85  TextScroll(bool isEntryList) : _isEntryList(isEntryList) {}
86 
87  void init() override;
88  void execute() override { PeepholePuzzle::execute(); }
89  void handleInput(NancyInput &input) override;
90 
91  void readData(Common::SeekableReadStream &stream) override;
92 
93 protected:
94  Common::String getRecordTypeName() const override { return _isEntryList ? "AutotextEntryList" : "TextScroll"; }
95  void readExtraData(Common::SeekableReadStream &stream) override;
96 
97  bool _isEntryList;
98 };
99 
100 } // End of namespace Action
101 } // End of namespace Nancy
102 
103 #endif // NANCY_ACTION_PEEPHOLEPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: peepholepuzzle.h:32
Definition: rect.h:524
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: commontypes.h:172
Definition: actionrecord.h:152
Definition: autotext.h:36
Definition: peepholepuzzle.h:83
Definition: actionmanager.h:32