29
29
import com .minecrafttas .tasmod .virtual .VirtualMouse ;
30
30
31
31
/**
32
- * <p>The base class of a flavor.
32
+ * <p>The base class of a flavor
33
33
*
34
34
* <p>All serialisation and deserialisation is broken apart into functions whenever possible,<br>
35
35
* with the intention of allowing small changes to the existing syntax.
@@ -116,32 +116,61 @@ public abstract class SerialiserFlavorBase implements Registerable {
116
116
*/
117
117
118
118
/**
119
+ * <h3>Example</h3>
120
+ * <pre>
121
+ * ##################### TASfile ####################
122
+ * </pre>
119
123
* @return The very top of the header
120
124
*/
121
125
protected String headerStart () {
122
126
return createCenteredHeading ("TASfile" , '#' , 50 );
123
127
}
124
128
125
129
/**
126
- * The end of the header, used for detecting when the header stops
130
+ * <p>The end of the header, used for detecting when the header stops
131
+ * <h3>Example</h3>
132
+ * <pre>
133
+ * ##################################################
134
+ * </pre>
127
135
* @return The end of the header
128
136
*/
129
137
protected String headerEnd () {
130
138
return createPaddedString ('#' , 50 );
131
139
}
132
140
133
141
/**
134
- * <p>Serialises the flavor of this file, the enabled file commands and other metadata.
135
- * <p>{@link #serialiseFlavorName(List)}
142
+ * <p>Serialises the flavor of this file, the enabled file commands and other metadata
143
+ * <h3>Tree</h3>
136
144
* <pre>
137
145
* serialiseHeader
138
- * ├── {@link #headerStart()} // The start of the header
139
- * ├── {@link #serialiseFlavorName(List)} // The name of the flavor
140
- * ├── {@link #serialiseFileCommandNames(List)} // The names of the enabled file commands
141
- * ├── {@link #serialiseMetadata(List)} // The metadata of this movie
142
- * │ ├── {@link #serialiseMetadataName(List, String)} // The metadata extension name
143
- * │ └── {@link #serialiseMetadataValues(List, LinkedHashMap)} // All values in the extension
144
- * └── {@link #headerEnd()} // The end of the header
146
+ * ├── {@link #headerStart()}
147
+ * ├── {@link #serialiseFlavorName(List)}
148
+ * ├── {@link #serialiseFileCommandNames(List)}
149
+ * ├── {@link #serialiseMetadata(List)}
150
+ * │ ├── {@link #serialiseMetadataName(List, String)}
151
+ * │ └── {@link #serialiseMetadataValues(List, LinkedHashMap)}
152
+ * └── {@link #headerEnd()}
153
+ * </pre>
154
+ * <h3>Example</h3>
155
+ * <pre>
156
+ * ##################### TASfile #################### // {@link #headerStart()}
157
+ * Flavor: beta1 // {@link #serialiseFlavorName(List)}
158
+ * FileCommand-Extensions: tasmod_desyncMonitor@v1, tasmod_options@v1, tasmod_label@v1 // {@link #serialiseFileCommandNames(List)}
159
+ *
160
+ * --------------------- Credits -------------------- // {@link #serialiseMetadataName(List, String)}
161
+ * Title:Insert TAS category here // {@link #serialiseMetadataValues(List, LinkedHashMap)}
162
+ * Author:Insert author here
163
+ * Playing Time:00:00.0
164
+ * Rerecords:0
165
+ *
166
+ * ----------------- Start Position -----------------
167
+ * x:-32.577311363268976
168
+ * y:56.0
169
+ * z:-4.457057187505265
170
+ * pitch:29.25007
171
+ * yaw:-88.80094
172
+ *
173
+ * ################################################## // {@link #headerEnd()}
145
174
* </pre>
146
175
* @return List of lines containing the header
147
176
*/
@@ -156,16 +185,28 @@ public List<String> serialiseHeader() {
156
185
}
157
186
158
187
/**
159
- * <p>How the flavor name is serialised.
188
+ * <p>How the flavor name is serialised
160
189
* <p>You normally don't have to edit this,<br>
161
190
* as the flavor name is taken from the extension name.
191
+ * <h3>Example</h3>
192
+ * <pre>
193
+ * Flavor: beta1
194
+ * </pre>
162
195
*
163
196
* @param out The serialised lines, passed by reference
164
197
*/
165
198
protected void serialiseFlavorName (List <String > out ) {
166
199
out .add ("Flavor: " + getExtensionName ());
167
200
}
168
201
202
+ /**
203
+ * <p>Adds the file commands that are enabled to the lines
204
+ * <h3>Example</h3>
205
+ * <pre>
206
+ * FileCommand-Extensions: tasmod_label@v1, tasmod_desyncMonitor@v1
207
+ * </pre>
208
+ * @param out The serialised lines, passed by reference
209
+ */
169
210
protected void serialiseFileCommandNames (List <String > out ) {
170
211
List <String > stringlist = new ArrayList <>();
171
212
List <PlaybackFileCommandExtension > extensionList = TASmodAPIRegistry .PLAYBACK_FILE_COMMAND .getEnabled ();
@@ -176,6 +217,25 @@ protected void serialiseFileCommandNames(List<String> out) {
176
217
out .add ("" );
177
218
}
178
219
220
+ /**
221
+ * <p>Serialises the metadata to the header of the TASfile
222
+ * <h3>Example</h3>
223
+ * <pre>
224
+ * --------------------- Credits --------------------
225
+ * Title:Insert TAS category here
226
+ * Author:Insert author here
227
+ * Playing Time:00:00.0
228
+ * Rerecords:0
229
+ *
230
+ * ----------------- Start Position -----------------
231
+ * x:-32.577311363268976
232
+ * y:56.0
233
+ * z:-4.457057187505265
234
+ * pitch:29.25007
235
+ * yaw:-88.80094
236
+ * </pre>
237
+ * @param out
238
+ */
179
239
protected void serialiseMetadata (List <String > out ) {
180
240
if (!processExtensions )
181
241
return ;
@@ -189,16 +249,64 @@ protected void serialiseMetadata(List<String> out) {
189
249
}
190
250
}
191
251
252
+ /**
253
+ * <p>Serialises only the name of the metadata section
254
+ * <h3>Example</h3>
255
+ * <pre>
256
+ * --------------------- Credits --------------------
257
+ * </pre>
258
+ * @param out The lines passed in by reference
259
+ * @param name The name to process
260
+ */
192
261
protected void serialiseMetadataName (List <String > out , String name ) {
193
262
out .add (createCenteredHeading (name , '-' , 50 ));
194
263
}
195
264
265
+ /**
266
+ * <p>Serialises only the values of the metadata section
267
+ * <h3>Example</h3>
268
+ * <pre>
269
+ * Title:Insert TAS category here
270
+ * Author:Insert author here
271
+ * Playing Time:00:00.0
272
+ * Rerecords:0
273
+ * </pre>
274
+ * @param out
275
+ * @param data
276
+ */
196
277
protected void serialiseMetadataValues (List <String > out , LinkedHashMap <String , String > data ) {
197
278
data .forEach ((key , value ) -> {
198
279
out .add (String .format ("%s:%s" , key , value ));
199
280
});
200
281
}
201
282
283
+ /*
284
+ ___ _____ _ _ ____ ____ _ _ ____
285
+ / __)( _ )( \( )(_ _)( ___)( \( )(_ _)
286
+ ( (__ )(_)( ) ( )( )__) ) ( )(
287
+ \___)(_____)(_)\_) (__) (____)(_)\_) (__)
288
+
289
+ */
290
+
291
+ /**
292
+ * <p>Serialises a list of inputs into a list of strings
293
+ * <h3>Tree</h3>
294
+ * <pre>
295
+ * serialise
296
+ * └── {@link #serialiseContainer(BigArrayList, TickContainer)}
297
+ * ├── {@link #serialiseKeyboard(VirtualKeyboard)}
298
+ * ├── {@link #serialiseMouse(VirtualMouse)}
299
+ * ├── {@link #serialiseCameraAngle(VirtualCameraAngle)}
300
+ * ├── {@link #serialiseInlineComments(List, List)}
301
+ * │ └── {@link #serialiseFileCommandsInLine(List)}
302
+ * ├── {@link #serialiseEndlineComments(List, List)} // Same as serialiseInlineComments
303
+ * │ └── {@link #serialiseFileCommandsEndLine(List)} // Unused
304
+ * └── {@link #mergeInputs(BigArrayList, List, List, List, List)}
305
+ * </pre>
306
+ * @param inputs The inputs to serialise
307
+ * @param toTick The tick where to stop, used for partial serialisation by savestates. -1 to serialise all
308
+ * @return The list of lines
309
+ */
202
310
public BigArrayList <String > serialise (BigArrayList <TickContainer > inputs , long toTick ) {
203
311
BigArrayList <String > out = new BigArrayList <>();
204
312
@@ -253,6 +361,10 @@ protected String serialiseFileCommandsInLine(List<PlaybackFileCommand> fileComma
253
361
return String .join (" " , serialisedCommands );
254
362
}
255
363
364
+ protected String serialiseFileCommandsEndLine (List <PlaybackFileCommand > fileCommands ) {
365
+ return serialiseFileCommandsInLine (fileCommands );
366
+ }
367
+
256
368
protected List <String > serialiseKeyboard (VirtualKeyboard keyboard ) {
257
369
List <String > out = new ArrayList <>();
258
370
0 commit comments