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 (mode %d)", _index, _value, _mode);
64  }
65 
66 protected:
67  Common::String getRecordTypeName() const override { return "SetValue"; }
68 
69  enum SetMode : byte {
70  kAdd = 0,
71  kSet = 1,
72  kSetRandom = 2 // Nancy16+
73  };
74 
75  byte _index = 0;
76  SetMode _mode = kAdd;
77  int16 _value = kNoTableValue;
78  int16 _randomMax = 0;
79 };
80 
81 class SetValueCombo : public ActionRecord {
82 public:
83  void readData(Common::SeekableReadStream &stream) override;
84  void execute() override;
85 
86  Common::String getRecordExtraInfo() const override {
87  return Common::String::format("Value %d", _valueIndex);
88  }
89 
90 protected:
91  Common::String getRecordTypeName() const override { return "SetValueCombo"; }
92 
93  byte _valueIndex = 0;
94  Common::Array<byte> _indices;
95  Common::Array<int16> _percentages;
96 };
97 
98 class ValueTest : public ActionRecord {
99 public:
100  void readData(Common::SeekableReadStream &stream) override;
101  void execute() override;
102 
103  Common::String getRecordExtraInfo() const override {
104  return Common::String::format("Value %d. Test type %d, condition %d. Set flag %d", _valueIndex, _testType, _condition, _flagToSet);
105  }
106 
107 protected:
108  Common::String getRecordTypeName() const override { return "ValueTest"; }
109 
110  byte _valueIndex = 0;
111  byte _testType = 0;
112  byte _condition = 0;
113  Common::Array<byte> _indicesToTest;
114 
115  int16 _flagToSet = kFlagNoLabel;
116 };
117 
118 // Sets up to 10 flags at once.
119 class EventFlags : public ActionRecord {
120 public:
121  enum FlagsType { kEventFlags, kEventFlagsTerse };
122 
123  EventFlags(FlagsType flagsType) : _flagsType(flagsType) {}
124  virtual ~EventFlags() {}
125 
126  void readData(Common::SeekableReadStream &stream) override;
127  void execute() override;
128 
130  FlagsType _flagsType;
131 
132  Common::String getRecordExtraInfo() const override;
133 
134 protected:
135  Common::String getRecordTypeName() const override { return _flagsType == kEventFlagsTerse ? "EventFlagsTerse" : "EventFlags"; }
136 };
137 
138 // Sets up to 10 flags when clicked. Hotspot can move alongside background frame.
140 public:
141  enum HotspotType { kMultiHS, kCursorHS, kHSTerse };
142 
143  EventFlagsMultiHS(HotspotType hotspotType) :
144  EventFlags(hotspotType == kHSTerse ? kEventFlagsTerse : kEventFlags), _hotspotType(hotspotType) {}
145  virtual ~EventFlagsMultiHS() {}
146 
147  void readData(Common::SeekableReadStream &stream) override;
148  void execute() override;
149 
150  CursorManager::CursorType getHoverCursor() const override;
151  bool cursorSetFromScript() const override;
152 
153  CursorManager::CursorType _hoverCursor = CursorManager::kHotspot;
155 
156  HotspotType _hotspotType;
157 
158  bool canHaveHotspot() const override { return true; }
159 
160 protected:
161  Common::String getRecordTypeName() const override {
162  switch (_hotspotType) {
163  case kCursorHS:
164  return "EventFlagsCursorHS";
165  case kHSTerse:
166  return "EventFlagsHSTerse";
167  default:
168  return "EventFlagsMultiHS";
169  }
170  }
171 };
172 
173 // Nancy 11+ AR 96. Sets each of a list of event flags to a random boolean value.
175 public:
176  void readData(Common::SeekableReadStream &stream) override;
177  void execute() override;
178 
179  Common::Array<int16> _flagLabels;
180 
181 protected:
182  Common::String getRecordTypeName() const override { return "RandomizeEventFlags"; }
183 };
184 
185 // Sets the difficulty level for the current save. Only appears at the start of the game.
186 // First appears in nancy1. Nancy1 and nancy2 have three difficulty values, while later games
187 // only have two: 0 and 2.
189 public:
190  void readData(Common::SeekableReadStream &stream) override;
191  void execute() override;
192 
193  uint16 _difficulty = 0;
194  FlagDescription _flag;
195 
196 protected:
197  Common::String getRecordTypeName() const override { return "DifficultyLevel"; }
198 };
199 
201 public:
202  enum Type { kAdd, kDelete, kMark };
203 
204  ModifyListEntry(Type type) : _type(type) {}
205  virtual ~ModifyListEntry() {}
206 
207  void readData(Common::SeekableReadStream &stream) override;
208  void execute() override;
209 
210  Type _type;
211 
212  uint16 _surfaceID = 0;
213  Common::String _stringID;
214  uint16 _mark = 0;
215  uint16 _sceneID = kNoScene;
216 
217 protected:
218  Common::String getRecordTypeName() const override;
219 };
220 
221 } // End of namespace Action
222 } // End of namespace Nancy
223 
224 #endif // NANCY_ACTION_DATARECORDS_H
Definition: commontypes.h:235
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:81
Definition: stream.h:745
Definition: datarecords.h:188
Definition: datarecords.h:174
Definition: datarecords.h:98
Definition: datarecords.h:200
Definition: datarecords.h:119
Definition: actionrecord.h:107
Definition: datarecords.h:57
Definition: commontypes.h:201
Definition: actionmanager.h:32
Definition: datarecords.h:139