-
Notifications
You must be signed in to change notification settings - Fork 52
/
h5pal.html
115 lines (115 loc) · 3.37 KB
/
h5pal.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>h5pal</title>
<link rel="stylesheet" type="text/css" href="/dist/css/h5pal.css">
</head>
<body class="page">
<div class="ui content">
<div id="wrap">
<canvas id="cvs" style=""></canvas>
<!-- <canvas id="debug" style=""></canvas>
<div id="debugLayer"></div> -->
<audio autoplay loop id="bg-music">
<source id="bg-music-source" src="/pal-assets/MP3/005.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div class="control-panel">
<input type="button" id="save" value="SAVE" />
<input type="button" id="load" value="LOAD" />
<label for="invincible">无敌<input type="checkbox" id="invincible" /></label>
<label for="superAttack">超强攻击力<input type="checkbox" id="superAttack" /></label>
<label for="superDefense">超强防御力<input type="checkbox" id="superDefense" /></label>
</div>
</div>
<script src="/dist/lib/requirejs/require.js"></script>
<script>
require.config({
baseUrl: '/dist/js',
waitSeconds: 5,
paths: {
'jquery': '../lib/jquery/jquery.min',
'q': '../lib/q/q',
'sprintf': '../lib/sprintf/sprintf.min'
},
shim: {
'semantic-ui': {
deps: ['jquery']
},
'pal/binary-helper': {
deps: ['shim']
},
'pal/pal-global': {
deps: ['pal/common']
},
'pal/common': {
deps: ['pal/binary-helper']
},
'pal/script_extras': {
deps: ['pal/script']
},
'h5pal': {
deps: ['jquery', 'sprintf', 'shim', 'pal/common', 'pal/pal-global', 'pal/utils']
}
}
});
</script>
<script>
require(['h5pal'], function(pal) {
$('#save').click(function() {
var me = $(this), text = me.val();
me.val(text + '...');
co(function*() {
var s = game._saveGame();
var buf = s.uint8Array
var arr = new Array(buf.length);
for (var i = 0; i < buf.length; ++i) {
arr[i] = buf[i];
}
localStorage['PAL-SAVE'] = JSON.stringify(arr);
me.val(text + '...Done!');
yield sleep(1000);
me.val(text);
})
});
$('#load').click(function() {
co(function*() {
try {
var str = localStorage['PAL-SAVE'];
var arr = JSON.parse(str);
var buf = new Uint8Array(SaveData.size);
for (var i = 0; i < arr.length; ++i) {
buf[i] = arr[i];
}
var s = new SaveData(buf);
yield game._initGameData(s);
} catch(ex) {
alert('failed');
}
});
});
$.fn.checked = function(f) {
if (typeof f === 'undefined') {
return $(this).prop('checked');
}
return $(this).prop('checked', f);
};
['invincible', 'superAttack', 'superDefense'].forEach(function(key) {
var variable = key.replace(/[A-Z]/g, function($0) { return '_' + $0; }).toUpperCase();
var checkbox = $('#' + key);
checkbox.checked(window[variable]);
checkbox.change(function(e) {
var me = $(this);
window[variable] = me.checked();
})
})
});
</script>
<script>
</script>
</body>
</html>