Add FPSCounter toggle button (Debug only)

This commit is contained in:
OleSTEEP 2024-01-09 02:09:56 +03:00
parent bc89b1f1ff
commit f4a9d6897e
2 changed files with 26 additions and 0 deletions

View file

@ -38,6 +38,15 @@
min-height: 6vh;
}
.fps-button {
position: absolute;
left: 5px;
top: 5px;
width: 90px;
height: 40px;
z-index: 1489;
}
.gamepad-buttons {
opacity: 0.9;
z-index: 1488;

View file

@ -50,6 +50,22 @@ function create_control_buttons() {
document.body.appendChild(DivBMain);
}
function create_fps_button() {
// Remove in release
const keys = [{ key: 'F2', keyCode: 113 }];
const FPSBtn = document.createElement("div");
FPSBtn.className = "fps-button";
FPSBtn.id = "buttonF2";
document.body.appendChild(FPSBtn);
for (const key of keys) {
const elementId = key.id === undefined ? `button${key.key}` : key.id;
console.log(`Setting up the ${elementId} key...`);
setupKey(elementId, key.key, key.keyCode);
}
}
function create_dpad_buttons() {
// Скуфting elements
const DivDMain = document.createElement("div");
@ -266,6 +282,7 @@ function setupKey(id, key, keyCode) {
}
window.addEventListener('load', () => {
create_fps_button(); // Remove in release
if (navigator.getGamepads().length == 0) {
create_control_buttons();
create_dpad_buttons();