OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
savingstages.hpp
Go to the documentation of this file.
1 #ifndef CSM_DOC_SAVINGSTAGES_H
2 #define CSM_DOC_SAVINGSTAGES_H
3 
4 #include "stage.hpp"
5 
6 #include "../world/record.hpp"
7 #include "../world/idcollection.hpp"
8 #include "../world/scope.hpp"
9 
10 #include <components/esm/defs.hpp>
11 
12 #include "savingstate.hpp"
13 
14 namespace ESM
15 {
16  struct Dialogue;
17 }
18 
19 namespace CSMWorld
20 {
21  class InfoCollection;
22 }
23 
24 namespace CSMDoc
25 {
26  class Document;
27  class SavingState;
28 
29  class OpenSaveStage : public Stage
30  {
34 
35  public:
36 
37  OpenSaveStage (Document& document, SavingState& state, bool projectFile);
39 
40  virtual int setup();
42 
43  virtual void perform (int stage, Messages& messages);
45  };
46 
47  class WriteHeaderStage : public Stage
48  {
51  bool mSimple;
52 
53  public:
54 
55  WriteHeaderStage (Document& document, SavingState& state, bool simple);
57 
58  virtual int setup();
60 
61  virtual void perform (int stage, Messages& messages);
63  };
64 
65 
66  template<class CollectionT>
67  class WriteCollectionStage : public Stage
68  {
69  const CollectionT& mCollection;
72 
73  public:
74 
75  WriteCollectionStage (const CollectionT& collection, SavingState& state,
77 
78  virtual int setup();
80 
81  virtual void perform (int stage, Messages& messages);
83  };
84 
85  template<class CollectionT>
87  SavingState& state, CSMWorld::Scope scope)
88  : mCollection (collection), mState (state), mScope (scope)
89  {}
90 
91  template<class CollectionT>
93  {
94  return mCollection.getSize();
95  }
96 
97  template<class CollectionT>
99  {
100  if (CSMWorld::getScopeFromId (mCollection.getRecord (stage).get().mId)!=mScope)
101  return;
102 
103  ESM::ESMWriter& writer = mState.getWriter();
104  CSMWorld::RecordBase::State state = mCollection.getRecord (stage).mState;
105  typename CollectionT::ESXRecord record = mCollection.getRecord (stage).get();
106 
110  {
111  writer.startRecord (record.sRecordId);
112  record.save (writer, state == CSMWorld::RecordBase::State_Deleted);
113  writer.endRecord (record.sRecordId);
114  }
115  }
116 
117 
119  {
123 
124  public:
125 
126  WriteDialogueCollectionStage (Document& document, SavingState& state, bool journal);
127 
128  virtual int setup();
130 
131  virtual void perform (int stage, Messages& messages);
133  };
134 
135 
137  {
140 
141  public:
142 
143  WriteRefIdCollectionStage (Document& document, SavingState& state);
144 
145  virtual int setup();
147 
148  virtual void perform (int stage, Messages& messages);
150  };
151 
152 
154  {
157 
158  public:
159 
160  CollectionReferencesStage (Document& document, SavingState& state);
161 
162  virtual int setup();
164 
165  virtual void perform (int stage, Messages& messages);
167  };
168 
170  {
173 
174  public:
175 
176  WriteCellCollectionStage (Document& document, SavingState& state);
177 
178  virtual int setup();
180 
181  virtual void perform (int stage, Messages& messages);
183  };
184 
185 
187  {
190 
191  public:
192 
194 
195  virtual int setup();
197 
198  virtual void perform (int stage, Messages& messages);
200  };
201 
202 
204  {
207 
208  public:
209 
210  WriteLandCollectionStage (Document& document, SavingState& state);
211 
212  virtual int setup();
214 
215  virtual void perform (int stage, Messages& messages);
217  };
218 
219 
221  {
224 
225  public:
226 
228 
229  virtual int setup();
231 
232  virtual void perform (int stage, Messages& messages);
234  };
235 
236  class CloseSaveStage : public Stage
237  {
239 
240  public:
241 
242  CloseSaveStage (SavingState& state);
243 
244  virtual int setup();
246 
247  virtual void perform (int stage, Messages& messages);
249  };
250 
251  class FinalSavingStage : public Stage
252  {
255 
256  public:
257 
258  FinalSavingStage (Document& document, SavingState& state);
259 
260  virtual int setup();
262 
263  virtual void perform (int stage, Messages& messages);
265  };
266 }
267 
268 #endif
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:381
SavingState & mState
Definition: savingstages.hpp:254
Definition: savingstages.hpp:236
Definition: savingstages.hpp:47
virtual int setup()
Definition: savingstages.cpp:481
void startRecord(const std::string &name, uint32_t flags=0)
Definition: esmwriter.cpp:89
SavingState & mState
Definition: savingstages.hpp:238
bool mProjectFile
Definition: savingstages.hpp:33
Definition: savingstages.hpp:29
virtual int setup()
Definition: savingstages.cpp:256
CSMWorld::InfoCollection & mInfos
Definition: savingstages.hpp:122
CloseSaveStage(SavingState &state)
Definition: savingstages.cpp:459
SavingState & mState
Definition: savingstages.hpp:139
CSMWorld::Scope mScope
Definition: savingstages.hpp:71
virtual int setup()
Definition: savingstages.cpp:45
WriteDialogueCollectionStage(Document &document, SavingState &state, bool journal)
Definition: savingstages.cpp:89
FinalSavingStage(Document &document, SavingState &state)
Definition: savingstages.cpp:477
virtual int setup()
Definition: savingstages.cpp:96
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:443
Definition: infocollection.hpp:14
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:417
Definition: savingstages.hpp:136
Definition: messages.hpp:38
WriteRefIdCollectionStage(Document &document, SavingState &state)
Definition: savingstages.cpp:180
bool mSimple
Definition: savingstages.hpp:51
Definition: savingstages.hpp:118
virtual int setup()
Definition: savingstages.cpp:463
SavingState & mState
Definition: savingstages.hpp:156
SavingState & mState
Definition: savingstages.hpp:189
Definition: record.hpp:13
Document & mDocument
Definition: savingstages.hpp:49
State
Definition: record.hpp:10
Definition: savingstages.hpp:169
Definition: esmwriter.hpp:17
WritePathgridCollectionStage(Document &document, SavingState &state)
Definition: savingstages.cpp:371
virtual int setup()
Definition: savingstages.cpp:200
Definition: savingstages.hpp:153
Document & mDocument
Definition: savingstages.hpp:155
virtual int setup()
Definition: savingstages.cpp:376
Document & mDocument
Definition: savingstages.hpp:138
Document & mDocument
Definition: savingstages.hpp:31
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.hpp:98
virtual int setup()
Definition: savingstages.cpp:412
Definition: savingstages.hpp:67
CollectionReferencesStage(Document &document, SavingState &state)
Definition: savingstages.cpp:195
virtual int setup()
Definition: savingstages.cpp:23
Scope
Definition: scope.hpp:8
virtual int setup()
Definition: savingstages.cpp:184
Definition: stage.hpp:15
Definition: record.hpp:15
Scope getScopeFromId(const std::string &id)
Definition: scope.cpp:7
WriteLandTextureCollectionStage(Document &document, SavingState &state)
Definition: savingstages.cpp:433
const CSMWorld::IdCollection< ESM::Dialogue > & mTopics
Definition: savingstages.hpp:121
WriteLandCollectionStage(Document &document, SavingState &state)
Definition: savingstages.cpp:407
WriteHeaderStage(Document &document, SavingState &state, bool simple)
Definition: savingstages.cpp:41
WriteCollectionStage(const CollectionT &collection, SavingState &state, CSMWorld::Scope scope=CSMWorld::Scope_Content)
Definition: savingstages.hpp:86
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:468
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:486
SavingState & mState
Definition: savingstages.hpp:206
Definition: scope.hpp:11
Definition: document.hpp:57
SavingState & mState
Definition: savingstages.hpp:120
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:261
SavingState & mState
Definition: savingstages.hpp:50
const CollectionT & mCollection
Definition: savingstages.hpp:69
SavingState & mState
Definition: savingstages.hpp:223
Definition: savingstages.hpp:186
Definition: savingstages.hpp:220
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:28
Document & mDocument
Definition: savingstages.hpp:205
Definition: savingstages.hpp:251
WriteCellCollectionStage(Document &document, SavingState &state)
Definition: savingstages.cpp:251
Document & mDocument
Definition: savingstages.hpp:222
Document & mDocument
Definition: savingstages.hpp:188
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:101
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:189
SavingState & mState
Definition: savingstages.hpp:70
void endRecord(const std::string &name)
Definition: esmwriter.cpp:132
SavingState & mState
Definition: savingstages.hpp:172
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:212
Document & mDocument
Definition: savingstages.hpp:253
virtual int setup()
Definition: savingstages.hpp:92
Definition: savingstate.hpp:20
SavingState & mState
Definition: savingstages.hpp:32
Document & mDocument
Definition: savingstages.hpp:171
virtual int setup()
Definition: savingstages.cpp:438
OpenSaveStage(Document &document, SavingState &state, bool projectFile)
Definition: savingstages.cpp:19
virtual void perform(int stage, Messages &messages)
Messages resulting from this stage will be appended to messages.
Definition: savingstages.cpp:50
Definition: savingstages.hpp:203