ScummVM API documentation
puzzlerecord.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_PUZZLERECORD_H
23 #define NANCY_ACTION_PUZZLERECORD_H
24 
25 #include "common/path.h"
26 
27 #include "graphics/managed_surface.h"
28 
29 #include "engines/nancy/commontypes.h"
30 #include "engines/nancy/action/actionrecord.h"
31 
32 namespace Nancy {
33 namespace Action {
34 
35 // Common base for all puzzle action records. Holds the scene changes and
36 // give-up hotspot that nearly every puzzle has.
38 public:
39  PuzzleRecord(uint zOrder) : RenderActionRecord(zOrder) {}
40  virtual ~PuzzleRecord() {}
41 
42  Common::String getRecordExtraInfo() const override;
43 
44 protected:
45  // Loads _imageName into _image, keyed to the draw surface's transparent color
46  void loadImage();
47 
48  // Creates a transparent, viewport-sized draw surface and shows it over the viewport
49  void initViewportSurface();
50 
51  // The ids in the AR data are raw cursor types, which is what the "set from script" path expects
52  void setDataCursor(uint16 cursorType, bool hotspotVariant = true) const;
53 
54  // Nancy16 hangs a held piece off the current cursor: the piece is centered on the
55  // cursor's image, then moved back by the offset from the data
56  Common::Point getHeldPiecePos(const Common::Point &mousePos, const Common::Rect &src, const Common::Point &offset) const;
57 
58  // Plays a random sound from the block and shows its caption, looked up by the sound's
59  // name, first in AUTOTEXT, then in CONVO. Returns the sound's description, which is
60  // left as "NO SOUND" when the block has nothing to play.
61  SoundDescription playSoundBlock(const RandomSoundBlock &block);
62  bool isSoundBlockPlaying(const RandomSoundBlock &block) const;
63 
64  // Reads the Nancy 13+ count-prefixed give-up hotspot array into the exit fields,
65  // keeping only the first record.
66  void readExitHotspot(Common::SeekableReadStream &stream);
67 
68  bool isExitHotspotHovered(const NancyInput &input) const;
69  void setExitCursor() const;
70 
71  // Shows the exit cursor and returns true while the mouse is over the give-up hotspot
72  bool hoverExitHotspot(const NancyInput &input) const;
73 
74  // A solve sound named "NO SOUND" or left empty counts as absent: it never plays,
75  // and is never reported as playing.
76  bool hasSolveSound() const;
77  void playSolveSound();
78  bool isSolveSoundPlaying() const;
79 
80  // The puzzle's sprite sheet
81  Common::Path _imageName;
83 
84  // Scene the puzzle moves to when solved; its flag is set on solve
85  SceneChangeWithFlag _solveScene;
86  SoundDescription _solveSound;
87  uint16 _solveSoundDelay = 0; // units differ per puzzle
88 
89  // Scene the puzzle moves to when left unsolved, e.g. via the give-up hotspot
90  SceneChangeWithFlag _exitScene;
91  Common::Rect _exitHotspot;
92  uint16 _exitCursorType = 0;
93  bool _exitCursorFromData = false; // otherwise the generic puzzle exit cursor is used
94 };
95 
96 } // End of namespace Action
97 } // End of namespace Nancy
98 
99 #endif // NANCY_ACTION_PUZZLERECORD_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: rect.h:536
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: commontypes.h:206
Definition: actionrecord.h:169
Definition: commontypes.h:324
Definition: rect.h:144
Definition: puzzlerecord.h:37
Definition: commontypes.h:306
Definition: actionmanager.h:32