修复素材区

This commit is contained in:
ckcz123 2021-08-20 12:41:37 +08:00
parent dd96cbb933
commit 92ecb5210c
4 changed files with 32 additions and 21 deletions

View File

@ -769,10 +769,15 @@ editor.prototype.drawInitData = function (icons) {
}
var width = images[img].width, height = images[img].height, mh = height;
if (editor.uivalues.folded) {
if (img == 'terrains') {
width = Math.ceil((height / 32 + 2) / editor.uivalues.foldPerCol) * 32;
if (width > 32) mh = 32 * editor.uivalues.foldPerCol;
} else {
var per_height = (img == 'enemy48' || img == 'npc48' ? 48 : 32);
width = Math.ceil(height / per_height / editor.uivalues.foldPerCol) * 32;
if (width > 32) mh = per_height * editor.uivalues.foldPerCol;
}
}
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + width) / 32, height];
sumWidth += width;
maxHeight = Math.max(maxHeight, mh + 64);
@ -852,10 +857,14 @@ editor.prototype.drawInitData = function (icons) {
})(editor.airwallImg,nowx);
if (editor.uivalues.folded) {
// --- 单列 & 折行
var subimgs = core.splitImage(images[img], 32, editor.uivalues.foldPerCol * 32);
var canvas = document.createElement("canvas");
canvas.width = 32;
canvas.height = images[img].height + 64;
canvas.getContext('2d').drawImage(images[img], 0, 64);
var subimgs = core.splitImage(canvas, 32, editor.uivalues.foldPerCol * 32);
var frames = images[img].width / 32;
for (var i = 0; i < subimgs.length; i+=frames) {
drawImage(subimgs[i], nowx, i==0?2*32:0, img);
drawImage(subimgs[i], nowx, 0, img);
nowx += 32;
}
}

View File

@ -150,10 +150,10 @@ editor_materialpanel_wrapper = function (editor) {
}
else {
var height = editor.widthsX[spriter][3], col = height / ysize;
if (spriter == 'terrains') col += 2;
if (editor.uivalues.folded && core.tilesets.indexOf(pos.images) == -1) {
col = (pos.x == editor.widthsX[spriter][2] - 1) ? ((col - 1) % editor.uivalues.foldPerCol + 1) : editor.uivalues.foldPerCol;
}
if (spriter == 'terrains' && pos.x == editor.widthsX[spriter][1]) col += 2;
pos.y = Math.min(pos.y, col - 1);
}
@ -177,7 +177,7 @@ editor_materialpanel_wrapper = function (editor) {
if (editor.uivalues.folded) {
y += editor.uivalues.foldPerCol * (pos.x - editor.widthsX[spriter][1]);
}
if (pos.images == 'terrains' && pos.x == 0) y -= 2;
if (pos.images == 'terrains') y -= 2;
editor.info = { 'images': pos.images, 'y': y }
}

View File

@ -305,16 +305,16 @@
</div>
<div class="tools">
<div id="tip"></div>
<select id="editModeSelect">
<option value="map">地图编辑Z</option>
<option value="loc">地图选点X</option>
<option value="enemyitem">图块属性C</option>
<option value="floor">楼层属性V</option>
<option value="tower">全塔属性B</option>
<option value="functions">脚本编辑N</option>
<option value="appendpic">追加素材M</option>
<option value="commonevent">公共事件 ,</option>
<option value="plugins">插件编写 .</option>
<select id="editModeSelect" style="font-size: 13px">
<option value="map">地图编辑(Z)</option>
<option value="loc">地图选点(X)</option>
<option value="enemyitem">图块属性(C)</option>
<option value="floor">楼层属性(V)</option>
<option value="tower">全塔属性(B)</option>
<option value="functions">脚本编辑(N)</option>
<option value="appendpic">追加素材(M)</option>
<option value="commonevent">公共事件(,)</option>
<option value="plugins">插件编写(.)</option>
</select>
<span style="font-size: 12px"><input type="checkbox" id="showMovable" style="margin-left:0;margin-right: 2px"/>通行度</span>
<select id="editorTheme" style="margin-left: 0; font-size: 11px;">
@ -336,14 +336,13 @@
<input type="radio" id="layerMod3" name="layerMod" value="fgmap" style="margin-left: 5px" />前景层
</span>
<br>
<div id="viewportButtons">
<div id="viewportButtons" style="margin-bottom: 7px">
<input type="button" value="←"/>
<input type="button" value="↑"/>
<input type="button" value="↓"/>
<input type="button" value="→"/>
<input type="button" id='bigmapBtn' value="大地图" style="margin-left: 5px"/>
</div>
<br>
<select id="selectFloor" style="margin-bottom: 5px;"></select>
<input type="button" value="保存地图" id='saveFloor'/>
<input type="button" value="后退" id="undoFloor" />

View File

@ -438,13 +438,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// 背景层2插入事件层前
parent.insertBefore(input, child);
// 不能直接更改背景层2的innerText 所以创建文本节点
var txt = document.createTextNode('背景层2');
var txt = document.createTextNode('bg2');
// 插入事件层前(即新插入的背景层2前)
parent.insertBefore(txt, child);
// 向最后插入前景层2(即插入前景层后)
parent.appendChild(input2);
var txt2 = document.createTextNode('前景层2');
var txt2 = document.createTextNode('fg2');
parent.appendChild(txt2);
parent.childNodes[2].replaceWith("bg");
parent.childNodes[6].replaceWith("事件");
parent.childNodes[8].replaceWith("fg");
} else {
var input = createCanvasBtn_mobile('bg2');
var input2 = createCanvasBtn_mobile('fg2');