diff options
Diffstat (limited to 'src/renderer/gameserver/serverView/screenshots.ts')
-rw-r--r-- | src/renderer/gameserver/serverView/screenshots.ts | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/renderer/gameserver/serverView/screenshots.ts b/src/renderer/gameserver/serverView/screenshots.ts index 3157365..b2c0abf 100644 --- a/src/renderer/gameserver/serverView/screenshots.ts +++ b/src/renderer/gameserver/serverView/screenshots.ts @@ -1,4 +1,4 @@ -import { ipcRenderer, shell } from "electron"; +import { ML_Runtime } from "../../runtime"; import { GameServerPage } from "./serverPage"; export class ServerScreenshotPage extends GameServerPage { @@ -7,24 +7,28 @@ export class ServerScreenshotPage extends GameServerPage { screenshotContainer.classList.add("screenshotsContainer"); screenshotContainer.id = "screenshots"; - ipcRenderer.send("getScreenshots", this.server.profile.address); + ML_Runtime.getScreenshots(this.server.profile.address) + .then(this.dataLoadedCallback.bind(null, screenshotContainer)) + .catch((err) => { + // handle this? + console.error(err); + }); return screenshotContainer; } -} -ipcRenderer.on( - "getScreenshots", - (event: any, data: { dir: string; screenshots: string[] }) => { + private dataLoadedCallback( + screenshotContainer: HTMLDivElement, + data: { dir: string; screenshots: string[] } + ) { console.log(data); - const screenshots = document.getElementById("screenshots"); - if (screenshots) { + if (screenshotContainer) { // Display screenshots if that tab is open if (data.screenshots.length !== 0) { data.screenshots.forEach((fileName: string) => { const screenshot = document.createElement("div"); screenshot.classList.add("screenshot"); - screenshots.appendChild(screenshot); + screenshotContainer.appendChild(screenshot); const img = document.createElement("img"); img.src = data.dir + fileName; screenshot.appendChild(img); @@ -34,7 +38,7 @@ ipcRenderer.on( // screenshot.appendChild(text); screenshot.addEventListener("dragstart", (event) => { event.preventDefault(); - ipcRenderer.send("dragFileOut", data.dir + fileName); + ML_Runtime.dragFileOut(data.dir + fileName); }); }); } else { @@ -43,15 +47,15 @@ ipcRenderer.on( nothingHere.innerText = "There is nothing here, yet. Make some screenshots in Game and come back here. The default key for snaping screenshots is 'P'."; - screenshots.appendChild(nothingHere); + screenshotContainer.appendChild(nothingHere); } const openFolderButton = document.createElement("button"); openFolderButton.innerText = "Open folder to see all"; openFolderButton.addEventListener("click", () => { - shell.openPath(data.dir); + ML_Runtime.openFolder(data.dir); }); - screenshots.appendChild(openFolderButton); + screenshotContainer.appendChild(openFolderButton); } } -); +} |