-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
framework.js
125 lines (109 loc) · 3.33 KB
/
framework.js
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const heads = document.getElementsByTagName("head");
if (heads && heads.length > 0) {
const requireScripts = [
"system_class.js",
"extension_method.js",
"input_class.js",
"chat_class.js",
"lighting_class.js",
"ui_class.js",
"graphics_class.js",
"map_class.js",
"map_office.js",
"minimap_class.js",
"effect_class.js",
"particle_class.js",
"object_class.js",
"sprite_class.js",
"camera_class.js",
"sound_class.js",
"player_class.js",
"weather_class.js",
"network_class.js",
"debug_class.js",
];
for (let i = 0; i < requireScripts.length; i++) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", requireScripts[i]);
heads[0].appendChild(script);
}
}
let systemClass;
window.onload = function () {
$("html, body").css({
height: "100%",
width: "100%",
margin: "0px",
padding: "0px",
background: "#313131",
});
const frameworkRootDiv = this.document.getElementById("framework_root");
frameworkRootDiv.style.position = "relative";
frameworkRootDiv.style.width = "100%";
frameworkRootDiv.style.height = "100%";
if (frameworkRootDiv) {
const canvas = document.createElement("canvas");
canvas.width = 1280;
canvas.height = 720;
//canvas.style.zIndex = 1;
canvas.style.border = "0px solid black";
canvas.style.position = "absolute";
canvas.style.maxWidth = "100%";
canvas.style.maxHeight = "100%";
canvas.style.width = "auto";
canvas.style.height = "auto";
canvas.style.margin = "auto";
canvas.style.top = "0";
canvas.style.bottom = "0";
canvas.style.left = "0";
canvas.style.right = "0";
canvas.addEventListener("contextmenu", (e) => {
e.preventDefault();
});
document.addEventListener("keydown", (e) => {
switch (e.keyCode) {
case KEYCODE_TAB:
case KEYCODE_F5:
case KEYCODE_F12:
e.preventDefault();
break;
}
});
canvas.requestPointerLock =
canvas.requestPointerLock || canvas.mozRequestPointerLock;
document.exitPointerLock =
document.exitPointerLock || document.mozExitPointerLock;
const lightingCanvas = canvas.cloneNode(false);
lightingCanvas.addEventListener("contextmenu", (e) => {
e.preventDefault();
});
const uiCanvas = canvas.cloneNode(false);
uiCanvas.addEventListener("contextmenu", (e) => {
e.preventDefault();
});
if (canvas.getContext) {
frameworkRootDiv.appendChild(canvas);
frameworkRootDiv.appendChild(uiCanvas);
systemClass = new SystemClass(window, frameworkRootDiv, canvas, uiCanvas);
systemClass.run();
} else {
// error
}
}
};
function setCookie(name, value, exp) {
var date = new Date();
date.setTime(date.getTime() + exp * 24 * 60 * 60 * 1000);
document.cookie =
name + "=" + value + ";expires=" + date.toUTCString() + ";path=/";
}
function getCookie(name) {
var value = document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
return value ? value[2] : null;
}
function isMobile() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);
}