ScummVM API documentation
puzzledata.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 #include "common/serializer.h"
23 #include "common/array.h"
24 #include "common/hashmap.h"
25 
26 #include "engines/nancy/commontypes.h"
27 
28 #ifndef NANCY_PUZZLEDATA_H
29 #define NANCY_PUZZLEDATA_H
30 
31 namespace Nancy {
32 
33 // The following structs contain persistent data for specific
34 // puzzle types, which is to be stored in savefiles
35 
36 struct PuzzleData {
37  PuzzleData() {}
38  virtual ~PuzzleData() {}
39 
40  virtual void synchronize(Common::Serializer &ser) = 0;
41 };
42 
43 struct SliderPuzzleData : public PuzzleData {
45  virtual ~SliderPuzzleData() {}
46 
47  static constexpr uint32 getTag() { return MKTAG('S', 'L', 'I', 'D'); }
48  virtual void synchronize(Common::Serializer &ser);
49 
50  Common::Array<Common::Array<int16>> playerTileOrder;
51  bool playerHasTriedPuzzle;
52 };
53 
56  virtual ~RippedLetterPuzzleData() {}
57 
58  static constexpr uint32 getTag() { return MKTAG('R', 'I', 'P', 'L'); }
59  virtual void synchronize(Common::Serializer &ser);
60 
61  Common::Array<int8> order;
62  Common::Array<byte> rotations;
63  bool playerHasTriedPuzzle;
64 
65  // Temporary values, do not save to file
66  int8 _pickedUpPieceID = -1;
67  byte _pickedUpPieceRot = 0;
68  int _pickedUpPieceLastPos = -1;
69 };
70 
71 struct TowerPuzzleData : public PuzzleData {
73  virtual ~TowerPuzzleData() {}
74 
75  static constexpr uint32 getTag() { return MKTAG('T', 'O', 'W', 'R'); }
76  virtual void synchronize(Common::Serializer &ser);
77 
79  bool playerHasTriedPuzzle;
80 };
81 
82 struct RiddlePuzzleData : public PuzzleData {
84  virtual ~RiddlePuzzleData() {}
85 
86  static constexpr uint32 getTag() { return MKTAG('R', 'I', 'D', 'L'); }
87  virtual void synchronize(Common::Serializer &ser);
88 
89  Common::Array<byte> solvedRiddleIDs;
90  int8 incorrectRiddleID;
91 };
92 
95  virtual ~SoundEqualizerPuzzleData() {}
96 
97  static constexpr uint32 getTag() { return MKTAG('S', 'E', 'Q', 'L'); }
98  virtual void synchronize(Common::Serializer &ser);
99 
100  Common::Array<byte> sliderValues;
101 };
102 
103 // Contains a single bool indicating whether the puzzle was solved
104 struct SimplePuzzleData : public PuzzleData {
106  virtual ~SimplePuzzleData() {}
107 
108  virtual void synchronize(Common::Serializer &ser);
109 
110  bool solvedPuzzle;
111 };
112 
114  static constexpr uint32 getTag() { return MKTAG('A', 'S', 'M', 'B'); }
115 };
116 
117 struct QuizPuzzleData : public PuzzleData {
118  QuizPuzzleData() {}
119  virtual ~QuizPuzzleData() {}
120 
121  static constexpr uint32 getTag() { return MKTAG('Q', 'U', 'I', 'Z'); }
122  virtual void synchronize(Common::Serializer &ser);
123 
124  // Keyed by solve-scene ID so that multiple QuizPuzzle instances
125  // (e.g. a two-page Nancy 9 puzzle) each maintain their own state.
128 };
129 
130 struct JournalData : public PuzzleData {
131  JournalData() {}
132  virtual ~JournalData() {}
133 
134  struct Entry {
135  Entry(const Common::String &s = Common::String(), uint16 m = 0, uint16 sc = kNoScene) : stringID(s), mark(m), sceneID(sc) {}
136 
137  Common::String stringID;
138  uint16 mark = 0;
139  uint16 sceneID = kNoScene;
140  };
141 
142  static constexpr uint32 getTag() { return MKTAG('J', 'O', 'U', 'R'); }
143  virtual void synchronize(Common::Serializer &ser);
144 
146 };
147 
148 // Contains variables that can be read and modified through action records.
149 // Mixes two separate things:
150 // - the exhibit data table in nancy6
151 // - the general variable storage in nancy8 and up
152 // The exhibit data was only ever used in nancy6, so mixing these should be ok.
153 struct TableData : public PuzzleData {
154  TableData();
155  virtual ~TableData() {}
156 
157  static constexpr uint32 getTag() { return MKTAG('T', 'A', 'B', 'L'); }
158  virtual void synchronize(Common::Serializer &ser);
159 
160  void setSingleValue(uint16 index, int16 value);
161  int16 getSingleValue(uint16 index) const;
162 
163  void setComboValue(uint16 index, float value);
164  float getComboValue(uint16 index) const;
165 
166  Common::Array<int16> singleValues;
167  Common::Array<float> comboValues;
168 };
169 
170 PuzzleData *makePuzzleData(const uint32 tag);
171 
172 } // End of namespace Nancy
173 
174 #endif // NANCY_PUZZLEDATA_H
Definition: puzzledata.h:113
Definition: str.h:59
Definition: puzzledata.h:54
Definition: array.h:52
Definition: puzzledata.h:36
Definition: puzzledata.h:104
Definition: puzzledata.h:117
Definition: serializer.h:79
Definition: puzzledata.h:43
Definition: puzzledata.h:153
Definition: hashmap.h:85
Definition: puzzledata.h:93
Definition: puzzledata.h:82
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: puzzledata.h:134
Definition: puzzledata.h:71
Definition: puzzledata.h:130
Definition: actionmanager.h:32