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