Skip to content

Commit

Permalink
Line: shift transform times when detokenizing.
Browse files Browse the repository at this point in the history
This should save a bit of time creating a bunch of transform tables, as
well as fix some weird problems.
  • Loading branch information
torque committed Oct 17, 2014
1 parent b3bdbbb commit aadd9b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 13 additions & 3 deletions src/Line.moon
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,13 @@ class Line

detokenizeTransforms: =>
@loopOverTokenizedTransforms ( index ) ->
return @transforms[tonumber index]\toString @
transform = @transforms[tonumber index]
transform.startTime -= @transformShift
transform.endTime -= @transformShift
result = transform\toString!
transform.startTime += @transformShift
transform.endTime += @transformShift
return result

if @transformEnded
@transformEnded = nil
Expand All @@ -308,10 +314,14 @@ class Line
interpolateTransforms: =>
@loopOverTokenizedTransforms ( index ) ->
transform = @transforms[tonumber index]
transform.startTime -= @transformShift
transform.endTime -= @transformShift
transform\gatherTagsInEffect!
transform\collectPriorState @
return transform\interpolate aegisub.ms_from_frame(aegisub.frame_from_ms(@start_time)+1) - @start_time
@deduplicateTags!
result = transform\interpolate aegisub.ms_from_frame(aegisub.frame_from_ms(@start_time)+1) - @start_time
transform.startTime += @transformShift
transform.endTime += @transformShift
return result

combineWithLine: ( line ) =>
if @text == line.text and @style == line.style and (@start_time == line.end_time or @end_time == line.start_time)
Expand Down
10 changes: 1 addition & 9 deletions src/MotionHandler.moon
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,7 @@ class MotionHandler
newText = newText\gsub pattern, ( tag, value ) ->
tag .. callback @, value, frame

newTransforms = { }
for transform in *.transforms
table.insert newTransforms, Transform transform.startTime - timeDelta,
transform.endTime - timeDelta,
transform.accel,
transform.effect,
transform.index

@resultingCollection\addLine Line line, @resultingCollection, { text: newText, start_time: newStartTime, end_time: newEndTime, transforms: newTransforms }
@resultingCollection\addLine Line line, @resultingCollection, { text: newText, start_time: newStartTime, end_time: newEndTime, transformShift: timeDelta }

position = ( pos, frame ) =>
x, y = pos\match "([%-%d%.]+),([%-%d%.]+)"
Expand Down

0 comments on commit aadd9b8

Please sign in to comment.