Merge branch 'v2.x' of https://github.com/ckcz123/mota-js into v2.x

This commit is contained in:
ckcz123 2020-05-21 10:58:27 +08:00
commit 57fff1b3e2
10 changed files with 74 additions and 65 deletions

View File

@ -20,7 +20,7 @@ function editor() {
chooseThis : document.getElementById('chooseThis'),
chooseInRight : document.getElementById('chooseInRight'),
copyLoc : document.getElementById('copyLoc'),
moveLoc : document.getElementById('moveLoc'),
pasteLoc : document.getElementById('pasteLoc'),
clearEvent : document.getElementById('clearEvent'),
clearLoc : document.getElementById('clearLoc'),
brushMod:document.getElementById('brushMod'),
@ -80,9 +80,6 @@ function editor() {
scrollBarHeight :0,
folded:false,
foldPerCol: 50,
// 画图区菜单
lastRightButtonPos:[{x:0,y:0},{x:0,y:0}],
lastCopyedInfo : [null, null],
//
ratio : 1,
// blockly转义

View File

@ -1172,9 +1172,8 @@ Blockly.FieldColour.prototype.createWidget_ = function() {
setTimeout(function () {
document.getElementById("colorPicker").value = getValue();
window.jsColorPicker.confirm = setValue;
// 设置位置
triggerColorPicker(Blockly.WidgetDiv.DIV.style.left, Blockly.WidgetDiv.DIV.style.top);
openColorPicker(Blockly.WidgetDiv.DIV.style.left, Blockly.WidgetDiv.DIV.style.top, setValue);
});
return document.createElement('table');

View File

@ -32,7 +32,7 @@ editor_listen_wrapper = function (editor) {
editor.dom.chooseThis.onmousedown = editor.uifunctions.chooseThis_click
editor.dom.chooseInRight.onmousedown = editor.uifunctions.chooseInRight_click
editor.dom.copyLoc.onmousedown = editor.uifunctions.copyLoc_click
editor.dom.moveLoc.onmousedown = editor.uifunctions.moveLoc_click
editor.dom.pasteLoc.onmousedown = editor.uifunctions.pasteLoc_click
editor.dom.clearEvent.onmousedown = editor.uifunctions.clearEvent_click
editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click
@ -130,8 +130,8 @@ editor_listen_wrapper = function (editor) {
editor.dom.chooseInRight.onmousedown = null
editor.dom.copyLoc.ontouchstart = editor.dom.copyLoc.onmousedown
editor.dom.copyLoc.onmousedown = null
editor.dom.moveLoc.ontouchstart = editor.dom.moveLoc.onmousedown
editor.dom.moveLoc.onmousedown = null
editor.dom.pasteLoc.ontouchstart = editor.dom.pasteLoc.onmousedown
editor.dom.pasteLoc.onmousedown = null
editor.dom.clearLoc.ontouchstart = editor.dom.clearLoc.onmousedown
editor.dom.clearLoc.onmousedown = null

View File

@ -342,12 +342,7 @@ editor_mappanel_wrapper = function (editor) {
* 显示右键菜单
*/
editor.uifunctions.showMidMenu = function (x, y) {
editor.uivalues.lastRightButtonPos = JSON.parse(JSON.stringify(
[editor.pos, editor.uivalues.lastRightButtonPos[0]]
));
// --- copy
editor.uivalues.lastCopyedInfo = [editor.copyFromPos(), editor.uivalues.lastCopyedInfo[0]];
var locStr = '(' + editor.uivalues.lastRightButtonPos[1].x + ',' + editor.uivalues.lastRightButtonPos[1].y + ')';
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
@ -386,8 +381,8 @@ editor_mappanel_wrapper = function (editor) {
else editor.dom.extraEvent.style.display = 'none';
editor.dom.chooseThis.children[0].innerHTML = '选中此点' + '(' + editor.pos.x + ',' + editor.pos.y + ')'
editor.dom.copyLoc.children[0].innerHTML = '复制事件' + locStr + '到此处';
editor.dom.moveLoc.children[0].innerHTML = '交换事件' + locStr + '与此事件的位置';
editor.dom.copyLoc.children[0].innerHTML = '复制事件';
editor.dom.pasteLoc.children[0].innerHTML = '粘贴到此事件';
editor.dom.midMenu.style = 'top:' + (y + scrollTop) + 'px;left:' + (x + scrollLeft) + 'px;';
}
@ -568,34 +563,39 @@ editor_mappanel_wrapper = function (editor) {
editor.uifunctions.copyLoc_click = function (e) {
editor.uifunctions.hideMidMenu();
e.stopPropagation();
e.preventDefault();
editor_mode.onmode('');
editor.uivalues.copyedInfo = editor.copyFromPos();
printf('该点事件已复制');
return;
}
/**
* editor.dom.pasteLoc.onmousedown
* 菜单 移动此事件
*/
editor.uifunctions.pasteLoc_click = function (e) {
editor.uifunctions.hideMidMenu();
e.stopPropagation();
e.preventDefault();
if (!editor.uivalues.copyedInfo) {
printe("没有复制的事件");
return;
}
editor.savePreMap();
editor_mode.onmode('');
var now = editor.pos, last = editor.uivalues.lastRightButtonPos[1];
if (now.x == last.x && now.y == last.y) return;
editor.pasteToPos(editor.uivalues.lastCopyedInfo[1]);
editor.pasteToPos(editor.uivalues.copyedInfo);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw (err)
}
; printf('复制事件成功');
; printf('粘贴到事件成功');
editor.uifunctions.unhighlightSaveFloorButton();
editor.drawPosSelection();
});
}
/**
* editor.dom.moveLoc.onmousedown
* 菜单 移动此事件
*/
editor.uifunctions.moveLoc_click = function (e) {
editor.uifunctions.hideMidMenu();
e.stopPropagation();
editor.savePreMap();
editor_mode.onmode('');
editor.exchangePos(editor.pos, editor.uivalues.lastRightButtonPos[1]);
editor.uifunctions.unhighlightSaveFloorButton();
return;
}
/**

View File

@ -412,6 +412,7 @@ editor_table_wrapper = function (editor) {
if (cobj._type === 'event') editor_blockly.import(guid, { type: cobj._event });
if (cobj._type === 'textarea') editor_multi.import(guid, { lint: cobj._lint, string: cobj._string });
if (cobj._type === 'material') editor.table.selectMaterial(input, cobj);
if (cobj._type === 'color') editor.table.selectColor(input);
}
/**
@ -426,6 +427,7 @@ editor_table_wrapper = function (editor) {
if (cobj._type === 'event') editor_blockly.import(guid, { type: cobj._event });
if (cobj._type === 'textarea') editor_multi.import(guid, { lint: cobj._lint, string: cobj._string });
if (cobj._type === 'material') editor.table.selectMaterial(input, cobj);
if (cobj._type === 'color') editor.table.selectColor(input);
} else if (editor_mode.doubleClickMode === 'add') {
editor_mode.doubleClickMode = 'change';
editor.table.addfunc(guid, obj, commentObj, thisTr, input, field, cobj, modeNode)
@ -446,6 +448,21 @@ editor_table_wrapper = function (editor) {
})
}
editor_table.prototype.selectColor = function (input) {
if (input.value != null) {
var str = input.value.toString().replace(/[^\d.,]/g, '');
if (/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/.test(str)) {
document.getElementById('colorPicker').value = str;
}
}
var boundingBox = input.getBoundingClientRect();
openColorPicker(boundingBox.x, boundingBox.y + boundingBox.height, function (value) {
value = value.replace(/[^\d.,]/g, '');
input.value = '[' + value +']';
input.onchange();
})
}
/**
* 删除表格项
*/

View File

@ -465,7 +465,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
},
"color": {
"_leaf": true,
"_type": "textarea",
"_type": "color",
"_docs": "色调",
"_data": "该层的默认画面色调。本项可不写代表无色调如果写需要是一个RGBA数组如[255,0,0,0.3]"
},

View File

@ -121,7 +121,7 @@
colorPickers.current = colorPickers[index];
}
},
createListener = function(e) {
createListener = function() {
elm = document.getElementById("colorPicker");
var input = elm,
position = window.ColorPicker.getOrigin(input),
@ -268,9 +268,19 @@ jsColorPicker('input.color', {
size: 1,
});
function openColorFromButton() {
delete window.jsColorPicker.confirm;
triggerColorPicker('414px', '53px');
function openColorPicker(px, py, callback) {
window.jsColorPicker.confirm = callback;
var colorPanel = document.getElementById('colorPanel');
if (colorPanel.style.display=='none' && px != null && py != null) {
colorPanel.style.display = "inline-block";
colorPanel.style.left = px + 'px';
colorPanel.style.top = py + 'px';
window.jsColorPicker.create();
}
else {
colorPanel.style.display = 'none';
delete window.jsColorPicker.confirm;
}
}
function confirmColor() {
@ -287,22 +297,8 @@ function confirmColor() {
colorPicker.select();
document.execCommand("Copy");
}
triggerColorPicker();
}
function triggerColorPicker(left, top) {
var colorPanel = document.getElementById('colorPanel');
if (colorPanel.style.display=='none' && left && top) {
colorPanel.style.display = "inline-block";
colorPanel.style.left = left;
colorPanel.style.top = top;
window.jsColorPicker.create();
}
else {
colorPanel.style.display = 'none';
delete window.jsColorPicker.confirm;
}
colorPanel.style.display = 'none';
delete window.jsColorPicker.confirm;
}
// ------ AutoCompletion ------

View File

@ -229,10 +229,6 @@
<div class="searchLogo"></div>
<input type="text" id="searchBlock" placeholder="搜索图块"/>
</div>
<div id="colorPanel" class="cpPanel" style="display: none">
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</div>
<button class="cpPanel" onclick="editor_blockly.selectPoint()">地图选点</button>
<button class="cpPanel" onclick="editor.uievent.searchUsedFlags()" style="margin-left:5px">变量出现位置搜索</button>
<input type="checkbox" class="cpPanel" id="blocklyReplace" onchange="editor_blockly.triggerReplace()" style="margin-left: 10px" />
@ -250,6 +246,10 @@
</div>
</div>
</div>
<div id="colorPanel" class="cpPanel" style="display: none">
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</div>
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
<button onclick="editor_multi.confirm()">确认</button>
<button onclick="editor_multi.cancel()">取消</button>
@ -368,7 +368,7 @@
<div id='chooseThis' class="menuitem"><div class="menuitem-content">选中此点</div></div>
<div id='chooseInRight' class="menuitem"><div class="menuitem-content">在素材区选中此图块</div></div>
<div id='copyLoc' class="menuitem"><div class="menuitem-content">复制此事件</div></div>
<div id='moveLoc' class="menuitem"><div class="menuitem-content">移动此事件</div></div>
<div id='pasteLoc' class="menuitem"><div class="menuitem-content">粘贴到此事件</div></div>
<div id='clearEvent' class="menuitem"><div class="menuitem-content">仅清空此点事件</div></div>
<div id='clearLoc' class="menuitem"><div class="menuitem-content">清空此点及事件</div></div>
</div>

View File

@ -224,10 +224,6 @@
<div class="searchLogo"></div>
<input type="text" id="searchBlock" placeholder="搜索图块"/>
</div>
<div id="colorPanel" class="cpPanel" style="display: none">
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</div>
<button class="cpPanel" onclick="editor_blockly.selectPoint()" style="margin-left:5px">地图选点</button>
<button class="cpPanel" onclick="editor.uievent.searchUsedFlags()" style="margin-left:5px">变量出现位置搜索</button>
<input type="checkbox" class="cpPanel" id="blocklyReplace" onchange="editor_blockly.triggerReplace()" style="margin-left: 10px" />
@ -245,6 +241,10 @@
</div>
</div>
</div>
<div id="colorPanel" class="cpPanel" style="display: none">
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</div>
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
<button onclick="editor_multi.confirm()">确认</button>
<button onclick="editor_multi.cancel()">取消</button>
@ -391,7 +391,7 @@
<div id='chooseThis' class="menuitem"><div class="menuitem-content">选中此点</div></div>
<div id='chooseInRight' class="menuitem"><div class="menuitem-content">在素材区选中此图块</div></div>
<div id='copyLoc' class="menuitem"><div class="menuitem-content">复制此事件</div></div>
<div id='moveLoc' class="menuitem"><div class="menuitem-content">移动此事件</div></div>
<div id='pasteLoc' class="menuitem"><div class="menuitem-content">粘贴到此事件</div></div>
<div id='clearEvent' class="menuitem"><div class="menuitem-content">仅清空此点事件</div></div>
<div id='clearLoc' class="menuitem"><div class="menuitem-content">清空此点及事件</div></div>
</div>

View File

@ -61,7 +61,7 @@
(已完成!) 难度分歧的图块颜色含SL界面
(已完成!) 装备同时加属性和比例
(已完成!) removeMap和resumeMap
右键图块选择复制/粘贴事件
(已完成!) 右键图块选择复制/粘贴事件
(已完成!) showImage, drawImage立绘等加上对称选项
更多的图块blockly化
勇士帧抖动