diff --git a/docs/TimelineGuide.md b/docs/TimelineGuide.md index 08f92bd22d..3acbbb59f3 100644 --- a/docs/TimelineGuide.md +++ b/docs/TimelineGuide.md @@ -76,14 +76,19 @@ Every timeline entry begins with the ability time and the ability name. `Number "String" (duration Number)` -`Number "String" sync /Regex/ (window Number,Number) (jump Number) (duration Number)` +`Number "String" sync /Regex/ (window Number,Number) (jump NumberOrLabel) (duration Number)` -`Number "String" sync /Regex/ (window Number,Number) (forcejump Number) (duration Number)` +`Number "String" sync /Regex/ (window Number,Number) (forcejump NumberOrLabel) (duration Number)` + +`Number label "String"` (The parentheses here indicate optionality and are not literal parentheses.) **Number** can be an integer, e.g. `34`, or a float, e.g. `84.381`. +**NumberOrLabel** can be a **Number** (e.g. `42` or `12.8`) +or a label name with double quotes (e.g. `"loop"` or `"branch2"`). + **String** is a character string, e.g. `"Liftoff"` or `"Double Attack"` **Regex** is a [Javascript regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). diff --git a/ui/raidboss/data/00-misc/test.txt b/ui/raidboss/data/00-misc/test.txt index 77cb7c9b6f..14e7aee9c7 100644 --- a/ui/raidboss/data/00-misc/test.txt +++ b/ui/raidboss/data/00-misc/test.txt @@ -29,14 +29,16 @@ hideall "--sync--" 30 "Dummy Stands Still" 40 "Death" -50 "--sync--" sync /:test sync2:/ window 100,1 forcejump 100 +50 "--sync--" sync /:test sync2:/ window 100,1 forcejump "loop" # Loop test! +100 label "loop" 102 "Two" +103 label "three" 103 "Three" 104 "Four" 106 "Six" 110 "Ten" #duration 100 115 "Fifteen" -118 "Force Jump Three" sync /:test sync3:/ window 10,10 forcejump 103 +118 "Force Jump Three" sync /:test sync3:/ window 10,10 forcejump "three" 120 "Invisible" sync /:test sync4:/ forcejump 1000 diff --git a/ui/raidboss/timeline_parser.ts b/ui/raidboss/timeline_parser.ts index 336888d947..c4dc3b3cdf 100644 --- a/ui/raidboss/timeline_parser.ts +++ b/ui/raidboss/timeline_parser.ts @@ -79,13 +79,24 @@ export class TimelineParser { protected replacements: TimelineReplacement[]; private timelineConfig: TimelineConfig; - public ignores: { [ignoreId: string]: boolean }; - public events: Event[]; - public texts: Text[]; - public syncStarts: Sync[]; - public syncEnds: Sync[]; - public forceJumps: Sync[]; - public errors: Error[]; + // A set of names which will not be notified about. + public ignores: { [ignoreId: string]: boolean } = {}; + // Sorted by event occurrence time. + public events: Event[] = []; + // Sorted by event occurrence time. + public texts: Text[] = []; + // Sorted by sync.start time. + public syncStarts: Sync[] = []; + // Sorted by sync.end time. + public syncEnds: Sync[] = []; + // Sorted by event occurrence time. + public forceJumps: Sync[] = []; + // Sorted by line. + public errors: Error[] = []; + // Map of encountered label names to their time. + private labelToTime: { [name: string]: number } = {}; + // Map of encountered syncs to the label they are jumping to. + private labelToSync: { [name: string]: Sync[] } = {}; constructor( text: string, @@ -99,21 +110,6 @@ export class TimelineParser { this.perTriggerAutoConfig = this.options.PerTriggerAutoConfig; this.replacements = replacements; - // A set of names which will not be notified about. - this.ignores = {}; - // Sorted by event occurrence time. - this.events = []; - // Sorted by event occurrence time. - this.texts = []; - // Sorted by sync.start time. - this.syncStarts = []; - // Sorted by sync.end time. - this.syncEnds = []; - // Sorted by event occurrence time. - this.forceJumps = []; - // Sorted by line. - this.errors = []; - this.timelineConfig = typeof zoneId === 'number' ? this.options.PerZoneTimelineConfig[zoneId] ?? {} : {}; @@ -150,7 +146,8 @@ export class TimelineParser { durationCommand: /(?:[^#]*?\s)?(?duration\s+(?[0-9]+(?:\.[0-9]+)?))(\s.*)?$/, ignore: /^hideall\s+\"(?[^"]+)\"(?:\s*#.*)?$/, jumpCommand: - /(?:[^#]*?\s)?(?(?(?:force|)jump)\s+(?[0-9]+(?:\.[0-9]+)?))(?:\s.*)?$/, + /(?:[^#]*?\s)?(?(?(?:force|)jump)\s+(?:"(?