-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRiichi-Mahjong.html
221 lines (201 loc) · 7.97 KB
/
Riichi-Mahjong.html
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>F**k Mahjong</title>
<style>
body {
font-size: 0.7em;
}
#loadingContainer {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: black;
}
#loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-weight: bold;
text-align: center;
}
#loading .entry {
margin: 0.5em 0;
padding: 0.5em 1em;
transition: background-color 0.3s;
}
#loading .entry.active {
background-color: white;
}
#loading .status {
margin-top: 0.5em;
display: block;
}
#loading .status.running {
color: darkblue;
}
#loading .status.finished {
color: lightgreen;
}
#loading .error {
color: darkorchid;
}
.version {
position: absolute;
right: 1em;
bottom: 1em;
font-weight: normal;
text-align: right;
font-size: 1.2em;
color: gray;
}
</style>
<script src="player_api.js?v2"></script>
<script>
if (window.parent === window) {
// 调试环境下先'''同步'''加载一个TweenMax
document.write('<script src="node_modules/gsap/src/minified/TweenMax.min.js"><\/script>');
} else {
infoProvider.v2.setMinSize(0, 600);
infoProvider.v2.setSeekCallbackSuppressable();
}
</script>
</head>
<body>
<div id="game">
<div id="background"></div>
<canvas id="mainCanvas"></canvas>
<div id="cssRenderOverlay"></div>
<div id="spectatorToolbar"></div>
<div class="version">
Botzone 立直麻将展示界面<br />
版本 <span id="js-version"></span> / <span id="css-version"></span>
</div>
</div>
<div id="gameResultBackground"></div>
<div id="logs"></div>
<div id="doraIndicators"></div>
<div id="loadingContainer">
<div id="loading"></div>
<div class="version">
Botzone 立直麻将展示界面<br />
by Zhouhy
</div>
</div>
<script>
let loadingPromise = Promise.resolve();
const loadingDiv = document.getElementById("loading");
const Loader = (window.Loader = {
addInitializable(initializable) {
const loadingEntry = document.createElement("div");
loadingEntry.className = "entry";
const progressBar = document.createElement("progress");
progressBar.min = 0;
progressBar.value = 0;
progressBar.style.display = "none";
const status = document.createElement("span");
status.className = "status";
status.textContent = "<步骤尚未开始>";
loadingEntry.appendChild(progressBar);
loadingEntry.appendChild(status);
loadingDiv.appendChild(loadingEntry);
let progress = 0;
loadingPromise = loadingPromise.then(() => {
const info = initializable(() =>
setTimeout(() => {
const newProgress = (progressBar.value = ++progress);
if (newProgress == info.totalProgress) {
status.textContent = info.description + "完成";
status.className = "status finished";
loadingEntry.className = "entry";
progressBar.style.display = "none";
} else {
status.textContent =
info.description + " (" + newProgress + " / " + info.totalProgress + ")";
}
}, 1)
);
progressBar.max = info.totalProgress;
progressBar.removeAttribute("value");
progressBar.style.display = "";
status.className = "status running";
loadingEntry.className = "entry active";
status.textContent = info.description + " (0 / " + info.totalProgress + ")";
return info.finishPromise.catch(function () {
const textDiv = document.createElement("div");
textDiv.className = "error";
textDiv.textContent =
info.description +
"失败:" +
Array.from(arguments)
.map(arg => (arg && arg.stack) || arg)
.join("\n");
loadingDiv.appendChild(textDiv);
infoProvider.v2.setRequestCallback(() => undefined);
infoProvider.v2.setDisplayCallback(() => undefined);
infoProvider.v2.notifyInitComplete();
return Promise.reject();
});
});
},
loadScripts(scripts, description) {
return addProgress => {
const promises = scripts.map(
src =>
new Promise((ac, rej) => {
const script = document.createElement("script");
script.src = src;
script.addEventListener("load", () => {
addProgress();
ac();
});
script.addEventListener("error", rej);
document.body.appendChild(script);
const version = src.match(/app\.js\?(.*)$/);
version && (document.getElementById("js-version").textContent = version[1]);
})
);
return {
totalProgress: scripts.length,
description: description,
finishPromise: Promise.all(promises)
};
};
},
loadCSS(addProgress) {
return {
totalProgress: 1,
description: "加载样式",
finishPromise: new Promise((ac, rej) => {
const css = document.createElement("link");
css.rel = "stylesheet";
css.href = "Mahjong-JP/app.css?191103-1";
css.addEventListener("load", () => {
addProgress();
ac();
});
css.addEventListener("error", rej);
document.body.appendChild(css);
const version = css.href.match(/app\.css\?(.*)$/);
document.getElementById("css-version").textContent = version[1];
})
};
}
});
Loader.addInitializable(Loader.loadScripts(["Mahjong-JP/three.min.js"], "加载图形库"));
Loader.addInitializable(
Loader.loadScripts(
["Mahjong-JP/postprocessing.min.js", "Mahjong-JP/CSS3DRenderer.js"],
"加载后期处理和 CSS 渲染器"
)
);
Loader.addInitializable(Loader.loadCSS);
Loader.addInitializable(Loader.loadScripts(["Mahjong-JP/app.js?191103-5"], "加载主程序"));
</script>
</body>
</html>