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 () {
var editor_blockly = {entryType:'event'};
var editor_blockly = { entryType: 'event' };
editor.uivalues.disableBlocklyReplace = editor.config.get("disableBlocklyReplace", false);
var replaceCheckbox = document.getElementById('blocklyReplace');
@ -62,7 +62,7 @@ editor_blockly = function () {
matchBrackets: true,
lineWrapping: true,
continueComments: "Enter",
extraKeys: {"Ctrl-Q": "toggleComment"},
extraKeys: { "Ctrl-Q": "toggleComment" },
});
codeAreaHL.on('changes', function () {
editor_blockly.highlightParse(!changeFromBlockly);
@ -103,8 +103,8 @@ editor_blockly = function () {
editor_blockly.parse = function () {
MotaActionFunctions.parse(
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
return {'<': '&lt;', '>': '&gt;', '&': '&amp;'}[c];
}).replace(/\\(r|f|i|c|d|e|g|z)/g,'\\\\$1')),
return { '<': '&lt;', '>': '&gt;', '&': '&amp;' }[c];
}).replace(/\\(r|f|i|c|d|e|g|z)/g, '\\\\$1')),
editor_blockly.isCommonEntry() ? 'common' : editor_blockly.entryType
);
}
@ -132,7 +132,7 @@ editor_blockly = function () {
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
editor_blockly.show = function () {
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected(false);
if (typeof (selectBox) !== typeof (undefined)) selectBox.isSelected(false);
document.getElementById('left6').style = '';
for (var ii = 0, node; node = blocklyWidgetDiv[ii]; ii++) {
node.style.zIndex = 201;
@ -172,14 +172,14 @@ editor_blockly = function () {
alert('你尚未解析修改后的内容,请进行解析或放弃操作');
return;
}
if(editor_blockly.workspace.topBlocks_.length>=2){
if (editor_blockly.workspace.topBlocks_.length >= 2) {
editor_blockly.setValue('入口方块只能有一个');
return;
}
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;
if(blockType!==eventType+'_m' && !(editor_blockly.isCommonEntry() && blockType == 'common_m')){
if (blockType !== eventType + '_m' && !(editor_blockly.isCommonEntry() && blockType == 'common_m')) {
editor_blockly.setValue('入口方块类型错误');
return;
}
@ -196,7 +196,7 @@ editor_blockly = function () {
input.onchange();
}
if (codeAreaHL.getValue() === '') {
eventType==='shop'?setvalue('[]'):setvalue('null');
eventType === 'shop' ? setvalue('[]') : setvalue('null');
return;
}
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
@ -255,7 +255,7 @@ editor_blockly = function () {
var _isTextAttributeSet = false;
editor_blockly.previewBlock = function (b,args) {
editor_blockly.previewBlock = function (b, args) {
var previewTextDrawing = function (content) {
var arr = [];
@ -263,9 +263,9 @@ editor_blockly = function () {
var list = str.split(",");
if (list.length == 3 || list.length == 5 || list.length >= 9) {
var name = list[0];
var obj = {"type": "drawImage"};
var obj = { "type": "drawImage" };
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);
}
obj.image = name;
@ -282,7 +282,7 @@ editor_blockly = function () {
obj.h1 = parseFloat(list[8]);
}
if (list.length >= 10) {
arr.push({"type": "setAttribute", "alpha": parseFloat(list[9])});
arr.push({ "type": "setAttribute", "alpha": parseFloat(list[9]) });
}
if (list.length >= 11) {
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') + "]";
eval("var obj="+code);
eval("var obj=" + code);
if (obj.length == 0) return true;
obj = obj[0];
switch (b.type) {
@ -326,40 +326,46 @@ editor_blockly = function () {
alert('已成功设置此属性为显示文章的预览属性!')
break;
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] + ")",
"style": "rgba(255,0,0,0.5)"}]);
"style": "rgba(255,0,0,0.5)"
}]);
break;
case 'showImage_s': // 显示图片
case 'showImage_1_s':
if (obj.sloc) {
editor.uievent.previewUI([
{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: "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
}
]);
} else {
editor.uievent.previewUI([
{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: "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 }
]);
}
break;
case 'showGif_s': // 显示动图
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;
case 'setCurtain_0_s': // 更改色调
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;
case 'floorOneImage': // 楼层贴图
obj.w = obj.w / (obj.frame || 1);
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;
case 'previewUI_s': // 预览
@ -370,11 +376,11 @@ editor_blockly = function () {
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]);
value = main.nameMap[value] || value;
editor.uievent.selectMaterial([value], '请选择素材', material[0], function (one) {
@ -388,7 +394,7 @@ editor_blockly = function () {
// 检测是否别名替换
for (var name in main.nameMap) {
if (main.nameMap[name] == value) {
if (confirm("检测到该文件存在别名:"+name+"\n是否使用别名进行替换")) {
if (confirm("检测到该文件存在别名:" + name + "\n是否使用别名进行替换")) {
b.setFieldValue(name, material[1]);
return;
} 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);
//多行编辑
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')) {
newvalue = newvalue.split('\n').join('\\n');
}
@ -415,23 +421,23 @@ editor_blockly = function () {
editor_blockly.doubleClickBlock = function (blockId) {
var b = editor_blockly.workspace.getBlockById(blockId);
if (b && MotaActionBlocks[b.type].previewBlock){
editor_blockly.previewBlock(b,MotaActionBlocks[b.type].previewBlock)
if (b && MotaActionBlocks[b.type].previewBlock) {
editor_blockly.previewBlock(b, MotaActionBlocks[b.type].previewBlock)
return;
}
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;
}
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;
}
if (b && MotaActionBlocks[b.type].doubleclicktext) { //多行编辑
editor_blockly.doubleclicktext(b,MotaActionBlocks[b.type].doubleclicktext);
editor_blockly.doubleclicktext(b, MotaActionBlocks[b.type].doubleclicktext);
return;
}
}
@ -439,7 +445,7 @@ editor_blockly = function () {
editor_blockly.selectPointFromButton = function () {
var b = Blockly.selected;
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;
} else {
editor.uievent.selectPoint();
@ -448,11 +454,11 @@ editor_blockly = function () {
editor_blockly.showKeyCodes = function () {
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'
+'空格:13 回车:32 ESC:27 后退:8 Tab:9 Shift:16 Ctrl:17 Alt:18\nPgUp:33 PgDn:34 左:37 上:38 右:39 下:40\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更多键值请自行百度查表')
}
editor_blockly.lastUsedType=[
editor_blockly.lastUsedType = [
'text_0_s',
'comment_s',
'show_s',
@ -469,33 +475,33 @@ editor_blockly = function () {
'setBlock_s',
'insert_1_s'
]; // 最常用的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);
if(!b)return;
if (!b) return;
var blockType = b.type;
if(!blockType || blockType.indexOf("_s")!==blockType.length-2 || blockType==='pass_s')return;
editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) {return v!==blockType;});
if (!blockType || blockType.indexOf("_s") !== blockType.length - 2 || blockType === 'pass_s') return;
editor_blockly.lastUsedType = editor_blockly.lastUsedType.filter(function (v) { return v !== blockType; });
if (editor_blockly.lastUsedType.length >= editor_blockly.lastUsedTypeNum)
editor_blockly.lastUsedType.pop();
editor_blockly.lastUsedType.unshift(blockType);
document.getElementById("searchBlock").value='';
document.getElementById("searchBlock").value = '';
}
// 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;
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;
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.closeToolbox = function() {
editor_blockly.closeToolbox = function () {
editor_blockly.workspace.toolbox_.clearSelection();
}
@ -514,14 +520,14 @@ editor_blockly = function () {
if (value == '') return editor_blockly.lastUsedType;
var results = [];
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];
if(block && block.json) {
if ((block.json.type||"").toLowerCase().indexOf(value)>=0
|| (block.json.message0||"").toLowerCase().indexOf(value)>=0
|| (block.json.tooltip||"").toLowerCase().indexOf(value)>=0) {
if (block && block.json) {
if ((block.json.type || "").toLowerCase().indexOf(value) >= 0
|| (block.json.message0 || "").toLowerCase().indexOf(value) >= 0
|| (block.json.tooltip || "").toLowerCase().indexOf(value) >= 0) {
results.push(name);
if (results.length>=editor_blockly.lastUsedTypeNum)
if (results.length >= editor_blockly.lastUsedTypeNum)
break;
}
}
@ -532,7 +538,7 @@ editor_blockly = function () {
// ------ 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;
@ -547,8 +553,8 @@ editor_blockly = function () {
if (fv != editor.currentFloorId || editor_blockly.entryType == 'commonEvent') block.setFieldValue(fv, arr[2]);
else block.setFieldValue(arr[3] ? fv : "", arr[2]);
}
block.setFieldValue(xv+"", arr[0]);
block.setFieldValue(yv+"", arr[1]);
block.setFieldValue(xv + "", arr[0]);
block.setFieldValue(yv + "", arr[1]);
if (block.type == 'changeFloor_m' || block.type == 'changeFloor_s') {
block.setFieldValue("floorId", "Floor_List_0");
block.setFieldValue("loc", "Stair_List_0");
@ -565,7 +571,7 @@ editor_blockly = function () {
var index = Math.max(content.lastIndexOf(":"), content.lastIndexOf(""));
if (index >= 0) {
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 (before.endsWith("状态") || (ch == ':' && before.endsWith("status"))) {
var list = Object.keys(core.status.hero);
@ -604,12 +610,12 @@ editor_blockly = function () {
return one != token && one.startsWith(token);
})
} 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);
if (index2 >= 0) {
before = content.substring(0, index2);
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) {
list = MotaActionFunctions.pattern.replaceEnemyValueList.map(function (v) {
return v[1];
@ -651,7 +657,7 @@ editor_blockly = function () {
// 提供 flags.xxx 补全
index = content.lastIndexOf("flags.");
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 one != token && one.startsWith(token)
&& /^[a-zA-Z_]\w*$/.test(one);
@ -661,7 +667,7 @@ editor_blockly = function () {
// 提供 hero.xxx 补全
index = content.lastIndexOf("hero.");
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 one != token && one.startsWith(token);
}).sort();
@ -696,14 +702,14 @@ editor_blockly = function () {
}).sort();
}
var namesObj={};
var namesObj = {};
namesObj.allIds = ["this"].concat(core.getAllIconIds());
namesObj.allIconIds = namesObj.allIds.concat(Object.keys(core.statusBar.icons).filter(function (x) {
return core.statusBar.icons[x] instanceof Image;
}));
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);
if (MotaActionFunctions && !MotaActionFunctions.disableReplace) {
namesObj.allEnemys = namesObj.allEnemys.concat(MotaActionFunctions.pattern.replaceEnemyList.map(function (x) {
@ -721,11 +727,11 @@ editor_blockly = function () {
}).map(function (x) { return x[1]; }));
}
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)
.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)
.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.allFloorIds = core.floorIds;
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++){
if (MotaActionBlocks[type][names] && eval(MotaActionBlocks[type][names]).indexOf(name)!==-1) {
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) {
return filter(namesObj[names], content);
}
}
@ -807,25 +813,25 @@ editor_blockly = function () {
editor_blockly.completeItems = [];
editor_blockly.onTextFieldCreate = function (self, htmlInput) {
var pb=self.sourceBlock_
var pb = self.sourceBlock_
var args = MotaActionBlocks[pb.type].args
var targetf=args[args.indexOf(self.name)+1]
var targetf = args[args.indexOf(self.name) + 1]
// ------ colour
if(targetf && targetf.slice(0,7)==='Colour_'){
if (targetf && targetf.slice(0, 7) === 'Colour_') {
var inputDom = htmlInput;
// var getValue=function(){ // 获得自己的字符串
// return pb.getFieldValue(self.name);
// }
var setValue = function(newValue){ // 设置右边颜色块的css颜色
var setValue = function (newValue) { // 设置右边颜色块的css颜色
pb.setFieldValue(newValue, targetf)
}
// 给inputDom绑事件
inputDom.oninput=function(){
var value=inputDom.value
if(/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)){
setValue('rgba('+value+')')
inputDom.oninput = function () {
var value = inputDom.value
if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)) {
setValue('rgba(' + value + ')')
}
}
}
@ -866,14 +872,14 @@ editor_blockly = function () {
});
editor_blockly.completeItems.unshift(text);
},
filter: function () {return true;},
filter: function () { return true; },
item: function (text, input) {
var id = text.label, info = core.getBlockInfo(id);
var li = document.createElement("li");
li.setAttribute("role", "option");
li.setAttribute("aria-selected", "false");
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;
if (info) {
var height = (info.height || 32), width = 32;
@ -907,10 +913,10 @@ editor_blockly = function () {
value = value.substring(0, index);
// cal prefix
awesomplete.prefix = value;
for (var i = index - 1; i>=0; i--) {
for (var i = index - 1; i >= 0; i--) {
var c = value.charAt(i);
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;
}
}
@ -945,16 +951,16 @@ editor_blockly = function () {
// --- modify Blockly
Blockly.FieldColour.prototype.showEditor_ = function() {
Blockly.FieldColour.prototype.showEditor_ = function () {
Blockly.WidgetDiv.hide();
// console.log('here')
var self=this;
var pb=self.sourceBlock_
var self = this;
var pb = self.sourceBlock_
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颜色
var f = pb.getFieldValue(targetf);
if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(f)) {
@ -964,9 +970,9 @@ Blockly.FieldColour.prototype.showEditor_ = function() {
// 也可以用 pb.getFieldValue(targetf) 获得颜色块左边的域的内容
}
var setValue=function(newValue){ // css颜色
var setValue = function (newValue) { // css颜色
self.setValue(newValue)
pb.setFieldValue(newValue.replace("rgba(","").replace(")",""), targetf) // 放在颜色块左边的域中
pb.setFieldValue(newValue.replace("rgba(", "").replace(")", ""), targetf) // 放在颜色块左边的域中
}
setTimeout(function () {
@ -983,7 +989,7 @@ Blockly.FieldColour.prototype.setValue = function (colour) {
this.doValueUpdate_(colour);
}
Blockly.FieldColour.prototype.initView = function() {
Blockly.FieldColour.prototype.initView = function () {
this.size_ = new Blockly.utils.Size(
this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,
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(
this, this.sourceBlock_.RTL, this.widgetDispose_.bind(this));
this.htmlInput_ = this.widgetCreate_();
@ -1005,12 +1011,12 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
editor_blockly.onTextFieldCreate(this, this.htmlInput_);
if (!quietInput) {
this.htmlInput_.focus({preventScroll:true});
this.htmlInput_.focus({ preventScroll: true });
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)) {
Blockly.WidgetDiv.hide();
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);
// force to resize the input
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);
// force to resize the input
this.htmlInput_.style.height = Blockly.WidgetDiv.DIV.style.height;
};
Blockly.copy_ = function(toCopy) {
Blockly.copy_ = function (toCopy) {
if (toCopy.isComment) {
var xml = toCopy.toXmlWithXY();
} else {
@ -1061,7 +1067,7 @@ Blockly.copy_ = function(toCopy) {
* Paste the provided block onto the workspace.
* @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 >=
this.remainingCapacity()) {
return;
@ -1081,7 +1087,7 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) {
// -- Support showing disabled blocks
Blockly.Generator.prototype.blockToCode = function(block, opt_thisOnly) {
Blockly.Generator.prototype.blockToCode = function (block, opt_thisOnly) {
if (this.isInitialized === false) {
console.warn(
'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);
};
Blockly.BlockSvg.prototype.generateContextMenu = function() {
Blockly.BlockSvg.prototype.generateContextMenu = function () {
if (this.workspace.options.readOnly || !this.contextMenu) {
return null;
}
@ -1153,7 +1159,7 @@ Blockly.BlockSvg.prototype.generateContextMenu = function() {
menuOptions.push({
text: this.isEnabled() ? Blockly.Msg['DISABLE_BLOCK'] : Blockly.Msg['ENABLE_BLOCK'],
enabled: !this.getInheritedDisabled(),
callback: function() {
callback: function () {
var group = Blockly.Events.getGroup();
if (!group) {
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_;
if (!value) return Blockly.Field.NBSP;
var curr = '', text = '';

View File

@ -7,7 +7,7 @@ editor_mappanel_wrapper = function (editor) {
*/
editor.uifunctions.fillPos = function (pos) {
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);
}
@ -85,7 +85,7 @@ editor_mappanel_wrapper = function (editor) {
*/
editor.uifunctions.map_ondown = function (e) {
editor.uivalues.selectedArea = null;
editor.uivalues.lastMoveE=e;
editor.uivalues.lastMoveE = e;
var loc = editor.uifunctions.eToLoc(e);
var pos = editor.uifunctions.locToPos(loc, true);
editor.pos = pos;
@ -131,9 +131,9 @@ editor_mappanel_wrapper = function (editor) {
var _getGridByPos = function (pos) {
if (editor.uivalues.bigmap) {
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 {
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.uivalues.lastMoveE=e;
editor.uivalues.lastMoveE = e;
if (!editor.uivalues.bigmap && !editor.isMobile && editor.dom.midMenu.style.display == 'none') {
var loc = editor.uifunctions.eToLoc(e);
var pos = editor.uifunctions.locToPos(loc);
_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()) {
@ -190,9 +190,9 @@ editor_mappanel_wrapper = function (editor) {
// draw rect
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)';
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));
}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);
}
@ -234,7 +234,7 @@ editor_mappanel_wrapper = function (editor) {
// draw rect
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)';
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));
}
@ -246,7 +246,7 @@ editor_mappanel_wrapper = function (editor) {
editor.uifunctions.map_onmoveout = function () {
if (!editor.uivalues.bigmap && !editor.isMobile) {
_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;
ee.preventDefault();
ee.stopPropagation();
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))) {
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))) {
editor.uifunctions.showMidMenu(e.clientX, e.clientY);
editor.uivalues.holdingPath = 0;
editor.uivalues.stepPostfix = [];
@ -272,7 +272,7 @@ editor_mappanel_wrapper = function (editor) {
if (e.buttons == 2) {
// 右键拖拽: 选中区域
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 {
// 左键拖拽: 交换
@ -321,11 +321,11 @@ editor_mappanel_wrapper = function (editor) {
var x0 = editor.uivalues.stepPostfix[0].x;
var y0 = editor.uivalues.stepPostfix[0].y;
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++) {
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]);
editor[editor.layerMod][editor.uivalues.stepPostfix[ii].y][editor.uivalues.stepPostfix[ii].x] = editor.ids[editor.indexs[idnum + dx+dy*imgWidth]];
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]);
editor[editor.layerMod][editor.uivalues.stepPostfix[ii].y][editor.uivalues.stepPostfix[ii].x] = editor.ids[editor.indexs[idnum + dx + dy * imgWidth]];
}
} else {
// 检测是否是填充模式
@ -338,11 +338,11 @@ editor_mappanel_wrapper = function (editor) {
editor[editor.layerMod][curry][currx] = editor.info;
// 检查上下楼梯绑定
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();
}
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();
}
}
@ -359,7 +359,7 @@ editor_mappanel_wrapper = function (editor) {
}
})
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);
}
@ -377,21 +377,21 @@ editor_mappanel_wrapper = function (editor) {
*/
editor.uifunctions._fillMode_bfs = function (array, x, y, maxWidth, maxHeight) {
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;
}
var number = _getNumber(x, y) || 0;
var visited = {}, result = [];
var list = [{x:x, y:y}];
var list = [{ x: x, y: y }];
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;
visited[key] = true;
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];
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)
wheel(Math.sign(e.detail));
}
catch (ee) {
console.log(ee);
catch (e) {
console.error(e);
}
return false;
}
@ -532,7 +532,7 @@ editor_mappanel_wrapper = function (editor) {
* 隐藏右键菜单
*/
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';
}
@ -575,8 +575,8 @@ editor_mappanel_wrapper = function (editor) {
editor.uifunctions._extraEvent_changeFloor = function () {
var changeFloor = editor.currentFloorData.changeFloor[editor.pos.x + "," + editor.pos.y];
if (!changeFloor) return false;
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;
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 info = core.events._changeFloor_getInfo(changeFloor.floorId, changeFloor.stair, targetLoc);
editor_mode.onmode('nextChange');
editor_mode.onmode('floor');
@ -629,7 +629,7 @@ editor_mappanel_wrapper = function (editor) {
*/
editor.uifunctions._extraEvent_bindSpecialDoor = function (thisevent) {
if (thisevent.id != 'specialDoor') return false;
var number = parseInt(prompt("请输入该机关门的怪物数量", "0"))|| 0;
var number = parseInt(prompt("请输入该机关门的怪物数量", "0")) || 0;
if (number <= 0) return true;
editor.uivalues.bindSpecialDoor.n = number;
editor.uivalues.bindSpecialDoor.loc = editor.pos.x + ',' + editor.pos.y;
@ -662,15 +662,15 @@ editor_mappanel_wrapper = function (editor) {
"delayExecute": false,
"multiExecute": false,
"data": [
{"type": "openDoor"},
{"type": "setValue", "name": doorFlag, "operator": "=", "value": "null"},
{ "type": "openDoor" },
{ "type": "setValue", "name": doorFlag, "operator": "=", "value": "null" },
]
}
};
bindSpecialDoor.enemys.forEach(function (loc) {
if (!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) {
if (err) {
@ -841,13 +841,13 @@ editor_mappanel_wrapper = function (editor) {
editor.layerMod = layer;
var canvas = ['ev', 'ev2'].concat(editor.dom.canvas);
canvas.forEach(function (one) {
editor.dom[one+'c'].style.opacity = 1;
editor.dom[one + 'c'].style.opacity = 1;
});
if (layer != 'map') {
canvas.filter(function (one) {
return one + 'map' != editor.layerMod
}).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');
saveFloor.classList.add('highlight');
}
editor.uifunctions.unhighlightSaveFloorButton=function(){
editor.uifunctions.unhighlightSaveFloorButton = function () {
var saveFloor = document.getElementById('saveFloor');
saveFloor.classList.remove('highlight');
}
@ -982,7 +982,7 @@ editor_mappanel_wrapper = function (editor) {
openDoc.onclick = function () {
if (editor.isMobile) {
if (!confirm('你确定要打开帮助文档吗?')) return;
window.location='/_docs/';
window.location = '/_docs/';
} else {
window.open('/_docs/', '_blank');
}
@ -994,7 +994,7 @@ editor_mappanel_wrapper = function (editor) {
e.stopImmediatePropagation();
e.stopPropagation();
if (editor.isMobile) return false;
editor.uivalues.tileSize = [1,1];
editor.uivalues.tileSize = [1, 1];
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
@ -1011,7 +1011,7 @@ editor_mappanel_wrapper = function (editor) {
if (e.button == 2) {
lastUsed[index].istop = lastUsed[index].istop ? 0 : 1;
printf("已"+(lastUsed[index].istop ? '置顶' : '取消置顶')+"该图块");
printf("已" + (lastUsed[index].istop ? '置顶' : '取消置顶') + "该图块");
editor.config.set('lastUsed', editor.uivalues.lastUsed);
editor.updateLastUsedMap();
return false;
@ -1031,7 +1031,7 @@ editor_mappanel_wrapper = function (editor) {
editor.uivalues.lastUsed = [];
editor.config.set('lastUsed', []);
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.uivalues.tileSize = [1,1];
editor.uivalues.tileSize = [1, 1];
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;
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 (x0 > x1) { x0 ^= x1; x1 ^= x0; x0 ^= x1; }//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 j = y0; j<= y1; ++j) {
for (var j = y0; j <= y1; ++j) {
var map = core.clone(editor[editor.layerMod][j][i]);
var events = {};
fields.forEach(function(v){
events[v] = core.clone(editor.currentFloorData[v][i+','+j]);
fields.forEach(function (v) {
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;
}
editor.constructor.prototype.pasteToPos = function (info, pos) {
editor.uivalues.tileSize = [1,1];
editor.uivalues.tileSize = [1, 1];
if (info == null) return;
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;
var w = info.w || 1, h = info.h || 1, layer = info.layer || 'map';
var data = core.clone(info.data || []);
for (var i = pos.x; i < pos.x+w; ++i) {
for (var j = pos.y; j < pos.y+h; ++j) {
for (var i = pos.x; i < pos.x + w; ++i) {
for (var j = pos.y; j < pos.y + h; ++j) {
var one = data.shift();
if (j >= editor[editor.layerMod].length || i >= editor[editor.layerMod][0].length) continue;
editor[editor.layerMod][j][i] = core.clone(one.map);
if (layer == 'map' && editor.layerMod == 'map') {
fields.forEach(function(v){
if (one.events[v] == null) delete editor.currentFloorData[v][i+","+j];
else editor.currentFloorData[v][i+","+j] = core.clone(one.events[v]);
fields.forEach(function (v) {
if (one.events[v] == null) delete editor.currentFloorData[v][i + "," + j];
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.uivalues.tileSize = [1,1];
editor.uivalues.tileSize = [1, 1];
if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
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.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
throw (err)
}
;printf('移动事件成功');
; printf('移动事件成功');
editor.drawPosSelection();
if (callback) 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.x == endPos.x && startPos.y == endPos.y) return;
var startInfo = editor.copyFromPos(startPos);
@ -1114,9 +1114,9 @@ editor_mappanel_wrapper = function (editor) {
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
throw (err)
}
;printf('交换事件成功');
; printf('交换事件成功');
editor.drawPosSelection();
if (callback) callback();
});
@ -1155,8 +1155,8 @@ editor_mappanel_wrapper = function (editor) {
if (clearPos)
editor[editor.layerMod][j][i] = 0;
if (editor.layerMod == 'map') {
fields.forEach(function(v){
delete editor.currentFloorData[v][i+","+j];
fields.forEach(function (v) {
delete editor.currentFloorData[v][i + "," + j];
});
}
}
@ -1165,9 +1165,9 @@ editor_mappanel_wrapper = function (editor) {
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
throw (err)
}
;printf(clearPos?'清空该点和事件成功':'只清空该点事件成功');
; printf(clearPos ? '清空该点和事件成功' : '只清空该点事件成功');
editor.drawPosSelection();
if (callback) callback();
});

View File

@ -41,7 +41,7 @@ editor_uievent_wrapper = function (editor) {
// 绘制UI
var background = uievent.elements.select.value;
if (background == 'thumbnail') {
core.drawThumbnail(editor.currentFloorId, null, {ctx: 'uievent'});
core.drawThumbnail(editor.currentFloorId, null, { ctx: 'uievent' });
}
else {
core.fillRect('uievent', 0, 0, core.__PIXELS__, core.__PIXELS__, background);
@ -61,7 +61,7 @@ editor_uievent_wrapper = function (editor) {
else if (type == "choices") {
for (var i = 0; i < data.choices.length; i++) {
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);
}
core.saveCanvas('uievent');
@ -127,8 +127,8 @@ editor_uievent_wrapper = function (editor) {
uievent.close();
if (callback) {
if (multipoints.length > 0) {
callback(floorId, multipoints.map(function (one) { return one.split(',')[0]}).join(','),
multipoints.map(function (one) { return one.split(',')[1]}).join(','));
callback(floorId, multipoints.map(function (one) { return one.split(',')[0] }).join(','),
multipoints.map(function (one) { return one.split(',')[1] }).join(','));
} else {
callback(floorId, x, y);
}
@ -186,7 +186,7 @@ editor_uievent_wrapper = function (editor) {
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]);
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');
}
@ -235,10 +235,10 @@ editor_uievent_wrapper = function (editor) {
var x = uievent.values.left + Math.floor(e.offsetX / uievent.values.size);
var y = uievent.values.top + Math.floor(e.offsetY / uievent.values.size);
uievent.values.multipoints = uievent.values.multipoints || [];
if (uievent.values.multipoints.indexOf(x+","+y) >= 0) {
uievent.values.multipoints = uievent.values.multipoints.filter(function (o) { return o != x+","+y;})
if (uievent.values.multipoints.indexOf(x + "," + y) >= 0) {
uievent.values.multipoints = uievent.values.multipoints.filter(function (o) { return o != x + "," + y; })
} else {
uievent.values.multipoints.push(x+","+y);
uievent.values.multipoints.push(x + "," + y);
}
uievent.values.x = x;
uievent.values.y = y;
@ -272,7 +272,7 @@ editor_uievent_wrapper = function (editor) {
}
if (ii == 5) {
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) {
@ -311,7 +311,7 @@ editor_uievent_wrapper = function (editor) {
index += Math.sign(e.wheelDelta);
else if (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);
uievent.values.multipoints = [];
uievent.setPoint(core.floorIds[index]);
@ -492,12 +492,12 @@ editor_uievent_wrapper = function (editor) {
var checked = one == uievent.values.floorId;
var floor = core.floors[one];
if (floor == null) 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 += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\""+one+"\"' style='cursor: default'>"
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 += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\"" + one + "\"' style='cursor: default'>"
+ one + '' + floor.title + '' + "</span>";
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/>';
});
floorList.innerHTML = html;
@ -522,7 +522,7 @@ editor_uievent_wrapper = function (editor) {
}
span.appendChild(uievent.values.dom);
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 {
button.innerText = '预览';
span.style.display = 'none';
@ -545,7 +545,7 @@ editor_uievent_wrapper = function (editor) {
return;
}
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);
data2 = (transform ? data2.map(transform) : data2).filter(function (one) {
return one && data.indexOf(one) < 0;
@ -567,7 +567,7 @@ editor_uievent_wrapper = function (editor) {
uievent.elements.yes.onclick = function () {
var list = Array.from(document.getElementsByClassName('materialCheckbox')).filter(function (one) {
return one.checked;
}).map(function (one) {return one.getAttribute('key'); });
}).map(function (one) { return one.getAttribute('key'); });
uievent.close();
if (callback) callback(list);
}
@ -576,44 +576,44 @@ editor_uievent_wrapper = function (editor) {
// 显示每一项内容
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/>";
if (_isTileset) {
html += "<b style='margin-top: 5px;'>警告!额外素材一旦注册成功将不可删除,否则可能会导致素材错位风险!如果你不再想用某个额外素材,"
+"但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。</b><br/>"
+ "但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。</b><br/>"
}
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' : ''
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
// 预览图片
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 += '<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')) {
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 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>`;
}
// 预览动画
if (directory.indexOf('animates') >= 0) {
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/>';
});
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' : '';
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
// 预览图片
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 += '<br style="display:none" key="'+one+'"/><br/>';
html += '<br style="display:none" key="' + one + '"/><br/>';
}
})
html += "</p>";
@ -670,7 +670,7 @@ editor_uievent_wrapper = function (editor) {
} else {
button.innerText = '播放';
br.style.display = 'none';
progress.style.display='none';
progress.style.display = 'none';
span.style.display = 'none';
audio.pause();
}
@ -683,7 +683,7 @@ editor_uievent_wrapper = function (editor) {
}
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) {
audio.previousElementSibling.previousElementSibling.innerText = _format(audio.currentTime) + " / " + _format(audio.duration);
audio.nextElementSibling.setAttribute('value', audio.currentTime / audio.duration);
@ -709,7 +709,7 @@ editor_uievent_wrapper = function (editor) {
var canvas = document.createElement('canvas');
canvas.width = canvas.height = core.__PIXELS__;
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);
var canvas2 = document.createElement('canvas');
canvas2.style.position = 'absolute';
@ -738,7 +738,7 @@ editor_uievent_wrapper = function (editor) {
var _previewMaterialAnimate_buildSounds = function (span, content) {
var sounds = content.se || {};
if (typeof sounds == 'string') sounds = {1: sounds};
if (typeof sounds == 'string') sounds = { 1: sounds };
var pitch = content.pitch || {};
span.appendChild(document.createElement('br'));
@ -761,14 +761,14 @@ editor_uievent_wrapper = function (editor) {
var html = "";
html += "第 <select>";
for (var i = 1; i <= frames; ++i) {
html += "<option value="+i;
html += "<option value=" + i;
if (index == i) html += " selected";
html += ">"+i+"</option>";
html += ">" + i + "</option>";
}
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 += "<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 += '<br/>';
return html;
@ -798,7 +798,7 @@ editor_uievent_wrapper = function (editor) {
} else {
fs.readFile(filename, 'utf-8', function (e, d) {
if (e) {
alert('无法打开动画文件!'+e); return;
alert('无法打开动画文件!' + e); return;
}
uievent.values.animates[filename] = core.loader._loadAnimate(d);
if (uievent.values.animates[filename]) {
@ -856,11 +856,11 @@ editor_uievent_wrapper = function (editor) {
}
}
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+':raw'].pitch = pitch;
fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename+':raw']), 'utf-8', function (e, d) {
if (e) alert('无法修改音效文件!'+e);
uievent.values.animates[filename + ':raw'].pitch = pitch;
fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename + ':raw']), 'utf-8', function (e, d) {
if (e) alert('无法修改音效文件!' + e);
else {
alert('动画音效修改成功!别忘了在全塔属性中注册音效哦!');
}
@ -900,11 +900,11 @@ editor_uievent_wrapper = function (editor) {
if (callback) callback(list);
}
var keys=Array.from(comments.key)
var prefixStrings=Array.from(comments.prefix)
var keys = Array.from(comments.key)
var prefixStrings = Array.from(comments.prefix)
for (var index = 0; index < value.length; index++) {
if (keys.indexOf(value[index])==-1) {
prefixStrings.push(value[index]+': ')
if (keys.indexOf(value[index]) == -1) {
prefixStrings.push(value[index] + ': ')
keys.push(value[index])
}
}
@ -915,7 +915,7 @@ editor_uievent_wrapper = function (editor) {
if (index % 3 == 0) {
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) {
table += '</tr>';
}
@ -923,7 +923,7 @@ editor_uievent_wrapper = function (editor) {
if (keys.length % 3 != 0) table += '</tr>';
table += '</table>';
uievent.elements.extraBody.innerHTML = "<p>"+table+"</p>";
uievent.elements.extraBody.innerHTML = "<p>" + table + "</p>";
}
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 += "<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/>当前变量值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>"
uievent.elements.extraBody.innerHTML = html;
@ -1021,7 +1021,7 @@ editor_uievent_wrapper = function (editor) {
if (!core.material.items[itemId]) return;
var itemCls = core.material.items[itemId].cls;
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(',');
try {
@ -1029,13 +1029,13 @@ editor_uievent_wrapper = function (editor) {
for (var flag in flags) {
core.status.hero.flags[flag] = flags[flag];
}
} catch (e) {}
} catch (e) { }
var ctx = canvas2.getContext('2d');
if (core.domStyle.isVertical) {
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) {
canvas.width = canvas2.width = Math.round(core.__PIXELS__ * 0.31);
canvas.height = canvas2.height = core.__PIXELS__ + 3 + 38;
@ -1064,5 +1064,5 @@ editor_uievent_wrapper = function (editor) {
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";
function actions() {
function actions () {
this._init();
this.SIZE = core.__SIZE__;
this.HSIZE = core.__HALF_SIZE__;
@ -79,7 +79,7 @@ actions.prototype.registerAction = function (action, name, func, priority) {
}
this.unregisterAction(action, name);
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) {
return b.priority - a.priority;
@ -106,8 +106,8 @@ actions.prototype.doRegisteredAction = function (action) {
return true;
}
catch (e) {
main.log(e);
main.log("ERROR in actions["+actions[i].name+"].");
console.error(e);
main.log("ERROR in actions[" + actions[i].name + "].");
}
}
return false;
@ -115,7 +115,7 @@ actions.prototype.doRegisteredAction = function (action) {
actions.prototype._checkReplaying = function () {
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 false;
}
@ -160,7 +160,7 @@ actions.prototype.onkeyDown = function (e) {
actions.prototype._sys_onkeyDown = function (e) {
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) {
for (var ii = 0; ii < core.status.holdingKeys.length; ii++) {
if (core.status.holdingKeys[ii] === e.keyCode) {
@ -220,7 +220,7 @@ actions.prototype._sys_onkeyUp_replay = 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) {
for (var ii = 0; ii < core.status.holdingKeys.length; ii++) {
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;
core.status.downTime = new Date();
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.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);
core.timeout.onDownTimeout = null;
@ -658,7 +658,7 @@ actions.prototype._sys_onmove = function (x, y, px, py) {
core.timeout.onDownTimeout = null;
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 directionDistance = [pos.y - pos0.y, pos0.x - pos.x, pos0.y - pos.y, pos.x - pos0.x];
var max = 0, index = 4;
@ -668,12 +668,12 @@ actions.prototype._sys_onmove = function (x, y, px, py) {
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) {
pos.x += pos0.x;
pos.y += pos0.y;
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;
@ -703,7 +703,7 @@ actions.prototype._sys_onup = function (x, y, px, py) {
if ((core.status.stepPostfix || []).length == 0) return false;
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++) {
var pos0 = core.status.stepPostfix[ii - 1];
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) {
var statusBar = {'x': 0, 'y': 0};
var statusBar = { 'x': 0, 'y': 0 };
var size = 32;
size = size * core.domStyle.scale;
@ -750,7 +750,7 @@ actions.prototype._getClickLoc = function (x, y) {
var left = core.dom.gameGroup.offsetLeft + statusBar.x;
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;
}
@ -787,7 +787,7 @@ actions.prototype._sys_onmousewheel = function (direct) {
// 存读档
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);
return;
@ -862,14 +862,14 @@ actions.prototype._sys_longClick_lockControl = function (x, y, px, py) {
}
// 长按楼传器的箭头可以快速翻页
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);
return true;
}
}
// 长按SL上下页快速翻页
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 (["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) {
this._clickSL(x, y);
return true;
}
@ -1120,7 +1120,7 @@ actions.prototype._clickAction = function (x, y, px, py) {
}
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);
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
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.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);
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
delete core.status.event.timeout;
@ -1183,7 +1183,7 @@ actions.prototype._keyUpAction = function (keycode) {
}
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;
delete core.status.event.timeout;
core.setFlag('timeout', timeout);
@ -1200,19 +1200,19 @@ actions.prototype._keyUpAction = function (keycode) {
actions.prototype._clickBook = function (x, y) {
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.ui.drawBook(core.status.event.data - pageinfo.per_page);
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.ui.drawBook(core.status.event.data + pageinfo.per_page);
return;
}
// 返回
if (x >= this.LAST-2 && y == this.LAST) {
if (x >= this.LAST - 2 && y == this.LAST) {
core.playSound('取消');
if (core.events.recoverEvents(core.status.event.interval)) {
return;
@ -1230,7 +1230,7 @@ actions.prototype._clickBook = function (x, y) {
var per_page = pageinfo.per_page, page = parseInt(data / per_page);
var u = this.LAST / per_page;
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;
core.ui.drawBook(index);
core.ui._drawBookDetail(index);
@ -1286,12 +1286,12 @@ actions.prototype._clickBookDetail = function () {
////// 楼层传送器界面时的点击操作 //////
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-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-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 >= 0 && x <= this.HSIZE+3 && y >= 3 && y <= this.LAST - 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 + 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.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)
core.flyTo(core.floorIds[core.status.event.data]);
return;
}
@ -1331,7 +1331,7 @@ actions.prototype._keyUpFly = function (keycode) {
core.ui.closePanel();
}
if (keycode == 13 || keycode == 32 || keycode == 67)
this._clickFly(this.HSIZE-1, this.HSIZE-1);
this._clickFly(this.HSIZE - 1, this.HSIZE - 1);
return;
}
@ -1548,7 +1548,7 @@ actions.prototype._clickToolbox = function (x, y) {
var toolsPage = core.status.event.data.toolsPage;
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) {
core.status.event.data.toolsPage--;
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)) {
core.status.event.data.toolsPage++;
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) {
core.status.event.data.page--;
core.playSound('光标移动');
@ -1766,7 +1766,7 @@ actions.prototype._clickEquipbox = function (x, y) {
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);
if (core.status.event.data.page < lastPage) {
core.status.event.data.page++;
@ -1931,19 +1931,19 @@ actions.prototype._clickSL = function (x, y) {
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.ui._drawSLPanel(10 * (page - 1) + offset);
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.ui._drawSLPanel(10 * (page + 1) + offset);
return;
}
// 返回
if (x >= this.LAST-2 && y == this.LAST) {
if (x >= this.LAST - 2 && y == this.LAST) {
core.playSound('取消');
if (core.events.recoverEvents(core.status.event.interval))
return;
@ -1960,25 +1960,25 @@ actions.prototype._clickSL = function (x, y) {
core.ui._drawSLPanel(index);
}
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')
core.ui._drawSLPanel(1, true);
else {
page = parseInt((core.saves.saveIndex-1)/5);
offset = core.saves.saveIndex-5*page;
core.ui._drawSLPanel(10*page + offset, true);
page = parseInt((core.saves.saveIndex - 1) / 5);
offset = core.saves.saveIndex - 5 * page;
core.ui._drawSLPanel(10 * page + offset, true);
}
}
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;
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 >= 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 && x < xRight) return this._clickSL_favorite(page, 4);
if (x >= xRight) return this._clickSL_favorite(page, 5);
@ -2007,7 +2007,7 @@ actions.prototype._clickSL = function (x, y) {
}
}
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];
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
index = core.saves.favorite[index - 1];
core.myprompt("请输入想要显示的存档名(长度不超过5字符)", null, function (value) {
if(value && value.length <= 5){
if (value && value.length <= 5) {
core.saves.favoriteName[index] = value;
core.control._updateFavoriteSaves();
core.ui._drawSLPanel(10 * page + offset);
@ -2037,7 +2037,7 @@ actions.prototype._clickSL_favorite = function (page, offset) {
}
else if (core.hasSave(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.control._updateFavoriteSaves();
@ -2049,7 +2049,7 @@ actions.prototype._clickSL_favorite = function (page, offset) {
actions.prototype._keyDownSL = function (keycode) {
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
core.playSound('光标移动');
@ -2123,7 +2123,7 @@ actions.prototype._keyUpSL = function (keycode) {
core.doSL("autoSave", core.status.event.id);
else {
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);
}
return;
@ -2139,7 +2139,7 @@ actions.prototype._keyUpSL = function (keycode) {
}
else {
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.ui._drawSLPanel(index, true);
});
@ -2591,7 +2591,7 @@ actions.prototype._clickNotes_show = function () {
core.playSound('确定');
core.status.hero.notes = core.status.hero.notes || [];
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 = [];
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]));
@ -2610,7 +2610,7 @@ actions.prototype._clickNotes_edit = function () {
core.myprompt("请输入要编辑的存档笔记编号1 - " + core.status.hero.notes.length + "", "1", function (data) {
if (!data) core.ui.closePanel();
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("不合法的输入!");
} else {
core.myprompt("请输入新内容不超过45字", core.status.hero.notes[value - 1], function (data) {
@ -2644,11 +2644,11 @@ actions.prototype._clickNotes_delete = function () {
core.drawText("所有存档笔记删除成功!");
} else {
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) {
core.drawText("没有要删除的笔记!");
} else {
data.sort(function (a, b) { return b - a;})
data.sort(function (a, b) { return b - a; })
.forEach(function (index) {
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);
}
catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in requestAnimationFrame[" + b.name + "]:已自动注销该项。");
core.unregisterAnimationFrame(b.name);
}
@ -215,7 +215,7 @@ control.prototype._animationFrame_weather = function (timestamp) {
try {
core.doFunc(core.control.weathers[type].frameFunc, core.control, timestamp, core.animateFrame.weather.level);
} catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in weather[" + type + "]:已自动注销该项。");
core.unregisterWeather(type);
}
@ -1626,7 +1626,7 @@ control.prototype._doReplayAction = function (action) {
try {
if (core.doFunc(this.replayActions[i].func, this, action)) return true;
} catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in replayActions[" + this.replayActions[i].name + "]:已自动注销该项。");
core.unregisterReplayAction(this.replayActions[i].name);
}
@ -2677,7 +2677,7 @@ control.prototype.setWeather = function (type, level) {
try {
core.doFunc(this.weathers[type].initFunc, this, level);
} catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in weather[" + type + "]:已自动注销该项。");
core.unregisterWeather(type);
}
@ -2842,7 +2842,7 @@ control.prototype.playBgm = function (bgm, startTime) {
core.material.bgms[bgm].pause();
}
catch (e) {
main.log(e);
console.error(e);
}
return;
}
@ -3002,7 +3002,7 @@ control.prototype.stopSound = function (id) {
else if (source.noteOff) source.noteOff();
}
catch (e) {
main.log(e);
console.error(e);
}
delete core.musicStatus.playingSounds[id];
}
@ -3060,7 +3060,7 @@ control.prototype.updateStatusBar_update = function () {
if (!core.control.noAutoEvents) core.checkAutoEvents();
core.control._updateStatusBar_setToolboxIcon();
core.clearRouteFolding();
});
})
core.control.needUpdate = false;
core.control.noAutoEvents = true;
}
@ -3253,7 +3253,7 @@ control.prototype._doResize = function (obj) {
try {
if (core.doFunc(this.resizes[i].func, this, obj)) return true;
} catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in resizes[" + this.resizes[i].name + "]:已自动注销该项。");
this.unregisterResize(this.resizes[i].name);
}

View File

@ -6,7 +6,7 @@
"use strict";
function core() {
function core () {
this.__SIZE__ = 13;
this.__PIXELS__ = this.__SIZE__ * 32;
this.__HALF_SIZE__ = Math.floor(this.__SIZE__ / 2);
@ -135,7 +135,7 @@ function core() {
// 勇士属性
'hero': {},
'heroCenter': {'px': null, 'py': null},
'heroCenter': { 'px': null, 'py': null },
// 当前地图
'floorId': null,
@ -231,10 +231,10 @@ function core() {
"statusLeftBackground": main.styles.statusLeftBackground || "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",
"borderColor": main.styles.borderColor || [204,204,204,1],
"statusBarColor": main.styles.statusBarColor || [255,255,255,1],
"borderColor": main.styles.borderColor || [204, 204, 204, 1],
"statusBarColor": main.styles.statusBarColor || [255, 255, 255, 1],
"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"
},
'curtainColor': null,
@ -306,7 +306,7 @@ core.prototype._init_flags = function () {
core.dom.logoLabel.innerText = core.firstData.title;
document.title = core.firstData.title + " - HTML5魔塔";
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();
// 初始化怪物、道具等
@ -344,15 +344,15 @@ core.prototype._init_flags = function () {
symbol: "_equipEvent_" + equipId,
currentFloor: false,
multiExecute: true,
condition: "core.hasEquip('" + equipId + "') && !core.hasFlag('"+equipFlag+"')",
data: core.precompile([{"type": "setValue", "name": "flag:" + equipFlag, "value": "true"}].concat(equip.equip.equipEvent||[])),
condition: "core.hasEquip('" + equipId + "') && !core.hasFlag('" + equipFlag + "')",
data: core.precompile([{ "type": "setValue", "name": "flag:" + equipFlag, "value": "true" }].concat(equip.equip.equipEvent || [])),
};
var autoEvent2 = {
symbol: "_unequipEvent_" + equipId,
currentFloor: false,
multiExecute: true,
condition: "!core.hasEquip('" + equipId + "') && core.hasFlag('"+equipFlag+"')",
data: core.precompile([{"type": "setValue", "name": "flag:" + equipFlag, "value": "null"}].concat(equip.equip.unequipEvent||[])),
condition: "!core.hasEquip('" + equipId + "') && core.hasFlag('" + equipFlag + "')",
data: core.precompile([{ "type": "setValue", "name": "flag:" + equipFlag, "value": "null" }].concat(equip.equip.unequipEvent || [])),
};
core.initStatus.autoEvents.push(autoEvent1);
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", "cloud", function (name, img) { core.animateFrame.weather.cloud = 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.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);
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.plugin = new function () {};
core.plugin = new function () { };
for (var name in plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1) {
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);
}
catch (e) {
main.log(e);
main.log("无法初始化插件"+name);
console.error(e);
main.log("无法初始化插件" + name);
}
}
}
@ -514,7 +514,7 @@ core.prototype._forwardFunc = function (name, funcname) {
}
if (core[funcname]) {
console.error("ERROR: 无法转发 "+name+" 中的函数 "+funcname+" 到 core 中!同名函数已存在。");
console.error("ERROR: 无法转发 " + name + " 中的函数 " + funcname + " 到 core 中!同名函数已存在。");
return;
}
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+");");
eval("core." + funcname + " = function (" + parameters + ") {\n\treturn core." + name + "." + funcname + "(" + parameters + ");\n}");
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";
function data() {
function data () {
this._init();
}

View File

@ -2,7 +2,7 @@
"use strict";
function enemys() {
function enemys () {
this._init();
}
@ -35,7 +35,7 @@ enemys.prototype.getEnemys = function () {
if (enemys[id].faceIds) {
var downId = enemys[id].faceIds.down;
if (downId != null && downId != id && enemys[downId]) {
enemys[id] = {id: id};
enemys[id] = { id: id };
for (var property in enemys[downId]) {
if (property != 'id' && enemys[downId].hasOwnProperty(property)) {
(function (id, downId, property) {
@ -150,7 +150,7 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
if (specials == null) return "";
for (var i = 0; i < specials.length; i++) {
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 "";
}
@ -167,8 +167,8 @@ enemys.prototype._calSpecialContent = function (enemy, content) {
////// 获得某个点上某个怪物的某项属性 //////
enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) {
floorId = floorId || core.status.floorId;
if ((((flags.enemyOnPoint||{})[floorId]||{})[x+","+y]||{})[name] != null) {
return flags.enemyOnPoint[floorId][x+","+y][name];
if ((((flags.enemyOnPoint || {})[floorId] || {})[x + "," + y] || {})[name] != null) {
return flags.enemyOnPoint[floorId][x + "," + y][name];
}
if (enemy == null) {
var block = core.getBlock(x, y, floorId);
@ -236,7 +236,7 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) {
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) {
return [[info.__overAtk__ || 0, 0]];
}
@ -263,11 +263,11 @@ enemys.prototype._nextCriticals_overAtk = function (enemy, x, y, floorId) {
while (start < end) {
var mid = Math.floor((start + end) / 2);
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;
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 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]);
}
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 (pre > nextInfo.damage) {
pre = nextInfo.damage;
@ -317,12 +317,12 @@ enemys.prototype._nextCriticals_useBinarySearch = function (enemy, info, number,
while (start < end) {
var mid = Math.floor((start + end) / 2);
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 (pre > nextInfo.damage) end = mid;
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];
}
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'));
if (nextAtk <= start_atk) break;
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;
list.push([nextAtk - hero_atk, Math.floor(info.damage - nextInfo.damage)]);
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];
k = k || 1;
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 "???";
return nowDamage - nextDamage;
}
@ -508,7 +508,7 @@ enemys.prototype.hasEnemyLeft = function (enemyId, floorId) {
if (floorId == null) floorId = core.status.floorId;
if (!(floorId instanceof Array)) floorId = [floorId];
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 enemyMap = null;
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);
}
catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in systemEvents[" + type + "]");
}
}
@ -347,7 +347,7 @@ events.prototype.trigger = function (x, y, callback) {
core.clearRouteFolding();
try {
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 {
eval(block.event.script);
} catch (e) { main.log(e); }
} catch (ee) { console.error(ee) }
// 碰触事件
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);
}
catch (e) {
main.log(e);
console.error(e);
main.log("ERROR in actions[" + type + "]");
}
}
@ -1104,7 +1104,7 @@ events.prototype.insertCommonEvent = function (name, args, x, y, callback, addTo
try {
if (args[i] != null)
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 {
if (data.args[i] != null)
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);
@ -2363,7 +2363,7 @@ events.prototype._action_function = function (data, x, y, prefix) {
eval('(' + func + ')()');
}
} catch (e) {
main.log(e);
console.error(e);
}
if (!data.async)
core.doAction();

View File

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

View File

@ -2,7 +2,7 @@
"use strict";
function icons() {
function icons () {
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);
if (id >= startOffset && id < startOffset + width * height) {
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;
}

View File

@ -2,7 +2,7 @@
"use strict";
function items() {
function items () {
this._init();
}
@ -39,7 +39,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
eval(itemEffect);
}
catch (e) {
main.log(e);
console.error(e);
}
}
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
@ -50,7 +50,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
core.insertAction(useItemEvent);
}
catch (e) {
main.log(e);
console.error(e);
}
}
core.updateStatusBar();
@ -70,7 +70,7 @@ items.prototype.getItemEffectTip = function (itemId) {
try {
return core.replaceText(itemEffectTip) || "";
} catch (e) {
main.log(e);
console.error(e);
return "";
}
}
@ -100,7 +100,7 @@ items.prototype._useItemEffect = function (itemId) {
eval(useItemEffect);
}
catch (e) {
main.log(e);
console.error(e);
}
}
var useItemEvent = core.material.items[itemId].useItemEvent;
@ -109,7 +109,7 @@ items.prototype._useItemEffect = function (itemId) {
core.insertAction(useItemEvent);
}
catch (e) {
main.log(e);
console.error(e);
}
}
}
@ -135,7 +135,7 @@ items.prototype.canUseItem = function (itemId) {
return eval(canUseItemEffect);
}
catch (e) {
main.log(e);
console.error(e);
return false;
}
}
@ -269,7 +269,7 @@ items.prototype.canEquip = function (equipId, hint) {
}
}
catch (e) {
console.log(e);
console.error(e);
return false;
}
}
@ -307,7 +307,7 @@ items.prototype.unloadEquip = function (equipType, callback) {
}
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];
for (var one in result) {
for (var name in core.status.hero) {
@ -366,7 +366,7 @@ items.prototype.quickSaveEquip = function (index) {
var saveEquips = core.getFlag("saveEquips", []);
saveEquips[index] = core.clone(core.status.hero.equipment);
core.setFlag("saveEquips", saveEquips);
core.status.route.push("saveEquip:"+index);
core.status.route.push("saveEquip:" + index);
core.drawTip("已保存" + index + "号套装");
}
@ -385,7 +385,7 @@ items.prototype.quickLoadEquip = function (index) {
if (v && !this.canEquip(v, true))
return;
}
core.status.route.push("loadEquip:"+index);
core.status.route.push("loadEquip:" + index);
core.setFlag("__quickLoadEquip__", true);
// 快速换装
var toEquip = [];
@ -424,7 +424,7 @@ items.prototype.setEquip = function (equipId, valueType, name, value, operator,
if (core.hasEquip(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);
delete core.material.items[tempId];
core.updateStatusBar();

View File

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

View File

@ -198,7 +198,7 @@ utils.prototype.decompress = function (value) {
return JSON.parse(value);
}
catch (e) {
main.log(e);
console.error(e);
}
return null;
}
@ -222,7 +222,7 @@ utils.prototype.setLocalStorage = function (key, value) {
return true;
}
catch (e) {
main.log(e);
console.error(e);
return false;
}
}
@ -1035,7 +1035,7 @@ utils.prototype.readFileContent = function (content) {
try {
obj = JSON.parse(content);
} 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"),
'greenKey': document.getElementById("greenKey"),
'poison': document.getElementById('poison'),
'weak':document.getElementById('weak'),
'weak': document.getElementById('weak'),
'curse': document.getElementById('curse'),
'pickaxe': document.getElementById('pickaxe'),
'bomb': document.getElementById('bomb'),
@ -198,22 +198,22 @@ main.prototype.init = function (mode, callback) {
}
main.mode = mode;
main.loadJs('project', main.pureData, function(){
main.loadJs('project', main.pureData, function () {
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.levelChoose = main.levelChoose || [];
main.levelChoose.forEach(function (value) {
var span = document.createElement('span');
span.setAttribute('class','startButton');
span.innerText=value.title || '';
(function(span,str_){
span.setAttribute('class', 'startButton');
span.innerText = value.title || '';
(function (span, str_) {
span.onclick = function () {
core.events.startGame(str_);
}
})(span,value.name||'');
})(span, value.name || '');
main.dom.levelChooseButtons.appendChild(span);
});
main.createOnChoiceAnimation();
@ -228,7 +228,7 @@ main.prototype.init = function (mode, callback) {
main.core[name] = new window[name]();
}
main.loadFloors(function() {
main.loadFloors(function () {
var coreData = {};
["dom", "statusBar", "canvas", "images", "tilesets", "materials",
"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) {
var script = document.createElement('script');
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 () {
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');
script.src = 'project/floors/' + floorId +'.js?v=' + this.version;
script.src = 'project/floors/' + floorId + '.js?v=' + this.version;
main.dom.body.appendChild(script);
script.onload = function () {
callback(floorId);
@ -331,8 +331,9 @@ main.prototype.setMainTipsText = function (text) {
main.dom.mainTips.innerHTML = text;
}
main.prototype.log = function (e) {
main.prototype.log = function (e, error) {
if (e) {
if (error) return console.error(e);
if (main.core && main.core.platform && !main.core.platform.isPC) {
console.log((e.stack || e.toString()));
}
@ -351,9 +352,9 @@ main.prototype.createOnChoiceAnimation = function () {
var style = document.createElement("style");
style.type = 'text/css';
var keyFrames = "onChoice { " +
"0% { border-color: rgba("+value+", 0.9); } " +
"50% { border-color: rgba("+value+", 0.3); } " +
"100% { border-color: rgba("+value+", 0.9); } " +
"0% { border-color: rgba(" + value + ", 0.9); } " +
"50% { border-color: rgba(" + value + ", 0.3); } " +
"100% { border-color: rgba(" + value + ", 0.9); } " +
"}";
style.innerHTML = "@-webkit-keyframes " + keyFrames + " @keyframes " + keyFrames;
document.body.appendChild(style);
@ -364,7 +365,7 @@ main.prototype.createOnChoiceAnimation = function () {
main.prototype.selectButton = function (index) {
var select = function (children) {
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[index].classList.add("onChoiceAnimate");
@ -393,7 +394,7 @@ main.prototype.importFonts = function (fonts) {
style.type = 'text/css';
var html = '';
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;
document.body.appendChild(style);
@ -401,31 +402,31 @@ main.prototype.importFonts = function (fonts) {
main.prototype.listen = function () {
////// 窗口大小变化时 //////
window.onresize = function () {
////// 窗口大小变化时 //////
window.onresize = function () {
try {
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 {
if (main.dom.inputDiv.style.display == 'block') return;
if (main.core && (main.core.isPlaying() || main.core.status.lockControl))
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 {
if (main.dom.startPanel.style.display == 'block' &&
(main.dom.startButtons.style.display == 'block' || main.dom.levelChooseButtons.style.display == 'block')) {
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
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
main.selectButton(main.selectedButton);
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 &&
(main.core.isPlaying() || main.core.status.lockControl))
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) {
for (var i = 0; i < dom.children.length; ++i) {
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;
}
}
////// 鼠标按下时 //////
main.dom.data.onmousedown = function (e) {
////// 鼠标按下时 //////
main.dom.data.onmousedown = function (e) {
try {
e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return;
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 {
e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return;
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 {
e.stopPropagation();
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return;
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 {
if (e.wheelDelta)
main.core.onmousewheel(Math.sign(e.wheelDelta))
else if (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 {
e.preventDefault();
var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return;
main.lastTouchLoc = 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 {
e.preventDefault();
var loc = main.core.actions._getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return;
main.lastTouchLoc = 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 {
e.preventDefault();
if (main.lastTouchLoc == null) return;
@ -539,21 +540,21 @@ main.dom.data.ontouchend = function (e) {
delete main.lastTouchLoc;
main.core.onup(loc);
} catch (e) {
main.log(e);
console.error(e);
}
}
}
main.dom.statusCanvas.onclick = function (e) {
main.dom.statusCanvas.onclick = function (e) {
try {
e.preventDefault();
main.core.onStatusBarClick(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();
if (core.isReplaying()) {
@ -563,10 +564,10 @@ main.statusBar.image.book.onclick = function (e) {
if (main.core.isPlaying())
main.core.openBook(true);
}
}
////// 点击状态栏中的楼层传送器/装备栏时 //////
main.statusBar.image.fly.onclick = function (e) {
////// 点击状态栏中的楼层传送器/装备栏时 //////
main.statusBar.image.fly.onclick = function (e) {
e.stopPropagation();
// 播放录像时
@ -583,10 +584,10 @@ main.statusBar.image.fly.onclick = function (e) {
main.core.openEquipbox(true)
}
}
}
}
////// 点击状态栏中的工具箱时 //////
main.statusBar.image.toolbox.onclick = function (e) {
////// 点击状态栏中的工具箱时 //////
main.statusBar.image.toolbox.onclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -597,10 +598,10 @@ main.statusBar.image.toolbox.onclick = function (e) {
if (main.core.isPlaying()) {
main.core.openToolbox(core.status.event.id != 'equipbox');
}
}
}
////// 双击状态栏中的工具箱时 //////
main.statusBar.image.toolbox.ondblclick = function (e) {
////// 双击状态栏中的工具箱时 //////
main.statusBar.image.toolbox.ondblclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -610,10 +611,10 @@ main.statusBar.image.toolbox.ondblclick = function (e) {
if (main.core.isPlaying())
main.core.openEquipbox(true);
}
}
////// 点击状态栏中的虚拟键盘时 //////
main.statusBar.image.keyboard.onclick = function (e) {
////// 点击状态栏中的虚拟键盘时 //////
main.statusBar.image.keyboard.onclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -623,10 +624,10 @@ main.statusBar.image.keyboard.onclick = function (e) {
if (main.core.isPlaying())
main.core.openKeyBoard(true);
}
}
////// 点击状态栏中的快捷商店时 //////
main.statusBar.image.shop.onclick = function (e) {
////// 点击状态栏中的快捷商店时 //////
main.statusBar.image.shop.onclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -636,27 +637,27 @@ main.statusBar.image.shop.onclick = function (e) {
if (main.core.isPlaying())
main.core.openQuickShop(true);
}
}
////// 点击金币时也可以开启快捷商店 //////
main.statusBar.image.money.onclick = function (e) {
////// 点击金币时也可以开启快捷商店 //////
main.statusBar.image.money.onclick = function (e) {
e.stopPropagation();
if (main.core.isPlaying())
main.core.openQuickShop(true);
}
}
////// 点击楼梯图标也可以浏览地图 //////
main.statusBar.image.floor.onclick = function (e) {
////// 点击楼梯图标也可以浏览地图 //////
main.statusBar.image.floor.onclick = function (e) {
e.stopPropagation();
if (main.core && main.core.isPlaying() && !core.isMoving() && !core.status.lockControl) {
core.ui._drawViewMaps();
}
}
}
////// 点击状态栏中的存档按钮时 //////
main.statusBar.image.save.onclick = function (e) {
////// 点击状态栏中的存档按钮时 //////
main.statusBar.image.save.onclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -666,10 +667,10 @@ main.statusBar.image.save.onclick = function (e) {
if (main.core.isPlaying())
main.core.save(true);
}
}
////// 点击状态栏中的读档按钮时 //////
main.statusBar.image.load.onclick = function (e) {
////// 点击状态栏中的读档按钮时 //////
main.statusBar.image.load.onclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -679,10 +680,10 @@ main.statusBar.image.load.onclick = function (e) {
if (main.core.isPlaying())
main.core.load(true);
}
}
////// 点击状态栏中的系统菜单时 //////
main.statusBar.image.settings.onclick = function (e) {
////// 点击状态栏中的系统菜单时 //////
main.statusBar.image.settings.onclick = function (e) {
e.stopPropagation();
if (core.isReplaying()) {
@ -692,52 +693,52 @@ main.statusBar.image.settings.onclick = function (e) {
if (main.core.isPlaying())
main.core.openSettings(true);
}
}
////// 点击工具栏时 //////
main.dom.hard.onclick = function () {
////// 点击工具栏时 //////
main.dom.hard.onclick = function () {
if (core.isReplaying())
return;
main.core.control.setToolbarButton(!core.domStyle.toolbarBtn);
}
}
////// 手机端的按钮1-7 //////
main.statusBar.image.btn1.onclick = function (e) {
////// 手机端的按钮1-7 //////
main.statusBar.image.btn1.onclick = function (e) {
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();
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();
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();
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();
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();
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();
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();
if (core.getLocalStorage('altKey')) {
core.removeLocalStorage('altKey');
@ -749,42 +750,42 @@ main.statusBar.image.btn8.onclick = function (e) {
core.drawTip("Alt模式已开启此模式下1~7按钮视为Alt+1~7。");
main.statusBar.image.btn8.style.filter = 'sepia(1) contrast(1.5)';
}
};
};
////// 点击“开始游戏”时 //////
main.dom.playGame.onclick = function () {
main.dom.startButtons.style.display='none';
////// 点击“开始游戏”时 //////
main.dom.playGame.onclick = function () {
main.dom.startButtons.style.display = 'none';
main.core.control.checkBgm();
if (main.levelChoose.length == 0) {
core.events.startGame("");
} else {
main.dom.levelChooseButtons.style.display='block';
main.dom.levelChooseButtons.style.display = 'block';
main.selectedButton = null;
main.selectButton(0);
}
}
}
////// 点击“载入游戏”时 //////
main.dom.loadGame.onclick = function() {
////// 点击“载入游戏”时 //////
main.dom.loadGame.onclick = function () {
main.core.control.checkBgm();
main.core.load();
}
}
////// 点击“录像回放”时 //////
main.dom.replayGame.onclick = function () {
////// 点击“录像回放”时 //////
main.dom.replayGame.onclick = function () {
main.core.control.checkBgm();
main.core.chooseReplayFile();
}
}
main.dom.musicBtn.onclick = function () {
main.dom.musicBtn.onclick = function () {
try {
if (main.core)
main.core.triggerBgm();
} catch (e) {main.log(e);}
}
} catch (ee) { console.error(ee) }
}
main.dom.enlargeBtn.onclick = function () {
main.dom.enlargeBtn.onclick = function () {
try {
if (main.core) {
main.core.setDisplayScale(1);
@ -793,30 +794,30 @@ main.dom.enlargeBtn.onclick = function () {
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) {
try {
main.core.control.checkAutosave();
} catch (e) {}
} catch (e) { }
}
}
}
main.dom.inputYes.onclick = function () {
main.dom.inputYes.onclick = function () {
main.dom.inputDiv.style.display = 'none';
var func = core.platform.successCallback;
core.platform.successCallback = core.platform.errorCallback = null;
if (func) func(main.dom.inputBox.value);
}
}
main.dom.inputNo.onclick = function () {
main.dom.inputNo.onclick = function () {
main.dom.inputDiv.style.display = 'none';
var func = core.platform.errorCallback;
core.platform.successCallback = core.platform.errorCallback = null;
if (func) func(null);
}
}
}//listen end

View File

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