|
@@ -19,7 +19,7 @@
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
- <div id="hdr" style="background-color: antiquewhite;">
|
|
|
+ <div id="hdr" style="background-color: antiquewhite; margin-bottom: 20px;">
|
|
|
<input type="text" id="group-suffix" placeholder="分组文件的后缀">
|
|
|
<button id="load_grp">加载分组信息</button>
|
|
|
</div>
|
|
@@ -27,13 +27,13 @@
|
|
|
<div id="nav" style="overflow-y: scroll; height: 90%; width: 5%; background-color: coral;">
|
|
|
<ul>
|
|
|
<li>
|
|
|
- <button id="levels">关卡</button>
|
|
|
+ <button id="levels" style="margin-top: 10px;">关卡</button>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <button id="examples">实例</button>
|
|
|
+ <button id="examples" style="margin-top: 10px;">实例</button>
|
|
|
</li>
|
|
|
<li>
|
|
|
- <button id="templates">模板</button>
|
|
|
+ <button id="templates"style="margin-top: 10px;">模板</button>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
@@ -142,10 +142,12 @@
|
|
|
editTemplateButton.textContent = '编辑模板';
|
|
|
editTemplateButton.style.marginLeft = '10px';
|
|
|
editTemplateButton.addEventListener('click', () => {
|
|
|
+ // 获取当前的模板名称
|
|
|
+ const templateName = document.getElementById('template-select').value;
|
|
|
// 判断模板是在哪个目录下
|
|
|
for (let dir in templateFNsByDir) {
|
|
|
- if (templateFNsByDir[dir].has(inst.template)) {
|
|
|
- window.electron.send('open-app', '/Applications/Tiled.app/Contents/MacOS/Tiled ' + dir + '/' + inst.template + '.json');
|
|
|
+ if (templateFNsByDir[dir].has(templateName)) {
|
|
|
+ window.electron.send('open-app', dir, '/Applications/Tiled.app/Contents/MacOS/Tiled ' + dir + '/' + inst.template + '.json');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -158,7 +160,12 @@
|
|
|
copyTemplateButton.textContent = '复制模板';
|
|
|
copyTemplateButton.style.marginLeft = '10px';
|
|
|
copyTemplateButton.addEventListener('click', () => {
|
|
|
- // 复制模板
|
|
|
+ // 获取当前的实例
|
|
|
+ const inst = getInstanceByName(document.getElementById('instid-in-inst-detail').textContent.split(':')[1].trim());
|
|
|
+ if (inst.template == "") {
|
|
|
+ // 取options里面当前显示的值
|
|
|
+ inst.template = document.getElementById('template-select').value;
|
|
|
+ }
|
|
|
var path = "";
|
|
|
for (let dir in templateFNsByDir) {
|
|
|
if (templateFNsByDir[dir].has(inst.template)) {
|
|
@@ -176,7 +183,7 @@
|
|
|
const filename = arr[arr.length - 1];
|
|
|
const prefix = arr.slice(0, arr.length - 1).join('/');
|
|
|
// 放入到templateFNsByDir中
|
|
|
- templateName = filename.split(".")[0];
|
|
|
+ const templateName = filename.split(".")[0];
|
|
|
if (templateFNsByDir[prefix] == null) {
|
|
|
templateFNsByDir[prefix] = new Set();
|
|
|
}
|
|
@@ -190,6 +197,8 @@
|
|
|
option.value = templateName;
|
|
|
option.textContent = templateName;
|
|
|
option.selected = true;
|
|
|
+
|
|
|
+ const templateSelect = document.getElementById('template-select');
|
|
|
templateSelect.appendChild(option);
|
|
|
}
|
|
|
});
|
|
@@ -379,11 +388,15 @@
|
|
|
}
|
|
|
});
|
|
|
levelDetails.innerHTML = `
|
|
|
- <h2 id='lvid-in-lvdetails'>关卡ID: ${level.lvid}</h2>
|
|
|
- <p id='instid-in-lvdetails'>关卡实例名称: ${level.lvinst}</p>`
|
|
|
- //
|
|
|
- if (level.lvinst == '') {
|
|
|
- // 实例不存在,
|
|
|
+ <h2 id='lvid-in-lvdetails'>关卡ID: ${level.lvid}</h2>`
|
|
|
+ // 关卡实例名称
|
|
|
+ {
|
|
|
+ const div = document.createElement('div');
|
|
|
+ const p = document.createElement('p');
|
|
|
+ p.style.display = 'inline';
|
|
|
+ p.appendChild(document.createTextNode('关卡实例名称: '));
|
|
|
+ div.appendChild(p);
|
|
|
+
|
|
|
// 显示一个下来列表,选择实例
|
|
|
const instSelect = document.createElement('select');
|
|
|
instSelect.id = 'inst-select';
|
|
@@ -391,9 +404,14 @@
|
|
|
const option = document.createElement('option');
|
|
|
option.value = inst.lvinst;
|
|
|
option.textContent = inst.lvinst;
|
|
|
+ if (inst.lvinst == level.lvinst) {
|
|
|
+ option.selected = true;
|
|
|
+ }
|
|
|
instSelect.appendChild(option);
|
|
|
});
|
|
|
- levelDetails.appendChild(instSelect);
|
|
|
+ div.appendChild(instSelect);
|
|
|
+
|
|
|
+ levelDetails.appendChild(div);
|
|
|
}
|
|
|
// 加入一个按钮,点击后可以创建实例
|
|
|
{
|
|
@@ -401,12 +419,12 @@
|
|
|
const createInstButton = document.createElement('button');
|
|
|
createInstButton.id = 'create-instance-button';
|
|
|
createInstButton.textContent = '创建新的实例';
|
|
|
+ createInstButton.style.marginBottom = '15px';
|
|
|
div.appendChild(createInstButton);
|
|
|
levelDetails.appendChild(div);
|
|
|
// createInstButton.addEventListener('click', () => {
|
|
|
// addNewInst(level);
|
|
|
// });
|
|
|
- console.log(createInstButton.onclick);
|
|
|
}
|
|
|
{
|
|
|
const div = document.createElement('div');
|
|
@@ -558,16 +576,16 @@
|
|
|
const inst = {
|
|
|
lvinst: instName,
|
|
|
template: '',
|
|
|
- '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'
|
|
|
+ 'try1(tileCnt|seed|param_template)': '0|100|normal',
|
|
|
+ 'try2(tileCnt|seed|param_template)': '0|200|normal',
|
|
|
+ 'try3(tileCnt|seed|param_template)': '0|300|normal',
|
|
|
+ 'try4(tileCnt|seed|param_template)': '0|400|normal',
|
|
|
+ 'try5(tileCnt|seed|param_template)': '0|500|normal',
|
|
|
+ 'try6(tileCnt|seed|param_template)': '0|600|normal',
|
|
|
+ 'try7(tileCnt|seed|param_template)': '0|700|normal',
|
|
|
+ 'try8(tileCnt|seed|param_template)': '0|800|normal',
|
|
|
+ 'try9(tileCnt|seed|param_template)': '0|900|normal',
|
|
|
+ 'try10(tileCnt|seed|param_template)': '0|1000|normal'
|
|
|
};
|
|
|
instances.push(inst);
|
|
|
const instDetails = document.getElementById('instance-details');
|
|
@@ -580,9 +598,13 @@
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- // 刷新页面
|
|
|
- const instId = document.getElementById('instid-in-lvdetails');
|
|
|
- instId.textContent = '关卡实例名称: ' + instName;
|
|
|
+ // 刷新页面, 增加一个option,并置为选中
|
|
|
+ const instId = document.getElementById('inst-select');
|
|
|
+ const option = document.createElement('option');
|
|
|
+ option.value = instName;
|
|
|
+ option.textContent = instName;
|
|
|
+ option.selected = true;
|
|
|
+ instId.appendChild(option);
|
|
|
});
|
|
|
|
|
|
document.getElementById('load_grp').addEventListener('click', function() {
|