ScummVM API documentation
datarecords.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_DATARECORDS_H
23 #define NANCY_ACTION_DATARECORDS_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 
29 class NancyEngine;
30 
31 namespace Action {
32 
33 // Changes the selected value inside the TableData. Value can be incremented, decremented, or not changed.
34 // Also responsible for checking whether all values are correct (as described in the TABL chunk). nancy6 only.
36 public:
37  void readData(Common::SeekableReadStream &stream) override;
38  void execute() override;
39 
40  CursorManager::CursorType getHoverCursor() const override { return (CursorManager::CursorType)_cursorType; }
41  bool cursorSetFromScript() const override { return true; }
42 
43 protected:
44  Common::String getRecordTypeName() const override { return "TableIndexSetValueHS"; }
45 
46  uint16 _tableIndex = 0;
47  byte _valueChangeType = kNoChangeTableValue;
48  int16 _entryCorrectFlagID = -1;
49  int16 _allEntriesCorrectFlagID = -1;
50 
52  uint16 _cursorType = 1;
54 };
55 
56 // Sets (or adds to) a value inside the TableData struct
57 class SetValue : public ActionRecord {
58 public:
59  void readData(Common::SeekableReadStream &stream) override;
60  void execute() override;
61 
62  Common::String getRecordExtraInfo() const override {
63  return Common::String::format("Value %d -> %d (should set is %d)", _index, _value, _shouldSet);
64  }
65 
66 protected:
67  Common::String getRecordTypeName() const override { return "SetValue"; }
68 
69  byte _index = 0;
70  bool _shouldSet = false;
71  int16 _value = kNoTableValue;
72 };
73 
74 class SetValueCombo : public ActionRecord {
75 public:
76  void readData(Common::SeekableReadStream &stream) override;
77  void execute() override;
78 
79  Common::String getRecordExtraInfo() const override {
80  return Common::String::format("Value %d", _valueIndex);
81  }
82 
83 protected:
84  Common::String getRecordTypeName() const override { return "SetValueCombo"; }
85 
86  byte _valueIndex = 0;
87  Common::Array<byte> _indices;
88  Common::Array<int16> _percentages;
89 };
90 
91 class ValueTest : public ActionRecord {
92 public:
93  void readData(Common::SeekableReadStream &stream) override;
94  void execute() override;
95 
96  Common::String getRecordExtraInfo() const override {
97  return Common::String::format("Value %d. Test type %d, condition %d. Set flag %d", _valueIndex, _testType, _condition, _flagToSet);
98  }
99 
100 protected:
101  Common::String getRecordTypeName() const override { return "ValueTest"; }
102 
103  byte _valueIndex = 0;
104  byte _testType = 0;
105  byte _condition = 0;
106  Common::Array<byte> _indicesToTest;
107 
108  int16 _flagToSet = kFlagNoLabel;
109 };
110 
111 // Sets up to 10 flags at once.
112 class EventFlags : public ActionRecord {
113 public:
114  EventFlags(bool terse = false) : _isTerse(terse) {}
115  virtual ~EventFlags() {}
116 
117  void readData(Common::SeekableReadStream &stream) override;
118  void execute() override;
119 
121  bool _isTerse;
122 
123 protected:
124  Common::String getRecordTypeName() const override { return _isTerse ? "EventFlagsTerse" : "EventFlags"; }
125 };
126 
127 // Sets up to 10 flags when clicked. Hotspot can move alongside background frame.
129 public:
130  EventFlagsMultiHS(bool isCursor, bool terse = false) : EventFlags(terse), _isCursor(isCursor) {}
131  virtual ~EventFlagsMultiHS() {}
132 
133  void readData(Common::SeekableReadStream &stream) override;
134  void execute() override;
135 
136  CursorManager::CursorType getHoverCursor() const override;
137  bool cursorSetFromScript() const override;
138 
139  CursorManager::CursorType _hoverCursor = CursorManager::kHotspot;
141 
142  bool _isCursor;
143 
144  bool canHaveHotspot() const override { return true; }
145 
146 protected:
147  Common::String getRecordTypeName() const override { return _isCursor ? (_isTerse ? "EventFlagsHSTerse" : "EventFlagsCursorHS") : "EventFlagsMultiHS"; }
148 };
149 
150 // Nancy 11+ AR 96. Sets each of a list of event flags to a random boolean value.
152 public:
153  void readData(Common::SeekableReadStream &stream) override;
154  void execute() override;
155 
156  Common::Array<int16> _flagLabels;
157 
158 protected:
159  Common::String getRecordTypeName() const override { return "RandomizeEventFlags"; }
160 };
161 
162 // Sets the difficulty level for the current save. Only appears at the start of the game.
163 // First appears in nancy1. Nancy1 and nancy2 have three difficulty values, while later games
164 // only have two: 0 and 2.
166 public:
167  void readData(Common::SeekableReadStream &stream) override;
168  void execute() override;
169 
170  uint16 _difficulty = 0;
171  FlagDescription _flag;
172 
173 protected:
174  Common::String getRecordTypeName() const override { return "DifficultyLevel"; }
175 };
176 
178 public:
179  enum Type { kAdd, kDelete, kMark };
180 
181  ModifyListEntry(Type type) : _type(type) {}
182  virtual ~ModifyListEntry() {}
183 
184  void readData(Common::SeekableReadStream &stream) override;
185  void execute() override;
186 
187  Type _type;
188 
189  uint16 _surfaceID = 0;
190  Common::String _stringID;
191  uint16 _mark = 0;
192  uint16 _sceneID = kNoScene;
193 
194 protected:
195  Common::String getRecordTypeName() const override;
196 };
197 
198 } // End of namespace Action
199 } // End of namespace Nancy
200 
201 #endif // NANCY_ACTION_DATARECORDS_H
Definition: commontypes.h:213
Definition: str.h:59
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: array.h:52
Definition: datarecords.h:35
Definition: datarecords.h:74
Definition: stream.h:745
Definition: datarecords.h:165
Definition: datarecords.h:151
Definition: datarecords.h:91
Definition: datarecords.h:177
Definition: datarecords.h:112
Definition: actionrecord.h:98
Definition: datarecords.h:57
Definition: commontypes.h:180
Definition: actionmanager.h:32
Definition: datarecords.h:128