|
@@ -140,6 +140,7 @@
|
|
const editTemplateButton = document.createElement('button');
|
|
const editTemplateButton = document.createElement('button');
|
|
editTemplateButton.id = 'edit-template-button';
|
|
editTemplateButton.id = 'edit-template-button';
|
|
editTemplateButton.textContent = '编辑模板';
|
|
editTemplateButton.textContent = '编辑模板';
|
|
|
|
+ editTemplateButton.style.marginLeft = '10px';
|
|
editTemplateButton.addEventListener('click', () => {
|
|
editTemplateButton.addEventListener('click', () => {
|
|
// 判断模板是在哪个目录下
|
|
// 判断模板是在哪个目录下
|
|
for (let dir in templateFNsByDir) {
|
|
for (let dir in templateFNsByDir) {
|
|
@@ -151,6 +152,50 @@
|
|
});
|
|
});
|
|
div1.appendChild(editTemplateButton);
|
|
div1.appendChild(editTemplateButton);
|
|
|
|
|
|
|
|
+ // 增加一个复制模板的按钮
|
|
|
|
+ const copyTemplateButton = document.createElement('button');
|
|
|
|
+ copyTemplateButton.id = 'copy-template-button';
|
|
|
|
+ copyTemplateButton.textContent = '复制模板';
|
|
|
|
+ copyTemplateButton.style.marginLeft = '10px';
|
|
|
|
+ copyTemplateButton.addEventListener('click', () => {
|
|
|
|
+ // 复制模板
|
|
|
|
+ var path = "";
|
|
|
|
+ for (let dir in templateFNsByDir) {
|
|
|
|
+ if (templateFNsByDir[dir].has(inst.template)) {
|
|
|
|
+ path = dir + '/' + inst.template + '.json';
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ window.electron.send('copy-template', path);
|
|
|
|
+ window.electron.receive('copy-template-replay', (data) => {
|
|
|
|
+ if (data.length == "0") {
|
|
|
|
+ // 失败了
|
|
|
|
+ } else {
|
|
|
|
+ // 得到文件名和路径前缀
|
|
|
|
+ const arr = data.split('/');
|
|
|
|
+ const filename = arr[arr.length - 1];
|
|
|
|
+ const prefix = arr.slice(0, arr.length - 1).join('/');
|
|
|
|
+ // 放入到templateFNsByDir中
|
|
|
|
+ templateName = filename.split(".")[0];
|
|
|
|
+ if (templateFNsByDir[prefix] == null) {
|
|
|
|
+ templateFNsByDir[prefix] = new Set();
|
|
|
|
+ }
|
|
|
|
+ templateFNsByDir[prefix].add(templateName);
|
|
|
|
+ // 放入到templateFNs中
|
|
|
|
+ templateFNs.push(templateName);
|
|
|
|
+ // 设置为新的模板
|
|
|
|
+ inst.template = templateName;
|
|
|
|
+ // 刷新页面,增加templateSelect的选项,并选中新的,同时取消旧的选中状态
|
|
|
|
+ const option = document.createElement('option');
|
|
|
|
+ option.value = templateName;
|
|
|
|
+ option.textContent = templateName;
|
|
|
|
+ option.selected = true;
|
|
|
|
+ templateSelect.appendChild(option);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ div1.appendChild(copyTemplateButton);
|
|
|
|
+
|
|
div.appendChild(div1);
|
|
div.appendChild(div1);
|
|
}
|
|
}
|
|
// 加入表格
|
|
// 加入表格
|
|
@@ -513,19 +558,31 @@
|
|
const inst = {
|
|
const inst = {
|
|
lvinst: instName,
|
|
lvinst: instName,
|
|
template: '',
|
|
template: '',
|
|
- 'try1(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try2(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try3(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try4(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try5(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try6(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try7(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try8(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try9(tileCnt|seed|param_template)': '0|0|0',
|
|
|
|
- 'try10(tileCnt|seed|param_template)': '0|0|0'
|
|
|
|
|
|
+ 'try1(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try2(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try3(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try4(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try5(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try6(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try7(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try8(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try9(tileCnt|seed|param_template)': '0|0|normal',
|
|
|
|
+ 'try10(tileCnt|seed|param_template)': '0|0|normal'
|
|
};
|
|
};
|
|
instances.push(inst);
|
|
instances.push(inst);
|
|
|
|
+ const instDetails = document.getElementById('instance-details');
|
|
showInstanceInfoAt(instDetails, inst);
|
|
showInstanceInfoAt(instDetails, inst);
|
|
|
|
+ // 将当前关卡关联到该实例
|
|
|
|
+ const lvid = document.getElementById('lvid-in-lvdetails').textContent.split(':')[1].trim();
|
|
|
|
+ for (let i = 0; i < levels.length; i++) {
|
|
|
|
+ if (levels[i].lvid == lvid) {
|
|
|
|
+ levels[i].lvinst = instName;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 刷新页面
|
|
|
|
+ const instId = document.getElementById('instid-in-lvdetails');
|
|
|
|
+ instId.textContent = '关卡实例名称: ' + instName;
|
|
});
|
|
});
|
|
|
|
|
|
document.getElementById('load_grp').addEventListener('click', function() {
|
|
document.getElementById('load_grp').addEventListener('click', function() {
|