replay-viewer
Version:
Rocket League replay viewer React component and tooling
58 lines • 2.58 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import Button from "@mui/material/Button";
import Grid from "@mui/material/Grid";
import React, { Component } from "react";
import { addPlayPauseListener, dispatchPlayPauseEvent, removePlayPauseListener, } from "../../eventbus/events/playPause";
import { GameManager } from "../../managers/GameManager";
var PlayControls = /** @class */ (function (_super) {
__extends(PlayControls, _super);
function PlayControls(props) {
var _this = _super.call(this, props) || this;
_this.setPlayPause = function () {
var isPaused = _this.state.paused;
dispatchPlayPauseEvent({
paused: !isPaused,
});
};
_this.onPlayPause = function (_a) {
var paused = _a.paused;
_this.setState({
paused: paused,
});
};
_this.state = {
paused: false,
};
addPlayPauseListener(_this.onPlayPause);
return _this;
}
PlayControls.prototype.componentWillUnmount = function () {
removePlayPauseListener(this.onPlayPause);
};
PlayControls.prototype.render = function () {
var clock = GameManager.getInstance().clock;
var onResetClick = function () { return clock.setFrame(0); };
return (React.createElement(Grid, { container: true, spacing: 3 },
React.createElement(Grid, { item: true },
React.createElement(Button, { variant: "outlined", onClick: this.setPlayPause }, this.state.paused ? "Play" : "Pause")),
React.createElement(Grid, { item: true },
React.createElement(Button, { variant: "outlined", onClick: onResetClick }, "Reset"))));
};
return PlayControls;
}(Component));
export default PlayControls;
//# sourceMappingURL=PlayControls.js.map