ScummVM API documentation
dancepuzzle.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_DANCEPUZZLE_H
23 #define NANCY_ACTION_DANCEPUZZLE_H
24 
25 #include "engines/nancy/commontypes.h"
26 #include "engines/nancy/action/puzzlerecord.h"
27 
28 namespace Nancy {
29 namespace Action {
30 
31 // Nancy18 dance floor. A song plays, and at set times one of the dance moves is
32 // called for, which an event flag lets the scene show. The player has a button
33 // for every move; the sooner the right one is pressed the more points it is
34 // worth, and a wrong one, or none, costs some. The points go into the value
35 // table, and the audience reacts to them. The dancing itself is done by a movie
36 // record of the scene, which gets told what to play.
37 class DancePuzzle : public PuzzleRecord {
38 public:
39  // Drawn above the stage light movies, which cover the buttons
40  DancePuzzle() : PuzzleRecord(15) {}
41  virtual ~DancePuzzle() {}
42 
43  void init() override;
44 
45  void readData(Common::SeekableReadStream &stream) override;
46  void execute() override;
47  void handleInput(NancyInput &input) override;
48 
49  bool isViewportRelative() const override { return true; }
50 
51 protected:
52  Common::String getRecordTypeName() const override { return "DancePuzzle"; }
53 
54  struct Move {
55  Common::Rect hoverSrc;
56  Common::Rect src;
57  Common::Rect dest;
58  Common::String movieName;
59  };
60 
61  // What a move is worth up to a point in time
62  struct TimedPoints {
63  int32 time = 0; // in milliseconds from the start of the song
64  int16 points = 0;
65  };
66 
67  struct Step {
68  // -- File data --
69  Common::String movieName; // of the move that is called for
70  int16 flag = -1;
71  int32 startTime = 0;
72  int32 endTime = 0;
74 
75  // -- Runtime --
76  bool hasScored = false;
77  bool hasHadWrongMove = false;
78  };
79 
80  struct Reaction {
81  int16 minPoints = 0;
82  int16 maxPoints = 0;
83  RandomSoundBlock sound;
84  };
85 
86  int16 scoreMove(Step &step, int32 time, const Common::String &movieName);
87  void addPoints(int16 points);
88  void endStep(int32 time);
89  void startStep(uint stepID);
90  void playMovie(const Common::String &movieName);
91  void redraw();
92 
93  // -- File data --
94  Common::String _movieRecordName;
95  uint16 _hoverCursor = 0;
96  int16 _pointsTableIndex = 0;
97  Common::String _rootMovieName; // played whenever no move is
98  Common::Array<Move> _moves;
99  RandomSoundBlock _music;
100  Common::Array<Step> _steps;
101  Common::Array<Reaction> _reactions;
102 
103  // -- Runtime --
104  uint32 _startTime = 0;
105  int _activeStep = -1;
106  uint _nextStep = 0;
107  Common::String _currentMovieName;
108  int _hoveredMove = -1;
109 };
110 
111 } // End of namespace Action
112 } // End of namespace Nancy
113 
114 #endif // NANCY_ACTION_DANCEPUZZLE_H
Definition: str.h:59
Definition: dancepuzzle.h:67
Definition: array.h:52
Definition: rect.h:536
Definition: stream.h:745
Definition: input.h:41
Definition: dancepuzzle.h:80
Definition: commontypes.h:324
Definition: dancepuzzle.h:62
Definition: puzzlerecord.h:37
Definition: dancepuzzle.h:54
Definition: dancepuzzle.h:37
Definition: actionmanager.h:32