/
start.ts
78 lines (54 loc) · 2.01 KB
/
start.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//The function ran on initialization of the game engine.
var editor; //CodeMirror editor
var debug; //Debugger for the engine
var Game = new GameFiles() //The files to be built
const Windows = document.getElementsByClassName("Window")
const UserScripts : UserScript[] = [] //Creates an array of userscripts
//with a default constant
//inline userscript which will be
//included in the build's HTML
//file
const Sounds : HTMLAudioElement[] = [] //Sounds will be an array which will be stopped when the editor is replayed
let CurrentUserScript : number = 0; //Goes by index
new UserScript('Inline Script')
async function CreateImageIcons()
{
const pathForm = new FormData()
pathForm.append("path", 'upload/resources')
//First off, find the files in the image directory already.
const result = await fetch('/imgfiles', {
method: "POST",
body: pathForm
})
.then(async (response) =>
{
console.log("POST request for the images in the folder /upload/resources has been answered.")
const f = response.headers.get('files')
const fsplit = f.split(',')
console.log("The files have been gotten from the response headers.")
for (let i = 0; i < fsplit.length; i++)
{
fsplit[i] = fsplit[i].replace(' ', '')
if (fsplit[i] == 'keep.gitkeep')
{
console.log("keep.gitkeep has been culled.")
fsplit.splice(i, 1)
}
}
return fsplit
})
//Cycle through each part of result and make a new image icon for each
//file name inside.
result.forEach(el =>
{
new ImageFileIcon(String(el).replace(/ /g, ''))
})
}
var keysDownArr = []
const Start = async () =>
{
console.log("Thor Game Engine is initialized and starting.")
LoadSaveFile()
CreateImageIcons()
}
Start()