blob: 2d6fc622126d6fc40f8f722a6554a185cba536c2 (
plain) (
blame)
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
|
import { ipcRenderer, shell } from "electron";
import { GameServerPage } from "./serverPage";
export class ServerScreenshotPage extends GameServerPage {
getPage(): HTMLElement {
const screenshotContainer = document.createElement('div');
screenshotContainer.classList.add("screenshotsContainer");
screenshotContainer.id = "screenshots";
ipcRenderer.send('getScreenshots', this.server.profile.address);
return screenshotContainer;
}
}
ipcRenderer.on('getScreenshots', (event: any, data: { dir: string, screenshots: string[] }) => {
console.log(data)
const screenshots = document.getElementById('screenshots');
if (screenshots) {
// 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);
const img = document.createElement("img");
img.src = data.dir + fileName;
screenshot.appendChild(img);
// const text = document.createElement("span");
// text.innerText = fileName;
// screenshot.appendChild(text);
screenshot.addEventListener('dragstart', (event) => {
event.preventDefault()
ipcRenderer.send('dragFileOut', data.dir + fileName)
})
});
} else {
const nothingHere = document.createElement("p");
nothingHere.classList.add("nothingHere");
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);
}
const openFolderButton = document.createElement('button');
openFolderButton.innerText = "Open folder to see all";
openFolderButton.addEventListener('click', () => {
shell.openItem(data.dir);
});
screenshots.appendChild(openFolderButton);
}
})
|