add save-replay button when watch replay

This commit is contained in:
deardrops 2017-05-16 17:34:40 +08:00
parent 5e3e853583
commit 50c2c50696
7 changed files with 29 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

@ -988,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);
@ -1014,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