ScummVM API documentation
hamradiopuzzle.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_HAMRADIOPUZZLE_H
23 #define NANCY_ACTION_HAMRADIOPUZZLE_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // A puzzle that has the player input radio frequencies, and
31 // send morse code data via ham radio. Used in nancy6.
33 public:
35  virtual ~HamRadioPuzzle() {}
36 
37  void init() override;
38  void updateGraphics() override;
39 
40  void readData(Common::SeekableReadStream &stream) override;
41  void execute() override;
42  void handleInput(NancyInput &input) override;
43 
44 protected:
45  Common::String getRecordTypeName() const override { return "HamRadioPuzzle"; }
46  bool isViewportRelative() const override { return true; }
47 
48  void setFrequency(const Common::Array<uint16> &freq);
49 
50  // 0-10 are the digit buttons
51  enum ButtonPress { kNone = -1, kConnect = 10, kDot = 11, kDash = 12, kSend = 13, kDelete = 14, kReset = 15 };
52 
53  struct CCSound {
54  Common::String text;
55  SoundDescription sound;
56 
57  void readData(Common::SeekableReadStream &stream);
58  void loadAndPlay();
59  };
60 
61  struct Frequency {
62  Common::Array<uint16> frequency;
63  CCSound sound;
64  FlagDescription flag;
65 
66  void readData(Common::SeekableReadStream &stream, uint16 numDigits);
67  };
68 
69  Common::Path _imageName;
70 
71  uint16 _numDigits = 0;
72 
73  Frequency _startFreq;
74  Frequency _correctFreq;
75 
76  uint16 _passwordMaxSize = 0;
77  Common::String _password;
78  FlagDescription _passwordFlag;
79  Common::String _codeWord;
80 
81  Common::Array<Common::Rect> _digitDests;
82  Common::Array<Common::Rect> _buttonDests;
83 
84  Common::Array<Common::Rect> _digitSrcs;
85  Common::Array<Common::Rect> _buttonSrcs;
86 
87  SoundDescription _digitRollSound;
88  CCSound _frequencyButtonSound;
89  CCSound _connectButtonSound;
90  CCSound _dotButtonSound;
91  CCSound _dashButtonSound;
92  CCSound _sendButtonSound;
93  CCSound _deleteButtonSound;
94  CCSound _resetButtonSound;
95  CCSound _badLetterSound;
96  CCSound _longMorseOtherSound;
97  CCSound _goodPasswordSound;
98  CCSound _longMorseSound;
99  Common::Array<CCSound> _badFrequencySounds;
100 
101  SceneChangeWithFlag _solveScene;
102  uint16 _solveSoundDelay = 0; // not used
103  CCSound _solveSound;
104 
105  Common::Rect _exitButtonDest;
106  Common::Rect _exitButtonSrc;
107 
108  SceneChangeWithFlag _exitScene;
109  uint16 _exitSoundDelay = 0; // not used
110  SoundDescription _exitSound; // not used
111 
112  Common::Array<Frequency> _otherFrequencies;
113 
115 
116  // Frequency display data
117  bool _digitsRolling = true;
118  Common::Array<uint16> _curDigits;
119  Common::Array<uint16> _displayedDigitFrames;
120  Common::Array<uint32> _nextDigitFrameTimes;
121 
122  // Sent morse code
123  Common::String _curMorseString;
124  Common::String _curCharString;
125 
126  int _pressedButton = kNone;
127  uint32 _buttonEndTime = 0;
128 
129  bool _isOnCorrectFrequency = false;
130  bool _solvedPassword = false;
131  bool _solvedCodeword = false;
132 };
133 
134 } // End of namespace Action
135 } // End of namespace Nancy
136 
137 #endif // NANCY_ACTION_HAMRADIOPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: hamradiopuzzle.h:61
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: hamradiopuzzle.h:32
Definition: hamradiopuzzle.h:53
Definition: commontypes.h:254
Definition: commontypes.h:166
Definition: actionmanager.h:32