From b2592aad8c4b66b326af57ef1d6fe33e4c3b8578 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 24 Sep 2014 21:01:58 -0700 Subject: [PATCH] Fixed more off-by-one errors in playback ratios. Fixed some clickability problems with the scrubber handle. --- app/lib/surface/Surface.coffee | 4 ++-- app/styles/play/level.sass | 2 +- app/styles/play/level/playback.sass | 10 +++++++--- app/views/play/level/LevelPlaybackView.coffee | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/lib/surface/Surface.coffee b/app/lib/surface/Surface.coffee index 1dcc5aad8..c0267e081 100644 --- a/app/lib/surface/Surface.coffee +++ b/app/lib/surface/Surface.coffee @@ -249,7 +249,7 @@ module.exports = Surface = class Surface extends CocoClass createjs.Tween.removeTweens(@) @currentFrame = @scrubbingTo - @scrubbingTo = Math.min(Math.round(progress * @world.frames.length), @world.frames.length) + @scrubbingTo = Math.min(Math.round(progress * (@world.frames.length - 1)), @world.frames.length - 1) @scrubbingPlaybackSpeed = Math.sqrt(Math.abs(@scrubbingTo - @currentFrame) * @world.dt / (scrubDuration or 0.5)) if scrubDuration t = createjs.Tween @@ -433,7 +433,7 @@ module.exports = Surface = class Surface extends CocoClass @setWorld event.world @onFrameChanged(true) fastForwardBuffer = 2 - if @playing and not @realTime and (ffToFrame = Math.min(event.firstChangedFrame, @frameBeforeCast, @world.frames.length)) and ffToFrame > @currentFrame + fastForwardBuffer * @world.frameRate + if @playing and not @realTime and (ffToFrame = Math.min(event.firstChangedFrame, @frameBeforeCast, @world.frames.length - 1)) and ffToFrame > @currentFrame + fastForwardBuffer * @world.frameRate @fastForwardingToFrame = ffToFrame @fastForwardingSpeed = Math.max 4, 4 * 90 / (@world.maxTotalFrames * @world.dt) else if @realTime diff --git a/app/styles/play/level.sass b/app/styles/play/level.sass index d0ffb4ab3..6e864a168 100644 --- a/app/styles/play/level.sass +++ b/app/styles/play/level.sass @@ -123,7 +123,7 @@ $level-resize-transition-time: 0.5s .gradient position: absolute - z-index: 10 + z-index: 5 #code-area-gradient top: 0px diff --git a/app/styles/play/level/playback.sass b/app/styles/play/level/playback.sass index b67e8ee28..f98ac1492 100644 --- a/app/styles/play/level/playback.sass +++ b/app/styles/play/level/playback.sass @@ -100,25 +100,29 @@ // Can't do this transition because handle then jitters, but would be good for streaming. //@include transition(width .2s linear) - &.disabled + &.disabled, &.ui-slider-disabled cursor: default + .progress-bar .scrubber-handle + cursor: default + .progress-bar @include transition(width .0s linear) position: relative - pointer-events: none // Remove gradient background in favor of solid fill background-color: #67A4C8 //background-image: none // gradient looks kind of cool though; keep it in .scrubber-handle + cursor: pointer position: absolute - pointer-events: none right: -16px top: -9px background: transparent url(/images/level/playback_thumb.png) width: 32px height: 32px + // z: above the gradient line bordering the playback bar + z-index: 6 .ui-slider-handle height: 100% diff --git a/app/views/play/level/LevelPlaybackView.coffee b/app/views/play/level/LevelPlaybackView.coffee index ca2312515..8e7cdd847 100644 --- a/app/views/play/level/LevelPlaybackView.coffee +++ b/app/views/play/level/LevelPlaybackView.coffee @@ -179,8 +179,8 @@ module.exports = class LevelPlaybackView extends CocoView @updateBarWidth e.world.frames.length, e.world.maxTotalFrames, e.world.dt updateBarWidth: (loadedFrameCount, maxTotalFrames, dt) -> - @totalTime = loadedFrameCount * dt - pct = parseInt(100 * loadedFrameCount / maxTotalFrames) + '%' + @totalTime = (loadedFrameCount - 1) * dt + pct = parseInt(100 * loadedFrameCount / (maxTotalFrames - 1)) + '%' @barWidth = $('.progress', @$el).css('width', pct).show().width() $('.scrubber .progress', @$el).slider('enable', true) @newTime = 0