Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/angular/controllers/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function($scope, $window, $route, $location, $element, Match) {
// console.log("matchscope", $scope);
$scope.$watch('current_frame', function(v) {
if(v) {
$scope.current_time = Sc2.frameToTime(v);
$scope.current_time = Sc2.frameToTime(v, $scope.match.expansion);
$scope.time_has_been_set = true
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/angular/directives/armychart.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ gg.directive('armychart', ['$location', '$timeout', function($location, $timeout
scope.freeze = function(frame, updateURL) {
switch(typeof frame) {
case "number": frame = frame; break;
case "string": frame = Sc2.timeToFrame(frame); break;
case "string": frame = Sc2.timeToFrame(frame, scope.match.expansion); break;
default: return false;
}

Expand Down Expand Up @@ -162,7 +162,7 @@ gg.directive('armychart', ['$location', '$timeout', function($location, $timeout
if(typeof e == "number") {
frame = e;
} else if(typeof e == "string") {
frame = Sc2.timeToFrame(e);
frame = Sc2.timeToFrame(e, scope.match.expansion);
} else {
// If clicked on the background, we have xAxis on the event, if clicked
// on a series, we'll have the point.
Expand Down
16 changes: 12 additions & 4 deletions app/assets/javascripts/angular/helpers/sc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,13 @@ for (var expansion_tag in Sc2.armyUnits) {

// I'd rather stuff these here, than in Match

Sc2.frameToTime = function(frame) {
minute = Math.floor(frame / (60 * 16));
second = Math.floor((frame / 16) % 60).toString();
Sc2.frameToTime = function(frame, expansion) {
fps = 16;
if (expansion >= 2) {
fps *= 1.4;
}
minute = Math.floor(frame / (60 * fps));
second = Math.floor((frame / fps) % 60).toString();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to doublecheck carefully:
Pre-LotV: 960 frames = 1:00 on the game clock = 0:43 on a real clock
LotV: 960 frames = 0:43 on the game clock = 0:43 on a real clock

so, yeah there used to be 16 frames per game second, and now there's ~16 * 1.4 frames per game second. looks good to me.

if (second.length < 2) {
second = "0" + second;
}
Expand All @@ -271,7 +275,11 @@ Sc2.timeToFrame = function(time) {
parts = time.split(':');
seconds = parseInt(parts[parts.length-1]);
minutes = parseInt(parts[parts.length-2]);
frame = ((minutes*60) + seconds) * 16;
fps = 16;
if (expansion >= 2) {
fps *= 1.4;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would recommend using a constant for the 1.4, because i suspect we may want to change it to 1.36 or 1.38 at some point, and we want it to be easy to change everywhere.

}
frame = ((minutes*60) + seconds) * fps;
return frame;
}

Expand Down