ScummVM API documentation
orderingpuzzle.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_ORDERINGPUZZLE_H
23 #define NANCY_ACTION_ORDERINGPUZZLE_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // Class implementing several action records of the type where
31 // the player has to press a sequence of buttons in a certain order.
32 // - OrderingPuzzle: The most simple type. Allows for manual depressing of buttons
33 // - PianoPuzzle: Buttons always auto-depress; every button has unique sound file
34 // - OrderItemsPuzzle: Buttons may depress or stay down, but player can't depress manually.
35 // Has second button state that is activated when player is holding a specific item. (see fingerprint keypad puzzle in nancy4)
36 // - KeypadPuzzle: Buttons may auto-depress, stay down, and can be depressed manually by player.
37 // Adds an optional button for manually checking for correct solution, number of possible buttons is 30.
38 // - KeypadPuzzleTerse: Same as above, but data format is shorter, and supports up to 100 buttons
40 public:
41  enum SolveState { kNotSolved, kPlaySound, kWaitForSound };
42  enum PuzzleType { kOrdering, kPiano, kOrderItems, kKeypad, kKeypadTerse };
43  OrderingPuzzle(PuzzleType type) : RenderActionRecord(7), _puzzleType(type) {}
44  virtual ~OrderingPuzzle() {}
45 
46  void init() override;
47 
48  void readData(Common::SeekableReadStream &stream) override;
49  void execute() override;
50  void handleInput(NancyInput &input) override;
51 
52 protected:
53  Common::String getRecordTypeName() const override;
54  bool isViewportRelative() const override { return true; }
55 
56  void pushDown(uint id);
57  void setToSecondState(uint id);
58  void popUp(uint id);
59  void clearAllElements();
60 
61  Common::Path _imageName;
62  bool _hasSecondState = false;
63  bool _itemsStayDown = true;
64  bool _needButtonToCheckSuccess = false;
65  bool _checkOrder = true;
66  Common::Rect _checkButtonSrc;
67  Common::Rect _checkButtonDest;
68  Common::Array<Common::Rect> _down1Rects;
70  Common::Array<Common::Rect> _down2Rects;
71  Common::Array<Common::Rect> _destRects;
73  Common::Array<uint16> _correctSequence;
74 
75  uint16 _specialCursor1Id = CursorManager::kHotspot;
76  Common::Rect _specialCursor1Dest;
77  uint16 _specialCursor2Id = CursorManager::kHotspot;
78  Common::Rect _specialCursor2Dest;
79 
80  Common::Array<Common::String> _pianoSoundNames; // nancy8 and up
81 
82  uint16 _state2InvItem = 0;
83  Common::Array<Common::Rect> _overlaySrcs;
84  Common::Array<Common::Rect> _overlayDests;
85 
86  Nancy::SoundDescription _pushDownSound;
87  Nancy::SoundDescription _itemSound;
88  Nancy::SoundDescription _popUpSound;
89 
90  SceneChangeWithFlag _solveExitScene;
91  uint16 _solveSoundDelay = 0;
92  Nancy::SoundDescription _solveSound;
93  SceneChangeWithFlag _exitScene;
94  Common::Rect _exitHotspot;
95 
96  SolveState _solveState = kNotSolved;
98  Common::Array<uint16> _clickedSequence;
99  Common::Array<bool> _downItems;
100  Common::Array<bool> _secondStateItems;
101  Time _solveSoundPlayTime;
102  bool _checkButtonPressed = false;
103 
104  PuzzleType _puzzleType;
105 };
106 
107 } // End of namespace Action
108 } // End of namespace Nancy
109 
110 #endif // NANCY_ACTION_ORDERINGPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: time.h:30
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: orderingpuzzle.h:39
Definition: commontypes.h:254
Definition: actionmanager.h:32