@@ -307,10 +307,10 @@ protected void serialiseMetadataValues(List<String> out, LinkedHashMap<String, S
307
307
* ├── {@link #serialiseCameraAngle(VirtualCameraAngle)}
308
308
* │ └── {@link #serialiseCameraAngleSubtick(VirtualCameraAngle)}
309
309
* ├── {@link #serialiseInlineComments(List, List)}
310
- * │ └── {@link #serialiseFileCommandsInLine (List)}
310
+ * │ └── {@link #serialiseFileCommandsInline (List)}
311
311
* │ └── {@link #serialiseFileCommand(PlaybackFileCommand)}
312
312
* ├── {@link #serialiseEndlineComments(List, List)} // Same as serialiseInlineComments
313
- * │ └── {@link #serialiseFileCommandsEndLine (List)} // Unused
313
+ * │ └── {@link #serialiseFileCommandsEndline (List)} // Unused
314
314
* │ └── {@link #serialiseFileCommand(PlaybackFileCommand)}
315
315
* └── {@link #mergeInputs(BigArrayList, List, List, List, List)}
316
316
* ├── {@link #mergeInput(long, String, String, String, String)}
@@ -489,7 +489,7 @@ protected String serialiseCameraAngleSubtick(VirtualCameraAngle cameraAngleSubti
489
489
490
490
/**
491
491
* <p>Serialise comments that take up an entire line
492
- * <p>In addition, comments can contain {@link PlaybackFileCommand FileCommands} that are serialised in {@link #serialiseFileCommandsInLine (List)}
492
+ * <p>In addition, comments can contain {@link PlaybackFileCommand FileCommands} that are serialised in {@link #serialiseFileCommandsInline (List)}
493
493
* <h5>Example</h5>
494
494
* <pre>
495
495
* // Inline comment
@@ -518,7 +518,7 @@ protected List<String> serialiseInlineComments(List<String> inlineComments, List
518
518
519
519
String command = null ;
520
520
if (fileCommandQueue != null ) {
521
- command = serialiseFileCommandsInLine (fileCommandQueue .poll ()); // Trying to poll a fileCommand. Command can be null at this point
521
+ command = serialiseFileCommandsInline (fileCommandQueue .poll ()); // Trying to poll a fileCommand. Command can be null at this point
522
522
}
523
523
524
524
// Add an empty line if comment and command is null
@@ -537,7 +537,7 @@ protected List<String> serialiseInlineComments(List<String> inlineComments, List
537
537
// add the rest of the fileCommands to the end
538
538
while (!fileCommandQueue .isEmpty ()) {
539
539
540
- String command = serialiseFileCommandsInLine (fileCommandQueue .poll ());
540
+ String command = serialiseFileCommandsInline (fileCommandQueue .poll ());
541
541
if (command != null ) {
542
542
out .add (serialiseInlineComment (command ));
543
543
} else {
@@ -582,7 +582,7 @@ protected List<String> serialiseEndlineComments(List<String> endlineComments, Li
582
582
583
583
String command = null ;
584
584
if (fileCommandQueue != null ) {
585
- command = serialiseFileCommandsEndLine (fileCommandQueue .poll ()); // Trying to poll a fileCommand. Command can be null at this point
585
+ command = serialiseFileCommandsEndline (fileCommandQueue .poll ()); // Trying to poll a fileCommand. Command can be null at this point
586
586
}
587
587
588
588
// Add an empty line if comment and command is null
@@ -601,7 +601,7 @@ protected List<String> serialiseEndlineComments(List<String> endlineComments, Li
601
601
// add the rest of the fileCommands to the end
602
602
while (!fileCommandQueue .isEmpty ()) {
603
603
604
- String command = serialiseFileCommandsEndLine (fileCommandQueue .poll ());
604
+ String command = serialiseFileCommandsEndline (fileCommandQueue .poll ());
605
605
if (command != null ) {
606
606
out .add (serialiseEndlineComment (command ));
607
607
} else {
@@ -629,7 +629,7 @@ protected String serialiseEndlineComment(String comment) {
629
629
* @param fileCommands The file commands to serialise
630
630
* @return A string of serialised file commands or null if fileCommands is null
631
631
*/
632
- protected String serialiseFileCommandsInLine (List <PlaybackFileCommand > fileCommands ) {
632
+ protected String serialiseFileCommandsInline (List <PlaybackFileCommand > fileCommands ) {
633
633
// File commands is null if there are no file commands in the comment.
634
634
// Return null if that is the case
635
635
if (fileCommands == null ) {
@@ -645,16 +645,16 @@ protected String serialiseFileCommandsInLine(List<PlaybackFileCommand> fileComma
645
645
/**
646
646
* <p>Serialises a list of file commands in an endline comment
647
647
* <p>This is added in case a flavor needs a different format for endline and inline commands,<br>
648
- * but by default this is the same as {@link #serialiseFileCommandsInLine (List) serialiseFileCommandsInLine}
648
+ * but by default this is the same as {@link #serialiseFileCommandsInline (List) serialiseFileCommandsInLine}
649
649
* <h5>Example</h5>
650
650
* <pre>
651
651
* 12|W;w||0;0 // $fileCommandName1(argument1); $fileCommandName2(argument1, argument2);
652
652
* </pre>
653
653
* @param fileCommands The file commands to serialise
654
654
* @return A string of serialised file commands or null if fileCommands is null
655
655
*/
656
- protected String serialiseFileCommandsEndLine (List <PlaybackFileCommand > fileCommands ) {
657
- return serialiseFileCommandsInLine (fileCommands );
656
+ protected String serialiseFileCommandsEndline (List <PlaybackFileCommand > fileCommands ) {
657
+ return serialiseFileCommandsInline (fileCommands );
658
658
}
659
659
660
660
/**
@@ -990,7 +990,7 @@ public BigArrayList<TickContainer> deserialise(BigArrayList<String> lines, long
990
990
// Extract the tick and set the index
991
991
i = extractContainer (container , lines , i );
992
992
currentLine = i ;
993
- // Extract container
993
+ // Deserialise container
994
994
deserialiseContainer (out , container );
995
995
currentTick ++;
996
996
}
@@ -1222,7 +1222,7 @@ protected void deserialiseMultipleInlineComments(List<String> inlineComments, Li
1222
1222
}
1223
1223
1224
1224
protected String deserialiseInlineComment (String comment , List <PlaybackFileCommand > deserialisedFileCommands ) {
1225
- comment = deserialiseFileCommands (comment , deserialisedFileCommands );
1225
+ comment = deserialiseFileCommandsInline (comment , deserialisedFileCommands );
1226
1226
comment = extract ("^// ?(.+)" , comment , 1 );
1227
1227
if (comment != null ) {
1228
1228
comment = comment .trim ();
@@ -1234,11 +1234,36 @@ protected String deserialiseInlineComment(String comment, List<PlaybackFileComma
1234
1234
}
1235
1235
1236
1236
protected String deserialiseEndlineComment (String comment , List <PlaybackFileCommand > deserialisedFileCommands ) {
1237
- return deserialiseInlineComment (comment , deserialisedFileCommands );
1237
+ comment = deserialiseFileCommandsEndline (comment , deserialisedFileCommands );
1238
+ comment = extract ("^// ?(.+)" , comment , 1 );
1239
+ if (comment != null ) {
1240
+ comment = comment .trim ();
1241
+ if (comment .isEmpty ()) {
1242
+ comment = null ;
1243
+ }
1244
+ }
1245
+ return comment ;
1238
1246
}
1239
1247
1240
- protected String deserialiseFileCommands (String comment , List <PlaybackFileCommand > deserialisedFileCommands ) {
1248
+ protected String deserialiseFileCommandsInline (String comment , List <PlaybackFileCommand > deserialisedFileCommands ) {
1249
+ Matcher matcher = extract ("\\ $(.+?)\\ ((.*?)\\ );" , comment );
1250
+
1251
+ // Iterate through all file commands and add each to the list
1252
+ while (matcher .find ()) {
1253
+ String name = matcher .group (1 );
1254
+ String [] args = matcher .group (2 ).split (", ?" );
1255
+
1256
+ if (processExtensions )
1257
+ deserialisedFileCommands .add (new PlaybackFileCommand (name , args ));
1241
1258
1259
+ comment = matcher .replaceFirst ("" );
1260
+ matcher .reset (comment );
1261
+ }
1262
+
1263
+ return comment ;
1264
+ }
1265
+
1266
+ protected String deserialiseFileCommandsEndline (String comment , List <PlaybackFileCommand > deserialisedFileCommands ) {
1242
1267
Matcher matcher = extract ("\\ $(.+?)\\ ((.*?)\\ );" , comment );
1243
1268
1244
1269
// Iterate through all file commands and add each to the list
@@ -1467,7 +1492,7 @@ protected void splitInputs(List<String> lines, List<String> serialisedKeyboard,
1467
1492
}
1468
1493
1469
1494
for (String line : lines ) {
1470
- Matcher tickMatcher = extract ("^ \\ t? \\ d+ \\ |(.*?) \\ |(.*?) \\ |( \\ S*) \\ s?" , line );
1495
+ Matcher tickMatcher = extract (splitInputRegex () , line );
1471
1496
1472
1497
if (tickMatcher .find ()) {
1473
1498
if (!tickMatcher .group (1 ).isEmpty ()) {
@@ -1498,6 +1523,10 @@ protected void splitInputs(List<String> lines, List<String> serialisedKeyboard,
1498
1523
}
1499
1524
}
1500
1525
1526
+ protected String splitInputRegex () {
1527
+ return "^\\ t?\\ d+\\ |(.*?)\\ |(.*?)\\ |(\\ S*)\\ s?" ;
1528
+ }
1529
+
1501
1530
protected Matcher extract (String regex , String haystack ) {
1502
1531
Pattern pattern = Pattern .compile (regex , Pattern .MULTILINE );
1503
1532
Matcher matcher = pattern .matcher (haystack );
0 commit comments