kill main.log

This commit is contained in:
unamed 2022-02-02 00:32:58 +08:00
parent f7f3e66cd6
commit 1ad1e12df6
18 changed files with 2178 additions and 2162 deletions

View File

@ -1,6 +1,6 @@
editor_blockly = function () { editor_blockly = function () {
var editor_blockly = {entryType:'event'}; var editor_blockly = { entryType: 'event' };
editor.uivalues.disableBlocklyReplace = editor.config.get("disableBlocklyReplace", false); editor.uivalues.disableBlocklyReplace = editor.config.get("disableBlocklyReplace", false);
var replaceCheckbox = document.getElementById('blocklyReplace'); var replaceCheckbox = document.getElementById('blocklyReplace');
@ -62,7 +62,7 @@ editor_blockly = function () {
matchBrackets: true, matchBrackets: true,
lineWrapping: true, lineWrapping: true,
continueComments: "Enter", continueComments: "Enter",
extraKeys: {"Ctrl-Q": "toggleComment"}, extraKeys: { "Ctrl-Q": "toggleComment" },
}); });
codeAreaHL.on('changes', function () { codeAreaHL.on('changes', function () {
editor_blockly.highlightParse(!changeFromBlockly); editor_blockly.highlightParse(!changeFromBlockly);
@ -103,8 +103,8 @@ editor_blockly = function () {
editor_blockly.parse = function () { editor_blockly.parse = function () {
MotaActionFunctions.parse( MotaActionFunctions.parse(
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) { eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
return {'<': '&lt;', '>': '&gt;', '&': '&amp;'}[c]; return { '<': '&lt;', '>': '&gt;', '&': '&amp;' }[c];
}).replace(/\\(r|f|i|c|d|e|g|z)/g,'\\\\$1')), }).replace(/\\(r|f|i|c|d|e|g|z)/g, '\\\\$1')),
editor_blockly.isCommonEntry() ? 'common' : editor_blockly.entryType editor_blockly.isCommonEntry() ? 'common' : editor_blockly.entryType
); );
} }
@ -132,7 +132,7 @@ editor_blockly = function () {
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv'); var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
editor_blockly.show = function () { editor_blockly.show = function () {
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected(false); if (typeof (selectBox) !== typeof (undefined)) selectBox.isSelected(false);
document.getElementById('left6').style = ''; document.getElementById('left6').style = '';
for (var ii = 0, node; node = blocklyWidgetDiv[ii]; ii++) { for (var ii = 0, node; node = blocklyWidgetDiv[ii]; ii++) {
node.style.zIndex = 201; node.style.zIndex = 201;
@ -172,14 +172,14 @@ editor_blockly = function () {
alert('你尚未解析修改后的内容,请进行解析或放弃操作'); alert('你尚未解析修改后的内容,请进行解析或放弃操作');
return; return;
} }
if(editor_blockly.workspace.topBlocks_.length>=2){ if (editor_blockly.workspace.topBlocks_.length >= 2) {
editor_blockly.setValue('入口方块只能有一个'); editor_blockly.setValue('入口方块只能有一个');
return; return;
} }
var eventType = editor_blockly.entryType; var eventType = editor_blockly.entryType;
if(editor_blockly.workspace.topBlocks_.length==1){ if (editor_blockly.workspace.topBlocks_.length == 1) {
var blockType = editor_blockly.workspace.topBlocks_[0].type; var blockType = editor_blockly.workspace.topBlocks_[0].type;
if(blockType!==eventType+'_m' && !(editor_blockly.isCommonEntry() && blockType == 'common_m')){ if (blockType !== eventType + '_m' && !(editor_blockly.isCommonEntry() && blockType == 'common_m')) {
editor_blockly.setValue('入口方块类型错误'); editor_blockly.setValue('入口方块类型错误');
return; return;
} }
@ -196,7 +196,7 @@ editor_blockly = function () {
input.onchange(); input.onchange();
} }
if (codeAreaHL.getValue() === '') { if (codeAreaHL.getValue() === '') {
eventType==='shop'?setvalue('[]'):setvalue('null'); eventType === 'shop' ? setvalue('[]') : setvalue('null');
return; return;
} }
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace); var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
@ -255,7 +255,7 @@ editor_blockly = function () {
var _isTextAttributeSet = false; var _isTextAttributeSet = false;
editor_blockly.previewBlock = function (b,args) { editor_blockly.previewBlock = function (b, args) {
var previewTextDrawing = function (content) { var previewTextDrawing = function (content) {
var arr = []; var arr = [];
@ -263,9 +263,9 @@ editor_blockly = function () {
var list = str.split(","); var list = str.split(",");
if (list.length == 3 || list.length == 5 || list.length >= 9) { if (list.length == 3 || list.length == 5 || list.length >= 9) {
var name = list[0]; var name = list[0];
var obj = {"type": "drawImage"}; var obj = { "type": "drawImage" };
if (name.endsWith(":o") || name.endsWith(":x") || name.endsWith(":y")) { if (name.endsWith(":o") || name.endsWith(":x") || name.endsWith(":y")) {
obj.reverse = name.substring(name.length-2); obj.reverse = name.substring(name.length - 2);
name = name.substring(0, name.length - 2); name = name.substring(0, name.length - 2);
} }
obj.image = name; obj.image = name;
@ -282,7 +282,7 @@ editor_blockly = function () {
obj.h1 = parseFloat(list[8]); obj.h1 = parseFloat(list[8]);
} }
if (list.length >= 10) { if (list.length >= 10) {
arr.push({"type": "setAttribute", "alpha": parseFloat(list[9])}); arr.push({ "type": "setAttribute", "alpha": parseFloat(list[9]) });
} }
if (list.length >= 11) { if (list.length >= 11) {
obj.angle = parseFloat(list[10]); obj.angle = parseFloat(list[10]);
@ -303,7 +303,7 @@ editor_blockly = function () {
} }
var code = "[" + Blockly.JavaScript.blockToCode(b).replace(/\\(i|c|d|e|g|z)/g, '\\\\$1') + "]"; var code = "[" + Blockly.JavaScript.blockToCode(b).replace(/\\(i|c|d|e|g|z)/g, '\\\\$1') + "]";
eval("var obj="+code); eval("var obj=" + code);
if (obj.length == 0) return true; if (obj.length == 0) return true;
obj = obj[0]; obj = obj[0];
switch (b.type) { switch (b.type) {
@ -326,40 +326,46 @@ editor_blockly = function () {
alert('已成功设置此属性为显示文章的预览属性!') alert('已成功设置此属性为显示文章的预览属性!')
break; break;
case 'waitContext_2': // 等待用户操作坐标预览 case 'waitContext_2': // 等待用户操作坐标预览
editor.uievent.previewUI([{"type": "fillRect", "x": obj.px[0], "y": obj.py[0], editor.uievent.previewUI([{
"type": "fillRect", "x": obj.px[0], "y": obj.py[0],
"width": "(" + obj.px[1] + ")-(" + obj.px[0] + ")", "height": "(" + obj.py[1] + ")-(" + obj.py[0] + ")", "width": "(" + obj.px[1] + ")-(" + obj.px[0] + ")", "height": "(" + obj.py[1] + ")-(" + obj.py[0] + ")",
"style": "rgba(255,0,0,0.5)"}]); "style": "rgba(255,0,0,0.5)"
}]);
break; break;
case 'showImage_s': // 显示图片 case 'showImage_s': // 显示图片
case 'showImage_1_s': case 'showImage_1_s':
if (obj.sloc) { if (obj.sloc) {
editor.uievent.previewUI([ editor.uievent.previewUI([
{type: "setAttribute", alpha: obj.opacity}, { type: "setAttribute", alpha: obj.opacity },
{type: "drawImage", image: obj.image, x: obj.sloc[0], y: obj.sloc[1], w: obj.sloc[2], h: obj.sloc[3], {
x1: obj.loc[0], y1: obj.loc[1], w1: obj.loc[2], h1: obj.loc[3], reverse: obj.reverse} type: "drawImage", image: obj.image, x: obj.sloc[0], y: obj.sloc[1], w: obj.sloc[2], h: obj.sloc[3],
x1: obj.loc[0], y1: obj.loc[1], w1: obj.loc[2], h1: obj.loc[3], reverse: obj.reverse
}
]); ]);
} else { } else {
editor.uievent.previewUI([ editor.uievent.previewUI([
{type: "setAttribute", alpha: obj.opacity}, { type: "setAttribute", alpha: obj.opacity },
{type: "drawImage", image: obj.image, x: obj.loc[0], y: obj.loc[1], w: obj.loc[2], h: obj.loc[3], reverse: obj.reverse} { type: "drawImage", image: obj.image, x: obj.loc[0], y: obj.loc[1], w: obj.loc[2], h: obj.loc[3], reverse: obj.reverse }
]); ]);
} }
break; break;
case 'showGif_s': // 显示动图 case 'showGif_s': // 显示动图
if (obj.name && obj.loc) { if (obj.name && obj.loc) {
editor.uievent.previewUI([{type: "drawImage", image: obj.name, x: obj.loc[0], y: obj.loc[1]}]); editor.uievent.previewUI([{ type: "drawImage", image: obj.name, x: obj.loc[0], y: obj.loc[1] }]);
} }
break; break;
case 'setCurtain_0_s': // 更改色调 case 'setCurtain_0_s': // 更改色调
if (obj.color) { if (obj.color) {
editor.uievent.previewUI([{type: "fillRect", x: 0, y: 0, width: core.__PIXELS__, height: core.__PIXELS__, style: obj.color}]); editor.uievent.previewUI([{ type: "fillRect", x: 0, y: 0, width: core.__PIXELS__, height: core.__PIXELS__, style: obj.color }]);
} }
break; break;
case 'floorOneImage': // 楼层贴图 case 'floorOneImage': // 楼层贴图
obj.w = obj.w / (obj.frame || 1); obj.w = obj.w / (obj.frame || 1);
editor.uievent.previewUI([ editor.uievent.previewUI([
{type: "drawImage", image: obj.name, x: obj.sx || 0, y: obj.sy || 0, w: obj.w, h: obj.h, {
x1: obj.x, y1: obj.y, w1: obj.w, h1: obj.h, reverse: obj.reverse} type: "drawImage", image: obj.name, x: obj.sx || 0, y: obj.sy || 0, w: obj.w, h: obj.h,
x1: obj.x, y1: obj.y, w1: obj.w, h1: obj.h, reverse: obj.reverse
}
]); ]);
break; break;
case 'previewUI_s': // 预览 case 'previewUI_s': // 预览
@ -370,11 +376,11 @@ editor_blockly = function () {
editor.uievent.previewUI([obj]); editor.uievent.previewUI([obj]);
} }
} }
} catch (e) {main.log(e);} } catch (ee) { console.error(ee) }
} }
editor_blockly.selectMaterial = function(b,material){ editor_blockly.selectMaterial = function (b, material) {
var value = b.getFieldValue(material[1]); var value = b.getFieldValue(material[1]);
value = main.nameMap[value] || value; value = main.nameMap[value] || value;
editor.uievent.selectMaterial([value], '请选择素材', material[0], function (one) { editor.uievent.selectMaterial([value], '请选择素材', material[0], function (one) {
@ -388,7 +394,7 @@ editor_blockly = function () {
// 检测是否别名替换 // 检测是否别名替换
for (var name in main.nameMap) { for (var name in main.nameMap) {
if (main.nameMap[name] == value) { if (main.nameMap[name] == value) {
if (confirm("检测到该文件存在别名:"+name+"\n是否使用别名进行替换")) { if (confirm("检测到该文件存在别名:" + name + "\n是否使用别名进行替换")) {
b.setFieldValue(name, material[1]); b.setFieldValue(name, material[1]);
return; return;
} else { } else {
@ -401,10 +407,10 @@ editor_blockly = function () {
}); });
} }
editor_blockly.doubleclicktext = function(b,f){ editor_blockly.doubleclicktext = function (b, f) {
var value = b.getFieldValue(f); var value = b.getFieldValue(f);
//多行编辑 //多行编辑
editor_multi.multiLineEdit(value, b, f, {'lint': f === 'RawEvalString_0'}, function (newvalue, b, f) { editor_multi.multiLineEdit(value, b, f, { 'lint': f === 'RawEvalString_0' }, function (newvalue, b, f) {
if (!f.startsWith('EvalString_Multi')) { if (!f.startsWith('EvalString_Multi')) {
newvalue = newvalue.split('\n').join('\\n'); newvalue = newvalue.split('\n').join('\\n');
} }
@ -415,23 +421,23 @@ editor_blockly = function () {
editor_blockly.doubleClickBlock = function (blockId) { editor_blockly.doubleClickBlock = function (blockId) {
var b = editor_blockly.workspace.getBlockById(blockId); var b = editor_blockly.workspace.getBlockById(blockId);
if (b && MotaActionBlocks[b.type].previewBlock){ if (b && MotaActionBlocks[b.type].previewBlock) {
editor_blockly.previewBlock(b,MotaActionBlocks[b.type].previewBlock) editor_blockly.previewBlock(b, MotaActionBlocks[b.type].previewBlock)
return; return;
} }
if (b && MotaActionBlocks[b.type].selectPoint) { // selectPoint if (b && MotaActionBlocks[b.type].selectPoint) { // selectPoint
editor_blockly.selectPoint(b,eval(MotaActionBlocks[b.type].selectPoint)); editor_blockly.selectPoint(b, eval(MotaActionBlocks[b.type].selectPoint));
return; return;
} }
if (b && MotaActionBlocks[b.type].material) { if (b && MotaActionBlocks[b.type].material) {
editor_blockly.selectMaterial(b,JSON.parse(MotaActionBlocks[b.type].material)); editor_blockly.selectMaterial(b, JSON.parse(MotaActionBlocks[b.type].material));
return; return;
} }
if (b && MotaActionBlocks[b.type].doubleclicktext) { //多行编辑 if (b && MotaActionBlocks[b.type].doubleclicktext) { //多行编辑
editor_blockly.doubleclicktext(b,MotaActionBlocks[b.type].doubleclicktext); editor_blockly.doubleclicktext(b, MotaActionBlocks[b.type].doubleclicktext);
return; return;
} }
} }
@ -439,7 +445,7 @@ editor_blockly = function () {
editor_blockly.selectPointFromButton = function () { editor_blockly.selectPointFromButton = function () {
var b = Blockly.selected; var b = Blockly.selected;
if (b && MotaActionBlocks[b.type].selectPoint) { if (b && MotaActionBlocks[b.type].selectPoint) {
editor_blockly.selectPoint(b,eval(MotaActionBlocks[b.type].selectPoint)); editor_blockly.selectPoint(b, eval(MotaActionBlocks[b.type].selectPoint));
return; return;
} else { } else {
editor.uievent.selectPoint(); editor.uievent.selectPoint();
@ -448,11 +454,11 @@ editor_blockly = function () {
editor_blockly.showKeyCodes = function () { editor_blockly.showKeyCodes = function () {
alert('键值查询表:\nA65 B66 C67 D68 E69 F70 G71 H72 I73 J74 K75 L76 M77\n' alert('键值查询表:\nA65 B66 C67 D68 E69 F70 G71 H72 I73 J74 K75 L76 M77\n'
+'N78 O79 P80 Q81 R82 S83 T84 U85 V86 W87 X88 Y89 Z90\n0:48 1:49 2:50 3:51 4:52 5:53 6:54 7:55 8:56 9:57\n' + 'N78 O79 P80 Q81 R82 S83 T84 U85 V86 W87 X88 Y89 Z90\n0:48 1:49 2:50 3:51 4:52 5:53 6:54 7:55 8:56 9:57\n'
+'空格:13 回车:32 ESC:27 后退:8 Tab:9 Shift:16 Ctrl:17 Alt:18\nPgUp:33 PgDn:34 左:37 上:38 右:39 下:40\n更多键值请自行百度查表') + '空格:13 回车:32 ESC:27 后退:8 Tab:9 Shift:16 Ctrl:17 Alt:18\nPgUp:33 PgDn:34 左:37 上:38 右:39 下:40\n更多键值请自行百度查表')
} }
editor_blockly.lastUsedType=[ editor_blockly.lastUsedType = [
'text_0_s', 'text_0_s',
'comment_s', 'comment_s',
'show_s', 'show_s',
@ -469,33 +475,33 @@ editor_blockly = function () {
'setBlock_s', 'setBlock_s',
'insert_1_s' 'insert_1_s'
]; // 最常用的15个事件 ]; // 最常用的15个事件
editor_blockly.lastUsedTypeNum=15; editor_blockly.lastUsedTypeNum = 15;
editor_blockly.addIntoLastUsedType=function(blockId) { editor_blockly.addIntoLastUsedType = function (blockId) {
var b = editor_blockly.workspace.getBlockById(blockId); var b = editor_blockly.workspace.getBlockById(blockId);
if(!b)return; if (!b) return;
var blockType = b.type; var blockType = b.type;
if(!blockType || blockType.indexOf("_s")!==blockType.length-2 || blockType==='pass_s')return; if (!blockType || blockType.indexOf("_s") !== blockType.length - 2 || blockType === 'pass_s') return;
editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) {return v!==blockType;}); editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) { return v !== blockType; });
if (editor_blockly.lastUsedType.length >= editor_blockly.lastUsedTypeNum) if (editor_blockly.lastUsedType.length >= editor_blockly.lastUsedTypeNum)
editor_blockly.lastUsedType.pop(); editor_blockly.lastUsedType.pop();
editor_blockly.lastUsedType.unshift(blockType); editor_blockly.lastUsedType.unshift(blockType);
document.getElementById("searchBlock").value=''; document.getElementById("searchBlock").value = '';
} }
// Index from 1 - 9 // Index from 1 - 9
editor_blockly.openToolbox = function(index) { editor_blockly.openToolbox = function (index) {
if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length; if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length;
editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]); editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]);
} }
editor_blockly.reopenToolbox = function(index) { editor_blockly.reopenToolbox = function (index) {
if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length; if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length;
editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]); editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]);
editor_blockly.workspace.getFlyout().show(editor_blockly.workspace.toolbox_.tree_.children_[index].blocks); editor_blockly.workspace.getFlyout().show(editor_blockly.workspace.toolbox_.tree_.children_[index].blocks);
} }
editor_blockly.closeToolbox = function() { editor_blockly.closeToolbox = function () {
editor_blockly.workspace.toolbox_.clearSelection(); editor_blockly.workspace.toolbox_.clearSelection();
} }
@ -514,14 +520,14 @@ editor_blockly = function () {
if (value == '') return editor_blockly.lastUsedType; if (value == '') return editor_blockly.lastUsedType;
var results = []; var results = [];
for (var name in MotaActionBlocks) { for (var name in MotaActionBlocks) {
if (typeof name !== 'string' || name.indexOf("_s") !== name.length-2) continue; if (typeof name !== 'string' || name.indexOf("_s") !== name.length - 2) continue;
var block = MotaActionBlocks[name]; var block = MotaActionBlocks[name];
if(block && block.json) { if (block && block.json) {
if ((block.json.type||"").toLowerCase().indexOf(value)>=0 if ((block.json.type || "").toLowerCase().indexOf(value) >= 0
|| (block.json.message0||"").toLowerCase().indexOf(value)>=0 || (block.json.message0 || "").toLowerCase().indexOf(value) >= 0
|| (block.json.tooltip||"").toLowerCase().indexOf(value)>=0) { || (block.json.tooltip || "").toLowerCase().indexOf(value) >= 0) {
results.push(name); results.push(name);
if (results.length>=editor_blockly.lastUsedTypeNum) if (results.length >= editor_blockly.lastUsedTypeNum)
break; break;
} }
} }
@ -532,7 +538,7 @@ editor_blockly = function () {
// ------ select point ------ // ------ select point ------
editor_blockly.selectPoint = function (block,arr) { editor_blockly.selectPoint = function (block, arr) {
var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y; var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y;
@ -547,8 +553,8 @@ editor_blockly = function () {
if (fv != editor.currentFloorId || editor_blockly.entryType == 'commonEvent') block.setFieldValue(fv, arr[2]); if (fv != editor.currentFloorId || editor_blockly.entryType == 'commonEvent') block.setFieldValue(fv, arr[2]);
else block.setFieldValue(arr[3] ? fv : "", arr[2]); else block.setFieldValue(arr[3] ? fv : "", arr[2]);
} }
block.setFieldValue(xv+"", arr[0]); block.setFieldValue(xv + "", arr[0]);
block.setFieldValue(yv+"", arr[1]); block.setFieldValue(yv + "", arr[1]);
if (block.type == 'changeFloor_m' || block.type == 'changeFloor_s') { if (block.type == 'changeFloor_m' || block.type == 'changeFloor_s') {
block.setFieldValue("floorId", "Floor_List_0"); block.setFieldValue("floorId", "Floor_List_0");
block.setFieldValue("loc", "Stair_List_0"); block.setFieldValue("loc", "Stair_List_0");
@ -565,7 +571,7 @@ editor_blockly = function () {
var index = Math.max(content.lastIndexOf(":"), content.lastIndexOf("")); var index = Math.max(content.lastIndexOf(":"), content.lastIndexOf(""));
if (index >= 0) { if (index >= 0) {
var ch = content.charAt(index); var ch = content.charAt(index);
var before = content.substring(0, index), token = content.substring(index+1); var before = content.substring(0, index), token = content.substring(index + 1);
if (/^[a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]*$/.test(token)) { if (/^[a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]*$/.test(token)) {
if (before.endsWith("状态") || (ch == ':' && before.endsWith("status"))) { if (before.endsWith("状态") || (ch == ':' && before.endsWith("status"))) {
var list = Object.keys(core.status.hero); var list = Object.keys(core.status.hero);
@ -604,12 +610,12 @@ editor_blockly = function () {
return one != token && one.startsWith(token); return one != token && one.startsWith(token);
}) })
} else { } else {
var index2 = Math.max(content.lastIndexOf(":", index-1), content.lastIndexOf("", index-1)); var index2 = Math.max(content.lastIndexOf(":", index - 1), content.lastIndexOf("", index - 1));
var ch2 = content.charAt(index2); var ch2 = content.charAt(index2);
if (index2 >= 0) { if (index2 >= 0) {
before = content.substring(0, index2); before = content.substring(0, index2);
if (before.endsWith("怪物") || (ch == ':' && ch2 == ':' && before.endsWith("enemy"))) { if (before.endsWith("怪物") || (ch == ':' && ch2 == ':' && before.endsWith("enemy"))) {
var list = MotaActionBlocks['EnemyId_List'].options.map(function(v){return v[1]}); var list = MotaActionBlocks['EnemyId_List'].options.map(function (v) { return v[1] });
if (before.endsWith("怪物") && MotaActionFunctions) { if (before.endsWith("怪物") && MotaActionFunctions) {
list = MotaActionFunctions.pattern.replaceEnemyValueList.map(function (v) { list = MotaActionFunctions.pattern.replaceEnemyValueList.map(function (v) {
return v[1]; return v[1];
@ -651,7 +657,7 @@ editor_blockly = function () {
// 提供 flags.xxx 补全 // 提供 flags.xxx 补全
index = content.lastIndexOf("flags."); index = content.lastIndexOf("flags.");
if (index >= 0) { if (index >= 0) {
var token = content.substring(index+6); var token = content.substring(index + 6);
return Object.keys(editor.used_flags || {}).filter(function (one) { return Object.keys(editor.used_flags || {}).filter(function (one) {
return one != token && one.startsWith(token) return one != token && one.startsWith(token)
&& /^[a-zA-Z_]\w*$/.test(one); && /^[a-zA-Z_]\w*$/.test(one);
@ -661,7 +667,7 @@ editor_blockly = function () {
// 提供 hero.xxx 补全 // 提供 hero.xxx 补全
index = content.lastIndexOf("hero."); index = content.lastIndexOf("hero.");
if (index >= 0) { if (index >= 0) {
var token = content.substring(index+6); var token = content.substring(index + 6);
return Object.keys(core.status.hero).filter(function (one) { return Object.keys(core.status.hero).filter(function (one) {
return one != token && one.startsWith(token); return one != token && one.startsWith(token);
}).sort(); }).sort();
@ -696,14 +702,14 @@ editor_blockly = function () {
}).sort(); }).sort();
} }
var namesObj={}; var namesObj = {};
namesObj.allIds = ["this"].concat(core.getAllIconIds()); namesObj.allIds = ["this"].concat(core.getAllIconIds());
namesObj.allIconIds = namesObj.allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) { namesObj.allIconIds = namesObj.allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) {
return core.statusBar.icons[x] instanceof Image; return core.statusBar.icons[x] instanceof Image;
})); }));
namesObj.allImages = Object.keys(core.material.images.images) namesObj.allImages = Object.keys(core.material.images.images)
.concat(Object.keys(main.nameMap).filter(function (one) {return core.material.images.images[main.nameMap[one]];})); .concat(Object.keys(main.nameMap).filter(function (one) { return core.material.images.images[main.nameMap[one]]; }));
namesObj.allEnemys = Object.keys(core.material.enemys); namesObj.allEnemys = Object.keys(core.material.enemys);
if (MotaActionFunctions && !MotaActionFunctions.disableReplace) { if (MotaActionFunctions && !MotaActionFunctions.disableReplace) {
namesObj.allEnemys = namesObj.allEnemys.concat(MotaActionFunctions.pattern.replaceEnemyList.map(function (x) { namesObj.allEnemys = namesObj.allEnemys.concat(MotaActionFunctions.pattern.replaceEnemyList.map(function (x) {
@ -721,11 +727,11 @@ editor_blockly = function () {
}).map(function (x) { return x[1]; })); }).map(function (x) { return x[1]; }));
} }
namesObj.allAnimates = Object.keys(core.material.animates) namesObj.allAnimates = Object.keys(core.material.animates)
.concat(Object.keys(main.nameMap).filter(function (one) {return core.material.animates[main.nameMap[one]];})); .concat(Object.keys(main.nameMap).filter(function (one) { return core.material.animates[main.nameMap[one]]; }));
namesObj.allBgms = Object.keys(core.material.bgms) namesObj.allBgms = Object.keys(core.material.bgms)
.concat(Object.keys(main.nameMap).filter(function (one) {return core.material.bgms[main.nameMap[one]];})); .concat(Object.keys(main.nameMap).filter(function (one) { return core.material.bgms[main.nameMap[one]]; }));
namesObj.allSounds = Object.keys(core.material.sounds) namesObj.allSounds = Object.keys(core.material.sounds)
.concat(Object.keys(main.nameMap).filter(function (one) {return core.material.sounds[main.nameMap[one]];}));; .concat(Object.keys(main.nameMap).filter(function (one) { return core.material.sounds[main.nameMap[one]]; }));;
namesObj.allShops = Object.keys(core.status.shops); namesObj.allShops = Object.keys(core.status.shops);
namesObj.allFloorIds = core.floorIds; namesObj.allFloorIds = core.floorIds;
namesObj.allColors = ["aqua青色", "black黑色", "blue蓝色", "fuchsia品红色", "gray灰色", "green深绿色", "lime绿色", namesObj.allColors = ["aqua青色", "black黑色", "blue蓝色", "fuchsia品红色", "gray灰色", "green深绿色", "lime绿色",
@ -752,8 +758,8 @@ editor_blockly = function () {
// 对音效进行补全 // 对音效进行补全
// 对全局商店进行补全 // 对全局商店进行补全
// 对楼层名进行补全 // 对楼层名进行补全
for(var ii=0,names;names=['allIds','allEnemys','allItems','allEquips','allImages','allAnimates','allBgms','allSounds','allShops','allFloorIds','allDoors','allEvents'][ii];ii++){ for (var ii = 0, names; names = ['allIds', 'allEnemys', 'allItems', 'allEquips', 'allImages', 'allAnimates', 'allBgms', 'allSounds', 'allShops', 'allFloorIds', 'allDoors', 'allEvents'][ii]; ii++) {
if (MotaActionBlocks[type][names] && eval(MotaActionBlocks[type][names]).indexOf(name)!==-1) { if (MotaActionBlocks[type][names] && eval(MotaActionBlocks[type][names]).indexOf(name) !== -1) {
return filter(namesObj[names], content); return filter(namesObj[names], content);
} }
} }
@ -807,25 +813,25 @@ editor_blockly = function () {
editor_blockly.completeItems = []; editor_blockly.completeItems = [];
editor_blockly.onTextFieldCreate = function (self, htmlInput) { editor_blockly.onTextFieldCreate = function (self, htmlInput) {
var pb=self.sourceBlock_ var pb = self.sourceBlock_
var args = MotaActionBlocks[pb.type].args var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)+1] var targetf = args[args.indexOf(self.name) + 1]
// ------ colour // ------ colour
if(targetf && targetf.slice(0,7)==='Colour_'){ if (targetf && targetf.slice(0, 7) === 'Colour_') {
var inputDom = htmlInput; var inputDom = htmlInput;
// var getValue=function(){ // 获得自己的字符串 // var getValue=function(){ // 获得自己的字符串
// return pb.getFieldValue(self.name); // return pb.getFieldValue(self.name);
// } // }
var setValue = function(newValue){ // 设置右边颜色块的css颜色 var setValue = function (newValue) { // 设置右边颜色块的css颜色
pb.setFieldValue(newValue, targetf) pb.setFieldValue(newValue, targetf)
} }
// 给inputDom绑事件 // 给inputDom绑事件
inputDom.oninput=function(){ inputDom.oninput = function () {
var value=inputDom.value var value = inputDom.value
if(/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)){ if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)) {
setValue('rgba('+value+')') setValue('rgba(' + value + ')')
} }
} }
} }
@ -866,14 +872,14 @@ editor_blockly = function () {
}); });
editor_blockly.completeItems.unshift(text); editor_blockly.completeItems.unshift(text);
}, },
filter: function () {return true;}, filter: function () { return true; },
item: function (text, input) { item: function (text, input) {
var id = text.label, info = core.getBlockInfo(id); var id = text.label, info = core.getBlockInfo(id);
var li = document.createElement("li"); var li = document.createElement("li");
li.setAttribute("role", "option"); li.setAttribute("role", "option");
li.setAttribute("aria-selected", "false"); li.setAttribute("aria-selected", "false");
input = awesomplete.prefix.trim(); input = awesomplete.prefix.trim();
if (input != "") text = text.replace(new RegExp("^"+input, "i"), "<mark>$&</mark>"); if (input != "") text = text.replace(new RegExp("^" + input, "i"), "<mark>$&</mark>");
li.innerHTML = text; li.innerHTML = text;
if (info) { if (info) {
var height = (info.height || 32), width = 32; var height = (info.height || 32), width = 32;
@ -907,10 +913,10 @@ editor_blockly = function () {
value = value.substring(0, index); value = value.substring(0, index);
// cal prefix // cal prefix
awesomplete.prefix = value; awesomplete.prefix = value;
for (var i = index - 1; i>=0; i--) { for (var i = index - 1; i >= 0; i--) {
var c = value.charAt(i); var c = value.charAt(i);
if (!/^[a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]$/.test(c)) { if (!/^[a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]$/.test(c)) {
awesomplete.prefix = value.substring(i+1); awesomplete.prefix = value.substring(i + 1);
break; break;
} }
} }
@ -945,16 +951,16 @@ editor_blockly = function () {
// --- modify Blockly // --- modify Blockly
Blockly.FieldColour.prototype.showEditor_ = function() { Blockly.FieldColour.prototype.showEditor_ = function () {
Blockly.WidgetDiv.hide(); Blockly.WidgetDiv.hide();
// console.log('here') // console.log('here')
var self=this; var self = this;
var pb=self.sourceBlock_ var pb = self.sourceBlock_
var args = MotaActionBlocks[pb.type].args var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)-1] var targetf = args[args.indexOf(self.name) - 1]
var getValue=function(){ var getValue = function () {
// return self.getValue() // css颜色 // return self.getValue() // css颜色
var f = pb.getFieldValue(targetf); var f = pb.getFieldValue(targetf);
if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(f)) { if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(f)) {
@ -964,9 +970,9 @@ Blockly.FieldColour.prototype.showEditor_ = function() {
// 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容 // 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容
} }
var setValue=function(newValue){ // css颜色 var setValue = function (newValue) { // css颜色
self.setValue(newValue) self.setValue(newValue)
pb.setFieldValue(newValue.replace("rgba(","").replace(")",""), targetf) // 放在颜色块左边的域中 pb.setFieldValue(newValue.replace("rgba(", "").replace(")", ""), targetf) // 放在颜色块左边的域中
} }
setTimeout(function () { setTimeout(function () {
@ -983,7 +989,7 @@ Blockly.FieldColour.prototype.setValue = function (colour) {
this.doValueUpdate_(colour); this.doValueUpdate_(colour);
} }
Blockly.FieldColour.prototype.initView = function() { Blockly.FieldColour.prototype.initView = function () {
this.size_ = new Blockly.utils.Size( this.size_ = new Blockly.utils.Size(
this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH, this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,
this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT); this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT);
@ -996,7 +1002,7 @@ Blockly.FieldColour.prototype.initView = function() {
} }
}; };
Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { Blockly.FieldTextInput.prototype.showInlineEditor_ = function (quietInput) {
Blockly.WidgetDiv.show( Blockly.WidgetDiv.show(
this, this.sourceBlock_.RTL, this.widgetDispose_.bind(this)); this, this.sourceBlock_.RTL, this.widgetDispose_.bind(this));
this.htmlInput_ = this.widgetCreate_(); this.htmlInput_ = this.widgetCreate_();
@ -1005,12 +1011,12 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
editor_blockly.onTextFieldCreate(this, this.htmlInput_); editor_blockly.onTextFieldCreate(this, this.htmlInput_);
if (!quietInput) { if (!quietInput) {
this.htmlInput_.focus({preventScroll:true}); this.htmlInput_.focus({ preventScroll: true });
this.htmlInput_.select(); this.htmlInput_.select();
} }
}; };
Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function(e) { Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function (e) {
if (e.keyCode == Blockly.utils.KeyCodes.ENTER && !(window.awesomplete && window.awesomplete.opened)) { if (e.keyCode == Blockly.utils.KeyCodes.ENTER && !(window.awesomplete && window.awesomplete.opened)) {
Blockly.WidgetDiv.hide(); Blockly.WidgetDiv.hide();
Blockly.DropDownDiv.hideWithoutAnimation(); Blockly.DropDownDiv.hideWithoutAnimation();
@ -1026,19 +1032,19 @@ Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function(e) {
} }
}; };
Blockly.FieldMultilineInput.prototype.showInlineEditor_ = function(quietInput) { Blockly.FieldMultilineInput.prototype.showInlineEditor_ = function (quietInput) {
Blockly.FieldMultilineInput.superClass_.showInlineEditor_.call(this, quietInput); Blockly.FieldMultilineInput.superClass_.showInlineEditor_.call(this, quietInput);
// force to resize the input // force to resize the input
this.htmlInput_.style.height = Blockly.WidgetDiv.DIV.style.height; this.htmlInput_.style.height = Blockly.WidgetDiv.DIV.style.height;
}; };
Blockly.FieldMultilineInput.prototype.onHtmlInputChange_ = function(e) { Blockly.FieldMultilineInput.prototype.onHtmlInputChange_ = function (e) {
Blockly.FieldMultilineInput.superClass_.onHtmlInputChange_.call(this, e); Blockly.FieldMultilineInput.superClass_.onHtmlInputChange_.call(this, e);
// force to resize the input // force to resize the input
this.htmlInput_.style.height = Blockly.WidgetDiv.DIV.style.height; this.htmlInput_.style.height = Blockly.WidgetDiv.DIV.style.height;
}; };
Blockly.copy_ = function(toCopy) { Blockly.copy_ = function (toCopy) {
if (toCopy.isComment) { if (toCopy.isComment) {
var xml = toCopy.toXmlWithXY(); var xml = toCopy.toXmlWithXY();
} else { } else {
@ -1061,7 +1067,7 @@ Blockly.copy_ = function(toCopy) {
* Paste the provided block onto the workspace. * Paste the provided block onto the workspace.
* @param {!Element} xmlBlock XML block element. * @param {!Element} xmlBlock XML block element.
*/ */
Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) { Blockly.WorkspaceSvg.prototype.paste = function (xmlBlock) {
if (!this.rendered || xmlBlock.getElementsByTagName('block').length >= if (!this.rendered || xmlBlock.getElementsByTagName('block').length >=
this.remainingCapacity()) { this.remainingCapacity()) {
return; return;
@ -1081,7 +1087,7 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) {
// -- Support showing disabled blocks // -- Support showing disabled blocks
Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) { Blockly.Generator.prototype.blockToCode = function (block, opt_thisOnly) {
if (this.isInitialized === false) { if (this.isInitialized === false) {
console.warn( console.warn(
'Generator init was not called before blockToCode was called.'); 'Generator init was not called before blockToCode was called.');
@ -1129,7 +1135,7 @@ Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) {
throw SyntaxError('Invalid code generated: ' + code); throw SyntaxError('Invalid code generated: ' + code);
}; };
Blockly.BlockSvg.prototype.generateContextMenu = function() { Blockly.BlockSvg.prototype.generateContextMenu = function () {
if (this.workspace.options.readOnly || !this.contextMenu) { if (this.workspace.options.readOnly || !this.contextMenu) {
return null; return null;
} }
@ -1153,7 +1159,7 @@ Blockly.BlockSvg.prototype.generateContextMenu = function() {
menuOptions.push({ menuOptions.push({
text: this.isEnabled() ? Blockly.Msg['DISABLE_BLOCK'] : Blockly.Msg['ENABLE_BLOCK'], text: this.isEnabled() ? Blockly.Msg['DISABLE_BLOCK'] : Blockly.Msg['ENABLE_BLOCK'],
enabled: !this.getInheritedDisabled(), enabled: !this.getInheritedDisabled(),
callback: function() { callback: function () {
var group = Blockly.Events.getGroup(); var group = Blockly.Events.getGroup();
if (!group) { if (!group) {
Blockly.Events.setGroup(true); Blockly.Events.setGroup(true);
@ -1193,7 +1199,7 @@ Blockly.FieldDropdown.prototype.doValueUpdate_ = function (newValue) {
} }
}; };
Blockly.FieldMultilineInput.prototype.getDisplayText_ = function() { Blockly.FieldMultilineInput.prototype.getDisplayText_ = function () {
var value = this.value_; var value = this.value_;
if (!value) return Blockly.Field.NBSP; if (!value) return Blockly.Field.NBSP;
var curr = '', text = ''; var curr = '', text = '';

View File

@ -7,7 +7,7 @@ editor_mappanel_wrapper = function (editor) {
*/ */
editor.uifunctions.fillPos = function (pos) { editor.uifunctions.fillPos = function (pos) {
editor.dom.euiCtx.fillStyle = '#' + ~~(Math.random() * 8) + ~~(Math.random() * 8) + ~~(Math.random() * 8); editor.dom.euiCtx.fillStyle = '#' + ~~(Math.random() * 8) + ~~(Math.random() * 8) + ~~(Math.random() * 8);
var grid = _getGridByPos({x: pos.x, y: pos.y}); var grid = _getGridByPos({ x: pos.x, y: pos.y });
editor.dom.euiCtx.fillRect(grid.x + grid.size * 3 / 8, grid.y + grid.size * 3 / 8, grid.size / 4, grid.size / 4); editor.dom.euiCtx.fillRect(grid.x + grid.size * 3 / 8, grid.y + grid.size * 3 / 8, grid.size / 4, grid.size / 4);
} }
@ -85,7 +85,7 @@ editor_mappanel_wrapper = function (editor) {
*/ */
editor.uifunctions.map_ondown = function (e) { editor.uifunctions.map_ondown = function (e) {
editor.uivalues.selectedArea = null; editor.uivalues.selectedArea = null;
editor.uivalues.lastMoveE=e; editor.uivalues.lastMoveE = e;
var loc = editor.uifunctions.eToLoc(e); var loc = editor.uifunctions.eToLoc(e);
var pos = editor.uifunctions.locToPos(loc, true); var pos = editor.uifunctions.locToPos(loc, true);
editor.pos = pos; editor.pos = pos;
@ -131,9 +131,9 @@ editor_mappanel_wrapper = function (editor) {
var _getGridByPos = function (pos) { var _getGridByPos = function (pos) {
if (editor.uivalues.bigmap) { if (editor.uivalues.bigmap) {
var info = editor.uivalues.bigmapInfo; var info = editor.uivalues.bigmapInfo;
return {x: info.left + info.size * pos.x, y: info.top + info.size * pos.y, size: info.size}; return { x: info.left + info.size * pos.x, y: info.top + info.size * pos.y, size: info.size };
} else { } else {
return {x: 32 * pos.x - core.bigmap.offsetX, y: 32 * pos.y - core.bigmap.offsetY, size: 32}; return { x: 32 * pos.x - core.bigmap.offsetX, y: 32 * pos.y - core.bigmap.offsetY, size: 32 };
} }
} }
@ -155,12 +155,12 @@ editor_mappanel_wrapper = function (editor) {
* + 绘图模式时找到与队列尾相邻的鼠标方向的点画个矩形 * + 绘图模式时找到与队列尾相邻的鼠标方向的点画个矩形
*/ */
editor.uifunctions.map_onmove = function (e) { editor.uifunctions.map_onmove = function (e) {
editor.uivalues.lastMoveE=e; editor.uivalues.lastMoveE = e;
if (!editor.uivalues.bigmap && !editor.isMobile && editor.dom.midMenu.style.display == 'none') { if (!editor.uivalues.bigmap && !editor.isMobile && editor.dom.midMenu.style.display == 'none') {
var loc = editor.uifunctions.eToLoc(e); var loc = editor.uifunctions.eToLoc(e);
var pos = editor.uifunctions.locToPos(loc); var pos = editor.uifunctions.locToPos(loc);
_setMarksHightlight(Array.from(editor.dom.mapColMark.children[0].rows[0].cells), pos.x); _setMarksHightlight(Array.from(editor.dom.mapColMark.children[0].rows[0].cells), pos.x);
_setMarksHightlight(Array.from(editor.dom.mapRowMark.children[0].rows).map(function (tr) {return tr.cells[0];}), pos.y); _setMarksHightlight(Array.from(editor.dom.mapRowMark.children[0].rows).map(function (tr) { return tr.cells[0]; }), pos.y);
} }
if (!selectBox.isSelected()) { if (!selectBox.isSelected()) {
@ -190,9 +190,9 @@ editor_mappanel_wrapper = function (editor) {
// draw rect // draw rect
editor.dom.euiCtx.clearRect(0, 0, editor.dom.euiCtx.canvas.width, editor.dom.euiCtx.canvas.height); editor.dom.euiCtx.clearRect(0, 0, editor.dom.euiCtx.canvas.width, editor.dom.euiCtx.canvas.height);
editor.dom.euiCtx.fillStyle = 'rgba(0, 127, 255, 0.4)'; editor.dom.euiCtx.fillStyle = 'rgba(0, 127, 255, 0.4)';
var grid = _getGridByPos({x: x0, y: y0}); var grid = _getGridByPos({ x: x0, y: y0 });
editor.dom.euiCtx.fillRect(grid.x, grid.y, grid.size * (x1 - x0 + 1), grid.size * (y1 - y0 + 1)); editor.dom.euiCtx.fillRect(grid.x, grid.y, grid.size * (x1 - x0 + 1), grid.size * (y1 - y0 + 1));
}else{ } else {
// 左键拖拽: 画箭头 // 左键拖拽: 画箭头
core.drawArrow('eui', startGrid.x + startGrid.size / 2, startGrid.y + startGrid.size / 2, endGrid.x + endGrid.size / 2, endGrid.y + endGrid.size / 2); core.drawArrow('eui', startGrid.x + startGrid.size / 2, startGrid.y + startGrid.size / 2, endGrid.x + endGrid.size / 2, endGrid.y + endGrid.size / 2);
} }
@ -234,7 +234,7 @@ editor_mappanel_wrapper = function (editor) {
// draw rect // draw rect
editor.dom.euiCtx.clearRect(0, 0, editor.dom.euiCtx.canvas.width, editor.dom.euiCtx.canvas.height); editor.dom.euiCtx.clearRect(0, 0, editor.dom.euiCtx.canvas.width, editor.dom.euiCtx.canvas.height);
editor.dom.euiCtx.fillStyle = 'rgba(0, 127, 255, 0.4)'; editor.dom.euiCtx.fillStyle = 'rgba(0, 127, 255, 0.4)';
var grid = _getGridByPos({x: x0, y: y0}); var grid = _getGridByPos({ x: x0, y: y0 });
editor.dom.euiCtx.fillRect(grid.x, grid.y, editor.dom.euiCtx.fillRect(grid.x, grid.y,
grid.size * (x1 - x0 + 1), grid.size * (y1 - y0 + 1)); grid.size * (x1 - x0 + 1), grid.size * (y1 - y0 + 1));
} }
@ -246,7 +246,7 @@ editor_mappanel_wrapper = function (editor) {
editor.uifunctions.map_onmoveout = function () { editor.uifunctions.map_onmoveout = function () {
if (!editor.uivalues.bigmap && !editor.isMobile) { if (!editor.uivalues.bigmap && !editor.isMobile) {
_setMarksHightlight(Array.from(editor.dom.mapColMark.children[0].rows[0].cells)); _setMarksHightlight(Array.from(editor.dom.mapColMark.children[0].rows[0].cells));
_setMarksHightlight(Array.from(editor.dom.mapRowMark.children[0].rows).map(function (tr) {return tr.cells[0];})); _setMarksHightlight(Array.from(editor.dom.mapRowMark.children[0].rows).map(function (tr) { return tr.cells[0]; }));
} }
} }
@ -259,8 +259,8 @@ editor_mappanel_wrapper = function (editor) {
editor.uivalues.selectedArea = null; editor.uivalues.selectedArea = null;
ee.preventDefault(); ee.preventDefault();
ee.stopPropagation(); ee.stopPropagation();
var e=editor.uivalues.lastMoveE; var e = editor.uivalues.lastMoveE;
if (e.buttons == 2 && (editor.uivalues.endPos==null || (editor.uivalues.startPos.x == editor.uivalues.endPos.x && editor.uivalues.startPos.y == editor.uivalues.endPos.y))) { if (e.buttons == 2 && (editor.uivalues.endPos == null || (editor.uivalues.startPos.x == editor.uivalues.endPos.x && editor.uivalues.startPos.y == editor.uivalues.endPos.y))) {
editor.uifunctions.showMidMenu(e.clientX, e.clientY); editor.uifunctions.showMidMenu(e.clientX, e.clientY);
editor.uivalues.holdingPath = 0; editor.uivalues.holdingPath = 0;
editor.uivalues.stepPostfix = []; editor.uivalues.stepPostfix = [];
@ -272,7 +272,7 @@ editor_mappanel_wrapper = function (editor) {
if (e.buttons == 2) { if (e.buttons == 2) {
// 右键拖拽: 选中区域 // 右键拖拽: 选中区域
printf('已经选中该区域') printf('已经选中该区域')
editor.uivalues.selectedArea = Object.assign({}, editor.uivalues.startPos, {x1: editor.uivalues.endPos.x, y1: editor.uivalues.endPos.y}); editor.uivalues.selectedArea = Object.assign({}, editor.uivalues.startPos, { x1: editor.uivalues.endPos.x, y1: editor.uivalues.endPos.y });
// 后续的处理 // 后续的处理
} else { } else {
// 左键拖拽: 交换 // 左键拖拽: 交换
@ -321,11 +321,11 @@ editor_mappanel_wrapper = function (editor) {
var x0 = editor.uivalues.stepPostfix[0].x; var x0 = editor.uivalues.stepPostfix[0].x;
var y0 = editor.uivalues.stepPostfix[0].y; var y0 = editor.uivalues.stepPostfix[0].y;
var idnum = editor.info.idnum; var idnum = editor.info.idnum;
var pmod=function(a,b){return (a%b+b)%b;} var pmod = function (a, b) { return (a % b + b) % b; }
for (var ii = 0; ii < editor.uivalues.stepPostfix.length; ii++) { for (var ii = 0; ii < editor.uivalues.stepPostfix.length; ii++) {
var dx=pmod(editor.uivalues.stepPostfix[ii].x-x0,editor.uivalues.tileSize[0]); var dx = pmod(editor.uivalues.stepPostfix[ii].x - x0, editor.uivalues.tileSize[0]);
var dy=pmod(editor.uivalues.stepPostfix[ii].y-y0,editor.uivalues.tileSize[1]); var dy = pmod(editor.uivalues.stepPostfix[ii].y - y0, editor.uivalues.tileSize[1]);
editor[editor.layerMod][editor.uivalues.stepPostfix[ii].y][editor.uivalues.stepPostfix[ii].x] = editor.ids[editor.indexs[idnum + dx+dy*imgWidth]]; editor[editor.layerMod][editor.uivalues.stepPostfix[ii].y][editor.uivalues.stepPostfix[ii].x] = editor.ids[editor.indexs[idnum + dx + dy * imgWidth]];
} }
} else { } else {
// 检测是否是填充模式 // 检测是否是填充模式
@ -338,11 +338,11 @@ editor_mappanel_wrapper = function (editor) {
editor[editor.layerMod][curry][currx] = editor.info; editor[editor.layerMod][curry][currx] = editor.info;
// 检查上下楼梯绑定 // 检查上下楼梯绑定
if (editor.layerMod == 'map' && editor.info && editor.info.id == 'upFloor') { if (editor.layerMod == 'map' && editor.info && editor.info.id == 'upFloor') {
editor.currentFloorData.changeFloor[currx+","+curry] = { "floorId": ":next", "stair": "downFloor" }; editor.currentFloorData.changeFloor[currx + "," + curry] = { "floorId": ":next", "stair": "downFloor" };
editor.drawEventBlock(); editor.drawEventBlock();
} }
if (editor.layerMod == 'map' && editor.info && editor.info.id == 'downFloor') { if (editor.layerMod == 'map' && editor.info && editor.info.id == 'downFloor') {
editor.currentFloorData.changeFloor[currx+","+curry] = { "floorId": ":before", "stair": "upFloor" }; editor.currentFloorData.changeFloor[currx + "," + curry] = { "floorId": ":before", "stair": "upFloor" };
editor.drawEventBlock(); editor.drawEventBlock();
} }
} }
@ -359,7 +359,7 @@ editor_mappanel_wrapper = function (editor) {
} }
}) })
if (!found) { if (!found) {
editor.uivalues.lastUsed.push(Object.assign({}, editor.info, {recent: new Date().getTime(), frequent: 1})); editor.uivalues.lastUsed.push(Object.assign({}, editor.info, { recent: new Date().getTime(), frequent: 1 }));
} }
editor.config.set("lastUsed", editor.uivalues.lastUsed); editor.config.set("lastUsed", editor.uivalues.lastUsed);
} }
@ -377,21 +377,21 @@ editor_mappanel_wrapper = function (editor) {
*/ */
editor.uifunctions._fillMode_bfs = function (array, x, y, maxWidth, maxHeight) { editor.uifunctions._fillMode_bfs = function (array, x, y, maxWidth, maxHeight) {
var _getNumber = function (x, y) { var _getNumber = function (x, y) {
if (x<0 || y<0 || x>=maxWidth || y>=maxHeight) return null; if (x < 0 || y < 0 || x >= maxWidth || y >= maxHeight) return null;
return array[y][x].idnum || array[y][x] || 0; return array[y][x].idnum || array[y][x] || 0;
} }
var number = _getNumber(x, y) || 0; var number = _getNumber(x, y) || 0;
var visited = {}, result = []; var visited = {}, result = [];
var list = [{x:x, y:y}]; var list = [{ x: x, y: y }];
while (list.length != 0) { while (list.length != 0) {
var next = list.shift(), key = next.x+","+next.y; var next = list.shift(), key = next.x + "," + next.y;
if (visited[key]) continue; if (visited[key]) continue;
visited[key] = true; visited[key] = true;
result.push(next); result.push(next);
[[-1,0],[1,0],[0,-1],[0,1]].forEach(function (dir) { [[-1, 0], [1, 0], [0, -1], [0, 1]].forEach(function (dir) {
var nx = next.x + dir[0], ny = next.y + dir[1]; var nx = next.x + dir[0], ny = next.y + dir[1];
if (_getNumber(nx, ny) == number) { if (_getNumber(nx, ny) == number) {
list.push({x: nx, y: ny}); list.push({ x: nx, y: ny });
} }
}); });
} }
@ -431,8 +431,8 @@ editor_mappanel_wrapper = function (editor) {
else if (e.detail) else if (e.detail)
wheel(Math.sign(e.detail)); wheel(Math.sign(e.detail));
} }
catch (ee) { catch (e) {
console.log(ee); console.error(e);
} }
return false; return false;
} }
@ -532,7 +532,7 @@ editor_mappanel_wrapper = function (editor) {
* 隐藏右键菜单 * 隐藏右键菜单
*/ */
editor.uifunctions.hideMidMenu = function () { editor.uifunctions.hideMidMenu = function () {
editor.uivalues.lastMoveE={buttons:0,clientX:0,clientY:0}; editor.uivalues.lastMoveE = { buttons: 0, clientX: 0, clientY: 0 };
editor.dom.midMenu.style = 'display:none'; editor.dom.midMenu.style = 'display:none';
} }
@ -575,8 +575,8 @@ editor_mappanel_wrapper = function (editor) {
editor.uifunctions._extraEvent_changeFloor = function () { editor.uifunctions._extraEvent_changeFloor = function () {
var changeFloor = editor.currentFloorData.changeFloor[editor.pos.x + "," + editor.pos.y]; var changeFloor = editor.currentFloorData.changeFloor[editor.pos.x + "," + editor.pos.y];
if (!changeFloor) return false; if (!changeFloor) return false;
core.status.hero.loc = {x: editor.pos.x, y: editor.pos.y, direction: "up"}; core.status.hero.loc = { x: editor.pos.x, y: editor.pos.y, direction: "up" };
var targetLoc = changeFloor.loc ? {x: changeFloor.loc[0], y: changeFloor.loc[1]} : null; var targetLoc = changeFloor.loc ? { x: changeFloor.loc[0], y: changeFloor.loc[1] } : null;
var info = core.events._changeFloor_getInfo(changeFloor.floorId, changeFloor.stair, targetLoc); var info = core.events._changeFloor_getInfo(changeFloor.floorId, changeFloor.stair, targetLoc);
editor_mode.onmode('nextChange'); editor_mode.onmode('nextChange');
editor_mode.onmode('floor'); editor_mode.onmode('floor');
@ -629,7 +629,7 @@ editor_mappanel_wrapper = function (editor) {
*/ */
editor.uifunctions._extraEvent_bindSpecialDoor = function (thisevent) { editor.uifunctions._extraEvent_bindSpecialDoor = function (thisevent) {
if (thisevent.id != 'specialDoor') return false; if (thisevent.id != 'specialDoor') return false;
var number = parseInt(prompt("请输入该机关门的怪物数量", "0"))|| 0; var number = parseInt(prompt("请输入该机关门的怪物数量", "0")) || 0;
if (number <= 0) return true; if (number <= 0) return true;
editor.uivalues.bindSpecialDoor.n = number; editor.uivalues.bindSpecialDoor.n = number;
editor.uivalues.bindSpecialDoor.loc = editor.pos.x + ',' + editor.pos.y; editor.uivalues.bindSpecialDoor.loc = editor.pos.x + ',' + editor.pos.y;
@ -662,15 +662,15 @@ editor_mappanel_wrapper = function (editor) {
"delayExecute": false, "delayExecute": false,
"multiExecute": false, "multiExecute": false,
"data": [ "data": [
{"type": "openDoor"}, { "type": "openDoor" },
{"type": "setValue", "name": doorFlag, "operator": "=", "value": "null"}, { "type": "setValue", "name": doorFlag, "operator": "=", "value": "null" },
] ]
} }
}; };
bindSpecialDoor.enemys.forEach(function (loc) { bindSpecialDoor.enemys.forEach(function (loc) {
if (!editor.currentFloorData.afterBattle[loc]) if (!editor.currentFloorData.afterBattle[loc])
editor.currentFloorData.afterBattle[loc] = []; editor.currentFloorData.afterBattle[loc] = [];
editor.currentFloorData.afterBattle[loc].push({"type": "setValue", "name": doorFlag, "operator": "+=", "value": "1"}); editor.currentFloorData.afterBattle[loc].push({ "type": "setValue", "name": doorFlag, "operator": "+=", "value": "1" });
}); });
editor.file.saveFloorFile(function (err) { editor.file.saveFloorFile(function (err) {
if (err) { if (err) {
@ -841,13 +841,13 @@ editor_mappanel_wrapper = function (editor) {
editor.layerMod = layer; editor.layerMod = layer;
var canvas = ['ev', 'ev2'].concat(editor.dom.canvas); var canvas = ['ev', 'ev2'].concat(editor.dom.canvas);
canvas.forEach(function (one) { canvas.forEach(function (one) {
editor.dom[one+'c'].style.opacity = 1; editor.dom[one + 'c'].style.opacity = 1;
}); });
if (layer != 'map') { if (layer != 'map') {
canvas.filter(function (one) { canvas.filter(function (one) {
return one + 'map' != editor.layerMod return one + 'map' != editor.layerMod
}).forEach(function (one) { }).forEach(function (one) {
editor.dom[one+'c'].style.opacity = 0.3; editor.dom[one + 'c'].style.opacity = 0.3;
}); });
} }
} }
@ -951,12 +951,12 @@ editor_mappanel_wrapper = function (editor) {
}); });
} }
editor.uifunctions.highlightSaveFloorButton=function(){ editor.uifunctions.highlightSaveFloorButton = function () {
var saveFloor = document.getElementById('saveFloor'); var saveFloor = document.getElementById('saveFloor');
saveFloor.classList.add('highlight'); saveFloor.classList.add('highlight');
} }
editor.uifunctions.unhighlightSaveFloorButton=function(){ editor.uifunctions.unhighlightSaveFloorButton = function () {
var saveFloor = document.getElementById('saveFloor'); var saveFloor = document.getElementById('saveFloor');
saveFloor.classList.remove('highlight'); saveFloor.classList.remove('highlight');
} }
@ -982,7 +982,7 @@ editor_mappanel_wrapper = function (editor) {
openDoc.onclick = function () { openDoc.onclick = function () {
if (editor.isMobile) { if (editor.isMobile) {
if (!confirm('你确定要打开帮助文档吗?')) return; if (!confirm('你确定要打开帮助文档吗?')) return;
window.location='/_docs/'; window.location = '/_docs/';
} else { } else {
window.open('/_docs/', '_blank'); window.open('/_docs/', '_blank');
} }
@ -994,7 +994,7 @@ editor_mappanel_wrapper = function (editor) {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
e.stopPropagation(); e.stopPropagation();
if (editor.isMobile) return false; if (editor.isMobile) return false;
editor.uivalues.tileSize = [1,1]; editor.uivalues.tileSize = [1, 1];
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
@ -1011,7 +1011,7 @@ editor_mappanel_wrapper = function (editor) {
if (e.button == 2) { if (e.button == 2) {
lastUsed[index].istop = lastUsed[index].istop ? 0 : 1; lastUsed[index].istop = lastUsed[index].istop ? 0 : 1;
printf("已"+(lastUsed[index].istop ? '置顶' : '取消置顶')+"该图块"); printf("已" + (lastUsed[index].istop ? '置顶' : '取消置顶') + "该图块");
editor.config.set('lastUsed', editor.uivalues.lastUsed); editor.config.set('lastUsed', editor.uivalues.lastUsed);
editor.updateLastUsedMap(); editor.updateLastUsedMap();
return false; return false;
@ -1031,7 +1031,7 @@ editor_mappanel_wrapper = function (editor) {
editor.uivalues.lastUsed = []; editor.uivalues.lastUsed = [];
editor.config.set('lastUsed', []); editor.config.set('lastUsed', []);
editor.updateLastUsedMap(); editor.updateLastUsedMap();
editor.dom.lastUsedDiv.scroll(0,0); editor.dom.lastUsedDiv.scroll(0, 0);
} }
} }
@ -1039,7 +1039,7 @@ editor_mappanel_wrapper = function (editor) {
editor.constructor.prototype.copyFromPos = function (pos) { editor.constructor.prototype.copyFromPos = function (pos) {
editor.uivalues.tileSize = [1,1]; editor.uivalues.tileSize = [1, 1];
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos; pos = pos || editor.pos;
var x0 = pos.x, y0 = pos.y, x1 = pos.x1, y1 = pos.y1; var x0 = pos.x, y0 = pos.y, x1 = pos.x1, y1 = pos.y1;
@ -1047,36 +1047,36 @@ editor_mappanel_wrapper = function (editor) {
if (y1 == null) y1 = y0; if (y1 == null) y1 = y0;
if (x0 > x1) { x0 ^= x1; x1 ^= x0; x0 ^= x1; }//swap if (x0 > x1) { x0 ^= x1; x1 ^= x0; x0 ^= x1; }//swap
if (y0 > y1) { y0 ^= y1; y1 ^= y0; y0 ^= y1; }//swap if (y0 > y1) { y0 ^= y1; y1 ^= y0; y0 ^= y1; }//swap
var result = {w: x1 - x0 + 1, h: y1 - y0 + 1, layer: editor.layerMod, data: []}; var result = { w: x1 - x0 + 1, h: y1 - y0 + 1, layer: editor.layerMod, data: [] };
for (var i = x0; i <= x1; ++i) { for (var i = x0; i <= x1; ++i) {
for (var j = y0; j<= y1; ++j) { for (var j = y0; j <= y1; ++j) {
var map = core.clone(editor[editor.layerMod][j][i]); var map = core.clone(editor[editor.layerMod][j][i]);
var events = {}; var events = {};
fields.forEach(function(v){ fields.forEach(function (v) {
events[v] = core.clone(editor.currentFloorData[v][i+','+j]); events[v] = core.clone(editor.currentFloorData[v][i + ',' + j]);
}) })
result.data.push({map: map, events: events}); result.data.push({ map: map, events: events });
} }
} }
return result; return result;
} }
editor.constructor.prototype.pasteToPos = function (info, pos) { editor.constructor.prototype.pasteToPos = function (info, pos) {
editor.uivalues.tileSize = [1,1]; editor.uivalues.tileSize = [1, 1];
if (info == null) return; if (info == null) return;
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data); var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos; pos = pos || editor.pos;
var w = info.w || 1, h = info.h || 1, layer = info.layer || 'map'; var w = info.w || 1, h = info.h || 1, layer = info.layer || 'map';
var data = core.clone(info.data || []); var data = core.clone(info.data || []);
for (var i = pos.x; i < pos.x+w; ++i) { for (var i = pos.x; i < pos.x + w; ++i) {
for (var j = pos.y; j < pos.y+h; ++j) { for (var j = pos.y; j < pos.y + h; ++j) {
var one = data.shift(); var one = data.shift();
if (j >= editor[editor.layerMod].length || i >= editor[editor.layerMod][0].length) continue; if (j >= editor[editor.layerMod].length || i >= editor[editor.layerMod][0].length) continue;
editor[editor.layerMod][j][i] = core.clone(one.map); editor[editor.layerMod][j][i] = core.clone(one.map);
if (layer == 'map' && editor.layerMod == 'map') { if (layer == 'map' && editor.layerMod == 'map') {
fields.forEach(function(v){ fields.forEach(function (v) {
if (one.events[v] == null) delete editor.currentFloorData[v][i+","+j]; if (one.events[v] == null) delete editor.currentFloorData[v][i + "," + j];
else editor.currentFloorData[v][i+","+j] = core.clone(one.events[v]); else editor.currentFloorData[v][i + "," + j] = core.clone(one.events[v]);
}); });
} }
} }
@ -1084,26 +1084,26 @@ editor_mappanel_wrapper = function (editor) {
} }
editor.constructor.prototype.movePos = function (startPos, endPos, callback) { editor.constructor.prototype.movePos = function (startPos, endPos, callback) {
editor.uivalues.tileSize = [1,1]; editor.uivalues.tileSize = [1, 1];
if (!startPos || !endPos) return; if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return; if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var copyed = editor.copyFromPos(startPos); var copyed = editor.copyFromPos(startPos);
editor.pasteToPos({w: 1, h: 1, layer: 'map', data: [{map:0, events: {}}]}, startPos); editor.pasteToPos({ w: 1, h: 1, layer: 'map', data: [{ map: 0, events: {} }] }, startPos);
editor.pasteToPos(copyed, endPos); editor.pasteToPos(copyed, endPos);
editor.updateMap(); editor.updateMap();
editor.file.saveFloorFile(function (err) { editor.file.saveFloorFile(function (err) {
if (err) { if (err) {
printe(err); printe(err);
throw(err) throw (err)
} }
;printf('移动事件成功'); ; printf('移动事件成功');
editor.drawPosSelection(); editor.drawPosSelection();
if (callback) callback(); if (callback) callback();
}); });
} }
editor.constructor.prototype.exchangePos = function (startPos, endPos, callback) { editor.constructor.prototype.exchangePos = function (startPos, endPos, callback) {
editor.uivalues.tileSize = [1,1]; editor.uivalues.tileSize = [1, 1];
if (!startPos || !endPos) return; if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return; if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var startInfo = editor.copyFromPos(startPos); var startInfo = editor.copyFromPos(startPos);
@ -1114,9 +1114,9 @@ editor_mappanel_wrapper = function (editor) {
editor.file.saveFloorFile(function (err) { editor.file.saveFloorFile(function (err) {
if (err) { if (err) {
printe(err); printe(err);
throw(err) throw (err)
} }
;printf('交换事件成功'); ; printf('交换事件成功');
editor.drawPosSelection(); editor.drawPosSelection();
if (callback) callback(); if (callback) callback();
}); });
@ -1155,8 +1155,8 @@ editor_mappanel_wrapper = function (editor) {
if (clearPos) if (clearPos)
editor[editor.layerMod][j][i] = 0; editor[editor.layerMod][j][i] = 0;
if (editor.layerMod == 'map') { if (editor.layerMod == 'map') {
fields.forEach(function(v){ fields.forEach(function (v) {
delete editor.currentFloorData[v][i+","+j]; delete editor.currentFloorData[v][i + "," + j];
}); });
} }
} }
@ -1165,9 +1165,9 @@ editor_mappanel_wrapper = function (editor) {
editor.file.saveFloorFile(function (err) { editor.file.saveFloorFile(function (err) {
if (err) { if (err) {
printe(err); printe(err);
throw(err) throw (err)
} }
;printf(clearPos?'清空该点和事件成功':'只清空该点事件成功'); ; printf(clearPos ? '清空该点和事件成功' : '只清空该点事件成功');
editor.drawPosSelection(); editor.drawPosSelection();
if (callback) callback(); if (callback) callback();
}); });

View File

@ -41,7 +41,7 @@ editor_uievent_wrapper = function (editor) {
// 绘制UI // 绘制UI
var background = uievent.elements.select.value; var background = uievent.elements.select.value;
if (background == 'thumbnail') { if (background == 'thumbnail') {
core.drawThumbnail(editor.currentFloorId, null, {ctx: 'uievent'}); core.drawThumbnail(editor.currentFloorId, null, { ctx: 'uievent' });
} }
else { else {
core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background); core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background);
@ -61,7 +61,7 @@ editor_uievent_wrapper = function (editor) {
else if (type == "choices") { else if (type == "choices") {
for (var i = 0; i < data.choices.length; i++) { for (var i = 0; i < data.choices.length; i++) {
if (typeof data.choices[i] === 'string') if (typeof data.choices[i] === 'string')
data.choices[i] = {"text": data.choices[i]}; data.choices[i] = { "text": data.choices[i] };
data.choices[i].text = core.replaceText(data.choices[i].text); data.choices[i].text = core.replaceText(data.choices[i].text);
} }
core.saveCanvas('uievent'); core.saveCanvas('uievent');
@ -127,8 +127,8 @@ editor_uievent_wrapper = function (editor) {
uievent.close(); uievent.close();
if (callback) { if (callback) {
if (multipoints.length > 0) { if (multipoints.length > 0) {
callback(floorId, multipoints.map(function (one) { return one.split(',')[0]}).join(','), callback(floorId, multipoints.map(function (one) { return one.split(',')[0] }).join(','),
multipoints.map(function (one) { return one.split(',')[1]}).join(',')); multipoints.map(function (one) { return one.split(',')[1] }).join(','));
} else { } else {
callback(floorId, x, y); callback(floorId, x, y);
} }
@ -186,7 +186,7 @@ editor_uievent_wrapper = function (editor) {
for (var i = 0; i < uievent.values.multipoints.length; ++i) { for (var i = 0; i < uievent.values.multipoints.length; ++i) {
var xy = uievent.values.multipoints[i].split(","), x = parseInt(xy[0]), y = parseInt(xy[1]); var xy = uievent.values.multipoints[i].split(","), x = parseInt(xy[0]), y = parseInt(xy[1]);
core.fillBoldText('uievent', i + 1, core.fillBoldText('uievent', i + 1,
32 * (x - uievent.values.left) + 28 , 32 * (y - uievent.values.top) + 26, '#FF7F00', null, '14px Verdana'); 32 * (x - uievent.values.left) + 28, 32 * (y - uievent.values.top) + 26, '#FF7F00', null, '14px Verdana');
} }
core.setTextAlign('uievent', 'left'); core.setTextAlign('uievent', 'left');
} }
@ -235,10 +235,10 @@ editor_uievent_wrapper = function (editor) {
var x = uievent.values.left + Math.floor(e.offsetX / uievent.values.size); var x = uievent.values.left + Math.floor(e.offsetX / uievent.values.size);
var y = uievent.values.top + Math.floor(e.offsetY / uievent.values.size); var y = uievent.values.top + Math.floor(e.offsetY / uievent.values.size);
uievent.values.multipoints = uievent.values.multipoints || []; uievent.values.multipoints = uievent.values.multipoints || [];
if (uievent.values.multipoints.indexOf(x+","+y) >= 0) { if (uievent.values.multipoints.indexOf(x + "," + y) >= 0) {
uievent.values.multipoints = uievent.values.multipoints.filter(function (o) { return o != x+","+y;}) uievent.values.multipoints = uievent.values.multipoints.filter(function (o) { return o != x + "," + y; })
} else { } else {
uievent.values.multipoints.push(x+","+y); uievent.values.multipoints.push(x + "," + y);
} }
uievent.values.x = x; uievent.values.x = x;
uievent.values.y = y; uievent.values.y = y;
@ -272,7 +272,7 @@ editor_uievent_wrapper = function (editor) {
} }
if (ii == 5) { if (ii == 5) {
node.onclick = function () { node.onclick = function () {
alert(core.copy(uievent.values.floorId) ? ('楼层ID '+uievent.values.floorId+' 已成功复制到剪切板') : '无法复制楼层ID'); alert(core.copy(uievent.values.floorId) ? ('楼层ID ' + uievent.values.floorId + ' 已成功复制到剪切板') : '无法复制楼层ID');
} }
} }
(function (x, y) { (function (x, y) {
@ -311,7 +311,7 @@ editor_uievent_wrapper = function (editor) {
index += Math.sign(e.wheelDelta); index += Math.sign(e.wheelDelta);
else if (e.detail) else if (e.detail)
index += Math.sign(e.detail); index += Math.sign(e.detail);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
index = core.clamp(index, 0, core.floorIds.length - 1); index = core.clamp(index, 0, core.floorIds.length - 1);
uievent.values.multipoints = []; uievent.values.multipoints = [];
uievent.setPoint(core.floorIds[index]); uievent.setPoint(core.floorIds[index]);
@ -492,12 +492,12 @@ editor_uievent_wrapper = function (editor) {
var checked = one == uievent.values.floorId; var checked = one == uievent.values.floorId;
var floor = core.floors[one]; var floor = core.floors[one];
if (floor == null) return; if (floor == null) return;
if (!one.includes(value) && !(floor.title||"").includes(value) && !(floor.name||"").includes(value)) return; if (!one.includes(value) && !(floor.title || "").includes(value) && !(floor.name || "").includes(value)) return;
html += "<input type='radio' name='uievent_selectFloor' onchange='editor.uievent.values.floorId=\""+one+"\"'" + (checked ? ' checked' : '') + ">"; html += "<input type='radio' name='uievent_selectFloor' onchange='editor.uievent.values.floorId=\"" + one + "\"'" + (checked ? ' checked' : '') + ">";
html += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\""+one+"\"' style='cursor: default'>" html += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\"" + one + "\"' style='cursor: default'>"
+ one + '' + floor.title + '' + "</span>"; + one + '' + floor.title + '' + "</span>";
html += "<button onclick='editor.uievent._selectFloor_preview(this)' style='margin-left: 10px'>预览</button>"; html += "<button onclick='editor.uievent._selectFloor_preview(this)' style='margin-left: 10px'>预览</button>";
html += "<span style='display:none;' key='"+one+"'></span>"; html += "<span style='display:none;' key='" + one + "'></span>";
html += '<br/>'; html += '<br/>';
}); });
floorList.innerHTML = html; floorList.innerHTML = html;
@ -522,7 +522,7 @@ editor_uievent_wrapper = function (editor) {
} }
span.appendChild(uievent.values.dom); span.appendChild(uievent.values.dom);
core.clearMap(uievent.values.ctx); core.clearMap(uievent.values.ctx);
core.drawThumbnail(floorId, null, {ctx: uievent.values.ctx, all: true}); core.drawThumbnail(floorId, null, { ctx: uievent.values.ctx, all: true });
} else { } else {
button.innerText = '预览'; button.innerText = '预览';
span.style.display = 'none'; span.style.display = 'none';
@ -545,7 +545,7 @@ editor_uievent_wrapper = function (editor) {
return; return;
} }
value = value || []; value = value || [];
data = (transform ? data.map(transform) : data).filter(function (one) {return one;}).sort(); data = (transform ? data.map(transform) : data).filter(function (one) { return one; }).sort();
var data2 = Object.keys(appendedImages); var data2 = Object.keys(appendedImages);
data2 = (transform ? data2.map(transform) : data2).filter(function (one) { data2 = (transform ? data2.map(transform) : data2).filter(function (one) {
return one && data.indexOf(one) < 0; return one && data.indexOf(one) < 0;
@ -567,7 +567,7 @@ editor_uievent_wrapper = function (editor) {
uievent.elements.yes.onclick = function () { uievent.elements.yes.onclick = function () {
var list = Array.from(document.getElementsByClassName('materialCheckbox')).filter(function (one) { var list = Array.from(document.getElementsByClassName('materialCheckbox')).filter(function (one) {
return one.checked; return one.checked;
}).map(function (one) {return one.getAttribute('key'); }); }).map(function (one) { return one.getAttribute('key'); });
uievent.close(); uievent.close();
if (callback) callback(list); if (callback) callback(list);
} }
@ -576,44 +576,44 @@ editor_uievent_wrapper = function (editor) {
// 显示每一项内容 // 显示每一项内容
var html = "<p style='margin-left: 10px; line-height: 25px'>"; var html = "<p style='margin-left: 10px; line-height: 25px'>";
html += "<button onclick='editor.uievent._selectAllMaterial(true)'>全选</button>"+ html += "<button onclick='editor.uievent._selectAllMaterial(true)'>全选</button>" +
"<button style='margin-left: 10px' onclick='editor.uievent._selectAllMaterial(false)'>全不选</button><br/>"; "<button style='margin-left: 10px' onclick='editor.uievent._selectAllMaterial(false)'>全不选</button><br/>";
if (_isTileset) { if (_isTileset) {
html += "<b style='margin-top: 5px;'>警告!额外素材一旦注册成功将不可删除,否则可能会导致素材错位风险!如果你不再想用某个额外素材," html += "<b style='margin-top: 5px;'>警告!额外素材一旦注册成功将不可删除,否则可能会导致素材错位风险!如果你不再想用某个额外素材,"
+"但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。</b><br/>" + "但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。</b><br/>"
} }
data.forEach(function (one) { data.forEach(function (one) {
var checked = value.indexOf(one) >= 0? 'checked' : ''; var checked = value.indexOf(one) >= 0 ? 'checked' : '';
var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : '' var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : ''
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`; html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
// 预览图片 // 预览图片
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) { if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) {
html += "<button onclick='editor.uievent._previewMaterialImage(this)' style='margin-left: 10px'>预览</button>"; html += "<button onclick='editor.uievent._previewMaterialImage(this)' style='margin-left: 10px'>预览</button>";
html += '<br style="display:none"/><img key="'+directory+one+'" style="display:none; max-width: 100%"/>'; html += '<br style="display:none"/><img key="' + directory + one + '" style="display:none; max-width: 100%"/>';
} }
// 试听音频 // 试听音频
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) { if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) {
html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>播放</button>" html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>播放</button>"
html += "<small> 音调:<input value='100' style='width:28px' onchange='editor.uievent._previewMaterialAudio_onPitchChange(this)'></small>"; html += "<small> 音调:<input value='100' style='width:28px' onchange='editor.uievent._previewMaterialAudio_onPitchChange(this)'></small>";
html += `<small style='display:none; margin-left: 15px'>0:00 / 0:00</small><br style="display:none"/> html += `<small style='display:none; margin-left: 15px'>0:00 / 0:00</small><br style="display:none"/>
<audio preload="none" src="${directory+one}" ontimeupdate="editor.uievent._previewMaterialAudio_onTimeUpdate(this)"></audio> <audio preload="none" src="${directory + one}" ontimeupdate="editor.uievent._previewMaterialAudio_onTimeUpdate(this)"></audio>
<progress value="0" max="1" style="display:none; width:100%" onclick="editor.uievent._previewMaterialAudio_seek(this, event)"></progress>`; <progress value="0" max="1" style="display:none; width:100%" onclick="editor.uievent._previewMaterialAudio_seek(this, event)"></progress>`;
} }
// 预览动画 // 预览动画
if (directory.indexOf('animates') >= 0) { if (directory.indexOf('animates') >= 0) {
html += "<button onclick='editor.uievent._previewMaterialAnimate(this)' style='margin-left: 10px'>预览</button>"; html += "<button onclick='editor.uievent._previewMaterialAnimate(this)' style='margin-left: 10px'>预览</button>";
html += "<span style='display:none; margin-left: 10px' key='"+directory+one+".animate'></span>"; html += "<span style='display:none; margin-left: 10px' key='" + directory + one + ".animate'></span>";
} }
html += '<br/>'; html += '<br/>';
}); });
data2.forEach(function (one) { data2.forEach(function (one) {
var checked = value.indexOf(one) >= 0? 'checked' : ''; var checked = value.indexOf(one) >= 0 ? 'checked' : '';
var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : ''; var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : '';
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`; html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
// 预览图片 // 预览图片
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) { if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) {
html += "<button onclick='editor.uievent._previewMaterialImage2(this)' style='margin-left: 10px'>预览</button>"; html += "<button onclick='editor.uievent._previewMaterialImage2(this)' style='margin-left: 10px'>预览</button>";
html += '<br style="display:none" key="'+one+'"/><br/>'; html += '<br style="display:none" key="' + one + '"/><br/>';
} }
}) })
html += "</p>"; html += "</p>";
@ -670,7 +670,7 @@ editor_uievent_wrapper = function (editor) {
} else { } else {
button.innerText = '播放'; button.innerText = '播放';
br.style.display = 'none'; br.style.display = 'none';
progress.style.display='none'; progress.style.display = 'none';
span.style.display = 'none'; span.style.display = 'none';
audio.pause(); audio.pause();
} }
@ -683,7 +683,7 @@ editor_uievent_wrapper = function (editor) {
} }
uievent._previewMaterialAudio_onTimeUpdate = function (audio) { uievent._previewMaterialAudio_onTimeUpdate = function (audio) {
var _format = function (time) { return parseInt(time/60) + ":" + core.setTwoDigits(parseInt(time) % 60); } var _format = function (time) { return parseInt(time / 60) + ":" + core.setTwoDigits(parseInt(time) % 60); }
if (audio.duration > 0) { if (audio.duration > 0) {
audio.previousElementSibling.previousElementSibling.innerText = _format(audio.currentTime) + " / " + _format(audio.duration); audio.previousElementSibling.previousElementSibling.innerText = _format(audio.currentTime) + " / " + _format(audio.duration);
audio.nextElementSibling.setAttribute('value', audio.currentTime / audio.duration); audio.nextElementSibling.setAttribute('value', audio.currentTime / audio.duration);
@ -709,7 +709,7 @@ editor_uievent_wrapper = function (editor) {
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
canvas.width = canvas.height = core.__PIXELS__; canvas.width = canvas.height = core.__PIXELS__;
canvas.style.position = 'absolute'; canvas.style.position = 'absolute';
core.drawThumbnail(editor.currentFloorId, null, {ctx: canvas.getContext('2d')}); core.drawThumbnail(editor.currentFloorId, null, { ctx: canvas.getContext('2d') });
dom.appendChild(canvas); dom.appendChild(canvas);
var canvas2 = document.createElement('canvas'); var canvas2 = document.createElement('canvas');
canvas2.style.position = 'absolute'; canvas2.style.position = 'absolute';
@ -738,7 +738,7 @@ editor_uievent_wrapper = function (editor) {
var _previewMaterialAnimate_buildSounds = function (span, content) { var _previewMaterialAnimate_buildSounds = function (span, content) {
var sounds = content.se || {}; var sounds = content.se || {};
if (typeof sounds == 'string') sounds = {1: sounds}; if (typeof sounds == 'string') sounds = { 1: sounds };
var pitch = content.pitch || {}; var pitch = content.pitch || {};
span.appendChild(document.createElement('br')); span.appendChild(document.createElement('br'));
@ -761,14 +761,14 @@ editor_uievent_wrapper = function (editor) {
var html = ""; var html = "";
html += "第 <select>"; html += "第 <select>";
for (var i = 1; i <= frames; ++i) { for (var i = 1; i <= frames; ++i) {
html += "<option value="+i; html += "<option value=" + i;
if (index == i) html += " selected"; if (index == i) html += " selected";
html += ">"+i+"</option>"; html += ">" + i + "</option>";
} }
html += "</select> 帧:"; html += "</select> 帧:";
html += '<input type="text" class="_audio" data-list="'+audios+'" data-minchars="1" data-autofirst="true" style="width: 110px" value="'+se+'"/>'; html += '<input type="text" class="_audio" data-list="' + audios + '" data-minchars="1" data-autofirst="true" style="width: 110px" value="' + se + '"/>';
html += '<button onclick="editor.uievent._previewMaterialAnimate_previewSound(this)" style="margin-left: 10px">试听</button>'; html += '<button onclick="editor.uievent._previewMaterialAnimate_previewSound(this)" style="margin-left: 10px">试听</button>';
html += "<small> 音调:<input value='"+(pitch||100)+"' style='width:28px'></small>"; html += "<small> 音调:<input value='" + (pitch || 100) + "' style='width:28px'></small>";
html += '<button onclick="editor.uievent._previewMaterialAnimate_deleteSound(this)" style="margin-left: 10px">删除</button>'; html += '<button onclick="editor.uievent._previewMaterialAnimate_deleteSound(this)" style="margin-left: 10px">删除</button>';
html += '<br/>'; html += '<br/>';
return html; return html;
@ -798,7 +798,7 @@ editor_uievent_wrapper = function (editor) {
} else { } else {
fs.readFile(filename, 'utf-8', function (e, d) { fs.readFile(filename, 'utf-8', function (e, d) {
if (e) { if (e) {
alert('无法打开动画文件!'+e); return; alert('无法打开动画文件!' + e); return;
} }
uievent.values.animates[filename] = core.loader._loadAnimate(d); uievent.values.animates[filename] = core.loader._loadAnimate(d);
if (uievent.values.animates[filename]) { if (uievent.values.animates[filename]) {
@ -856,11 +856,11 @@ editor_uievent_wrapper = function (editor) {
} }
} }
uievent.values.animates[filename].se = se; uievent.values.animates[filename].se = se;
uievent.values.animates[filename+':raw'].se = se; uievent.values.animates[filename + ':raw'].se = se;
uievent.values.animates[filename].pitch = pitch; uievent.values.animates[filename].pitch = pitch;
uievent.values.animates[filename+':raw'].pitch = pitch; uievent.values.animates[filename + ':raw'].pitch = pitch;
fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename+':raw']), 'utf-8', function (e, d) { fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename + ':raw']), 'utf-8', function (e, d) {
if (e) alert('无法修改音效文件!'+e); if (e) alert('无法修改音效文件!' + e);
else { else {
alert('动画音效修改成功!别忘了在全塔属性中注册音效哦!'); alert('动画音效修改成功!别忘了在全塔属性中注册音效哦!');
} }
@ -900,11 +900,11 @@ editor_uievent_wrapper = function (editor) {
if (callback) callback(list); if (callback) callback(list);
} }
var keys=Array.from(comments.key) var keys = Array.from(comments.key)
var prefixStrings=Array.from(comments.prefix) var prefixStrings = Array.from(comments.prefix)
for (var index = 0; index < value.length; index++) { for (var index = 0; index < value.length; index++) {
if (keys.indexOf(value[index])==-1) { if (keys.indexOf(value[index]) == -1) {
prefixStrings.push(value[index]+': ') prefixStrings.push(value[index] + ': ')
keys.push(value[index]) keys.push(value[index])
} }
} }
@ -915,7 +915,7 @@ editor_uievent_wrapper = function (editor) {
if (index % 3 == 0) { if (index % 3 == 0) {
table += '<tr>'; table += '<tr>';
} }
table += `<td class='popCheckboxItem'>${prefixStrings[index]}<input type="checkbox" _type="${typeof one}" key="${one}" class="uieventCheckboxSet" ${value.indexOf(one) >= 0? 'checked' : ''}/></td>`; table += `<td class='popCheckboxItem'>${prefixStrings[index]}<input type="checkbox" _type="${typeof one}" key="${one}" class="uieventCheckboxSet" ${value.indexOf(one) >= 0 ? 'checked' : ''}/></td>`;
if (index % 3 == 2) { if (index % 3 == 2) {
table += '</tr>'; table += '</tr>';
} }
@ -923,7 +923,7 @@ editor_uievent_wrapper = function (editor) {
if (keys.length % 3 != 0) table += '</tr>'; if (keys.length % 3 != 0) table += '</tr>';
table += '</table>'; table += '</table>';
uievent.elements.extraBody.innerHTML = "<p>"+table+"</p>"; uievent.elements.extraBody.innerHTML = "<p>" + table + "</p>";
} }
uievent.previewEditorMulti = function (mode, code) { uievent.previewEditorMulti = function (mode, code) {
@ -974,7 +974,7 @@ editor_uievent_wrapper = function (editor) {
html += "魔力:<input value='0'> 上限:<input value='-1'> 金币:<input value='0'> 经验:<input value='0'> 等级:<input value='1'> "; html += "魔力:<input value='0'> 上限:<input value='-1'> 金币:<input value='0'> 经验:<input value='0'> 等级:<input value='1'> ";
html += "<br/>当前道具ID以逗号分隔)<br/><textarea style='width:300px;height:40px'>yellowKey,yellowKey,blueKey</textarea>"; html += "<br/>当前道具ID以逗号分隔)<br/><textarea style='width:300px;height:40px'>yellowKey,yellowKey,blueKey</textarea>";
html += "<br/>当前装备ID以逗号分隔)<br/><textarea style='width:300px;height:40px'>sword1,sheild1</textarea>"; html += "<br/>当前装备ID以逗号分隔)<br/><textarea style='width:300px;height:40px'>sword1,sheild1</textarea>";
html += "<br/>当前变量值JSON格式<br/><textarea style='width:300px;height:80px'>"+JSON.stringify(flags)+"</textarea>"; html += "<br/>当前变量值JSON格式<br/><textarea style='width:300px;height:80px'>" + JSON.stringify(flags) + "</textarea>";
html += "</span></p>" html += "</span></p>"
uievent.elements.extraBody.innerHTML = html; uievent.elements.extraBody.innerHTML = html;
@ -1021,7 +1021,7 @@ editor_uievent_wrapper = function (editor) {
if (!core.material.items[itemId]) return; if (!core.material.items[itemId]) return;
var itemCls = core.material.items[itemId].cls; var itemCls = core.material.items[itemId].cls;
if (itemCls == 'items') return; if (itemCls == 'items') return;
core.status.hero.items[itemCls][itemId] = (core.status.hero.items[itemCls][itemId]||0) + 1; core.status.hero.items[itemCls][itemId] = (core.status.hero.items[itemCls][itemId] || 0) + 1;
}); });
core.status.hero.equipment = values[12].split(','); core.status.hero.equipment = values[12].split(',');
try { try {
@ -1029,13 +1029,13 @@ editor_uievent_wrapper = function (editor) {
for (var flag in flags) { for (var flag in flags) {
core.status.hero.flags[flag] = flags[flag]; core.status.hero.flags[flag] = flags[flag];
} }
} catch (e) {} } catch (e) { }
var ctx = canvas2.getContext('2d'); var ctx = canvas2.getContext('2d');
if (core.domStyle.isVertical) { if (core.domStyle.isVertical) {
canvas.width = canvas2.width = core.__PIXELS__; canvas.width = canvas2.width = core.__PIXELS__;
canvas.height = canvas2.height = 32*(core.values.statusCanvasRowsOnMobile||3)+9; canvas.height = canvas2.height = 32 * (core.values.statusCanvasRowsOnMobile || 3) + 9;
} else if (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.flags.extendToolbar) { } else if (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.flags.extendToolbar) {
canvas.width = canvas2.width = Math.round(core.__PIXELS__ * 0.31); canvas.width = canvas2.width = Math.round(core.__PIXELS__ * 0.31);
canvas.height = canvas2.height = core.__PIXELS__ + 3 + 38; canvas.height = canvas2.height = core.__PIXELS__ + 3 + 38;
@ -1064,5 +1064,5 @@ editor_uievent_wrapper = function (editor) {
window.flags = core.status.hero.flags; window.flags = core.status.hero.flags;
} }
editor.constructor.prototype.uievent=uievent; editor.constructor.prototype.uievent = uievent;
} }

View File

@ -7,7 +7,7 @@ actions.js用户交互的事件的处理
"use strict"; "use strict";
function actions() { function actions () {
this._init(); this._init();
this.SIZE = core.__SIZE__; this.SIZE = core.__SIZE__;
this.HSIZE = core.__HALF_SIZE__; this.HSIZE = core.__HALF_SIZE__;
@ -79,7 +79,7 @@ actions.prototype.registerAction = function (action, name, func, priority) {
} }
this.unregisterAction(action, name); this.unregisterAction(action, name);
this.actions[action].push( this.actions[action].push(
{"action": action, "name": name, "func": func, "priority": priority} { "action": action, "name": name, "func": func, "priority": priority }
); );
this.actions[action] = this.actions[action].sort(function (a, b) { this.actions[action] = this.actions[action].sort(function (a, b) {
return b.priority - a.priority; return b.priority - a.priority;
@ -106,8 +106,8 @@ actions.prototype.doRegisteredAction = function (action) {
return true; return true;
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in actions["+actions[i].name+"]."); main.log("ERROR in actions[" + actions[i].name + "].");
} }
} }
return false; return false;
@ -115,7 +115,7 @@ actions.prototype.doRegisteredAction = function (action) {
actions.prototype._checkReplaying = function () { actions.prototype._checkReplaying = function () {
if (core.isReplaying() && if (core.isReplaying() &&
['save','book','book-detail','viewMaps','toolbox','equipbox','text'].indexOf(core.status.event.id)<0) ['save', 'book', 'book-detail', 'viewMaps', 'toolbox', 'equipbox', 'text'].indexOf(core.status.event.id) < 0)
return true; return true;
return false; return false;
} }
@ -160,7 +160,7 @@ actions.prototype.onkeyDown = function (e) {
actions.prototype._sys_onkeyDown = function (e) { actions.prototype._sys_onkeyDown = function (e) {
core.status.holdingKeys = core.status.holdingKeys || [] core.status.holdingKeys = core.status.holdingKeys || []
var isArrow = {37: true, 38: true, 39: true, 40: true}[e.keyCode] var isArrow = { 37: true, 38: true, 39: true, 40: true }[e.keyCode]
if (isArrow && !core.status.lockControl) { if (isArrow && !core.status.lockControl) {
for (var ii = 0; ii < core.status.holdingKeys.length; ii++) { for (var ii = 0; ii < core.status.holdingKeys.length; ii++) {
if (core.status.holdingKeys[ii] === e.keyCode) { if (core.status.holdingKeys[ii] === e.keyCode) {
@ -220,7 +220,7 @@ actions.prototype._sys_onkeyUp_replay = function (e) {
} }
actions.prototype._sys_onkeyUp = function (e) { actions.prototype._sys_onkeyUp = function (e) {
var isArrow = {37: true, 38: true, 39: true, 40: true}[e.keyCode] var isArrow = { 37: true, 38: true, 39: true, 40: true }[e.keyCode]
if (isArrow && !core.status.lockControl) { if (isArrow && !core.status.lockControl) {
for (var ii = 0; ii < core.status.holdingKeys.length; ii++) { for (var ii = 0; ii < core.status.holdingKeys.length; ii++) {
if (core.status.holdingKeys[ii] === e.keyCode) { if (core.status.holdingKeys[ii] === e.keyCode) {
@ -571,10 +571,10 @@ actions.prototype._sys_ondown = function (x, y, px, py) {
if (core.status.lockControl) return false; if (core.status.lockControl) return false;
core.status.downTime = new Date(); core.status.downTime = new Date();
core.deleteCanvas('route'); core.deleteCanvas('route');
var pos = {'x': parseInt((px + core.bigmap.offsetX) / 32), 'y': parseInt((py + core.bigmap.offsetY) / 32)}; var pos = { 'x': parseInt((px + core.bigmap.offsetX) / 32), 'y': parseInt((py + core.bigmap.offsetY) / 32) };
core.status.stepPostfix = []; core.status.stepPostfix = [];
core.status.stepPostfix.push(pos); core.status.stepPostfix.push(pos);
core.fillRect('ui', pos.x*32+12-core.bigmap.offsetX,pos.y*32+12-core.bigmap.offsetY,8,8, '#bfbfbf'); core.fillRect('ui', pos.x * 32 + 12 - core.bigmap.offsetX, pos.y * 32 + 12 - core.bigmap.offsetY, 8, 8, '#bfbfbf');
clearTimeout(core.timeout.onDownTimeout); clearTimeout(core.timeout.onDownTimeout);
core.timeout.onDownTimeout = null; core.timeout.onDownTimeout = null;
@ -658,7 +658,7 @@ actions.prototype._sys_onmove = function (x, y, px, py) {
core.timeout.onDownTimeout = null; core.timeout.onDownTimeout = null;
if ((core.status.stepPostfix || []).length > 0) { if ((core.status.stepPostfix || []).length > 0) {
var pos = {'x': parseInt((px + core.bigmap.offsetX) / 32), 'y': parseInt((py + core.bigmap.offsetY) / 32)}; var pos = { 'x': parseInt((px + core.bigmap.offsetX) / 32), 'y': parseInt((py + core.bigmap.offsetY) / 32) };
var pos0 = core.status.stepPostfix[core.status.stepPostfix.length - 1]; var pos0 = core.status.stepPostfix[core.status.stepPostfix.length - 1];
var directionDistance = [pos.y - pos0.y, pos0.x - pos.x, pos0.y - pos.y, pos.x - pos0.x]; var directionDistance = [pos.y - pos0.y, pos0.x - pos.x, pos0.y - pos.y, pos.x - pos0.x];
var max = 0, index = 4; var max = 0, index = 4;
@ -668,12 +668,12 @@ actions.prototype._sys_onmove = function (x, y, px, py) {
max = directionDistance[ii]; max = directionDistance[ii];
} }
} }
pos = [{'x': 0, 'y': 1}, {'x': -1, 'y': 0}, {'x': 0, 'y': -1}, {'x': 1, 'y': 0}, false][index] pos = [{ 'x': 0, 'y': 1 }, { 'x': -1, 'y': 0 }, { 'x': 0, 'y': -1 }, { 'x': 1, 'y': 0 }, false][index]
if (pos) { if (pos) {
pos.x += pos0.x; pos.x += pos0.x;
pos.y += pos0.y; pos.y += pos0.y;
core.status.stepPostfix.push(pos); core.status.stepPostfix.push(pos);
core.fillRect('ui', pos.x*32+12-core.bigmap.offsetX,pos.y*32+12-core.bigmap.offsetY,8,8, '#bfbfbf'); core.fillRect('ui', pos.x * 32 + 12 - core.bigmap.offsetX, pos.y * 32 + 12 - core.bigmap.offsetY, 8, 8, '#bfbfbf');
} }
} }
return true; return true;
@ -703,7 +703,7 @@ actions.prototype._sys_onup = function (x, y, px, py) {
if ((core.status.stepPostfix || []).length == 0) return false; if ((core.status.stepPostfix || []).length == 0) return false;
var stepPostfix = []; var stepPostfix = [];
var direction = {'0': {'1': 'down', '-1': 'up'}, '-1': {'0': 'left'}, '1': {'0': 'right'}}; var direction = { '0': { '1': 'down', '-1': 'up' }, '-1': { '0': 'left' }, '1': { '0': 'right' } };
for (var ii = 1; ii < core.status.stepPostfix.length; ii++) { for (var ii = 1; ii < core.status.stepPostfix.length; ii++) {
var pos0 = core.status.stepPostfix[ii - 1]; var pos0 = core.status.stepPostfix[ii - 1];
var pos = core.status.stepPostfix[ii]; var pos = core.status.stepPostfix[ii];
@ -735,7 +735,7 @@ actions.prototype._sys_onup = function (x, y, px, py) {
////// 获得点击事件相对左上角的坐标 ////// ////// 获得点击事件相对左上角的坐标 //////
actions.prototype._getClickLoc = function (x, y) { actions.prototype._getClickLoc = function (x, y) {
var statusBar = {'x': 0, 'y': 0}; var statusBar = { 'x': 0, 'y': 0 };
var size = 32; var size = 32;
size = size * core.domStyle.scale; size = size * core.domStyle.scale;
@ -750,7 +750,7 @@ actions.prototype._getClickLoc = function (x, y) {
var left = core.dom.gameGroup.offsetLeft + statusBar.x; var left = core.dom.gameGroup.offsetLeft + statusBar.x;
var top = core.dom.gameGroup.offsetTop + statusBar.y; var top = core.dom.gameGroup.offsetTop + statusBar.y;
var loc = {'x': Math.max(x - left), 'y': Math.max(y - top, 0), 'size': size}; var loc = { 'x': Math.max(x - left), 'y': Math.max(y - top, 0), 'size': size };
return loc; return loc;
} }
@ -787,7 +787,7 @@ actions.prototype._sys_onmousewheel = function (direct) {
// 存读档 // 存读档
if (core.status.lockControl && (core.status.event.id == 'save' || core.status.event.id == 'load')) { if (core.status.lockControl && (core.status.event.id == 'save' || core.status.event.id == 'load')) {
var index = core.status.event.data.page*10+core.status.event.data.offset; var index = core.status.event.data.page * 10 + core.status.event.data.offset;
if (direct == 1) core.ui._drawSLPanel(index - 10); if (direct == 1) core.ui._drawSLPanel(index - 10);
if (direct == -1) core.ui._drawSLPanel(index + 10); if (direct == -1) core.ui._drawSLPanel(index + 10);
return; return;
@ -862,14 +862,14 @@ actions.prototype._sys_longClick_lockControl = function (x, y, px, py) {
} }
// 长按楼传器的箭头可以快速翻页 // 长按楼传器的箭头可以快速翻页
if (core.status.event.id == 'fly') { if (core.status.event.id == 'fly') {
if ((x == this.SIZE-2 || x == this.SIZE-3) && (y == this.HSIZE - 1 || y == this.HSIZE+3)) { if ((x == this.SIZE - 2 || x == this.SIZE - 3) && (y == this.HSIZE - 1 || y == this.HSIZE + 3)) {
this._clickFly(x, y); this._clickFly(x, y);
return true; return true;
} }
} }
// 长按SL上下页快速翻页 // 长按SL上下页快速翻页
if (["save","load","replayLoad","replayRemain","replaySince"].indexOf(core.status.event.id) >= 0) { if (["save", "load", "replayLoad", "replayRemain", "replaySince"].indexOf(core.status.event.id) >= 0) {
if ([this.HSIZE-2, this.HSIZE-3, this.HSIZE+2, this.HSIZE+3].indexOf(x) >= 0 && y == this.LAST) { if ([this.HSIZE - 2, this.HSIZE - 3, this.HSIZE + 2, this.HSIZE + 3].indexOf(x) >= 0 && y == this.LAST) {
this._clickSL(x, y); this._clickSL(x, y);
return true; return true;
} }
@ -1120,7 +1120,7 @@ actions.prototype._clickAction = function (x, y, px, py) {
} }
if (core.status.event.data.type == 'confirm') { if (core.status.event.data.type == 'confirm') {
if ((x == this.HSIZE-2 || x == this.HSIZE-1) && y == this.HSIZE+1) { if ((x == this.HSIZE - 2 || x == this.HSIZE - 1) && y == this.HSIZE + 1) {
clearTimeout(core.status.event.interval); clearTimeout(core.status.event.interval);
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
delete core.status.event.timeout; delete core.status.event.timeout;
@ -1129,7 +1129,7 @@ actions.prototype._clickAction = function (x, y, px, py) {
core.insertAction(core.status.event.ui.yes); core.insertAction(core.status.event.ui.yes);
core.doAction(); core.doAction();
} }
else if ((x == this.HSIZE+2 || x == this.HSIZE+1) && y == this.HSIZE+1) { else if ((x == this.HSIZE + 2 || x == this.HSIZE + 1) && y == this.HSIZE + 1) {
clearTimeout(core.status.event.interval); clearTimeout(core.status.event.interval);
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
delete core.status.event.timeout; delete core.status.event.timeout;
@ -1183,7 +1183,7 @@ actions.prototype._keyUpAction = function (keycode) {
} }
return; return;
} }
if (core.status.event.data.type == 'confirm'&& (keycode == 13 || keycode == 32 || keycode == 67)) { if (core.status.event.data.type == 'confirm' && (keycode == 13 || keycode == 32 || keycode == 67)) {
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0; var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
delete core.status.event.timeout; delete core.status.event.timeout;
core.setFlag('timeout', timeout); core.setFlag('timeout', timeout);
@ -1200,19 +1200,19 @@ actions.prototype._keyUpAction = function (keycode) {
actions.prototype._clickBook = function (x, y) { actions.prototype._clickBook = function (x, y) {
var pageinfo = core.ui._drawBook_pageinfo(); var pageinfo = core.ui._drawBook_pageinfo();
// 上一页 // 上一页
if ((x == this.HSIZE-2 || x == this.HSIZE-3) && y == this.LAST) { if ((x == this.HSIZE - 2 || x == this.HSIZE - 3) && y == this.LAST) {
core.playSound('光标移动'); core.playSound('光标移动');
core.ui.drawBook(core.status.event.data - pageinfo.per_page); core.ui.drawBook(core.status.event.data - pageinfo.per_page);
return; return;
} }
// 下一页 // 下一页
if ((x == this.HSIZE+2 || x == this.HSIZE+3) && y == this.LAST) { if ((x == this.HSIZE + 2 || x == this.HSIZE + 3) && y == this.LAST) {
core.playSound('光标移动'); core.playSound('光标移动');
core.ui.drawBook(core.status.event.data + pageinfo.per_page); core.ui.drawBook(core.status.event.data + pageinfo.per_page);
return; return;
} }
// 返回 // 返回
if (x >= this.LAST-2 && y == this.LAST) { if (x >= this.LAST - 2 && y == this.LAST) {
core.playSound('取消'); core.playSound('取消');
if (core.events.recoverEvents(core.status.event.interval)) { if (core.events.recoverEvents(core.status.event.interval)) {
return; return;
@ -1230,7 +1230,7 @@ actions.prototype._clickBook = function (x, y) {
var per_page = pageinfo.per_page, page = parseInt(data / per_page); var per_page = pageinfo.per_page, page = parseInt(data / per_page);
var u = this.LAST / per_page; var u = this.LAST / per_page;
for (var i = 0; i < per_page; ++i) { for (var i = 0; i < per_page; ++i) {
if (y >= u*i && y < u*(i+1)) { if (y >= u * i && y < u * (i + 1)) {
var index = per_page * page + i; var index = per_page * page + i;
core.ui.drawBook(index); core.ui.drawBook(index);
core.ui._drawBookDetail(index); core.ui._drawBookDetail(index);
@ -1286,12 +1286,12 @@ actions.prototype._clickBookDetail = function () {
////// 楼层传送器界面时的点击操作 ////// ////// 楼层传送器界面时的点击操作 //////
actions.prototype._clickFly = function (x, y) { actions.prototype._clickFly = function (x, y) {
if ((x == this.SIZE-2 || x == this.SIZE-3) && y == this.HSIZE+3) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(-1)); } if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE + 3) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(-1)); }
if ((x == this.SIZE-2 || x == this.SIZE-3) && y == this.HSIZE-1) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(1)); } if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE - 1) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(1)); }
if ((x == this.SIZE-2 || x == this.SIZE-3) && y == this.HSIZE+4) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(-10)); } if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE + 4) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(-10)); }
if ((x == this.SIZE-2 || x == this.SIZE-3) && y == this.HSIZE-2) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(10)); } if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE - 2) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(10)); }
if (x >= this.HSIZE-1 && x <= this.HSIZE+1 && y == this.LAST) { core.playSound('取消'); core.ui.closePanel(); } if (x >= this.HSIZE - 1 && x <= this.HSIZE + 1 && y == this.LAST) { core.playSound('取消'); core.ui.closePanel(); }
if (x >= 0 && x <= this.HSIZE+3 && y >= 3 && y <= this.LAST - 1) if (x >= 0 && x <= this.HSIZE + 3 && y >= 3 && y <= this.LAST - 1)
core.flyTo(core.floorIds[core.status.event.data]); core.flyTo(core.floorIds[core.status.event.data]);
return; return;
} }
@ -1331,7 +1331,7 @@ actions.prototype._keyUpFly = function (keycode) {
core.ui.closePanel(); core.ui.closePanel();
} }
if (keycode == 13 || keycode == 32 || keycode == 67) if (keycode == 13 || keycode == 32 || keycode == 67)
this._clickFly(this.HSIZE-1, this.HSIZE-1); this._clickFly(this.HSIZE - 1, this.HSIZE - 1);
return; return;
} }
@ -1548,7 +1548,7 @@ actions.prototype._clickToolbox = function (x, y) {
var toolsPage = core.status.event.data.toolsPage; var toolsPage = core.status.event.data.toolsPage;
var constantsPage = core.status.event.data.constantsPage; var constantsPage = core.status.event.data.constantsPage;
// 上一页 // 上一页
if (x == this.HSIZE-2 || x == this.HSIZE-3) { if (x == this.HSIZE - 2 || x == this.HSIZE - 3) {
if (y == this.LAST - 5 && toolsPage > 1) { if (y == this.LAST - 5 && toolsPage > 1) {
core.status.event.data.toolsPage--; core.status.event.data.toolsPage--;
core.playSound('光标移动'); core.playSound('光标移动');
@ -1561,7 +1561,7 @@ actions.prototype._clickToolbox = function (x, y) {
} }
} }
// 下一页 // 下一页
if (x == this.HSIZE+2 || x == this.HSIZE+3) { if (x == this.HSIZE + 2 || x == this.HSIZE + 3) {
if (y == this.LAST - 5 && toolsPage < Math.ceil(tools.length / this.LAST)) { if (y == this.LAST - 5 && toolsPage < Math.ceil(tools.length / this.LAST)) {
core.status.event.data.toolsPage++; core.status.event.data.toolsPage++;
core.playSound('光标移动'); core.playSound('光标移动');
@ -1757,7 +1757,7 @@ actions.prototype._clickEquipbox = function (x, y) {
} }
// 上一页 // 上一页
if ((x == this.HSIZE-2 || x == this.HSIZE-3) && y == this.LAST) { if ((x == this.HSIZE - 2 || x == this.HSIZE - 3) && y == this.LAST) {
if (core.status.event.data.page > 1) { if (core.status.event.data.page > 1) {
core.status.event.data.page--; core.status.event.data.page--;
core.playSound('光标移动'); core.playSound('光标移动');
@ -1766,7 +1766,7 @@ actions.prototype._clickEquipbox = function (x, y) {
return; return;
} }
// 下一页 // 下一页
if ((x == this.HSIZE+2 || x == this.HSIZE+3) && y == this.LAST) { if ((x == this.HSIZE + 2 || x == this.HSIZE + 3) && y == this.LAST) {
var lastPage = Math.ceil(core.getToolboxItems('equips').length / this.LAST); var lastPage = Math.ceil(core.getToolboxItems('equips').length / this.LAST);
if (core.status.event.data.page < lastPage) { if (core.status.event.data.page < lastPage) {
core.status.event.data.page++; core.status.event.data.page++;
@ -1931,19 +1931,19 @@ actions.prototype._clickSL = function (x, y) {
var index = page * 10 + offset; var index = page * 10 + offset;
// 上一页 // 上一页
if ((x == this.HSIZE-2 || x == this.HSIZE-3) && y == this.LAST) { if ((x == this.HSIZE - 2 || x == this.HSIZE - 3) && y == this.LAST) {
core.playSound('光标移动'); core.playSound('光标移动');
core.ui._drawSLPanel(10 * (page - 1) + offset); core.ui._drawSLPanel(10 * (page - 1) + offset);
return; return;
} }
// 下一页 // 下一页
if ((x == this.HSIZE+2 || x == this.HSIZE+3) && y == this.LAST) { if ((x == this.HSIZE + 2 || x == this.HSIZE + 3) && y == this.LAST) {
core.playSound('光标移动'); core.playSound('光标移动');
core.ui._drawSLPanel(10 * (page + 1) + offset); core.ui._drawSLPanel(10 * (page + 1) + offset);
return; return;
} }
// 返回 // 返回
if (x >= this.LAST-2 && y == this.LAST) { if (x >= this.LAST - 2 && y == this.LAST) {
core.playSound('取消'); core.playSound('取消');
if (core.events.recoverEvents(core.status.event.interval)) if (core.events.recoverEvents(core.status.event.interval))
return; return;
@ -1960,25 +1960,25 @@ actions.prototype._clickSL = function (x, y) {
core.ui._drawSLPanel(index); core.ui._drawSLPanel(index);
} }
else { // 显示收藏 else { // 显示收藏
core.status.event.data.mode = core.status.event.data.mode == 'all'?'fav':'all'; core.status.event.data.mode = core.status.event.data.mode == 'all' ? 'fav' : 'all';
if (core.status.event.data.mode == 'fav') if (core.status.event.data.mode == 'fav')
core.ui._drawSLPanel(1, true); core.ui._drawSLPanel(1, true);
else { else {
page = parseInt((core.saves.saveIndex-1)/5); page = parseInt((core.saves.saveIndex - 1) / 5);
offset = core.saves.saveIndex-5*page; offset = core.saves.saveIndex - 5 * page;
core.ui._drawSLPanel(10*page + offset, true); core.ui._drawSLPanel(10 * page + offset, true);
} }
} }
return; return;
} }
// 点存档名 // 点存档名
var xLeft = parseInt(this.SIZE/3), xRight = parseInt(this.SIZE*2/3); var xLeft = parseInt(this.SIZE / 3), xRight = parseInt(this.SIZE * 2 / 3);
var topY1 = 0, topY2 = this.HSIZE; var topY1 = 0, topY2 = this.HSIZE;
if(y >= topY1 && y <= topY1 + 1) { if (y >= topY1 && y <= topY1 + 1) {
if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 1); if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 1);
if (x >= xRight) return this._clickSL_favorite(page, 2); if (x >= xRight) return this._clickSL_favorite(page, 2);
} }
if(y >= topY2 && y <= topY2 + 1) { if (y >= topY2 && y <= topY2 + 1) {
if (x < xLeft) return this._clickSL_favorite(page, 3); if (x < xLeft) return this._clickSL_favorite(page, 3);
if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 4); if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 4);
if (x >= xRight) return this._clickSL_favorite(page, 5); if (x >= xRight) return this._clickSL_favorite(page, 5);
@ -2007,7 +2007,7 @@ actions.prototype._clickSL = function (x, y) {
} }
} }
else { else {
if(core.status.event.data.mode == 'fav' && id != 'autoSave') if (core.status.event.data.mode == 'fav' && id != 'autoSave')
id = core.saves.favorite[id - 1]; id = core.saves.favorite[id - 1];
core.doSL(id, core.status.event.id); core.doSL(id, core.status.event.id);
} }
@ -2020,7 +2020,7 @@ actions.prototype._clickSL_favorite = function (page, offset) {
if (core.status.event.data.mode == 'fav') { // 收藏模式下点击的下标直接对应favorite if (core.status.event.data.mode == 'fav') { // 收藏模式下点击的下标直接对应favorite
index = core.saves.favorite[index - 1]; index = core.saves.favorite[index - 1];
core.myprompt("请输入想要显示的存档名(长度不超过5字符)", null, function (value) { core.myprompt("请输入想要显示的存档名(长度不超过5字符)", null, function (value) {
if(value && value.length <= 5){ if (value && value.length <= 5) {
core.saves.favoriteName[index] = value; core.saves.favoriteName[index] = value;
core.control._updateFavoriteSaves(); core.control._updateFavoriteSaves();
core.ui._drawSLPanel(10 * page + offset); core.ui._drawSLPanel(10 * page + offset);
@ -2037,7 +2037,7 @@ actions.prototype._clickSL_favorite = function (page, offset) {
} }
else if (core.hasSave(index)) { // 存在存档则进行收藏 else if (core.hasSave(index)) { // 存在存档则进行收藏
core.saves.favorite.push(index); core.saves.favorite.push(index);
core.saves.favorite = core.saves.favorite.sort(function (a,b) {return a-b;}); // 保证有序 core.saves.favorite = core.saves.favorite.sort(function (a, b) { return a - b; }); // 保证有序
core.drawTip("收藏成功!"); core.drawTip("收藏成功!");
} }
core.control._updateFavoriteSaves(); core.control._updateFavoriteSaves();
@ -2049,7 +2049,7 @@ actions.prototype._clickSL_favorite = function (page, offset) {
actions.prototype._keyDownSL = function (keycode) { actions.prototype._keyDownSL = function (keycode) {
var page = core.status.event.data.page, offset = core.status.event.data.offset; var page = core.status.event.data.page, offset = core.status.event.data.offset;
var index = page*10 + offset; var index = page * 10 + offset;
if (keycode == 37) { // left if (keycode == 37) { // left
core.playSound('光标移动'); core.playSound('光标移动');
@ -2123,7 +2123,7 @@ actions.prototype._keyUpSL = function (keycode) {
core.doSL("autoSave", core.status.event.id); core.doSL("autoSave", core.status.event.id);
else { else {
var id = 5 * page + offset; var id = 5 * page + offset;
if(core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1]; if (core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1];
core.doSL(id, core.status.event.id); core.doSL(id, core.status.event.id);
} }
return; return;
@ -2139,7 +2139,7 @@ actions.prototype._keyUpSL = function (keycode) {
} }
else { else {
var id = 5 * page + offset; var id = 5 * page + offset;
if(core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1]; if (core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1];
core.removeSave(id, function () { core.removeSave(id, function () {
core.ui._drawSLPanel(index, true); core.ui._drawSLPanel(index, true);
}); });
@ -2591,7 +2591,7 @@ actions.prototype._clickNotes_show = function () {
core.playSound('确定'); core.playSound('确定');
core.status.hero.notes = core.status.hero.notes || []; core.status.hero.notes = core.status.hero.notes || [];
var result = []; var result = [];
for (var i = 0; i < core.status.hero.notes.length; i+=5) { for (var i = 0; i < core.status.hero.notes.length; i += 5) {
var v = []; var v = [];
for (var j = i; j < i + 5 && j < core.status.hero.notes.length; ++j) { for (var j = i; j < i + 5 && j < core.status.hero.notes.length; ++j) {
v.push(j + 1 + ". " + this.__clickNotes_replaceText(core.status.hero.notes[j])); v.push(j + 1 + ". " + this.__clickNotes_replaceText(core.status.hero.notes[j]));
@ -2610,7 +2610,7 @@ actions.prototype._clickNotes_edit = function () {
core.myprompt("请输入要编辑的存档笔记编号1 - " + core.status.hero.notes.length + "", "1", function (data) { core.myprompt("请输入要编辑的存档笔记编号1 - " + core.status.hero.notes.length + "", "1", function (data) {
if (!data) core.ui.closePanel(); if (!data) core.ui.closePanel();
var value = parseInt(data) || 0; var value = parseInt(data) || 0;
if (!value || value<=0 || value > core.status.hero.notes.length) { if (!value || value <= 0 || value > core.status.hero.notes.length) {
core.drawText("不合法的输入!"); core.drawText("不合法的输入!");
} else { } else {
core.myprompt("请输入新内容不超过45字", core.status.hero.notes[value - 1], function (data) { core.myprompt("请输入新内容不超过45字", core.status.hero.notes[value - 1], function (data) {
@ -2644,11 +2644,11 @@ actions.prototype._clickNotes_delete = function () {
core.drawText("所有存档笔记删除成功!"); core.drawText("所有存档笔记删除成功!");
} else { } else {
data = data.split(",").map(function (one) { return parseInt(one); }) data = data.split(",").map(function (one) { return parseInt(one); })
.filter(function (one) { return one && one > 0 && one <= core.status.hero.notes.length}); .filter(function (one) { return one && one > 0 && one <= core.status.hero.notes.length });
if (data.length == 0) { if (data.length == 0) {
core.drawText("没有要删除的笔记!"); core.drawText("没有要删除的笔记!");
} else { } else {
data.sort(function (a, b) { return b - a;}) data.sort(function (a, b) { return b - a; })
.forEach(function (index) { .forEach(function (index) {
core.status.hero.notes.splice(index - 1, 1); core.status.hero.notes.splice(index - 1, 1);
}); });

View File

@ -88,7 +88,7 @@ control.prototype._setRequestAnimationFrame = function () {
core.doFunc(b.func, core.control, timestamp); core.doFunc(b.func, core.control, timestamp);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in requestAnimationFrame[" + b.name + "]:已自动注销该项。"); main.log("ERROR in requestAnimationFrame[" + b.name + "]:已自动注销该项。");
core.unregisterAnimationFrame(b.name); core.unregisterAnimationFrame(b.name);
} }
@ -215,7 +215,7 @@ control.prototype._animationFrame_weather = function (timestamp) {
try { try {
core.doFunc(core.control.weathers[type].frameFunc, core.control, timestamp, core.animateFrame.weather.level); core.doFunc(core.control.weathers[type].frameFunc, core.control, timestamp, core.animateFrame.weather.level);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in weather[" + type + "]:已自动注销该项。"); main.log("ERROR in weather[" + type + "]:已自动注销该项。");
core.unregisterWeather(type); core.unregisterWeather(type);
} }
@ -1626,7 +1626,7 @@ control.prototype._doReplayAction = function (action) {
try { try {
if (core.doFunc(this.replayActions[i].func, this, action)) return true; if (core.doFunc(this.replayActions[i].func, this, action)) return true;
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in replayActions[" + this.replayActions[i].name + "]:已自动注销该项。"); main.log("ERROR in replayActions[" + this.replayActions[i].name + "]:已自动注销该项。");
core.unregisterReplayAction(this.replayActions[i].name); core.unregisterReplayAction(this.replayActions[i].name);
} }
@ -2677,7 +2677,7 @@ control.prototype.setWeather = function (type, level) {
try { try {
core.doFunc(this.weathers[type].initFunc, this, level); core.doFunc(this.weathers[type].initFunc, this, level);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in weather[" + type + "]:已自动注销该项。"); main.log("ERROR in weather[" + type + "]:已自动注销该项。");
core.unregisterWeather(type); core.unregisterWeather(type);
} }
@ -2842,7 +2842,7 @@ control.prototype.playBgm = function (bgm, startTime) {
core.material.bgms[bgm].pause(); core.material.bgms[bgm].pause();
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
return; return;
} }
@ -3002,7 +3002,7 @@ control.prototype.stopSound = function (id) {
else if (source.noteOff) source.noteOff(); else if (source.noteOff) source.noteOff();
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
delete core.musicStatus.playingSounds[id]; delete core.musicStatus.playingSounds[id];
} }
@ -3060,7 +3060,7 @@ control.prototype.updateStatusBar_update = function () {
if (!core.control.noAutoEvents) core.checkAutoEvents(); if (!core.control.noAutoEvents) core.checkAutoEvents();
core.control._updateStatusBar_setToolboxIcon(); core.control._updateStatusBar_setToolboxIcon();
core.clearRouteFolding(); core.clearRouteFolding();
}); })
core.control.needUpdate = false; core.control.needUpdate = false;
core.control.noAutoEvents = true; core.control.noAutoEvents = true;
} }
@ -3253,7 +3253,7 @@ control.prototype._doResize = function (obj) {
try { try {
if (core.doFunc(this.resizes[i].func, this, obj)) return true; if (core.doFunc(this.resizes[i].func, this, obj)) return true;
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in resizes[" + this.resizes[i].name + "]:已自动注销该项。"); main.log("ERROR in resizes[" + this.resizes[i].name + "]:已自动注销该项。");
this.unregisterResize(this.resizes[i].name); this.unregisterResize(this.resizes[i].name);
} }

View File

@ -6,7 +6,7 @@
"use strict"; "use strict";
function core() { function core () {
this.__SIZE__ = 13; this.__SIZE__ = 13;
this.__PIXELS__ = this.__SIZE__ * 32; this.__PIXELS__ = this.__SIZE__ * 32;
this.__HALF_SIZE__ = Math.floor(this.__SIZE__ / 2); this.__HALF_SIZE__ = Math.floor(this.__SIZE__ / 2);
@ -135,7 +135,7 @@ function core() {
// 勇士属性 // 勇士属性
'hero': {}, 'hero': {},
'heroCenter': {'px': null, 'py': null}, 'heroCenter': { 'px': null, 'py': null },
// 当前地图 // 当前地图
'floorId': null, 'floorId': null,
@ -231,10 +231,10 @@ function core() {
"statusLeftBackground": main.styles.statusLeftBackground || "url(project/materials/ground.png) repeat", "statusLeftBackground": main.styles.statusLeftBackground || "url(project/materials/ground.png) repeat",
"statusTopBackground": main.styles.statusTopBackground || "url(project/materials/ground.png) repeat", "statusTopBackground": main.styles.statusTopBackground || "url(project/materials/ground.png) repeat",
"toolsBackground": main.styles.toolsBackground || "url(project/materials/ground.png) repeat", "toolsBackground": main.styles.toolsBackground || "url(project/materials/ground.png) repeat",
"borderColor": main.styles.borderColor || [204,204,204,1], "borderColor": main.styles.borderColor || [204, 204, 204, 1],
"statusBarColor": main.styles.statusBarColor || [255,255,255,1], "statusBarColor": main.styles.statusBarColor || [255, 255, 255, 1],
"floorChangingStyle": main.styles.floorChangingStyle || "background-color: black; color: white", "floorChangingStyle": main.styles.floorChangingStyle || "background-color: black; color: white",
"selectColor": main.styles.selectColor || [255,215,0,1], "selectColor": main.styles.selectColor || [255, 215, 0, 1],
"font": main.styles.font || "Verdana" "font": main.styles.font || "Verdana"
}, },
'curtainColor': null, 'curtainColor': null,
@ -306,7 +306,7 @@ core.prototype._init_flags = function () {
core.dom.logoLabel.innerText = core.firstData.title; core.dom.logoLabel.innerText = core.firstData.title;
document.title = core.firstData.title + " - HTML5魔塔"; document.title = core.firstData.title + " - HTML5魔塔";
document.getElementById("startLogo").innerText = core.firstData.title; document.getElementById("startLogo").innerText = core.firstData.title;
(core.firstData.shops||[]).forEach(function (t) { core.initStatus.shops[t.id] = t; }); (core.firstData.shops || []).forEach(function (t) { core.initStatus.shops[t.id] = t; });
core.maps._initFloors(); core.maps._initFloors();
// 初始化怪物、道具等 // 初始化怪物、道具等
@ -344,15 +344,15 @@ core.prototype._init_flags = function () {
symbol: "_equipEvent_" + equipId, symbol: "_equipEvent_" + equipId,
currentFloor: false, currentFloor: false,
multiExecute: true, multiExecute: true,
condition: "core.hasEquip('" + equipId + "') && !core.hasFlag('"+equipFlag+"')", condition: "core.hasEquip('" + equipId + "') && !core.hasFlag('" + equipFlag + "')",
data: core.precompile([{"type": "setValue", "name": "flag:" + equipFlag, "value": "true"}].concat(equip.equip.equipEvent||[])), data: core.precompile([{ "type": "setValue", "name": "flag:" + equipFlag, "value": "true" }].concat(equip.equip.equipEvent || [])),
}; };
var autoEvent2 = { var autoEvent2 = {
symbol: "_unequipEvent_" + equipId, symbol: "_unequipEvent_" + equipId,
currentFloor: false, currentFloor: false,
multiExecute: true, multiExecute: true,
condition: "!core.hasEquip('" + equipId + "') && core.hasFlag('"+equipFlag+"')", condition: "!core.hasEquip('" + equipId + "') && core.hasFlag('" + equipFlag + "')",
data: core.precompile([{"type": "setValue", "name": "flag:" + equipFlag, "value": "null"}].concat(equip.equip.unequipEvent||[])), data: core.precompile([{ "type": "setValue", "name": "flag:" + equipFlag, "value": "null" }].concat(equip.equip.unequipEvent || [])),
}; };
core.initStatus.autoEvents.push(autoEvent1); core.initStatus.autoEvents.push(autoEvent1);
core.initStatus.autoEvents.push(autoEvent2); core.initStatus.autoEvents.push(autoEvent2);
@ -444,7 +444,7 @@ core.prototype._init_others = function () {
core.loadImage("materials", 'fog', function (name, img) { core.animateFrame.weather.fog = img; }); core.loadImage("materials", 'fog', function (name, img) { core.animateFrame.weather.fog = img; });
core.loadImage("materials", "cloud", function (name, img) { core.animateFrame.weather.cloud = img; }) core.loadImage("materials", "cloud", function (name, img) { core.animateFrame.weather.cloud = img; })
core.loadImage("materials", "sun", function (name, img) { core.animateFrame.weather.sun = img; }) core.loadImage("materials", "sun", function (name, img) { core.animateFrame.weather.sun = img; })
core.loadImage("materials", 'keyboard', function (name, img) {core.material.images.keyboard = img; }); core.loadImage("materials", 'keyboard', function (name, img) { core.material.images.keyboard = img; });
// 记录存档编号 // 记录存档编号
core.saves.saveIndex = core.getLocalStorage('saveIndex', 1); core.saves.saveIndex = core.getLocalStorage('saveIndex', 1);
core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; }); core.control.getSaveIndexes(function (indexes) { core.saves.ids = indexes; });
@ -467,7 +467,7 @@ core.prototype._afterLoadResources = function (callback) {
} }
var arr = core.splitImage(core.material.images.images[name], one.width, one.height); var arr = core.splitImage(core.material.images.images[name], one.width, one.height);
for (var i = 0; i < arr.length; ++i) { for (var i = 0; i < arr.length; ++i) {
core.material.images.images[(one.prefix||"") + i + '.png'] = arr[i]; core.material.images.images[(one.prefix || "") + i + '.png'] = arr[i];
} }
}); });
@ -478,7 +478,7 @@ core.prototype._afterLoadResources = function (callback) {
} }
core.prototype._init_plugins = function () { core.prototype._init_plugins = function () {
core.plugin = new function () {}; core.plugin = new function () { };
for (var name in plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1) { for (var name in plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1) {
if (plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name] instanceof Function) { if (plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name] instanceof Function) {
@ -486,8 +486,8 @@ core.prototype._init_plugins = function () {
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name].apply(core.plugin); plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name].apply(core.plugin);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("无法初始化插件"+name); main.log("无法初始化插件" + name);
} }
} }
} }
@ -514,7 +514,7 @@ core.prototype._forwardFunc = function (name, funcname) {
} }
if (core[funcname]) { if (core[funcname]) {
console.error("ERROR: 无法转发 "+name+" 中的函数 "+funcname+" 到 core 中!同名函数已存在。"); console.error("ERROR: 无法转发 " + name + " 中的函数 " + funcname + " 到 core 中!同名函数已存在。");
return; return;
} }
var parameterInfo = /^\s*function\s*[\w_$]*\(([\w_,$\s]*)\)\s*\{/.exec(core[name][funcname].toString()); var parameterInfo = /^\s*function\s*[\w_$]*\(([\w_,$\s]*)\)\s*\{/.exec(core[name][funcname].toString());
@ -522,7 +522,7 @@ core.prototype._forwardFunc = function (name, funcname) {
// core[funcname] = new Function(parameters, "return core."+name+"."+funcname+"("+parameters+");"); // core[funcname] = new Function(parameters, "return core."+name+"."+funcname+"("+parameters+");");
eval("core." + funcname + " = function (" + parameters + ") {\n\treturn core." + name + "." + funcname + "(" + parameters + ");\n}"); eval("core." + funcname + " = function (" + parameters + ") {\n\treturn core." + name + "." + funcname + "(" + parameters + ");\n}");
if (name == 'plugin') { if (name == 'plugin') {
main.log("插件函数转发core."+funcname+" = core.plugin."+funcname); main.log("插件函数转发core." + funcname + " = core.plugin." + funcname);
} }
} }

View File

@ -2,7 +2,7 @@
"use strict"; "use strict";
function data() { function data () {
this._init(); this._init();
} }

View File

@ -2,7 +2,7 @@
"use strict"; "use strict";
function enemys() { function enemys () {
this._init(); this._init();
} }
@ -35,7 +35,7 @@ enemys.prototype.getEnemys = function () {
if (enemys[id].faceIds) { if (enemys[id].faceIds) {
var downId = enemys[id].faceIds.down; var downId = enemys[id].faceIds.down;
if (downId != null && downId != id && enemys[downId]) { if (downId != null && downId != id && enemys[downId]) {
enemys[id] = {id: id}; enemys[id] = { id: id };
for (var property in enemys[downId]) { for (var property in enemys[downId]) {
if (property != 'id' && enemys[downId].hasOwnProperty(property)) { if (property != 'id' && enemys[downId].hasOwnProperty(property)) {
(function (id, downId, property) { (function (id, downId, property) {
@ -150,7 +150,7 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
if (specials == null) return ""; if (specials == null) return "";
for (var i = 0; i < specials.length; i++) { for (var i = 0; i < specials.length; i++) {
if (special == specials[i][0]) if (special == specials[i][0])
return "\r[#FF6A6A]\\d"+this._calSpecialContent(enemy, specials[i][1]) + "\\d\r[]" + this._calSpecialContent(enemy, specials[i][2]); return "\r[#FF6A6A]\\d" + this._calSpecialContent(enemy, specials[i][1]) + "\\d\r[]" + this._calSpecialContent(enemy, specials[i][2]);
} }
return ""; return "";
} }
@ -167,8 +167,8 @@ enemys.prototype._calSpecialContent = function (enemy, content) {
////// 获得某个点上某个怪物的某项属性 ////// ////// 获得某个点上某个怪物的某项属性 //////
enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) { enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) {
floorId = floorId || core.status.floorId; floorId = floorId || core.status.floorId;
if ((((flags.enemyOnPoint||{})[floorId]||{})[x+","+y]||{})[name] != null) { if ((((flags.enemyOnPoint || {})[floorId] || {})[x + "," + y] || {})[name] != null) {
return flags.enemyOnPoint[floorId][x+","+y][name]; return flags.enemyOnPoint[floorId][x + "," + y][name];
} }
if (enemy == null) { if (enemy == null) {
var block = core.getBlock(x, y, floorId); var block = core.getBlock(x, y, floorId);
@ -236,7 +236,7 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
info.__overAtk__ = overAtk[0]; info.__overAtk__ = overAtk[0];
} }
if (typeof info == 'number') return [[0,0]]; if (typeof info == 'number') return [[0, 0]];
if (info.damage <= 0 && !core.flags.enableNegativeDamage) { if (info.damage <= 0 && !core.flags.enableNegativeDamage) {
return [[info.__overAtk__ || 0, 0]]; return [[info.__overAtk__ || 0, 0]];
} }
@ -263,11 +263,11 @@ enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) {
while (start < end) { while (start < end) {
var mid = Math.floor((start + end) / 2); var mid = Math.floor((start + end) / 2);
if (mid - start > end - mid) mid--; if (mid - start > end - mid) mid--;
var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": mid}, x, y, floorId); var nextInfo = core.enemys.getDamageInfo(enemy, { "atk": mid }, x, y, floorId);
if (nextInfo != null) end = mid; if (nextInfo != null) end = mid;
else start = mid + 1; else start = mid + 1;
} }
var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": start}, x, y, floorId); var nextInfo = core.enemys.getDamageInfo(enemy, { "atk": start }, x, y, floorId);
return nextInfo == null ? null : [start - core.status.hero.atk, nextInfo]; return nextInfo == null ? null : [start - core.status.hero.atk, nextInfo];
} }
return calNext(core.status.hero.atk + 1, return calNext(core.status.hero.atk + 1,
@ -289,7 +289,7 @@ enemys.prototype._nextCriticals_useLoop = function (enemy, info, number, x, y, f
list.push([info.__overAtk__, -info.damage]); list.push([info.__overAtk__, -info.damage]);
} }
for (var atk = start_atk + 1; atk <= mon_hp + mon_def; atk++) { for (var atk = start_atk + 1; atk <= mon_hp + mon_def; atk++) {
var nextInfo = this.getDamageInfo(enemy, {"atk": atk}, x, y, floorId); var nextInfo = this.getDamageInfo(enemy, { "atk": atk }, x, y, floorId);
if (nextInfo == null || (typeof nextInfo == 'number')) break; if (nextInfo == null || (typeof nextInfo == 'number')) break;
if (pre > nextInfo.damage) { if (pre > nextInfo.damage) {
pre = nextInfo.damage; pre = nextInfo.damage;
@ -317,12 +317,12 @@ enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number,
while (start < end) { while (start < end) {
var mid = Math.floor((start + end) / 2); var mid = Math.floor((start + end) / 2);
if (mid - start > end - mid) mid--; if (mid - start > end - mid) mid--;
var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": mid}, x, y, floorId); var nextInfo = core.enemys.getDamageInfo(enemy, { "atk": mid }, x, y, floorId);
if (nextInfo == null || (typeof nextInfo == 'number')) return null; if (nextInfo == null || (typeof nextInfo == 'number')) return null;
if (pre > nextInfo.damage) end = mid; if (pre > nextInfo.damage) end = mid;
else start = mid + 1; else start = mid + 1;
} }
var nextInfo = core.enemys.getDamageInfo(enemy, {"atk": start}, x, y, floorId); var nextInfo = core.enemys.getDamageInfo(enemy, { "atk": start }, x, y, floorId);
return nextInfo == null || (typeof nextInfo == 'number') || nextInfo.damage >= pre ? null : [start, nextInfo.damage]; return nextInfo == null || (typeof nextInfo == 'number') || nextInfo.damage >= pre ? null : [start, nextInfo.damage];
} }
var currAtk = start_atk; var currAtk = start_atk;
@ -358,7 +358,7 @@ enemys.prototype._nextCriticals_useTurn = function (enemy, info, number, x, y, f
nextAtk = Math.ceil(nextAtk / core.getBuff('atk')); nextAtk = Math.ceil(nextAtk / core.getBuff('atk'));
if (nextAtk <= start_atk) break; if (nextAtk <= start_atk) break;
if (nextAtk != pre) { if (nextAtk != pre) {
var nextInfo = this.getDamageInfo(enemy, {"atk": nextAtk}, x, y, floorId); var nextInfo = this.getDamageInfo(enemy, { "atk": nextAtk }, x, y, floorId);
if (nextInfo == null || (typeof nextInfo == 'number')) break; if (nextInfo == null || (typeof nextInfo == 'number')) break;
list.push([nextAtk - hero_atk, Math.floor(info.damage - nextInfo.damage)]); list.push([nextAtk - hero_atk, Math.floor(info.damage - nextInfo.damage)]);
if (nextInfo.damage <= 0 && !core.flags.enableNegativeDamage) break; if (nextInfo.damage <= 0 && !core.flags.enableNegativeDamage) break;
@ -376,7 +376,7 @@ enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
k = k || 1; k = k || 1;
var nowDamage = this._getDamage(enemy, null, x, y, floorId); var nowDamage = this._getDamage(enemy, null, x, y, floorId);
var nextDamage = this._getDamage(enemy, {"def": core.status.hero.def + k}, x, y, floorId); var nextDamage = this._getDamage(enemy, { "def": core.status.hero.def + k }, x, y, floorId);
if (nowDamage == null || nextDamage == null) return "???"; if (nowDamage == null || nextDamage == null) return "???";
return nowDamage - nextDamage; return nowDamage - nextDamage;
} }
@ -508,7 +508,7 @@ enemys.prototype.hasEnemyLeft = function (enemyId, floorId) {
if (floorId == null) floorId = core.status.floorId; if (floorId == null) floorId = core.status.floorId;
if (!(floorId instanceof Array)) floorId = [floorId]; if (!(floorId instanceof Array)) floorId = [floorId];
var enemyMap = {}; var enemyMap = {};
if (enemyId instanceof Array) enemyId.forEach(function(v) { enemyMap[v] = true;}); if (enemyId instanceof Array) enemyId.forEach(function (v) { enemyMap[v] = true; });
else if (enemyId) enemyMap[enemyId] = true; else if (enemyId) enemyMap[enemyId] = true;
else enemyMap = null; else enemyMap = null;
for (var i = 0; i < floorId.length; i++) { for (var i = 0; i < floorId.length; i++) {

View File

@ -312,7 +312,7 @@ events.prototype.doSystemEvent = function (type, data, callback) {
return core.doFunc(this.systemEvents[type], this, data, callback); return core.doFunc(this.systemEvents[type], this, data, callback);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in systemEvents[" + type + "]"); main.log("ERROR in systemEvents[" + type + "]");
} }
} }
@ -347,7 +347,7 @@ events.prototype.trigger = function (x, y, callback) {
core.clearRouteFolding(); core.clearRouteFolding();
try { try {
eval(block.event.script); eval(block.event.script);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
// 碰触事件 // 碰触事件
@ -380,7 +380,7 @@ events.prototype._trigger_inAction = function (x, y) {
// 执行该点的脚本 // 执行该点的脚本
try { try {
eval(block.event.script); eval(block.event.script);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
// 碰触事件 // 碰触事件
if (block.event.event) { if (block.event.event) {
@ -952,7 +952,7 @@ events.prototype.doEvent = function (data, x, y, prefix) {
return core.doFunc(this.actions[type], this, data, x, y, prefix); return core.doFunc(this.actions[type], this, data, x, y, prefix);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in actions[" + type + "]"); main.log("ERROR in actions[" + type + "]");
} }
} }
@ -1104,7 +1104,7 @@ events.prototype.insertCommonEvent = function (name, args, x, y, callback, addTo
try { try {
if (args[i] != null) if (args[i] != null)
core.setFlag('arg' + (i + 1), args[i]); core.setFlag('arg' + (i + 1), args[i]);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
} }
@ -1826,7 +1826,7 @@ events.prototype._action_insert = function (data, x, y, prefix) {
try { try {
if (data.args[i] != null) if (data.args[i] != null)
core.setFlag('arg' + (i + 1), data.args[i]); core.setFlag('arg' + (i + 1), data.args[i]);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
} }
var loc = this.__action_getLoc(data.loc, x, y, prefix); var loc = this.__action_getLoc(data.loc, x, y, prefix);
@ -2363,7 +2363,7 @@ events.prototype._action_function = function (data, x, y, prefix) {
eval('(' + func + ')()'); eval('(' + func + ')()');
} }
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
if (!data.async) if (!data.async)
core.doAction(); core.doAction();

View File

@ -6,7 +6,7 @@ extensions.js负责拓展插件
"use strict"; "use strict";
function extensions() { function extensions () {
} }

View File

@ -2,7 +2,7 @@
"use strict"; "use strict";
function icons() { function icons () {
this._init(); this._init();
} }
@ -70,7 +70,7 @@ icons.prototype.getTilesetOffset = function (id) {
var width = Math.floor(parseInt(img.getAttribute('_width')) / 32), height = Math.floor(parseInt(img.getAttribute('_height')) / 32); var width = Math.floor(parseInt(img.getAttribute('_width')) / 32), height = Math.floor(parseInt(img.getAttribute('_height')) / 32);
if (id >= startOffset && id < startOffset + width * height) { if (id >= startOffset && id < startOffset + width * height) {
var x = (id - startOffset) % width, y = parseInt((id - startOffset) / width); var x = (id - startOffset) % width, y = parseInt((id - startOffset) / width);
return {"image": imgName, "x": x, "y": y}; return { "image": imgName, "x": x, "y": y };
} }
startOffset += this.tilesetStartOffset; startOffset += this.tilesetStartOffset;
} }

View File

@ -2,7 +2,7 @@
"use strict"; "use strict";
function items() { function items () {
this._init(); this._init();
} }
@ -39,7 +39,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
eval(itemEffect); eval(itemEffect);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp; core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
@ -50,7 +50,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
core.insertAction(useItemEvent); core.insertAction(useItemEvent);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
core.updateStatusBar(); core.updateStatusBar();
@ -70,7 +70,7 @@ items.prototype.getItemEffectTip = function (itemId) {
try { try {
return core.replaceText(itemEffectTip) || ""; return core.replaceText(itemEffectTip) || "";
} catch (e) { } catch (e) {
main.log(e); console.error(e);
return ""; return "";
} }
} }
@ -100,7 +100,7 @@ items.prototype._useItemEffect = function (itemId) {
eval(useItemEffect); eval(useItemEffect);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
var useItemEvent = core.material.items[itemId].useItemEvent; var useItemEvent = core.material.items[itemId].useItemEvent;
@ -109,7 +109,7 @@ items.prototype._useItemEffect = function (itemId) {
core.insertAction(useItemEvent); core.insertAction(useItemEvent);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
} }
@ -135,7 +135,7 @@ items.prototype.canUseItem = function (itemId) {
return eval(canUseItemEffect); return eval(canUseItemEffect);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
return false; return false;
} }
} }
@ -269,7 +269,7 @@ items.prototype.canEquip = function (equipId, hint) {
} }
} }
catch (e) { catch (e) {
console.log(e); console.error(e);
return false; return false;
} }
} }
@ -307,7 +307,7 @@ items.prototype.unloadEquip = function (equipType, callback) {
} }
items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) { items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) {
var result = {"value": {}, "percentage": {}}; var result = { "value": {}, "percentage": {} };
var first = core.material.items[compareEquipId], second = core.material.items[beComparedEquipId]; var first = core.material.items[compareEquipId], second = core.material.items[beComparedEquipId];
for (var one in result) { for (var one in result) {
for (var name in core.status.hero) { for (var name in core.status.hero) {
@ -366,7 +366,7 @@ items.prototype.quickSaveEquip = function (index) {
var saveEquips = core.getFlag("saveEquips", []); var saveEquips = core.getFlag("saveEquips", []);
saveEquips[index] = core.clone(core.status.hero.equipment); saveEquips[index] = core.clone(core.status.hero.equipment);
core.setFlag("saveEquips", saveEquips); core.setFlag("saveEquips", saveEquips);
core.status.route.push("saveEquip:"+index); core.status.route.push("saveEquip:" + index);
core.drawTip("已保存" + index + "号套装"); core.drawTip("已保存" + index + "号套装");
} }
@ -385,7 +385,7 @@ items.prototype.quickLoadEquip = function (index) {
if (v && !this.canEquip(v, true)) if (v && !this.canEquip(v, true))
return; return;
} }
core.status.route.push("loadEquip:"+index); core.status.route.push("loadEquip:" + index);
core.setFlag("__quickLoadEquip__", true); core.setFlag("__quickLoadEquip__", true);
// 快速换装 // 快速换装
var toEquip = []; var toEquip = [];
@ -424,7 +424,7 @@ items.prototype.setEquip = function (equipId, valueType, name, value, operator,
if (core.hasEquip(equipId)) { if (core.hasEquip(equipId)) {
// 设置一个临时装备,然后模拟换装操作 // 设置一个临时装备,然后模拟换装操作
var tempId = 'temp:' + equipId; var tempId = 'temp:' + equipId;
core.material.items[tempId] = {'cls': 'equips', 'equip': core.clone(toEquipInfo)}; core.material.items[tempId] = { 'cls': 'equips', 'equip': core.clone(toEquipInfo) };
this._loadEquipEffect(tempId, equipId); this._loadEquipEffect(tempId, equipId);
delete core.material.items[tempId]; delete core.material.items[tempId];
core.updateStatusBar(); core.updateStatusBar();

View File

@ -6,7 +6,7 @@ loader.js负责对资源的加载
*/ */
"use strict"; "use strict";
function loader() { function loader () {
this._init(); this._init();
} }
@ -49,7 +49,7 @@ loader.prototype._load_async = function (callback) {
var all = {}; var all = {};
var _makeOnProgress = function (name) { var _makeOnProgress = function (name) {
if (!all[name]) all[name] = {loaded: 0, total: 0, finished: false}; if (!all[name]) all[name] = { loaded: 0, total: 0, finished: false };
return function (loaded, total) { return function (loaded, total) {
all[name].loaded = loaded; all[name].loaded = loaded;
all[name].total = total; all[name].total = total;
@ -263,7 +263,7 @@ loader.prototype.loadImage = function (dir, imgName, callback) {
callback(imgName, null); callback(imgName, null);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
@ -362,7 +362,7 @@ loader.prototype._loadAnimate = function (content) {
image.src = t2; image.src = t2;
data.images.push(image); data.images.push(image);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
data.images.push(null); data.images.push(null);
} }
} }
@ -387,7 +387,7 @@ loader.prototype._loadAnimate = function (content) {
return data; return data;
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
return null; return null;
} }
} }
@ -463,7 +463,7 @@ loader.prototype._loadOneSound_decodeData = function (name, data) {
}) })
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
core.material.sounds[name] = null; core.material.sounds[name] = null;
} }
} }

View File

@ -198,7 +198,7 @@ utils.prototype.decompress = function (value) {
return JSON.parse(value); return JSON.parse(value);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
return null; return null;
} }
@ -222,7 +222,7 @@ utils.prototype.setLocalStorage = function (key, value) {
return true; return true;
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
return false; return false;
} }
} }
@ -1035,7 +1035,7 @@ utils.prototype.readFileContent = function (content) {
try { try {
obj = JSON.parse(content); obj = JSON.parse(content);
} catch (e) { } catch (e) {
main.log(e) console.error(e)
} }
} }

307
main.js
View File

@ -1,4 +1,4 @@
function main() { function main () {
//------------------------ 用户修改内容 ------------------------// //------------------------ 用户修改内容 ------------------------//
@ -178,7 +178,7 @@ function main() {
'redKey': document.getElementById("redKey"), 'redKey': document.getElementById("redKey"),
'greenKey': document.getElementById("greenKey"), 'greenKey': document.getElementById("greenKey"),
'poison': document.getElementById('poison'), 'poison': document.getElementById('poison'),
'weak':document.getElementById('weak'), 'weak': document.getElementById('weak'),
'curse': document.getElementById('curse'), 'curse': document.getElementById('curse'),
'pickaxe': document.getElementById('pickaxe'), 'pickaxe': document.getElementById('pickaxe'),
'bomb': document.getElementById('bomb'), 'bomb': document.getElementById('bomb'),
@ -198,22 +198,22 @@ main.prototype.init = function (mode, callback) {
} }
main.mode = mode; main.mode = mode;
main.loadJs('project', main.pureData, function(){ main.loadJs('project', main.pureData, function () {
var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main; var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main;
for(var ii in mainData)main[ii]=mainData[ii]; for (var ii in mainData) main[ii] = mainData[ii];
main.dom.startLogo.style=main.styles.startLogoStyle; main.dom.startLogo.style = main.styles.startLogoStyle;
main.dom.startButtonGroup.style = main.styles.startButtonsStyle; main.dom.startButtonGroup.style = main.styles.startButtonsStyle;
main.levelChoose = main.levelChoose || []; main.levelChoose = main.levelChoose || [];
main.levelChoose.forEach(function (value) { main.levelChoose.forEach(function (value) {
var span = document.createElement('span'); var span = document.createElement('span');
span.setAttribute('class','startButton'); span.setAttribute('class', 'startButton');
span.innerText=value.title || ''; span.innerText = value.title || '';
(function(span,str_){ (function (span, str_) {
span.onclick = function () { span.onclick = function () {
core.events.startGame(str_); core.events.startGame(str_);
} }
})(span,value.name||''); })(span, value.name || '');
main.dom.levelChooseButtons.appendChild(span); main.dom.levelChooseButtons.appendChild(span);
}); });
main.createOnChoiceAnimation(); main.createOnChoiceAnimation();
@ -228,7 +228,7 @@ main.prototype.init = function (mode, callback) {
main.core[name] = new window[name](); main.core[name] = new window[name]();
} }
main.loadFloors(function() { main.loadFloors(function () {
var coreData = {}; var coreData = {};
["dom", "statusBar", "canvas", "images", "tilesets", "materials", ["dom", "statusBar", "canvas", "images", "tilesets", "materials",
"animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) { "animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) {
@ -270,7 +270,7 @@ main.prototype.loadJs = function (dir, loadList, callback) {
main.prototype.loadMod = function (dir, modName, callback, onerror) { main.prototype.loadMod = function (dir, modName, callback, onerror) {
var script = document.createElement('script'); var script = document.createElement('script');
var name = modName; var name = modName;
script.src = dir + '/' + modName + (this.useCompress?".min":"") + '.js?v=' + this.version; script.src = dir + '/' + modName + (this.useCompress ? ".min" : "") + '.js?v=' + this.version;
script.onload = function () { script.onload = function () {
callback(name); callback(name);
} }
@ -317,9 +317,9 @@ main.prototype.loadFloors = function (callback) {
} }
////// 加载某一个楼层 ////// ////// 加载某一个楼层 //////
main.prototype.loadFloor = function(floorId, callback) { main.prototype.loadFloor = function (floorId, callback) {
var script = document.createElement('script'); var script = document.createElement('script');
script.src = 'project/floors/' + floorId +'.js?v=' + this.version; script.src = 'project/floors/' + floorId + '.js?v=' + this.version;
main.dom.body.appendChild(script); main.dom.body.appendChild(script);
script.onload = function () { script.onload = function () {
callback(floorId); callback(floorId);
@ -331,8 +331,9 @@ main.prototype.setMainTipsText = function (text) {
main.dom.mainTips.innerHTML = text; main.dom.mainTips.innerHTML = text;
} }
main.prototype.log = function (e) { main.prototype.log = function (e, error) {
if (e) { if (e) {
if (error) return console.error(e);
if (main.core && main.core.platform && !main.core.platform.isPC) { if (main.core && main.core.platform && !main.core.platform.isPC) {
console.log((e.stack || e.toString())); console.log((e.stack || e.toString()));
} }
@ -351,9 +352,9 @@ main.prototype.createOnChoiceAnimation = function () {
var style = document.createElement("style"); var style = document.createElement("style");
style.type = 'text/css'; style.type = 'text/css';
var keyFrames = "onChoice { " + var keyFrames = "onChoice { " +
"0% { border-color: rgba("+value+", 0.9); } " + "0% { border-color: rgba(" + value + ", 0.9); } " +
"50% { border-color: rgba("+value+", 0.3); } " + "50% { border-color: rgba(" + value + ", 0.3); } " +
"100% { border-color: rgba("+value+", 0.9); } " + "100% { border-color: rgba(" + value + ", 0.9); } " +
"}"; "}";
style.innerHTML = "@-webkit-keyframes " + keyFrames + " @keyframes " + keyFrames; style.innerHTML = "@-webkit-keyframes " + keyFrames + " @keyframes " + keyFrames;
document.body.appendChild(style); document.body.appendChild(style);
@ -364,7 +365,7 @@ main.prototype.createOnChoiceAnimation = function () {
main.prototype.selectButton = function (index) { main.prototype.selectButton = function (index) {
var select = function (children) { var select = function (children) {
index = (index + children.length) % children.length; index = (index + children.length) % children.length;
for (var i = 0;i < children.length; ++i) { for (var i = 0; i < children.length; ++i) {
children[i].classList.remove("onChoiceAnimate"); children[i].classList.remove("onChoiceAnimate");
} }
children[index].classList.add("onChoiceAnimate"); children[index].classList.add("onChoiceAnimate");
@ -393,7 +394,7 @@ main.prototype.importFonts = function (fonts) {
style.type = 'text/css'; style.type = 'text/css';
var html = ''; var html = '';
fonts.forEach(function (font) { fonts.forEach(function (font) {
html += '@font-face { font-family: "'+font+'"; src: url("project/fonts/'+font+'.ttf") format("truetype"); }'; html += '@font-face { font-family: "' + font + '"; src: url("project/fonts/' + font + '.ttf") format("truetype"); }';
}); });
style.innerHTML = html; style.innerHTML = html;
document.body.appendChild(style); document.body.appendChild(style);
@ -401,31 +402,31 @@ main.prototype.importFonts = function (fonts) {
main.prototype.listen = function () { main.prototype.listen = function () {
////// 窗口大小变化时 ////// ////// 窗口大小变化时 //////
window.onresize = function () { window.onresize = function () {
try { try {
main.core.resize(); main.core.resize();
}catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
////// 在界面上按下某按键时 ////// ////// 在界面上按下某按键时 //////
main.dom.body.onkeydown = function(e) { main.dom.body.onkeydown = function (e) {
try { try {
if (main.dom.inputDiv.style.display == 'block') return; if (main.dom.inputDiv.style.display == 'block') return;
if (main.core && (main.core.isPlaying() || main.core.status.lockControl)) if (main.core && (main.core.isPlaying() || main.core.status.lockControl))
main.core.onkeyDown(e); main.core.onkeyDown(e);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 在界面上放开某按键时 ////// ////// 在界面上放开某按键时 //////
main.dom.body.onkeyup = function(e) { main.dom.body.onkeyup = function (e) {
try { try {
if (main.dom.startPanel.style.display == 'block' && if (main.dom.startPanel.style.display == 'block' &&
(main.dom.startButtons.style.display == 'block' || main.dom.levelChooseButtons.style.display == 'block')) { (main.dom.startButtons.style.display == 'block' || main.dom.levelChooseButtons.style.display == 'block')) {
if (e.keyCode == 38 || e.keyCode == 33) // up/pgup if (e.keyCode == 38 || e.keyCode == 33) // up/pgup
main.selectButton((main.selectedButton||0) - 1); main.selectButton((main.selectedButton || 0) - 1);
else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn
main.selectButton((main.selectedButton||0) + 1); main.selectButton((main.selectedButton || 0) + 1);
else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space
main.selectButton(main.selectedButton); main.selectButton(main.selectedButton);
else if (e.keyCode == 27 && main.dom.levelChooseButtons.style.display == 'block') { // ESC else if (e.keyCode == 27 && main.dom.levelChooseButtons.style.display == 'block') { // ESC
@ -450,10 +451,10 @@ main.dom.body.onkeyup = function(e) {
if (main.core && main.core.isPlaying && main.core.status && if (main.core && main.core.isPlaying && main.core.status &&
(main.core.isPlaying() || main.core.status.lockControl)) (main.core.isPlaying() || main.core.status.lockControl))
main.core.onkeyUp(e); main.core.onkeyUp(e);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
}; };
[main.dom.startButtons, main.dom.levelChooseButtons].forEach(function (dom) { [main.dom.startButtons, main.dom.levelChooseButtons].forEach(function (dom) {
dom.onmousemove = function (e) { dom.onmousemove = function (e) {
for (var i = 0; i < dom.children.length; ++i) { for (var i = 0; i < dom.children.length; ++i) {
if (dom.children[i] == e.target && i != (main.selectedButton || 0)) { if (dom.children[i] == e.target && i != (main.selectedButton || 0)) {
@ -461,77 +462,77 @@ main.dom.body.onkeyup = function(e) {
} }
} }
} }
}); });
////// 开始选择时 ////// ////// 开始选择时 //////
main.dom.body.onselectstart = function () { main.dom.body.onselectstart = function () {
return false; return false;
} }
////// 鼠标按下时 ////// ////// 鼠标按下时 //////
main.dom.data.onmousedown = function (e) { main.dom.data.onmousedown = function (e) {
try { try {
e.stopPropagation(); e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.ondown(loc); main.core.ondown(loc);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 鼠标移动时 ////// ////// 鼠标移动时 //////
main.dom.data.onmousemove = function (e) { main.dom.data.onmousemove = function (e) {
try { try {
e.stopPropagation(); e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onmove(loc); main.core.onmove(loc);
}catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 鼠标放开时 ////// ////// 鼠标放开时 //////
main.dom.data.onmouseup = function (e) { main.dom.data.onmouseup = function (e) {
try { try {
e.stopPropagation(); e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onup(loc); main.core.onup(loc);
}catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
////// 鼠标滑轮滚动时 ////// ////// 鼠标滑轮滚动时 //////
main.dom.data.onmousewheel = function(e) { main.dom.data.onmousewheel = function (e) {
try { try {
if (e.wheelDelta) if (e.wheelDelta)
main.core.onmousewheel(Math.sign(e.wheelDelta)) main.core.onmousewheel(Math.sign(e.wheelDelta))
else if (e.detail) else if (e.detail)
main.core.onmousewheel(Math.sign(e.detail)); main.core.onmousewheel(Math.sign(e.detail));
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 手指在触摸屏开始触摸时 ////// ////// 手指在触摸屏开始触摸时 //////
main.dom.data.ontouchstart = function (e) { main.dom.data.ontouchstart = function (e) {
try { try {
e.preventDefault(); e.preventDefault();
var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return; if (loc == null) return;
main.lastTouchLoc = loc; main.lastTouchLoc = loc;
main.core.ondown(loc); main.core.ondown(loc);
}catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 手指在触摸屏上移动时 ////// ////// 手指在触摸屏上移动时 //////
main.dom.data.ontouchmove = function (e) { main.dom.data.ontouchmove = function (e) {
try { try {
e.preventDefault(); e.preventDefault();
var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return; if (loc == null) return;
main.lastTouchLoc = loc; main.lastTouchLoc = loc;
main.core.onmove(loc); main.core.onmove(loc);
}catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 手指离开触摸屏时 ////// ////// 手指离开触摸屏时 //////
main.dom.data.ontouchend = function (e) { main.dom.data.ontouchend = function (e) {
try { try {
e.preventDefault(); e.preventDefault();
if (main.lastTouchLoc == null) return; if (main.lastTouchLoc == null) return;
@ -539,21 +540,21 @@ main.dom.data.ontouchend = function (e) {
delete main.lastTouchLoc; delete main.lastTouchLoc;
main.core.onup(loc); main.core.onup(loc);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
}
} }
}
main.dom.statusCanvas.onclick = function (e) { main.dom.statusCanvas.onclick = function (e) {
try { try {
e.preventDefault(); e.preventDefault();
main.core.onStatusBarClick(e); main.core.onStatusBarClick(e);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
}
} }
}
////// 点击状态栏中的怪物手册时 ////// ////// 点击状态栏中的怪物手册时 //////
main.statusBar.image.book.onclick = function (e) { main.statusBar.image.book.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -563,10 +564,10 @@ main.statusBar.image.book.onclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.openBook(true); main.core.openBook(true);
} }
////// 点击状态栏中的楼层传送器/装备栏时 ////// ////// 点击状态栏中的楼层传送器/装备栏时 //////
main.statusBar.image.fly.onclick = function (e) { main.statusBar.image.fly.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
// 播放录像时 // 播放录像时
@ -583,10 +584,10 @@ main.statusBar.image.fly.onclick = function (e) {
main.core.openEquipbox(true) main.core.openEquipbox(true)
} }
} }
} }
////// 点击状态栏中的工具箱时 ////// ////// 点击状态栏中的工具箱时 //////
main.statusBar.image.toolbox.onclick = function (e) { main.statusBar.image.toolbox.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -597,10 +598,10 @@ main.statusBar.image.toolbox.onclick = function (e) {
if (main.core.isPlaying()) { if (main.core.isPlaying()) {
main.core.openToolbox(core.status.event.id != 'equipbox'); main.core.openToolbox(core.status.event.id != 'equipbox');
} }
} }
////// 双击状态栏中的工具箱时 ////// ////// 双击状态栏中的工具箱时 //////
main.statusBar.image.toolbox.ondblclick = function (e) { main.statusBar.image.toolbox.ondblclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -610,10 +611,10 @@ main.statusBar.image.toolbox.ondblclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.openEquipbox(true); main.core.openEquipbox(true);
} }
////// 点击状态栏中的虚拟键盘时 ////// ////// 点击状态栏中的虚拟键盘时 //////
main.statusBar.image.keyboard.onclick = function (e) { main.statusBar.image.keyboard.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -623,10 +624,10 @@ main.statusBar.image.keyboard.onclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.openKeyBoard(true); main.core.openKeyBoard(true);
} }
////// 点击状态栏中的快捷商店时 ////// ////// 点击状态栏中的快捷商店时 //////
main.statusBar.image.shop.onclick = function (e) { main.statusBar.image.shop.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -636,27 +637,27 @@ main.statusBar.image.shop.onclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.openQuickShop(true); main.core.openQuickShop(true);
} }
////// 点击金币时也可以开启快捷商店 ////// ////// 点击金币时也可以开启快捷商店 //////
main.statusBar.image.money.onclick = function (e) { main.statusBar.image.money.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.openQuickShop(true); main.core.openQuickShop(true);
} }
////// 点击楼梯图标也可以浏览地图 ////// ////// 点击楼梯图标也可以浏览地图 //////
main.statusBar.image.floor.onclick = function (e) { main.statusBar.image.floor.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (main.core && main.core.isPlaying() && !core.isMoving() && !core.status.lockControl) { if (main.core && main.core.isPlaying() && !core.isMoving() && !core.status.lockControl) {
core.ui._drawViewMaps(); core.ui._drawViewMaps();
} }
} }
////// 点击状态栏中的存档按钮时 ////// ////// 点击状态栏中的存档按钮时 //////
main.statusBar.image.save.onclick = function (e) { main.statusBar.image.save.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -666,10 +667,10 @@ main.statusBar.image.save.onclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.save(true); main.core.save(true);
} }
////// 点击状态栏中的读档按钮时 ////// ////// 点击状态栏中的读档按钮时 //////
main.statusBar.image.load.onclick = function (e) { main.statusBar.image.load.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -679,10 +680,10 @@ main.statusBar.image.load.onclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.load(true); main.core.load(true);
} }
////// 点击状态栏中的系统菜单时 ////// ////// 点击状态栏中的系统菜单时 //////
main.statusBar.image.settings.onclick = function (e) { main.statusBar.image.settings.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.isReplaying()) { if (core.isReplaying()) {
@ -692,52 +693,52 @@ main.statusBar.image.settings.onclick = function (e) {
if (main.core.isPlaying()) if (main.core.isPlaying())
main.core.openSettings(true); main.core.openSettings(true);
} }
////// 点击工具栏时 ////// ////// 点击工具栏时 //////
main.dom.hard.onclick = function () { main.dom.hard.onclick = function () {
if (core.isReplaying()) if (core.isReplaying())
return; return;
main.core.control.setToolbarButton(!core.domStyle.toolbarBtn); main.core.control.setToolbarButton(!core.domStyle.toolbarBtn);
} }
////// 手机端的按钮1-7 ////// ////// 手机端的按钮1-7 //////
main.statusBar.image.btn1.onclick = function (e) { main.statusBar.image.btn1.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 49, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 49, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn2.onclick = function (e) { main.statusBar.image.btn2.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 50, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 50, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn3.onclick = function (e) { main.statusBar.image.btn3.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 51, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 51, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn4.onclick = function (e) { main.statusBar.image.btn4.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 52, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 52, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn5.onclick = function (e) { main.statusBar.image.btn5.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 53, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 53, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn6.onclick = function (e) { main.statusBar.image.btn6.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 54, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 54, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn7.onclick = function (e) { main.statusBar.image.btn7.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
main.core.onkeyUp({"keyCode": 55, "altKey": core.getLocalStorage('altKey')}); main.core.onkeyUp({ "keyCode": 55, "altKey": core.getLocalStorage('altKey') });
}; };
main.statusBar.image.btn8.onclick = function (e) { main.statusBar.image.btn8.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
if (core.getLocalStorage('altKey')) { if (core.getLocalStorage('altKey')) {
core.removeLocalStorage('altKey'); core.removeLocalStorage('altKey');
@ -749,42 +750,42 @@ main.statusBar.image.btn8.onclick = function (e) {
core.drawTip("Alt模式已开启此模式下1~7按钮视为Alt+1~7。"); core.drawTip("Alt模式已开启此模式下1~7按钮视为Alt+1~7。");
main.statusBar.image.btn8.style.filter = 'sepia(1) contrast(1.5)'; main.statusBar.image.btn8.style.filter = 'sepia(1) contrast(1.5)';
} }
}; };
////// 点击“开始游戏”时 ////// ////// 点击“开始游戏”时 //////
main.dom.playGame.onclick = function () { main.dom.playGame.onclick = function () {
main.dom.startButtons.style.display='none'; main.dom.startButtons.style.display = 'none';
main.core.control.checkBgm(); main.core.control.checkBgm();
if (main.levelChoose.length == 0) { if (main.levelChoose.length == 0) {
core.events.startGame(""); core.events.startGame("");
} else { } else {
main.dom.levelChooseButtons.style.display='block'; main.dom.levelChooseButtons.style.display = 'block';
main.selectedButton = null; main.selectedButton = null;
main.selectButton(0); main.selectButton(0);
} }
} }
////// 点击“载入游戏”时 ////// ////// 点击“载入游戏”时 //////
main.dom.loadGame.onclick = function() { main.dom.loadGame.onclick = function () {
main.core.control.checkBgm(); main.core.control.checkBgm();
main.core.load(); main.core.load();
} }
////// 点击“录像回放”时 ////// ////// 点击“录像回放”时 //////
main.dom.replayGame.onclick = function () { main.dom.replayGame.onclick = function () {
main.core.control.checkBgm(); main.core.control.checkBgm();
main.core.chooseReplayFile(); main.core.chooseReplayFile();
} }
main.dom.musicBtn.onclick = function () { main.dom.musicBtn.onclick = function () {
try { try {
if (main.core) if (main.core)
main.core.triggerBgm(); main.core.triggerBgm();
} catch (e) {main.log(e);} } catch (ee) { console.error(ee) }
} }
main.dom.enlargeBtn.onclick = function () { main.dom.enlargeBtn.onclick = function () {
try { try {
if (main.core) { if (main.core) {
main.core.setDisplayScale(1); main.core.setDisplayScale(1);
@ -793,30 +794,30 @@ main.dom.enlargeBtn.onclick = function () {
main.core.resize(); main.core.resize();
} }
} }
} catch (e) {main.log(e)}; } catch (e) { main.log(e) };
} }
window.onblur = function () { window.onblur = function () {
if (main.core && main.core.control) { if (main.core && main.core.control) {
try { try {
main.core.control.checkAutosave(); main.core.control.checkAutosave();
} catch (e) {} } catch (e) { }
}
} }
}
main.dom.inputYes.onclick = function () { main.dom.inputYes.onclick = function () {
main.dom.inputDiv.style.display = 'none'; main.dom.inputDiv.style.display = 'none';
var func = core.platform.successCallback; var func = core.platform.successCallback;
core.platform.successCallback = core.platform.errorCallback = null; core.platform.successCallback = core.platform.errorCallback = null;
if (func) func(main.dom.inputBox.value); if (func) func(main.dom.inputBox.value);
} }
main.dom.inputNo.onclick = function () { main.dom.inputNo.onclick = function () {
main.dom.inputDiv.style.display = 'none'; main.dom.inputDiv.style.display = 'none';
var func = core.platform.errorCallback; var func = core.platform.errorCallback;
core.platform.successCallback = core.platform.errorCallback = null; core.platform.successCallback = core.platform.errorCallback = null;
if (func) func(null); if (func) func(null);
} }
}//listen end }//listen end

View File

@ -1,3 +1,4 @@
/// <reference path="../runtime.d.ts" />
var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
{ {
"events": { "events": {
@ -1571,7 +1572,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
try { try {
eval(core.floors[core.status.floorId].parallelDo); eval(core.floors[core.status.floorId].parallelDo);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
} }
} }

View File

@ -1,3 +1,4 @@
/// <reference path="../runtime.d.ts" />
var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
{ {
"init": function () { "init": function () {
@ -17,7 +18,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// 可以在任何地方如afterXXX或自定义脚本事件调用函数方法为 core.plugin.xxx(); // 可以在任何地方如afterXXX或自定义脚本事件调用函数方法为 core.plugin.xxx();
// 从V2.6开始插件中用this.XXX方式定义的函数也会被转发到core中详见文档-脚本-函数的转发。 // 从V2.6开始插件中用this.XXX方式定义的函数也会被转发到core中详见文档-脚本-函数的转发。
}, },
"drawLight": function () { "drawLight": function () {
// 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...) // 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...)
@ -78,7 +79,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
ctx.globalCompositeOperation = 'source-over'; ctx.globalCompositeOperation = 'source-over';
// 可以在任何地方如afterXXX或自定义脚本事件调用函数方法为 core.plugin.xxx(); // 可以在任何地方如afterXXX或自定义脚本事件调用函数方法为 core.plugin.xxx();
} }
}, },
"shop": function () { "shop": function () {
// 【全局商店】相关的功能 // 【全局商店】相关的功能
// //
@ -272,7 +273,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
} }
return false; return false;
}, 60); }, 60);
}, },
"removeMap": function () { "removeMap": function () {
// 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。 // 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。
// 推荐用法: // 推荐用法:
@ -359,7 +360,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
} }
}); });
} }
}, },
"fiveLayers": function () { "fiveLayers": function () {
// 是否启用五图层增加背景2层和前景2层 将__enable置为true即会启用启用后请保存后刷新编辑器 // 是否启用五图层增加背景2层和前景2层 将__enable置为true即会启用启用后请保存后刷新编辑器
// 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层 // 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层
@ -369,7 +370,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (!__enable) return; if (!__enable) return;
// 创建新图层 // 创建新图层
function createCanvas(name, zIndex) { function createCanvas (name, zIndex) {
if (!name) return; if (!name) return;
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
canvas.id = name; canvas.id = name;
@ -513,7 +514,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
fg2Array: this._getBgFgMapArray('fg2', floorId) fg2Array: this._getBgFgMapArray('fg2', floorId)
}; };
} }
}, },
"itemShop": function () { "itemShop": function () {
// 道具商店相关的插件 // 道具商店相关的插件
// 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找) // 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找)
@ -569,7 +570,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// Step 2获得列表并展示 // Step 2获得列表并展示
list = choices.filter(function (one) { list = choices.filter(function (one) {
if (one.condition != null && one.condition != '') { if (one.condition != null && one.condition != '') {
try { if (!core.calValue(one.condition)) return false; } catch (e) {} try { if (!core.calValue(one.condition)) return false; } catch (e) { }
} }
return (type == 0 && one.money != null) || (type == 1 && one.sell != null); return (type == 0 && one.money != null) || (type == 1 && one.sell != null);
}); });
@ -602,7 +603,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (curr == selectItem) { if (curr == selectItem) {
// 绘制描述,文字自动放缩 // 绘制描述,文字自动放缩
var text = core.material.items[item.id].text || "该道具暂无描述"; var text = core.material.items[item.id].text || "该道具暂无描述";
try { text = core.replaceText(text); } catch (e) {} try { text = core.replaceText(text); } catch (e) { }
for (var fontSize = 20; fontSize >= 8; fontSize -= 2) { for (var fontSize = 20; fontSize >= 8; fontSize -= 2) {
var config = { left: 10, fontSize: fontSize, maxWidth: 403 }; var config = { left: 10, fontSize: fontSize, maxWidth: 403 };
var height = core.getTextContentHeight(text, config); var height = core.getTextContentHeight(text, config);
@ -819,7 +820,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
]); ]);
} }
}, },
"enemyLevel": function () { "enemyLevel": function () {
// 此插件将提供怪物手册中的怪物境界显示 // 此插件将提供怪物手册中的怪物境界显示
// 使用此插件需要先给每个怪物定义境界,方法如下: // 使用此插件需要先给每个怪物定义境界,方法如下:
@ -907,7 +908,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
} }
}, },
"dynamicHp": function () { "dynamicHp": function () {
// 此插件允许人物血量动态进行变化 // 此插件允许人物血量动态进行变化
// 原作Fux2老黄鸡 // 原作Fux2老黄鸡
@ -939,7 +940,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.setStatusBarInnerHTML('hp', _currentHp); core.setStatusBarInnerHTML('hp', _currentHp);
} }
}); });
}, },
"multiHeros": function () { "multiHeros": function () {
// 多角色插件 // 多角色插件
// Step 1: 启用本插件 // Step 1: 启用本插件
@ -1022,9 +1023,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
var toSave = {}; var toSave = {};
// 暂时干掉 drawTip 和 音效,避免切装时的提示 // 暂时干掉 drawTip 和 音效,避免切装时的提示
var _drawTip = core.ui.drawTip; var _drawTip = core.ui.drawTip;
core.ui.drawTip = function () {}; core.ui.drawTip = function () { };
var _playSound = core.control.playSound; var _playSound = core.control.playSound;
core.control.playSound = function () {} core.control.playSound = function () { }
// 记录当前录像,因为可能存在换装问题 // 记录当前录像,因为可能存在换装问题
core.clearRouteFolding(); core.clearRouteFolding();
var routeLength = core.status.route.length; var routeLength = core.status.route.length;
@ -1085,7 +1086,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
]); ]);
core.setFlag("heroId", toHeroId); // 保存切换到的角色ID core.setFlag("heroId", toHeroId); // 保存切换到的角色ID
} }
}, },
"itemCategory": function () { "itemCategory": function () {
// 物品分类插件。此插件允许你对消耗道具和永久道具进行分类,比如标记「宝物类」「剧情道具」「药品」等等。 // 物品分类插件。此插件允许你对消耗道具和永久道具进行分类,比如标记「宝物类」「剧情道具」「药品」等等。
// 使用方法: // 使用方法:
@ -1223,7 +1224,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return true; return true;
}, 100); }, 100);
}, },
"heroFourFrames": function () { "heroFourFrames": function () {
// 样板的勇士/跟随者移动时只使用2、4两帧观感较差。本插件可以将四帧全用上。 // 样板的勇士/跟随者移动时只使用2、4两帧观感较差。本插件可以将四帧全用上。
@ -1276,7 +1277,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
} }
return false; return false;
} }
}, },
"startCanvas": function () { "startCanvas": function () {
// 使用本插件可以将自绘的标题界面居中。仅在【标题开启事件化】后才有效。 // 使用本插件可以将自绘的标题界面居中。仅在【标题开启事件化】后才有效。
// 由于一些技术性的原因,标题界面事件化无法应用到覆盖状态栏的整个界面。 // 由于一些技术性的原因,标题界面事件化无法应用到覆盖状态栏的整个界面。
@ -1297,8 +1298,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
_isTitleCanvasEnabled = true; _isTitleCanvasEnabled = true;
// 禁用窗口resize // 禁用窗口resize
window.onresize = function () {}; window.onresize = function () { };
core.resize = function () {} core.resize = function () { }
// 隐藏状态栏 // 隐藏状态栏
core.dom.statusBar.style.display = 'none'; core.dom.statusBar.style.display = 'none';
@ -1324,7 +1325,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this._resetTitleCanvas = function () { this._resetTitleCanvas = function () {
if (!_isTitleCanvasEnabled) return; if (!_isTitleCanvasEnabled) return;
_isTitleCanvasEnabled = false; _isTitleCanvasEnabled = false;
window.onresize = function () { try { main.core.resize(); } catch (e) { main.log(e); } } window.onresize = function () { try { main.core.resize(); } catch (ee) { console.error(ee) } }
core.resize = function () { return core.control.resize(); } core.resize = function () { return core.control.resize(); }
core.resize(); core.resize();
core.actions._getClickLoc = _getClickLoc; core.actions._getClickLoc = _getClickLoc;
@ -1362,5 +1363,5 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.plugin._resetTitleCanvas(); core.plugin._resetTitleCanvas();
_loadData.call(core.control, data, callback); _loadData.call(core.control, data, callback);
} }
} }
} }

7
runtime.d.ts vendored
View File

@ -2924,6 +2924,13 @@ type core = {
} & control & events & loader & enemys & items & maps & ui & utils & icons & actions & plugins } & control & events & loader & enemys & items & maps & ui & utils & icons & actions & plugins
declare class main {
readonly core: core
/** 输出内容极不好用建议换成console*/
log(e: string | Error, error: boolean): void
}
declare let core: core declare let core: core
declare let flags: { [x: string]: any } declare let flags: { [x: string]: any }
declare let hero = core.status.hero declare let hero = core.status.hero