Spaces:
Running
Running
File size: 4,998 Bytes
8086c81 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
(window["webpackJsonpGUI"] = window["webpackJsonpGUI"] || []).push([[1],{
/***/ "./node_modules/css-loader/index.js!./src/addons/addons/fps/userstyle.css":
/*!***********************************************************************!*\
!*** ./node_modules/css-loader!./src/addons/addons/fps/userstyle.css ***!
\***********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(/*! ../../../../node_modules/css-loader/lib/css-base.js */ "./node_modules/css-loader/lib/css-base.js")(false);
// imports
// module
exports.push([module.i, ".fps-counter {\n font-size: 0.625rem;\n font-weight: bold;\n font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n white-space: nowrap;\n padding: 0.25rem;\n user-select: none;\n color: #0fbd8c;\n display: none;\n align-items: center;\n}\n\n.fps-counter.show {\n display: flex;\n}\n\n.sa-small-stage .fps-counter {\n display: none;\n}", ""]);
// exports
/***/ }),
/***/ "./src/addons/addons/fps/_runtime_entry.js":
/*!*************************************************!*\
!*** ./src/addons/addons/fps/_runtime_entry.js ***!
\*************************************************/
/*! exports provided: resources */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resources", function() { return resources; });
/* harmony import */ var _userscript_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./userscript.js */ "./src/addons/addons/fps/userscript.js");
/* harmony import */ var _css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! css-loader!./userstyle.css */ "./node_modules/css-loader/index.js!./src/addons/addons/fps/userstyle.css");
/* harmony import */ var _css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1__);
/* generated by pull.js */
const resources = {
"userscript.js": _userscript_js__WEBPACK_IMPORTED_MODULE_0__["default"],
"userstyle.css": _css_loader_userstyle_css__WEBPACK_IMPORTED_MODULE_1___default.a
};
/***/ }),
/***/ "./src/addons/addons/fps/userscript.js":
/*!*********************************************!*\
!*** ./src/addons/addons/fps/userscript.js ***!
\*********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony default export */ __webpack_exports__["default"] = (async function (_ref) {
let {
addon,
console,
msg
} = _ref;
const {
vm
} = addon.tab.traps;
const {
runtime
} = vm;
if (!vm.editingTarget) {
await new Promise(resolve => runtime.once("PROJECT_LOADED", resolve));
}
let fpsCounterElement = document.createElement("span");
fpsCounterElement.className = "fps-counter";
addon.tab.displayNoneWhileDisabled(fpsCounterElement);
let lastRender;
let lastFps;
let wasRunning = false;
const {
renderer
} = runtime;
const _draw = renderer.draw;
renderer.draw = function () {
_draw.call(this);
const now = runtime.currentMSecs;
// If it's been more than 500ms since the last draw, we want to reset the variables.
if (typeof lastRender !== "number" || now - lastRender > 500) {
lastRender = now;
lastFps = null;
return;
}
// If the current time has been rendered, return, Don't show infinity.
if (now === lastRender) return;
// Every time this function is ran, store the current time and remove times from half a second ago
let smoothing = 0.9;
let calculatedFps = 1000 / (now - lastRender);
if (typeof lastFps !== "number") lastFps = calculatedFps;
// Calculate a smoothed FPS so that numbers aren't changing too fast.
const fps = Math.round(lastFps * smoothing + calculatedFps * (1 - smoothing));
lastRender = now;
// Show/Hide the element based on if there are any threads running
if (runtime.threads.length === 0) {
if (wasRunning) fpsCounterElement.classList.remove("show");
wasRunning = false;
return;
}
if (!wasRunning) fpsCounterElement.classList.add("show");
if (fps !== lastFps || !wasRunning) fpsCounterElement.innerText = "FPS: ".concat(lastFps = fps);
wasRunning = true;
};
while (true) {
await addon.tab.waitForElement('[class*="controls_controls-container"]', {
markAsSeen: true,
reduxEvents: ["scratch-gui/mode/SET_PLAYER", "fontsLoaded/SET_FONTS_LOADED", "scratch-gui/locales/SELECT_LOCALE"]
});
addon.tab.appendToSharedSpace({
space: "afterStopButton",
element: fpsCounterElement,
order: 3
});
}
});
/***/ })
}]);
//# sourceMappingURL=1.js.map |