()
| 1403 | return mergedButtonOptions; |
| 1404 | } |
| 1405 | createContextMenu() { |
| 1406 | this.elements.contextmenu = this.createElement("div"); |
| 1407 | this.elements.contextmenu.classList.add("ejs_context_menu"); |
| 1408 | this.addEventListener(this.game, "contextmenu", (e) => { |
| 1409 | e.preventDefault(); |
| 1410 | if ((this.config.buttonOpts && this.config.buttonOpts.rightClick === false) || !this.started) return; |
| 1411 | const parentRect = this.elements.parent.getBoundingClientRect(); |
| 1412 | this.elements.contextmenu.style.display = "block"; |
| 1413 | const rect = this.elements.contextmenu.getBoundingClientRect(); |
| 1414 | const up = e.offsetY + rect.height > parentRect.height - 25; |
| 1415 | const left = e.offsetX + rect.width > parentRect.width - 5; |
| 1416 | this.elements.contextmenu.style.left = (e.offsetX - (left ? rect.width : 0)) + "px"; |
| 1417 | this.elements.contextmenu.style.top = (e.offsetY - (up ? rect.height : 0)) + "px"; |
| 1418 | }) |
| 1419 | const hideMenu = () => { |
| 1420 | this.elements.contextmenu.style.display = "none"; |
| 1421 | } |
| 1422 | this.addEventListener(this.elements.contextmenu, "contextmenu", (e) => e.preventDefault()); |
| 1423 | this.addEventListener(this.elements.parent, "contextmenu", (e) => e.preventDefault()); |
| 1424 | this.addEventListener(this.game, "mousedown touchend", hideMenu); |
| 1425 | const parent = this.createElement("ul"); |
| 1426 | const addButton = (title, hidden, functi0n) => { |
| 1427 | //<li><a href="#" onclick="return false">'+title+'</a></li> |
| 1428 | const li = this.createElement("li"); |
| 1429 | if (hidden) li.hidden = true; |
| 1430 | const a = this.createElement("a"); |
| 1431 | if (functi0n instanceof Function) { |
| 1432 | this.addEventListener(li, "click", (e) => { |
| 1433 | e.preventDefault(); |
| 1434 | functi0n(); |
| 1435 | }); |
| 1436 | } |
| 1437 | a.href = "#"; |
| 1438 | a.onclick = "return false"; |
| 1439 | a.innerText = this.localization(title); |
| 1440 | li.appendChild(a); |
| 1441 | parent.appendChild(li); |
| 1442 | hideMenu(); |
| 1443 | return li; |
| 1444 | } |
| 1445 | let screenshotUrl; |
| 1446 | const screenshot = addButton("Take Screenshot", false, () => { |
| 1447 | if (screenshotUrl) URL.revokeObjectURL(screenshotUrl); |
| 1448 | const date = new Date(); |
| 1449 | const fileName = this.getBaseFileName() + "-" + date.getMonth() + "-" + date.getDate() + "-" + date.getFullYear(); |
| 1450 | this.screenshot((blob, format) => { |
| 1451 | screenshotUrl = URL.createObjectURL(blob); |
| 1452 | const a = this.createElement("a"); |
| 1453 | a.href = screenshotUrl; |
| 1454 | a.download = fileName + "." + format; |
| 1455 | a.click(); |
| 1456 | hideMenu(); |
| 1457 | }); |
| 1458 | }); |
| 1459 | |
| 1460 | let screenMediaRecorder = null; |
| 1461 | const startScreenRecording = addButton("Start Screen Recording", false, () => { |
| 1462 | if (screenMediaRecorder !== null) { |
no test coverage detected