Spaces:
Running
Running
(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__) { | |
; | |
__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__) { | |
; | |
__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 |