Skip to content

Commit

Permalink
POTENTIALLY BREAKING: Fix lengthless behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
marchc1 committed Jan 13, 2025
1 parent 84e970b commit 72554fc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lua/ponder/classes_cl/playback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function Ponder.Playback:FinalizeInstructionIndex(instrIndex)
end

function Ponder.Playback:IsInstructionIndexLengthless(instrIndex)
return self.InstructionIndices[instrIndex].Length == 0
return self.InstructionIndices[instrIndex].Instruction.Length == 0
end

function Ponder.Playback:RunLengthlessInstructionIndex(instrIndex)
Expand Down Expand Up @@ -197,6 +197,7 @@ function Ponder.Playback:ToggleIdentify()
end

function Ponder.Playback:GetInstructionProgress(instruction)
if instruction.Length == 0 then return 1 end
local curChapTime = self:GetChapter().StartTime
return math.Clamp(math.Remap(self.Time, curChapTime + instruction.Time, curChapTime + instruction.Time + instruction.Length, 0, 1), 0, 1)
end
Expand Down Expand Up @@ -357,13 +358,19 @@ function Ponder.Playback:SeekChapter(chapterIndex)
local seekChapter = self.Storyboard.Chapters[chapterIndex]
self.Time = seekChapter.StartTime

for _, instruction in ipairs(seekChapter.Instructions) do
self:ClearInstructionIndices()
self:InitializeInstructionIndices()

for instrIndex, instruction in ipairs(seekChapter.Instructions) do
if instruction.Time == 0 then
instruction:First(self)
if self:IsInstructionIndexLengthless(instrIndex) then
self:RunLengthlessInstructionIndex(instrIndex)
else
self:StartInstructionIndex(instrIndex)
self:UpdateInstructionIndex(instrIndex)
end
end
end

self:ClearInstructionIndices()
self:InitializeInstructionIndices()
self.Seeking = false
end

0 comments on commit 72554fc

Please sign in to comment.