ScummVM API documentation
wordfindpuzzle.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_WORDFINDPUZZLE_H
23 #define NANCY_ACTION_WORDFINDPUZZLE_H
24 
25 #include "engines/nancy/commontypes.h"
26 #include "engines/nancy/movieplayer.h"
27 #include "engines/nancy/action/actionrecord.h"
28 
29 namespace Nancy {
30 
31 struct WordFindPuzzleData;
32 
33 namespace Action {
34 
35 // Word-find puzzle, new in Nancy13 (AR 170). Despite the name it is not a free
36 // grid drag-select: the player works one target word at a time (progressing across
37 // scene visits), building a connected chain of orthogonally-adjacent letter cells;
38 // once the chain has the word's length and matches the answer path, the word's
39 // animation plays and the next word becomes active.
41 public:
43  virtual ~WordFindPuzzle() {}
44 
45  void init() override;
46 
47  void readData(Common::SeekableReadStream &stream) override;
48  void execute() override;
49  void handleInput(NancyInput &input) override;
50 
51  bool isViewportRelative() const override { return true; }
52 
53 protected:
54  Common::String getRecordTypeName() const override { return "WordFindPuzzle"; }
55 
56  struct Word {
57  Common::Path gridImageName; // +0x55 - the letter grid for this word
58  Common::Path overlayImageName; // +0x76 - overlay drawn on top
59  Common::Path animName; // +0x97 - the "found" animation (a movie)
60  Common::Array<Common::Point> answerCoords; // +0xb8 - the correct letter path (grid cells)
61  int16 eventFlagLabel = -1; // +0x10a - set when the word is found
62  Common::Array<Common::Rect> letterRects; // +0x10c - clickable letter cells
63  };
64 
65  // Grid (col,row) of a letter rect, using the same pixel maths as the original.
66  Common::Point gridCoord(const Common::Rect &rect) const;
67  bool isAdjacent(const Common::Point &a, const Common::Point &b) const;
68  int letterAtCursor(const Common::Point &mousePos) const;
69  int numSelected() const;
70  bool chainMatchesAnswer() const;
71  void loadWord();
72  void startFoundAnimation();
73  void finishCurrentWord();
74  void redraw();
75  WordFindPuzzleData *getPuzzleData() const;
76 
77  // -- File data --
78  uint16 _cursorType = 0; // base 0x00
79  uint16 _cellGapX = 0; // base 0x06 - added to a letter's width to get the column pitch
80  uint16 _cellGapY = 0; // base 0x08 - row pitch component
81  SceneChangeDescription _solveScene; // base 0x2a - shown once every word is found
82  Common::Path _solutionImageName; // base 0x2f
83  Common::Array<Word> _words;
84 
85  Common::Rect _exitHotspot;
86  uint16 _exitCursorType = 0;
87  SceneChangeDescription _exitScene;
88  FlagDescription _exitFlag; // set on give-up
89 
90  Common::Array<RandomSoundBlock> _sounds; // 4 blocks
91 
92  // -- Runtime state --
93  // The active word persists across scene visits (and saves) via WordFindPuzzleData.
94  int _currentWord = 0;
95  Common::Array<bool> _selected; // per letter of the current word
96  bool _allFound = false;
97 
98  // The "found word" animation that plays before advancing to the next word.
99  MoviePlayer _movie;
100  bool _playingMovie = false;
101 
102  Graphics::ManagedSurface _gridImage;
103  Graphics::ManagedSurface _overlayImage;
104 };
105 
106 } // End of namespace Action
107 } // End of namespace Nancy
108 
109 #endif // NANCY_ACTION_WORDFINDPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: commontypes.h:165
Definition: movieplayer.h:56
Definition: rect.h:536
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: puzzledata.h:372
Definition: actionrecord.h:161
Definition: wordfindpuzzle.h:56
Definition: rect.h:144
Definition: wordfindpuzzle.h:40
Definition: commontypes.h:180
Definition: actionmanager.h:32