Merge pull request #6 from Deardrops/fix/save-replay

Fix/save replay
This commit is contained in:
webxoss 2017-05-22 23:48:52 +08:00 committed by GitHub
commit 1d20899f95
7 changed files with 30 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
Localize.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -979,6 +979,7 @@ function playReplayContent (content) {
}
playingReplay = true;
gameStart('replay');
game.io.datas = content.messagePacks;
var i = 0;
var idle = true;
var auto = false;
@ -987,6 +988,7 @@ function playReplayContent (content) {
if (i >= content.messagePacks.length) {
$('button-replay-auto').onclick = null;
$('button-replay-step').onclick = null;
$('button-replay-save').onclick = null;
if (content.surrender) {
if (content.win) {
game.win(true);
@ -1013,6 +1015,23 @@ function playReplayContent (content) {
}
step();
};
$('button-replay-save').onclick = function (event) {
event.preventDefault();
var a = document.createElement('a');
var blob = objToBlob(createReplayObj(
content.messagePacks,
content.win,
content.surrender
));
var url = blobToUrl(blob);
var time = (new Date()).toISOString().replace('T',' ').substr(0,19).replace(/:/g,'-');
var filename = time + '.wxrep';
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
};
function step () {
if (!idle) return;
idle = false;

View file

@ -146,7 +146,9 @@
<!-- <canvas id="BattleFieldCanvas" width="576" height="734"></canvas> -->
</div>
<div id="div-replay-controls" style="display: none;">
<button id="button-replay-step">下一步</button> <button id="button-replay-auto">自动播放</button>
<button id="button-replay-step">下一步</button>
<button id="button-replay-auto">自动播放</button>
<button id="button-replay-save">保存录像</button>
</div>
<div id="div-surrender">
<span id="span-surrender">投降</span>

File diff suppressed because one or more lines are too long