-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsld.html
More file actions
239 lines (215 loc) · 6.27 KB
/
sld.html
File metadata and controls
239 lines (215 loc) · 6.27 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>SLD解析器(测试版) By WAIFor</title>
</head>
<body>
<div class="panel">
<h1>SLD 解析器(测试版) 1.4</h1>
<fieldset>
<legend>SLD信息</legend>
<label for="fileInput">单击此处选择文件或拖动至窗口<br>支持SLD和图像文件</label>
<input id="fileInput" type="file" onchange="loadSpriteFile(this.files[0])" style="display: none" />
<p id="fileInfo">
<button onclick="testLoad()" style="float: right" title="将数据压缩后再载入,显示压缩后的效果">编码测试</button>
<label>帧数:</label><em id="frameCountLabel">-</em><br/>
<label>加载用时:</label><em id="loadTime">-</em>
<label>不透明度:</label><input id="opacityLabel" type="number" min="0" max="255" value="255" /><br/>
</p>
</fieldset>
<fieldset>
<legend>输出选项</legend>
<div style="margin-bottom: 1rem">
<label>图像模式:</label>
<button id="reloadFrameImages" type="button" style="float: right">刷新帧</button>
<br/>
<select id="strideMode" value="0">
<option value="0">主体和阴影</option>
<option value="1">主体和阴影,玩家色</option>
<option value="2">主体和阴影,损伤</option>
<option value="3">主体和阴影,玩家色,损伤</option>
<option value="64">主体、阴影和玩家色</option>
<option value="66">主体、阴影和玩家色,损伤</option>
</select>
</div>
<div style="margin-bottom: 1rem">
<input id="includePlayerCheck" type="checkbox" checked />
<label for="includePlayerCheck">绘制玩家色:</label>
<br/>
<select id="playerColor" value="blue">
<option value="blue" class="dark">蓝色</option>
<option value="red">红色</option>
<option value="green" class="dark">绿色</option>
<option value="yellow">黄色</option>
<option value="cyan">青色</option>
<option value="purple" class="dark">紫色</option>
<option value="gray" class="dark">灰色</option>
<option value="orange">橙色</option>
<option value="brown" class="dark">褐色</option>
<option value="white">白色</option>
<option value="black" class="dark">黑色</option>
</select>
</div>
<label>每组图片行列数:</label>
<div>
<input id="outputRows" type="number" value="10" title="行"
/><input id="outputColumns" type="number" value="10" title="列" />
<button type="button" onclick="setOutputGridSizeAutomatic()" style="float: right">自动计算</button>
</div>
</fieldset>
<p id="statusLabel"></p>
<div class="btn-download">
<button id="downloadBtn" type="button" onclick="downloadImages()">下载图像</button><button
id="downloadBtn2" type="button" onclick="downloadSprite()">下载SLD</button>
</div>
<p>选择帧以修改其信息。</p>
<p>导入时,按顺序选择图片,使用“以Alpha区分玩家色、普通色和阴影”模式,并勾选使用CSV。</p>
</div>
<ol class="result">
</ol>
<div class="toolbar" style="display: none">
<button type="button" id="selectAllBtn">全选/全不选</button>
<button type="button" id="toggleLayerModeBtn" title="点击切换图层为地表/地上">改变图层</button>
<button type="button" id="setAnchorBtn">设置锚点</button>
<button type="button" id="removeBtn">删除帧</button>
</div>
<div class="loading">处理中...</div>
<script type="text/javascript">
const MESSAGES = {
'1': '这不是一个有效的SLD文件。',
'2': '帧数溢出。',
'3': '错误:导出图像边长不能大于 %d 像素。',
'4': '输入锚点,以空格或逗号分隔:'
}
</script>
<style>
.panel {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: 300px;
zoom: 1;
background-color: #FAECD0;
padding: 8px;
box-sizing: border-box;
accent-color: brown;
}
.panel h1 {
font-size: 1.25rem;
text-align: center;
}
.panel button, .toolbar button {
background-color: brown;
height: 1.5rem;
color: #FAECD0;
box-sizing: border-box;
border-radius: 3px;
font-size: 0.8rem;
cursor: pointer;
}
.panel button:disabled, .toolbar button:disabled {
background-color: gray;
}
.panel input[type="number"], .panel input[type="text"], .panel select {
background-color: #654;
height: 1.5rem;
color: #FAECD0;
box-sizing: border-box;
border-radius: 3px;
font-size: 0.8rem;
}
.panel fieldset {
margin-bottom: 1rem;
border-color: gray;
}
.result {
position: fixed;
left: 300px;
top: 0;
right: 0;
bottom: 0;
background-color: lightgray;
overflow: auto;
padding: 0;
margin: 0;
list-type: none;
counter-reset: frame-index;
}
.result > li {
background-color: #f0f;
image-rendering: pixelated;
margin: 1px 0 0 1px;
display: inline-block;
cursor: crosshair;
position: relative;
}
.result > li.overlay {
background-color: #F05;
}
.result > li:hover {
box-shadow: inset 0 0 16px 4px white;
}
.result > li.selected {
box-shadow: inset 0 0 16px 4px gold;
}
.result > li::before {
counter-increment: frame-index;
content: counter(frame-index);
position: absolute;
margin: 2px 0 0 4px;
font: 12px monospace;
color: white;
}
.btn-download {
width: 200px;
display: block;
margin: 12px auto;
}
.btn-download button {
width: 96px;
}
.panel em {
font-style: normal;
}
#outputRows, #outputColumns, #opacityLabel {
width: 88px;
}
#playerColor {
width: 132px;
color: black;
}
#playerColor .dark {
color: white;
}
#fileInfo label {
display: inline-block;
width: 6rem;
}
.toolbar {
position: fixed;
right: 0;
top: 0;
font-size: 0;
}
.loading {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(0, 0, 0, .35);
text-align: center;
font: bold 20px sans-serif;
line-height: 100vh;
display: none;
color: white;
cursor: wait;
}
</style>
<script type="text/javascript" src="sldedit.js"></script>
<script type="text/javascript" src="sld.js"></script>
<script type="text/javascript" src="jszip.min.js"></script>
</body>
</html>