From 1ad1e12df66f8b8e779c0e4cafc3c8709fc3f064 Mon Sep 17 00:00:00 2001
From: unamed <1319491857@qq.com>
Date: Wed, 2 Feb 2022 00:32:58 +0800
Subject: [PATCH] kill main.log
---
_server/editor_blockly.js | 408 +++---
_server/editor_mappanel.js | 148 +--
_server/editor_uievent.js | 120 +-
libs/actions.js | 136 +-
libs/control.js | 16 +-
libs/core.js | 40 +-
libs/data.js | 2 +-
libs/enemys.js | 36 +-
libs/events.js | 14 +-
libs/extensions.js | 2 +-
libs/icons.js | 4 +-
libs/items.js | 28 +-
libs/loader.js | 22 +-
libs/utils.js | 6 +-
main.js | 805 ++++++------
project/functions.js | 3 +-
project/plugins.js | 2543 ++++++++++++++++++------------------
runtime.d.ts | 7 +
18 files changed, 2178 insertions(+), 2162 deletions(-)
diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js
index e83c764a..69330640 100644
--- a/_server/editor_blockly.js
+++ b/_server/editor_blockly.js
@@ -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);
@@ -96,15 +96,15 @@ editor_blockly = function () {
}
editor_blockly.setValue = function (value) {
- changeFromBlockly = true;
- codeAreaHL.setValue(value);
+ changeFromBlockly = true;
+ codeAreaHL.setValue(value);
}
editor_blockly.parse = function () {
MotaActionFunctions.parse(
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
- return {'<': '<', '>': '>', '&': '&'}[c];
- }).replace(/\\(r|f|i|c|d|e|g|z)/g,'\\\\$1')),
+ return { '<': '<', '>': '>', '&': '&' }[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;
@@ -149,10 +149,10 @@ editor_blockly = function () {
var blocklyParseBtn = document.getElementById('blocklyParse');
editor_blockly.highlightParse = function (shouldHighLight) {
- if (shouldNotifyParse == shouldHighLight) return;
- shouldNotifyParse = shouldHighLight;
- if (shouldHighLight) blocklyParseBtn.classList.add('highlight');
- else blocklyParseBtn.classList.remove('highlight');
+ if (shouldNotifyParse == shouldHighLight) return;
+ shouldNotifyParse = shouldHighLight;
+ if (shouldHighLight) blocklyParseBtn.classList.add('highlight');
+ else blocklyParseBtn.classList.remove('highlight');
}
editor_blockly.cancel = function () {
@@ -169,20 +169,20 @@ editor_blockly = function () {
return;
}
if (shouldNotifyParse) {
- alert('你尚未解析修改后的内容,请进行解析或放弃操作');
- return;
+ alert('你尚未解析修改后的内容,请进行解析或放弃操作');
+ return;
}
- if(editor_blockly.workspace.topBlocks_.length>=2){
- editor_blockly.setValue('入口方块只能有一个');
- return;
+ if (editor_blockly.workspace.topBlocks_.length >= 2) {
+ editor_blockly.setValue('入口方块只能有一个');
+ return;
}
var eventType = editor_blockly.entryType;
- 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')){
- editor_blockly.setValue('入口方块类型错误');
- return;
- }
+ 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')) {
+ editor_blockly.setValue('入口方块类型错误');
+ return;
+ }
}
var setvalue = function (value) {
var thisTr = document.getElementById(editor_blockly.id);
@@ -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);
@@ -246,7 +246,7 @@ editor_blockly = function () {
}
}
}
- if (one.type == 'previewUI' && this.checkAsync(one.action)) return true;
+ if (one.type == 'previewUI' && this.checkAsync(one.action)) return true;
if (one.async && one.type != 'animate' && one.type != 'function' && one.type != 'text') hasAsync = true;
if (one.type == 'waitAsync' || one.type == 'stopAsync') hasAsync = false;
}
@@ -255,17 +255,17 @@ editor_blockly = function () {
var _isTextAttributeSet = false;
- editor_blockly.previewBlock = function (b,args) {
+ editor_blockly.previewBlock = function (b, args) {
var previewTextDrawing = function (content) {
var arr = [];
- content.replace(/(\f|\\f)\[(.*?)]/g, function (text, sympol, str) {
+ content.replace(/(\f|\\f)\[(.*?)]/g, function (text, sympol, str) {
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,78 +303,84 @@ 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) {
- case 'text_0_s':
- case 'text_1_s':
- case 'text_2_s':
- case 'choices_s':
- case 'confirm_s':
- if (!_isTextAttributeSet) {
- alert('警告!你尚未设置用于预览的剧情文本的属性,将采用默认属性进行预览。\n你可以双击“设置剧情文本的属性”事件来设置用于预览的属性。');
- core.status.textAttribute = core.clone(core.initStatus.textAttribute);
- _isTextAttributeSet = true;
- }
- editor.uievent.previewUI([obj]);
- break;
- case 'setText_s': // 设置剧情文本的属性
- _isTextAttributeSet = true;
- core.status.textAttribute = core.clone(core.initStatus.textAttribute);
- core.setTextAttribute(obj);
- alert('已成功设置此属性为显示文章的预览属性!')
- break;
- case 'waitContext_2': // 等待用户操作坐标预览
- 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)"}]);
- 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}
- ]);
- } 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}
- ]);
- }
- 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]}]);
- }
- 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}]);
- }
- 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}
- ]);
- break;
- case 'previewUI_s': // 预览
- editor.uievent.previewUI(obj.action);
- break;
- default:
- if (b.type.startsWith(obj.type)) {
+ case 'text_0_s':
+ case 'text_1_s':
+ case 'text_2_s':
+ case 'choices_s':
+ case 'confirm_s':
+ if (!_isTextAttributeSet) {
+ alert('警告!你尚未设置用于预览的剧情文本的属性,将采用默认属性进行预览。\n你可以双击“设置剧情文本的属性”事件来设置用于预览的属性。');
+ core.status.textAttribute = core.clone(core.initStatus.textAttribute);
+ _isTextAttributeSet = true;
+ }
editor.uievent.previewUI([obj]);
- }
+ break;
+ case 'setText_s': // 设置剧情文本的属性
+ _isTextAttributeSet = true;
+ core.status.textAttribute = core.clone(core.initStatus.textAttribute);
+ core.setTextAttribute(obj);
+ alert('已成功设置此属性为显示文章的预览属性!')
+ break;
+ case 'waitContext_2': // 等待用户操作坐标预览
+ 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)"
+ }]);
+ 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
+ }
+ ]);
+ } 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 }
+ ]);
+ }
+ 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] }]);
+ }
+ 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 }]);
+ }
+ 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
+ }
+ ]);
+ break;
+ case 'previewUI_s': // 预览
+ editor.uievent.previewUI(obj.action);
+ break;
+ default:
+ if (b.type.startsWith(obj.type)) {
+ 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);
@@ -596,20 +602,20 @@ editor_blockly = function () {
} else if (before.endsWith("怪物") || (ch == ':' && before.endsWith("enemy"))) {
var list = Object.keys(core.material.enemys);
if (before.endsWith("怪物") && MotaActionFunctions) {
- list = MotaActionFunctions.pattern.replaceEnemyList.map(function (v) {
- return v[1];
- }).concat(list);
+ list = MotaActionFunctions.pattern.replaceEnemyList.map(function (v) {
+ return v[1];
+ }).concat(list);
}
return list.filter(function (one) {
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;
+ 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,16 +727,16 @@ 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(绿色)",
- "maroon(深红色)", "navy(深蓝色)", "gold(金色)", "olive(黄褐色)", "orange(橙色)", "purple(品红色)",
- "red(红色)", "silver(淡灰色)", "teal(深青色)", "white(白色)", "yellow(黄色)"];
+ "maroon(深红色)", "navy(深蓝色)", "gold(金色)", "olive(黄褐色)", "orange(橙色)", "purple(品红色)",
+ "red(红色)", "silver(淡灰色)", "teal(深青色)", "white(白色)", "yellow(黄色)"];
namesObj.allFonts = [main.styles.font].concat(main.fonts);
namesObj.allDoors = ["this"].concat(Object.keys(maps_90f36752_8815_4be8_b32b_d7fad1d0542e)
.map(function (key) { return maps_90f36752_8815_4be8_b32b_d7fad1d0542e[key]; })
@@ -738,9 +744,9 @@ editor_blockly = function () {
.map(function (one) { return one.id; }));
namesObj.allEvents = Object.keys(core.events.commonEvent);
var filter = function (list, content) {
- return list.filter(function (one) {
- return one != content && one.startsWith(content);
- }).sort();
+ return list.filter(function (one) {
+ return one != content && one.startsWith(content);
+ }).sort();
}
// 对任意图块提供补全
@@ -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);
}
}
@@ -761,44 +767,44 @@ editor_blockly = function () {
// 对\f进行自动补全
index = Math.max(content.lastIndexOf("\f["), content.lastIndexOf("\\f["));
if (index >= 0) {
- if (content.charAt(index) == '\\') index++;
- var after = content.substring(index + 2);
- if (after.indexOf(",") < 0 && after.indexOf("]") < 0) {
- return filter(namesObj.allImages, after);
- }
+ if (content.charAt(index) == '\\') index++;
+ var after = content.substring(index + 2);
+ if (after.indexOf(",") < 0 && after.indexOf("]") < 0) {
+ return filter(namesObj.allImages, after);
+ }
}
// 对\\i进行补全
index = content.lastIndexOf("\\i[");
if (index >= 0) {
- var after = content.substring(index + 3);
- if (after.indexOf("]") < 0) {
- return filter(namesObj.allIconIds, after);
- }
+ var after = content.substring(index + 3);
+ if (after.indexOf("]") < 0) {
+ return filter(namesObj.allIconIds, after);
+ }
}
// 对\r进行补全
index = Math.max(content.lastIndexOf("\r["), content.lastIndexOf("\\r["));
if (index >= 0) {
- if (content.charAt(index) == '\\') index++;
- var after = content.substring(index + 2);
- if (after.indexOf("]") < 0) {
- return filter(namesObj.allColors, after);
- }
+ if (content.charAt(index) == '\\') index++;
+ var after = content.substring(index + 2);
+ if (after.indexOf("]") < 0) {
+ return filter(namesObj.allColors, after);
+ }
}
// 对\g进行补全
index = content.lastIndexOf("\\g[");
if (index >= 0) {
- var after = content.substring(index + 3);
- if (after.indexOf("]") < 0) {
- return filter(namesObj.allFonts, after);
- }
+ var after = content.substring(index + 3);
+ if (after.indexOf("]") < 0) {
+ return filter(namesObj.allFonts, after);
+ }
}
// 对\进行补全!
if (content.charAt(content.length - 1) == '\\') {
- return ["n(换行)", "f(立绘)", "r(变色)", "i(图标)", "z(暂停打字)", "t(标题图标)", "b(对话框)", "c(字体大小)", "d(粗体)", "e(斜体)", "g(字体)"];
+ return ["n(换行)", "f(立绘)", "r(变色)", "i(图标)", "z(暂停打字)", "t(标题图标)", "b(对话框)", "c(字体大小)", "d(粗体)", "e(斜体)", "g(字体)"];
}
return [];
@@ -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"), "$&");
+ if (input != "") text = text.replace(new RegExp("^" + input, "i"), "$&");
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;
}
}
@@ -933,7 +939,7 @@ editor_blockly = function () {
editor_blockly.isBlockCollapsedSupported = function (block) {
var supportedDisabledBlocks = [
- 'text_0_s', 'text_1_s', 'text_2_s', 'if_s', 'if_1_s', 'confirm_s', 'switch_s', 'choices_s',
+ 'text_0_s', 'text_1_s', 'text_2_s', 'if_s', 'if_1_s', 'confirm_s', 'switch_s', 'choices_s',
'for_s', 'forEach_s', 'while_s', 'dowhile_s', 'wait_s', 'previewUI_s',
'waitContext_1', 'waitContext_2', 'waitContext_3', 'switchCase', 'choicesContext'
];
@@ -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,21 +1002,21 @@ 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_();
this.isBeingEdited_ = true;
editor_blockly.onTextFieldCreate(this, this.htmlInput_);
-
+
if (!quietInput) {
- this.htmlInput_.focus({preventScroll:true});
- this.htmlInput_.select();
+ 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,14 +1135,14 @@ 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;
}
// Save the current block in a variable for use in closures.
var block = this;
var menuOptions = [];
-
+
if (!this.isInFlyout) {
// 删除
if (this.isDeletable() && this.isMovable()) {
@@ -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);
@@ -1169,13 +1175,13 @@ Blockly.BlockSvg.prototype.generateContextMenu = function() {
menuOptions.push(Blockly.ContextMenu.blockDeleteOption(block));
}
}
-
- menuOptions.push(Blockly.ContextMenu.blockHelpOption(block));
+
+ menuOptions.push(Blockly.ContextMenu.blockHelpOption(block));
if (this.customContextMenu) this.customContextMenu(menuOptions);
return menuOptions;
};
-Blockly.FieldDropdown.prototype.doClassValidation_ = function (opt_newValue) {
+Blockly.FieldDropdown.prototype.doClassValidation_ = function (opt_newValue) {
return opt_newValue;
}
@@ -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 = '';
diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js
index d451d3c7..9a7bf9d4 100644
--- a/_server/editor_mappanel.js
+++ b/_server/editor_mappanel.js
@@ -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()) {
@@ -172,7 +172,7 @@ editor_mappanel_wrapper = function (editor) {
if (editor.uivalues.endPos != null) {
endGrid = _getGridByPos(editor.uivalues.endPos);
editor.dom.euiCtx.clearRect(Math.min(startGrid.x, endGrid.x), Math.min(startGrid.y, endGrid.y),
- (Math.abs(editor.uivalues.startPos.x - editor.uivalues.endPos.x) + 1) * startGrid.size,
+ (Math.abs(editor.uivalues.startPos.x - editor.uivalues.endPos.x) + 1) * startGrid.size,
(Math.abs(editor.uivalues.startPos.y - editor.uivalues.endPos.y) + 1) * startGrid.size);
}
editor.uivalues.endPos = pos;
@@ -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,32 +321,32 @@ 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 {
// 检测是否是填充模式
if (editor.uivalues.stepPostfix.length == 1 && editor.brushMod == 'fill') {
editor.uivalues.stepPostfix = editor.uifunctions._fillMode_bfs(editor[editor.layerMod], editor.uivalues.stepPostfix[0].x, editor.uivalues.stepPostfix[0].y,
editor[editor.layerMod][0].length, editor[editor.layerMod].length);
- }
+ }
for (var ii = 0; ii < editor.uivalues.stepPostfix.length; ii++) {
var currx = editor.uivalues.stepPostfix[ii].x, curry = editor.uivalues.stepPostfix[ii].y;
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();
}
}
-
+
}
// console.log(editor.map);
if (editor.info.y != null) {
@@ -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;
}
@@ -519,7 +519,7 @@ editor_mappanel_wrapper = function (editor) {
parent.insertBefore(extraEvent, parent.firstChild);
editor.dom.extraEvent.style.display = 'block';
editor.dom.extraEvent.children[0].innerHTML = '绑定机关门事件';
- }
+ }
else editor.dom.extraEvent.style.display = 'none';
editor.dom.chooseThis.children[0].innerHTML = '选中此点' + '(' + editor.pos.x + ',' + editor.pos.y + ')'
@@ -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;
@@ -1026,12 +1026,12 @@ editor_mappanel_wrapper = function (editor) {
editor.uifunctions.clearLastUsedBtn_click = function () {
if (editor.isMobile) return;
-
+
if (confirm("你确定要清理全部最近使用图块么?\n所有最近使用和最常使用图块(含置顶图块)都将被清除;此过程不可逆!")) {
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,63 +1047,63 @@ 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]);
});
}
}
}
}
-
+
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();
});
@@ -1136,7 +1136,7 @@ editor_mappanel_wrapper = function (editor) {
}
}
}
-
+
editor.constructor.prototype.clearPos = function (clearPos, pos, callback) {
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;
@@ -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();
});
diff --git a/_server/editor_uievent.js b/_server/editor_uievent.js
index d19cdf84..3dba4c2a 100644
--- a/_server/editor_uievent.js
+++ b/_server/editor_uievent.js
@@ -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');
@@ -72,7 +72,7 @@ editor_uievent_wrapper = function (editor) {
return;
} else if (type == "confirm") {
core.saveCanvas('uievent');
- core.drawConfirmBox(data.text, null, null, 'uievent');
+ core.drawConfirmBox(data.text, null, null, 'uievent');
core.loadCanvas('uievent');
} else if (core.ui["_uievent_" + type])
core.ui["_uievent_" + type](data);
@@ -94,9 +94,9 @@ editor_uievent_wrapper = function (editor) {
uievent.elements.extraBody.style.display = 'none';
uievent.elements.body.style.overflow = "hidden";
- uievent.elements.select.innerHTML =
- '' +
- '' +
+ uievent.elements.select.innerHTML =
+ '' +
+ '' +
'';
uievent.elements.select.onchange = function () {
uievent.drawPreviewUI();
@@ -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);
}
@@ -157,7 +157,7 @@ editor_uievent_wrapper = function (editor) {
uievent.updateSelectPoint = function (redraw) {
uievent.elements.title.innerText = '地图选点【右键多选】 (' + uievent.values.x + "," + uievent.values.y + ')';
// 计算size
- uievent.values.boxSize = uievent.values.size *
+ uievent.values.boxSize = uievent.values.size *
(uievent.values.bigmap ? (core.__SIZE__ / Math.max(uievent.values.width, uievent.values.height)) : 1);
uievent.values.boxLeft = uievent.values.bigmap ?
(core.__PIXELS__ * Math.max(0, (1 - uievent.values.width / uievent.values.height) / 2)) : 0;
@@ -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');
}
@@ -228,17 +228,17 @@ editor_uievent_wrapper = function (editor) {
uievent.updateSelectPoint(false);
}
- uievent.elements.body.oncontextmenu = function (e) {
+ uievent.elements.body.oncontextmenu = function (e) {
e.preventDefault();
e.stopPropagation();
if (uievent.mode != 'selectPoint' || uievent.values.bigmap) return;
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]);
@@ -410,7 +410,7 @@ editor_uievent_wrapper = function (editor) {
list.push("道具 " + (item.name || id) + " 的装备属性");
}
// 使用事件
- if (hasUsedFlags(item.useItemEvent, flag)) {
+ if (hasUsedFlags(item.useItemEvent, flag)) {
list.push("道具 " + (item.name || id) + " 的使用事件");
}
}
@@ -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 += "";
- html += ""
+ if (!one.includes(value) && !(floor.title || "").includes(value) && !(floor.name || "").includes(value)) return;
+ html += "";
+ html += ""
+ one + '(' + floor.title + ')' + "";
html += "";
- html += "";
+ html += "";
html += '
';
});
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 = "";
- html += ""+
- "
";
+ html += "" +
+ "
";
if (_isTileset) {
html += "警告!额外素材一旦注册成功将不可删除,否则可能会导致素材错位风险!如果你不再想用某个额外素材,"
- +"但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。
"
+ + "但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。
"
}
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 += ` ${one}`;
// 预览图片
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) {
html += "";
- html += '
';
+ html += '
';
}
// 试听音频
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) {
html += ""
html += " 音调:";
html += `0:00 / 0:00
-
+
`;
}
// 预览动画
if (directory.indexOf('animates') >= 0) {
html += "";
- html += "";
+ html += "";
}
html += '
';
});
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 += ` ${one}`;
// 预览图片
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) {
html += "";
- html += '
';
+ html += '
';
}
})
html += "
";
@@ -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 += "第 帧:";
- html += '';
+ html += '';
html += '';
- html += " 音调:";
+ html += " 音调:";
html += '';
html += '
';
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('动画音效修改成功!别忘了在全塔属性中注册音效哦!');
}
@@ -894,17 +894,17 @@ editor_uievent_wrapper = function (editor) {
}).map(function (one) {
var value = one.getAttribute('key');
if (one.getAttribute('_type') == 'number') value = parseFloat(value);
- return value;
+ return value;
});
uievent.close();
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 += '';
}
- table += `| ${prefixStrings[index]}= 0? 'checked' : ''}/> | `;
+ table += `${prefixStrings[index]}= 0 ? 'checked' : ''}/> | `;
if (index % 3 == 2) {
table += '
';
}
@@ -923,7 +923,7 @@ editor_uievent_wrapper = function (editor) {
if (keys.length % 3 != 0) table += '';
table += '';
- uievent.elements.extraBody.innerHTML = ""+table+"
";
+ uievent.elements.extraBody.innerHTML = "" + table + "
";
}
uievent.previewEditorMulti = function (mode, code) {
@@ -974,7 +974,7 @@ editor_uievent_wrapper = function (editor) {
html += "魔力: 上限: 金币: 经验: 等级: ";
html += "
当前道具ID(以逗号分隔):
";
html += "
当前装备ID(以逗号分隔):
";
- html += "
当前变量值(JSON格式):
";
+ html += "
当前变量值(JSON格式):
";
html += "
"
uievent.elements.extraBody.innerHTML = html;
@@ -1020,8 +1020,8 @@ editor_uievent_wrapper = function (editor) {
values[11].split(',').forEach(function (itemId) {
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;
+ if (itemCls == 'items') return;
+ 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;
}
\ No newline at end of file
diff --git a/libs/actions.js b/libs/actions.js
index 298f5799..d967f063 100644
--- a/libs/actions.js
+++ b/libs/actions.js
@@ -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;
@@ -591,7 +591,7 @@ actions.prototype._sys_ondown = function (x, y, px, py) {
core.drawTip('已进入预览模式,可直接拖动大地图');
core.status.stepPostfix = [];
}, 500);
- }
+ }
}
////// 当在触摸屏上滑动时 //////
@@ -607,7 +607,7 @@ actions.prototype._sys_onmove_choices = function (x, y, px, py) {
switch (core.status.event.id) {
case 'action':
if (core.status.event.data.type == 'choices') {
- this._onMoveChoices(x, y);
+ this._onMoveChoices(x, y);
return true;
}
if (core.status.event.data.type == 'confirm') {
@@ -649,7 +649,7 @@ actions.prototype._sys_onmove = function (x, y, px, py) {
return true;
}
if (core.status.preview.prepareDragging) {
- if (Math.abs(px - core.status.preview.px) <= 20 && Math.abs(py - core.status.preview.py) <= 20)
+ if (Math.abs(px - core.status.preview.px) <= 20 && Math.abs(py - core.status.preview.py) <= 20)
return true;
else core.status.preview.prepareDragging = false;
}
@@ -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;
}
@@ -1044,7 +1044,7 @@ actions.prototype._onMoveConfirmBox = function (x, y, px, py) {
actions.prototype._clickAction_text = function () {
// 正在淡入淡出的话不执行
if (core.status.event.animateUI) return;
-
+
var data = core.clone(core.status.event.data.current);
if (typeof data == 'string') data = { "type": "text", "text": data };
@@ -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;
}
@@ -1522,7 +1522,7 @@ actions.prototype._keyUpQuickShop = function (keycode) {
////// 工具栏界面时的点击操作 //////
actions.prototype._clickToolbox = function (x, y) {
- var tools = core.getToolboxItems('tools'),
+ var tools = core.getToolboxItems('tools'),
constants = core.getToolboxItems('constants');
// 装备栏
@@ -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('光标移动');
@@ -1586,7 +1586,7 @@ actions.prototype._clickToolbox = function (x, y) {
////// 选择工具栏界面中某个Index后的操作 //////
actions.prototype._clickToolboxIndex = function (index) {
- var tools = core.getToolboxItems('tools'),
+ var tools = core.getToolboxItems('tools'),
constants = core.getToolboxItems('constants');
var items = null;
@@ -1618,7 +1618,7 @@ actions.prototype._keyDownToolbox = function (keycode) {
var last_index = this.LAST - 1;
- var tools = core.getToolboxItems('tools'),
+ var tools = core.getToolboxItems('tools'),
constants = core.getToolboxItems('constants');
var index = core.status.event.selection;
var toolsPage = core.status.event.data.toolsPage;
@@ -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);
});
@@ -2797,7 +2797,7 @@ actions.prototype._clickLocalSaveSelect = function (x, y) {
"version": core.firstData.version,
"data": saves
}
- core.download(core.firstData.name + "_" + core.formatDate2(new Date()) + ".h5save",
+ core.download(core.firstData.name + "_" + core.formatDate2(new Date()) + ".h5save",
LZString.compressToBase64(JSON.stringify(content)));
}
};
@@ -2940,7 +2940,7 @@ actions.prototype._clickReplay_replayRemain = function () {
core.closePanel();
core.drawText([
"\t[接续播放录像]该功能允许你播放\r[yellow]两个存档之间的录像\r,常常用于\r[yellow]区域优化\r。\n" +
- "例如,有若干个区,已经全部通关;之后重打一区并进行了优化,则可以对剩余区域直接播放录像而无需全部重打。\n\n" +
+ "例如,有若干个区,已经全部通关;之后重打一区并进行了优化,则可以对剩余区域直接播放录像而无需全部重打。\n\n" +
"详细使用方法参见露珠录制的视频教程:\n\r[yellow]https://bilibili.com/video/BV1az4y1C78x",
"\t[步骤1]请选择一个存档。\n\r[yellow]该存档的坐标必须和当前勇士坐标完全相同。\r\n将尝试从此处开始回放。",
], function () {
@@ -2956,7 +2956,7 @@ actions.prototype._clickReplay_replaySince = function () {
core.closePanel();
core.drawText([
"\t[播放存档剩余录像]该功能为【接续播放录像】的简化版本,允许你播放\r[yellow]一个存档中剩余的录像\r,常常用于\r[yellow]录像局部优化\r。\n" +
- "在录像正常播放中,你随时可以暂停并按S键进行存档;此时\r[yellow]剩余录像\r也会被记在存档中(在读档界面用\r[yellow][R]\r标识。)\n" +
+ "在录像正常播放中,你随时可以暂停并按S键进行存档;此时\r[yellow]剩余录像\r也会被记在存档中(在读档界面用\r[yellow][R]\r标识。)\n" +
"之后,你可以选择在路线优化后直接播放该存档的\r[yellow]剩余录像\r,而无需再像接续播放一样选择录像起点和终点。\n\n" +
"详细使用方法参见露珠录制的视频教程:\n\r[yellow]https://bilibili.com/video/BV1az4y1C78x",
"请选择一个存档。\n\n\r[yellow]该存档需为录像播放中存的,且坐标必须和当前勇士坐标完全相同。\r\n将尝试播放此存档的剩余录像。",
@@ -2971,7 +2971,7 @@ actions.prototype._clickReplay_replaySince = function () {
actions.prototype._clickReplay_download = function () {
// if (core.hasFlag('debug')) return core.drawText("\t[系统提示]调试模式下无法下载录像");
- core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route",
+ core.download(core.firstData.name + "_" + core.formatDate2() + ".h5route",
LZString.compressToBase64(JSON.stringify({
'name': core.firstData.name,
'hard': core.status.hard,
diff --git a/libs/control.js b/libs/control.js
index 32104e9d..5a8f0f72 100644
--- a/libs/control.js
+++ b/libs/control.js
@@ -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);
}
diff --git a/libs/core.js b/libs/core.js
index 804cbacf..d6906580 100644
--- a/libs/core.js
+++ b/libs/core.js
@@ -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);
@@ -104,7 +104,7 @@ function core() {
offsetX: 0, // in pixel
offsetY: 0,
posX: 0, //
- posY: 0,
+ posY: 0,
width: this.__SIZE__, // map width and height
height: this.__SIZE__,
v2: false,
@@ -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,
@@ -284,7 +284,7 @@ core.prototype.init = function (coreData, callback) {
core.extensions._load(function () {
core._afterLoadResources(callback);
});
- });
+ });
core.dom.musicBtn.style.display = 'block';
core.dom.enlargeBtn.style.display = 'block';
core.setMusicBtn();
@@ -295,7 +295,7 @@ core.prototype._init_flags = function () {
core.values = core.clone(core.data.values);
core.firstData = core.clone(core.data.firstData);
this._init_sys_flags();
-
+
// 让你总是拼错!
window.on = true;
window.off = false;
@@ -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);
}
}
diff --git a/libs/data.js b/libs/data.js
index 5ec17f8c..89ffb694 100644
--- a/libs/data.js
+++ b/libs/data.js
@@ -2,7 +2,7 @@
"use strict";
-function data() {
+function data () {
this._init();
}
diff --git a/libs/enemys.js b/libs/enemys.js
index 5cf7659f..d162a05c 100644
--- a/libs/enemys.js
+++ b/libs/enemys.js
@@ -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) {
@@ -46,7 +46,7 @@ enemys.prototype.getEnemys = 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,15 +263,15 @@ 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,
- core.getEnemyValue(enemy, 'hp', x, y, floorId) + core.getEnemyValue(enemy, 'def', x, y, floorId));
+ return calNext(core.status.hero.atk + 1,
+ core.getEnemyValue(enemy, 'hp', x, y, floorId) + core.getEnemyValue(enemy, 'def', x, y, floorId));
}
enemys.prototype._nextCriticals_special = function (enemy, number, x, y, floorId) {
@@ -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;
}
@@ -429,7 +429,7 @@ enemys.prototype._getCurrentEnemys_getEnemy = function (enemyId) {
if (!enemy) return null;
// 检查朝向;displayIdInBook
- return core.material.enemys[enemy.displayIdInBook] || core.material.enemys[(enemy.faceIds || {}).down] || enemy;
+ return core.material.enemys[enemy.displayIdInBook] || core.material.enemys[(enemy.faceIds || {}).down] || enemy;
}
enemys.prototype._getCurrentEnemys_addEnemy = function (enemyId, enemys, used, x, y, floorId) {
@@ -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++) {
diff --git a/libs/events.js b/libs/events.js
index 0ac09e82..e1db9565 100644
--- a/libs/events.js
+++ b/libs/events.js
@@ -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();
diff --git a/libs/extensions.js b/libs/extensions.js
index f3450523..7f4b9fce 100644
--- a/libs/extensions.js
+++ b/libs/extensions.js
@@ -6,7 +6,7 @@ extensions.js:负责拓展插件
"use strict";
-function extensions() {
+function extensions () {
}
diff --git a/libs/icons.js b/libs/icons.js
index 1c2b70a2..1f2d578a 100644
--- a/libs/icons.js
+++ b/libs/icons.js
@@ -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;
}
diff --git a/libs/items.js b/libs/items.js
index 77f1327c..a9795c9a 100644
--- a/libs/items.js
+++ b/libs/items.js
@@ -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);
}
}
}
@@ -128,14 +128,14 @@ items.prototype._afterUseItem = function (itemId) {
items.prototype.canUseItem = function (itemId) {
// 没有道具
if (!core.hasItem(itemId)) return false;
-
+
var canUseItemEffect = core.material.items[itemId].canUseItemEffect;
if (canUseItemEffect) {
try {
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 = [];
@@ -415,7 +415,7 @@ items.prototype.quickLoadEquip = function (index) {
////// 设置装备属性 //////
items.prototype.setEquip = function (equipId, valueType, name, value, operator, prefix) {
var equip = core.material.items[equipId];
- if (!equip || equip.cls != 'equips') return;
+ if (!equip || equip.cls != 'equips') return;
var equipInfo = equip.equip || {};
if (!equipInfo[valueType]) equipInfo[valueType] = {};
var toEquipInfo = core.clone(equipInfo);
@@ -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();
diff --git a/libs/loader.js b/libs/loader.js
index 8ca0868f..310a863d 100644
--- a/libs/loader.js
+++ b/libs/loader.js
@@ -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;
@@ -62,8 +62,8 @@ loader.prototype._load_async = function (callback) {
if (allLoaded == allTotal) {
core.loader._setStartLoadTipText("正在处理资源文件... 请稍候...");
} else {
- core.loader._setStartLoadTipText('正在加载资源文件... ' +
- core.formatSize(allLoaded) + " / " + core.formatSize(allTotal) +
+ core.loader._setStartLoadTipText('正在加载资源文件... ' +
+ core.formatSize(allLoaded) + " / " + core.formatSize(allTotal) +
" (" + (allLoaded / allTotal * 100).toFixed(2) + "%)");
}
core.loader._setStartProgressVal(allLoaded / allTotal * 100);
@@ -175,7 +175,7 @@ loader.prototype._loadAutotiles_async = function (onprogress, onfinished) {
}
loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) {
- // autotile需要保证顺序
+ // autotile需要保证顺序
keys.forEach(function (v) {
core.material.images.autotile[v] = autotiles[v];
});
@@ -183,7 +183,7 @@ loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) {
setTimeout(function () {
core.maps._makeAutotileEdges();
});
-
+
}
// ------ 加载额外素材 ------ //
@@ -263,7 +263,7 @@ loader.prototype.loadImage = function (dir, imgName, callback) {
callback(imgName, null);
}
catch (e) {
- main.log(e);
+ console.error(e);
}
}
@@ -322,7 +322,7 @@ loader.prototype._loadAnimates_sync = function () {
}
core.animates.forEach(function (t) {
- core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
+ core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
core.material.animates[t] = core.loader._loadAnimate(content);
}, function (e) {
main.log(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;
}
}
diff --git a/libs/utils.js b/libs/utils.js
index 988b1fe8..956340d4 100644
--- a/libs/utils.js
+++ b/libs/utils.js
@@ -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)
}
}
diff --git a/main.js b/main.js
index addc8163..9f63e05a 100644
--- a/main.js
+++ b/main.js
@@ -1,4 +1,4 @@
-function main() {
+function main () {
//------------------------ 用户修改内容 ------------------------//
@@ -83,7 +83,7 @@ function main() {
this.loadList = [
'loader', 'control', 'utils', 'items', 'icons', 'maps', 'enemys', 'events', 'actions', 'data', 'ui', 'extensions', 'core'
];
- this.pureData = [
+ this.pureData = [
'data', 'enemys', 'icons', 'maps', 'items', 'functions', 'events', 'plugins'
];
this.materials = [
@@ -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,27 +198,27 @@ 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];
-
- main.dom.startLogo.style=main.styles.startLogoStyle;
+ for (var ii in mainData) main[ii] = mainData[ii];
+
+ 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();
main.importFonts(main.fonts);
-
+
main.loadJs('libs', main.loadList, function () {
main.core = core;
@@ -228,12 +228,12 @@ 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) {
- coreData[t] = main[t];
- })
+ coreData[t] = main[t];
+ })
main.core.init(coreData, callback);
main.core.resize();
});
@@ -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);
}
@@ -311,15 +311,15 @@ main.prototype.loadFloors = function (callback) {
callback();
}
});
- }
+ }
}
main.dom.body.appendChild(script);
}
////// 加载某一个楼层 //////
-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,422 +402,422 @@ main.prototype.importFonts = function (fonts) {
main.prototype.listen = function () {
-////// 窗口大小变化时 //////
-window.onresize = function () {
- try {
- main.core.resize();
- }catch (e) { main.log(e); }
-}
+ ////// 窗口大小变化时 //////
+ window.onresize = function () {
+ try {
+ main.core.resize();
+ } catch (ee) { console.error(ee) }
+ }
-////// 在界面上按下某按键时 //////
-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); }
-}
+ ////// 在界面上按下某按键时 //////
+ 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) { console.error(ee) }
+ }
-////// 在界面上放开某按键时 //////
-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);
- else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn
- 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
- main.core.showStartAnimate(true);
+ ////// 在界面上放开某按键时 //////
+ 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);
+ else if (e.keyCode == 40 || e.keyCode == 34) // down/pgdn
+ 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
+ main.core.showStartAnimate(true);
+ }
+ e.stopPropagation();
+ return;
}
+ if (main.dom.inputDiv.style.display == 'block') {
+ if (e.keyCode == 13) {
+ setTimeout(function () {
+ main.dom.inputYes.click();
+ }, 50);
+ }
+ else if (e.keyCode == 27) {
+ setTimeout(function () {
+ main.dom.inputNo.click();
+ }, 50);
+ }
+ return;
+ }
+ if (main.core && main.core.isPlaying && main.core.status &&
+ (main.core.isPlaying() || main.core.status.lockControl))
+ main.core.onkeyUp(e);
+ } catch (ee) { console.error(ee) }
+ };
+
+ [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)) {
+ main.selectButton(i);
+ }
+ }
+ }
+ });
+
+ ////// 开始选择时 //////
+ main.dom.body.onselectstart = function () {
+ return false;
+ }
+
+ ////// 鼠标按下时 //////
+ 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) { console.error(ee) }
+ }
+
+ ////// 鼠标移动时 //////
+ 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) { console.error(ee) }
+ }
+
+ ////// 鼠标放开时 //////
+ 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 (ee) { console.error(ee) }
+ }
+
+ ////// 鼠标滑轮滚动时 //////
+ 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) { console.error(ee) }
+ }
+
+ ////// 手指在触摸屏开始触摸时 //////
+ 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) { console.error(ee) }
+ }
+
+ ////// 手指在触摸屏上移动时 //////
+ 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) { console.error(ee) }
+ }
+
+ ////// 手指离开触摸屏时 //////
+ main.dom.data.ontouchend = function (e) {
+ try {
+ e.preventDefault();
+ if (main.lastTouchLoc == null) return;
+ var loc = main.lastTouchLoc;
+ delete main.lastTouchLoc;
+ main.core.onup(loc);
+ } catch (e) {
+ console.error(e);
+ }
+ }
+
+ main.dom.statusCanvas.onclick = function (e) {
+ try {
+ e.preventDefault();
+ main.core.onStatusBarClick(e);
+ } catch (e) {
+ console.error(e);
+ }
+ }
+
+ ////// 点击状态栏中的怪物手册时 //////
+ main.statusBar.image.book.onclick = function (e) {
+ e.stopPropagation();
+
+ if (core.isReplaying()) {
+ core.triggerReplay();
return;
}
- if (main.dom.inputDiv.style.display == 'block') {
- if (e.keyCode == 13) {
- setTimeout(function () {
- main.dom.inputYes.click();
- }, 50);
- }
- else if (e.keyCode == 27) {
- setTimeout(function () {
- main.dom.inputNo.click();
- }, 50);
- }
+
+ if (main.core.isPlaying())
+ main.core.openBook(true);
+ }
+
+ ////// 点击状态栏中的楼层传送器/装备栏时 //////
+ main.statusBar.image.fly.onclick = function (e) {
+ e.stopPropagation();
+
+ // 播放录像时
+ if (core.isReplaying()) {
+ core.stopReplay();
return;
}
- 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); }
-};
-[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)) {
- main.selectButton(i);
+ if (main.core.isPlaying()) {
+ if (!main.core.flags.equipboxButton) {
+ main.core.useFly(true);
+ }
+ else {
+ main.core.openEquipbox(true)
}
}
}
-});
-////// 开始选择时 //////
-main.dom.body.onselectstart = function () {
- return false;
-}
-
-////// 鼠标按下时 //////
-main.dom.data.onmousedown = function (e) {
- try {
+ ////// 点击状态栏中的工具箱时 //////
+ main.statusBar.image.toolbox.onclick = function (e) {
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); }
-}
-////// 鼠标移动时 //////
-main.dom.data.onmousemove = function (e) {
- try {
+ if (core.isReplaying()) {
+ core.rewindReplay();
+ return;
+ }
+
+ if (main.core.isPlaying()) {
+ main.core.openToolbox(core.status.event.id != 'equipbox');
+ }
+ }
+
+ ////// 双击状态栏中的工具箱时 //////
+ main.statusBar.image.toolbox.ondblclick = function (e) {
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); }
-}
-////// 鼠标放开时 //////
-main.dom.data.onmouseup = function (e) {
- try {
+ if (core.isReplaying()) {
+ return;
+ }
+
+ if (main.core.isPlaying())
+ main.core.openEquipbox(true);
+
+ }
+
+ ////// 点击状态栏中的虚拟键盘时 //////
+ main.statusBar.image.keyboard.onclick = function (e) {
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); }
-}
-////// 鼠标滑轮滚动时 //////
-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); }
-}
+ if (core.isReplaying()) {
+ core.control._replay_book();
+ return;
+ }
-////// 手指在触摸屏开始触摸时 //////
-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); }
-}
-
-////// 手指在触摸屏上移动时 //////
-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); }
-}
-
-////// 手指离开触摸屏时 //////
-main.dom.data.ontouchend = function (e) {
- try {
- e.preventDefault();
- if (main.lastTouchLoc == null) return;
- var loc = main.lastTouchLoc;
- delete main.lastTouchLoc;
- main.core.onup(loc);
- } catch (e) {
- main.log(e);
- }
-}
-
-main.dom.statusCanvas.onclick = function (e) {
- try {
- e.preventDefault();
- main.core.onStatusBarClick(e);
- } catch (e) {
- main.log(e);
- }
-}
-
-////// 点击状态栏中的怪物手册时 //////
-main.statusBar.image.book.onclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.triggerReplay();
- return;
+ if (main.core.isPlaying())
+ main.core.openKeyBoard(true);
}
- if (main.core.isPlaying())
- main.core.openBook(true);
-}
+ ////// 点击状态栏中的快捷商店时 //////
+ main.statusBar.image.shop.onclick = function (e) {
+ e.stopPropagation();
-////// 点击状态栏中的楼层传送器/装备栏时 //////
-main.statusBar.image.fly.onclick = function (e) {
- e.stopPropagation();
+ if (core.isReplaying()) {
+ core.control._replay_viewMap();
+ return;
+ }
- // 播放录像时
- if (core.isReplaying()) {
- core.stopReplay();
- return;
+ if (main.core.isPlaying())
+ main.core.openQuickShop(true);
}
- if (main.core.isPlaying()) {
- if (!main.core.flags.equipboxButton) {
- main.core.useFly(true);
+ ////// 点击金币时也可以开启快捷商店 //////
+ main.statusBar.image.money.onclick = function (e) {
+ e.stopPropagation();
+
+ if (main.core.isPlaying())
+ main.core.openQuickShop(true);
+ }
+
+ ////// 点击楼梯图标也可以浏览地图 //////
+ 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) {
+ e.stopPropagation();
+
+ if (core.isReplaying()) {
+ core.speedDownReplay();
+ return;
+ }
+
+ if (main.core.isPlaying())
+ main.core.save(true);
+ }
+
+ ////// 点击状态栏中的读档按钮时 //////
+ main.statusBar.image.load.onclick = function (e) {
+ e.stopPropagation();
+
+ if (core.isReplaying()) {
+ core.speedUpReplay();
+ return;
+ }
+
+ if (main.core.isPlaying())
+ main.core.load(true);
+ }
+
+ ////// 点击状态栏中的系统菜单时 //////
+ main.statusBar.image.settings.onclick = function (e) {
+ e.stopPropagation();
+
+ if (core.isReplaying()) {
+ core.control._replay_SL();
+ return;
+ }
+
+ if (main.core.isPlaying())
+ main.core.openSettings(true);
+ }
+
+ ////// 点击工具栏时 //////
+ 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) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 49, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn2.onclick = function (e) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 50, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn3.onclick = function (e) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 51, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn4.onclick = function (e) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 52, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn5.onclick = function (e) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 53, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn6.onclick = function (e) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 54, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn7.onclick = function (e) {
+ e.stopPropagation();
+ main.core.onkeyUp({ "keyCode": 55, "altKey": core.getLocalStorage('altKey') });
+ };
+
+ main.statusBar.image.btn8.onclick = function (e) {
+ e.stopPropagation();
+ if (core.getLocalStorage('altKey')) {
+ core.removeLocalStorage('altKey');
+ core.drawTip("Alt模式已关闭。");
+ main.statusBar.image.btn8.style.filter = '';
}
else {
- main.core.openEquipbox(true)
+ core.setLocalStorage('altKey', true);
+ 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.core.control.checkBgm();
+
+ if (main.levelChoose.length == 0) {
+ core.events.startGame("");
+ } else {
+ main.dom.levelChooseButtons.style.display = 'block';
+ main.selectedButton = null;
+ main.selectButton(0);
}
}
-}
-////// 点击状态栏中的工具箱时 //////
-main.statusBar.image.toolbox.onclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.rewindReplay();
- return;
+ ////// 点击“载入游戏”时 //////
+ main.dom.loadGame.onclick = function () {
+ main.core.control.checkBgm();
+ main.core.load();
}
- if (main.core.isPlaying()) {
- main.core.openToolbox(core.status.event.id != 'equipbox');
- }
-}
-
-////// 双击状态栏中的工具箱时 //////
-main.statusBar.image.toolbox.ondblclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- return;
+ ////// 点击“录像回放”时 //////
+ main.dom.replayGame.onclick = function () {
+ main.core.control.checkBgm();
+ main.core.chooseReplayFile();
}
- if (main.core.isPlaying())
- main.core.openEquipbox(true);
-
-}
-
-////// 点击状态栏中的虚拟键盘时 //////
-main.statusBar.image.keyboard.onclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.control._replay_book();
- return;
- }
-
- if (main.core.isPlaying())
- main.core.openKeyBoard(true);
-}
-
-////// 点击状态栏中的快捷商店时 //////
-main.statusBar.image.shop.onclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.control._replay_viewMap();
- return;
- }
-
- if (main.core.isPlaying())
- main.core.openQuickShop(true);
-}
-
-////// 点击金币时也可以开启快捷商店 //////
-main.statusBar.image.money.onclick = function (e) {
- e.stopPropagation();
-
- if (main.core.isPlaying())
- main.core.openQuickShop(true);
-}
-
-////// 点击楼梯图标也可以浏览地图 //////
-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) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.speedDownReplay();
- return;
- }
-
- if (main.core.isPlaying())
- main.core.save(true);
-}
-
-////// 点击状态栏中的读档按钮时 //////
-main.statusBar.image.load.onclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.speedUpReplay();
- return;
- }
-
- if (main.core.isPlaying())
- main.core.load(true);
-}
-
-////// 点击状态栏中的系统菜单时 //////
-main.statusBar.image.settings.onclick = function (e) {
- e.stopPropagation();
-
- if (core.isReplaying()) {
- core.control._replay_SL();
- return;
- }
-
- if (main.core.isPlaying())
- main.core.openSettings(true);
-}
-
-////// 点击工具栏时 //////
-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) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 49, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn2.onclick = function (e) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 50, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn3.onclick = function (e) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 51, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn4.onclick = function (e) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 52, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn5.onclick = function (e) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 53, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn6.onclick = function (e) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 54, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn7.onclick = function (e) {
- e.stopPropagation();
- main.core.onkeyUp({"keyCode": 55, "altKey": core.getLocalStorage('altKey')});
-};
-
-main.statusBar.image.btn8.onclick = function (e) {
- e.stopPropagation();
- if (core.getLocalStorage('altKey')) {
- core.removeLocalStorage('altKey');
- core.drawTip("Alt模式已关闭。");
- main.statusBar.image.btn8.style.filter = '';
- }
- else {
- core.setLocalStorage('altKey', true);
- 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.core.control.checkBgm();
-
- if (main.levelChoose.length == 0) {
- core.events.startGame("");
- } else {
- main.dom.levelChooseButtons.style.display='block';
- main.selectedButton = null;
- main.selectButton(0);
- }
-}
-
-////// 点击“载入游戏”时 //////
-main.dom.loadGame.onclick = function() {
- main.core.control.checkBgm();
- main.core.load();
-}
-
-////// 点击“录像回放”时 //////
-main.dom.replayGame.onclick = function () {
- main.core.control.checkBgm();
- main.core.chooseReplayFile();
-}
-
-main.dom.musicBtn.onclick = function () {
- try {
- if (main.core)
- main.core.triggerBgm();
- } catch (e) {main.log(e);}
-}
-
-main.dom.enlargeBtn.onclick = function () {
- try {
- if (main.core) {
- main.core.setDisplayScale(1);
- if (!main.core.isPlaying() && main.core.flags.enableHDCanvas) {
- main.core.domStyle.ratio = Math.max(window.devicePixelRatio || 1, main.core.domStyle.scale);
- main.core.resize();
- }
- }
- } catch (e) {main.log(e)};
-}
-
-window.onblur = function () {
- if (main.core && main.core.control) {
+ main.dom.musicBtn.onclick = function () {
try {
- main.core.control.checkAutosave();
- } catch (e) {}
+ if (main.core)
+ main.core.triggerBgm();
+ } catch (ee) { console.error(ee) }
}
-}
-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.enlargeBtn.onclick = function () {
+ try {
+ if (main.core) {
+ main.core.setDisplayScale(1);
+ if (!main.core.isPlaying() && main.core.flags.enableHDCanvas) {
+ main.core.domStyle.ratio = Math.max(window.devicePixelRatio || 1, main.core.domStyle.scale);
+ main.core.resize();
+ }
+ }
+ } catch (e) { main.log(e) };
+ }
-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);
-}
+ window.onblur = function () {
+ if (main.core && main.core.control) {
+ try {
+ main.core.control.checkAutosave();
+ } catch (e) { }
+ }
+ }
+
+ 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.inputDiv.style.display = 'none';
+ var func = core.platform.errorCallback;
+ core.platform.successCallback = core.platform.errorCallback = null;
+ if (func) func(null);
+ }
}//listen end
diff --git a/project/functions.js b/project/functions.js
index 4021e500..1f776f9d 100644
--- a/project/functions.js
+++ b/project/functions.js
@@ -1,3 +1,4 @@
+///
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);
}
}
}
diff --git a/project/plugins.js b/project/plugins.js
index 730b7eed..b7b8b745 100644
--- a/project/plugins.js
+++ b/project/plugins.js
@@ -1,809 +1,810 @@
-var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
+///
+var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
{
- "init": function () {
+ "init": function () {
- console.log("插件编写测试");
+ console.log("插件编写测试");
- // 可以写一些直接执行的代码
- // 在这里写的代码将会在【资源加载前】被执行,此时图片等资源尚未被加载。
- // 请勿在这里对包括bgm,图片等资源进行操作。
+ // 可以写一些直接执行的代码
+ // 在这里写的代码将会在【资源加载前】被执行,此时图片等资源尚未被加载。
+ // 请勿在这里对包括bgm,图片等资源进行操作。
- this._afterLoadResources = function () {
- // 本函数将在所有资源加载完毕后,游戏开启前被执行
- // 可以在这个函数里面对资源进行一些操作。
- // 若需要进行切分图片,可以使用 core.splitImage() 函数,或直接在全塔属性-图片切分中操作
- }
-
- // 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
- // 从V2.6开始,插件中用this.XXX方式定义的函数也会被转发到core中,详见文档-脚本-函数的转发。
-},
- "drawLight": function () {
-
- // 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...)
- // 【参数说明】
- // name:必填,要绘制到的画布名;可以是一个系统画布,或者是个自定义画布;如果不存在则创建
- // color:可选,只能是一个0~1之间的数,为不透明度的值。不填则默认为0.9。
- // lights:可选,一个数组,定义了每个独立的灯光。
- // 其中每一项是三元组 [x,y,r] x和y分别为该灯光的横纵坐标,r为该灯光的半径。
- // lightDec:可选,0到1之间,光从多少百分比才开始衰减(在此范围内保持全亮),不设置默认为0。
- // 比如lightDec为0.5代表,每个灯光部分内圈50%的范围全亮,50%以后才开始快速衰减。
- // 【调用样例】
- // core.plugin.drawLight('curtain'); // 在curtain层绘制全图不透明度0.9,等价于更改画面色调为[0,0,0,0.9]。
- // core.plugin.drawLight('ui', 0.95, [[25,11,46]]); // 在ui层绘制全图不透明度0.95,其中在(25,11)点存在一个半径为46的灯光效果。
- // core.plugin.drawLight('test', 0.2, [[25,11,46,0.1]]); // 创建一个test图层,不透明度0.2,其中在(25,11)点存在一个半径为46的灯光效果,灯光中心不透明度0.1。
- // core.plugin.drawLight('test2', 0.9, [[25,11,46],[105,121,88],[301,221,106]]); // 创建test2图层,且存在三个灯光效果,分别是中心(25,11)半径46,中心(105,121)半径88,中心(301,221)半径106。
- // core.plugin.drawLight('xxx', 0.3, [[25,11,46],[105,121,88,0.2]], 0.4); // 存在两个灯光效果,它们在内圈40%范围内保持全亮,40%后才开始衰减。
- this.drawLight = function (name, color, lights, lightDec) {
-
- // 清空色调层;也可以修改成其它层比如animate/weather层,或者用自己创建的canvas
- var ctx = core.getContextByName(name);
- if (ctx == null) {
- if (typeof name == 'string')
- ctx = core.createCanvas(name, 0, 0, core.__PIXELS__, core.__PIXELS__, 98);
- else return;
+ this._afterLoadResources = function () {
+ // 本函数将在所有资源加载完毕后,游戏开启前被执行
+ // 可以在这个函数里面对资源进行一些操作。
+ // 若需要进行切分图片,可以使用 core.splitImage() 函数,或直接在全塔属性-图片切分中操作
}
- ctx.mozImageSmoothingEnabled = false;
- ctx.webkitImageSmoothingEnabled = false;
- ctx.msImageSmoothingEnabled = false;
- ctx.imageSmoothingEnabled = false;
+ // 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
+ // 从V2.6开始,插件中用this.XXX方式定义的函数也会被转发到core中,详见文档-脚本-函数的转发。
+ },
+ "drawLight": function () {
- core.clearMap(name);
- // 绘制色调层,默认不透明度
- if (color == null) color = 0.9;
- ctx.fillStyle = "rgba(0,0,0," + color + ")";
- ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+ // 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...)
+ // 【参数说明】
+ // name:必填,要绘制到的画布名;可以是一个系统画布,或者是个自定义画布;如果不存在则创建
+ // color:可选,只能是一个0~1之间的数,为不透明度的值。不填则默认为0.9。
+ // lights:可选,一个数组,定义了每个独立的灯光。
+ // 其中每一项是三元组 [x,y,r] x和y分别为该灯光的横纵坐标,r为该灯光的半径。
+ // lightDec:可选,0到1之间,光从多少百分比才开始衰减(在此范围内保持全亮),不设置默认为0。
+ // 比如lightDec为0.5代表,每个灯光部分内圈50%的范围全亮,50%以后才开始快速衰减。
+ // 【调用样例】
+ // core.plugin.drawLight('curtain'); // 在curtain层绘制全图不透明度0.9,等价于更改画面色调为[0,0,0,0.9]。
+ // core.plugin.drawLight('ui', 0.95, [[25,11,46]]); // 在ui层绘制全图不透明度0.95,其中在(25,11)点存在一个半径为46的灯光效果。
+ // core.plugin.drawLight('test', 0.2, [[25,11,46,0.1]]); // 创建一个test图层,不透明度0.2,其中在(25,11)点存在一个半径为46的灯光效果,灯光中心不透明度0.1。
+ // core.plugin.drawLight('test2', 0.9, [[25,11,46],[105,121,88],[301,221,106]]); // 创建test2图层,且存在三个灯光效果,分别是中心(25,11)半径46,中心(105,121)半径88,中心(301,221)半径106。
+ // core.plugin.drawLight('xxx', 0.3, [[25,11,46],[105,121,88,0.2]], 0.4); // 存在两个灯光效果,它们在内圈40%范围内保持全亮,40%后才开始衰减。
+ this.drawLight = function (name, color, lights, lightDec) {
- lightDec = core.clamp(lightDec, 0, 1);
-
- // 绘制每个灯光效果
- ctx.globalCompositeOperation = 'destination-out';
- lights.forEach(function (light) {
- // 坐标,半径,中心不透明度
- var x = light[0],
- y = light[1],
- r = light[2];
- // 计算衰减距离
- var decDistance = parseInt(r * lightDec);
- // 正方形区域的直径和左上角坐标
- var grd = ctx.createRadialGradient(x, y, decDistance, x, y, r);
- grd.addColorStop(0, "rgba(0,0,0,1)");
- grd.addColorStop(1, "rgba(0,0,0,0)");
- ctx.beginPath();
- ctx.fillStyle = grd;
- ctx.arc(x, y, r, 0, 2 * Math.PI);
- ctx.fill();
- });
- ctx.globalCompositeOperation = 'source-over';
- // 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
- }
-},
- "shop": function () {
- // 【全局商店】相关的功能
- //
- // 打开一个全局商店
- // shopId:要打开的商店id;noRoute:是否不计入录像
- this.openShop = function (shopId, noRoute) {
- var shop = core.status.shops[shopId];
- // Step 1: 检查能否打开此商店
- if (!this.canOpenShop(shopId)) {
- core.drawTip("该商店尚未开启");
- return false;
- }
-
- // Step 2: (如有必要)记录打开商店的脚本事件
- if (!noRoute) {
- core.status.route.push("shop:" + shopId);
- }
-
- // Step 3: 检查道具商店 or 公共事件
- if (shop.item) {
- if (core.openItemShop) {
- core.openItemShop(shopId);
- } else {
- core.playSound('操作失败');
- core.insertAction("道具商店插件不存在!请检查是否存在该插件!");
+ // 清空色调层;也可以修改成其它层比如animate/weather层,或者用自己创建的canvas
+ var ctx = core.getContextByName(name);
+ if (ctx == null) {
+ if (typeof name == 'string')
+ ctx = core.createCanvas(name, 0, 0, core.__PIXELS__, core.__PIXELS__, 98);
+ else return;
}
- return;
- }
- if (shop.commonEvent) {
- core.insertCommonEvent(shop.commonEvent, shop.args);
- return;
- }
- _shouldProcessKeyUp = true;
+ ctx.mozImageSmoothingEnabled = false;
+ ctx.webkitImageSmoothingEnabled = false;
+ ctx.msImageSmoothingEnabled = false;
+ ctx.imageSmoothingEnabled = false;
- // Step 4: 执行标准公共商店
- core.insertAction(this._convertShop(shop));
- return true;
- }
+ core.clearMap(name);
+ // 绘制色调层,默认不透明度
+ if (color == null) color = 0.9;
+ ctx.fillStyle = "rgba(0,0,0," + color + ")";
+ ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
- ////// 将一个全局商店转变成可预览的公共事件 //////
- this._convertShop = function (shop) {
- return [
- { "type": "function", "function": "function() {core.addFlag('@temp@shop', 1);}" },
- {
- "type": "while",
- "condition": "true",
- "data": [
- // 检测能否访问该商店
- {
- "type": "if",
- "condition": "core.isShopVisited('" + shop.id + "')",
- "true": [
- // 可以访问,直接插入执行效果
- { "type": "function", "function": "function() { core.plugin._convertShop_replaceChoices('" + shop.id + "', false) }" },
- ],
- "false": [
- // 不能访问的情况下:检测能否预览
- {
- "type": "if",
- "condition": shop.disablePreview,
- "true": [
- // 不可预览,提示并退出
- { "type": "playSound", "name": "操作失败" },
- "当前无法访问该商店!",
- { "type": "break" },
- ],
- "false": [
- // 可以预览:将商店全部内容进行替换
- { "type": "tip", "text": "当前处于预览模式,不可购买" },
- { "type": "function", "function": "function() { core.plugin._convertShop_replaceChoices('" + shop.id + "', true) }" },
- ]
- }
- ]
- }
- ]
- },
- { "type": "function", "function": "function() {core.addFlag('@temp@shop', -1);}" }
- ];
- }
+ lightDec = core.clamp(lightDec, 0, 1);
- this._convertShop_replaceChoices = function (shopId, previewMode) {
- var shop = core.status.shops[shopId];
- var choices = (shop.choices || []).filter(function (choice) {
- if (choice.condition == null || choice.condition == '') return true;
- try { return core.calValue(choice.condition); } catch (e) { return true; }
- }).map(function (choice) {
- var ableToBuy = core.calValue(choice.need);
- return {
- "text": choice.text,
- "icon": choice.icon,
- "color": ableToBuy && !previewMode ? choice.color : [153, 153, 153, 1],
- "action": ableToBuy && !previewMode ? [{ "type": "playSound", "name": "商店" }].concat(choice.action) : [
- { "type": "playSound", "name": "操作失败" },
- { "type": "tip", "text": previewMode ? "预览模式下不可购买" : "购买条件不足" }
- ]
- };
- }).concat({ "text": "离开", "action": [{ "type": "playSound", "name": "取消" }, { "type": "break" }] });
- core.insertAction({ "type": "choices", "text": shop.text, "choices": choices });
- }
-
- /// 是否访问过某个快捷商店
- this.isShopVisited = function (id) {
- if (!core.hasFlag("__shops__")) core.setFlag("__shops__", {});
- var shops = core.getFlag("__shops__");
- if (!shops[id]) shops[id] = {};
- return shops[id].visited;
- }
-
- /// 当前应当显示的快捷商店列表
- this.listShopIds = function () {
- return Object.keys(core.status.shops).filter(function (id) {
- return core.isShopVisited(id) || !core.status.shops[id].mustEnable;
- });
- }
-
- /// 是否能够打开某个商店
- this.canOpenShop = function (id) {
- if (this.isShopVisited(id)) return true;
- var shop = core.status.shops[id];
- if (shop.item || shop.commonEvent || shop.mustEnable) return false;
- return true;
- }
-
- /// 启用或禁用某个快捷商店
- this.setShopVisited = function (id, visited) {
- if (!core.hasFlag("__shops__")) core.setFlag("__shops__", {});
- var shops = core.getFlag("__shops__");
- if (!shops[id]) shops[id] = {};
- if (visited) shops[id].visited = true;
- else delete shops[id].visited;
- }
-
- /// 能否使用快捷商店
- this.canUseQuickShop = function (id) {
- // 如果返回一个字符串,表示不能,字符串为不能使用的提示
- // 返回null代表可以使用
-
- // 检查当前楼层的canUseQuickShop选项是否为false
- if (core.status.thisMap.canUseQuickShop === false)
- return '当前楼层不能使用快捷商店。';
- return null;
- }
-
- var _shouldProcessKeyUp = true;
-
- /// 允许商店X键退出
- core.registerAction('keyUp', 'shops', function (keycode) {
- if (!core.status.lockControl || core.status.event.id != 'action') return false;
- if ((keycode == 13 || keycode == 32) && !_shouldProcessKeyUp) {
- _shouldProcessKeyUp = true;
- return true;
- }
-
- if (!core.hasFlag("@temp@shop") || core.status.event.data.type != 'choices') return false;
- var data = core.status.event.data.current;
- var choices = data.choices;
- var topIndex = core.actions._getChoicesTopIndex(choices.length);
- if (keycode == 88 || keycode == 27) { // X, ESC
- core.actions._clickAction(core.actions.HSIZE, topIndex + choices.length - 1);
- return true;
- }
- return false;
- }, 60);
-
- /// 允许长按空格或回车连续执行操作
- core.registerAction('keyDown', 'shops', function (keycode) {
- if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false;
- if (core.status.event.data.type != 'choices') return false;
- var data = core.status.event.data.current;
- var choices = data.choices;
- var topIndex = core.actions._getChoicesTopIndex(choices.length);
- if (keycode == 13 || keycode == 32) { // Space, Enter
- core.actions._clickAction(core.actions.HSIZE, topIndex + core.status.event.selection);
- _shouldProcessKeyUp = false;
- return true;
- }
- return false;
- }, 60);
-
- // 允许长按屏幕连续执行操作
- core.registerAction('longClick', 'shops', function (x, y, px, py) {
- if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false;
- if (core.status.event.data.type != 'choices') return false;
- var data = core.status.event.data.current;
- var choices = data.choices;
- var topIndex = core.actions._getChoicesTopIndex(choices.length);
- if (x >= core.actions.CHOICES_LEFT && x <= core.actions.CHOICES_RIGHT && y >= topIndex && y < topIndex + choices.length) {
- core.actions._clickAction(x, y);
- return true;
- }
- return false;
- }, 60);
-},
- "removeMap": function () {
- // 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。
- // 推荐用法:
- // 对于超高层或分区域塔,当在1区时将2区以后的地图删除;1区结束时恢复2区,进二区时删除1区地图,以此类推
- // 这样可以大幅减少存档空间,以及加快存读档速度
-
- // 删除楼层
- // core.removeMaps("MT1", "MT300") 删除MT1~MT300之间的全部层
- // core.removeMaps("MT10") 只删除MT10层
- this.removeMaps = function (fromId, toId) {
- toId = toId || fromId;
- var fromIndex = core.floorIds.indexOf(fromId),
- toIndex = core.floorIds.indexOf(toId);
- if (toIndex < 0) toIndex = core.floorIds.length - 1;
- flags.__visited__ = flags.__visited__ || {};
- flags.__removed__ = flags.__removed__ || [];
- flags.__disabled__ = flags.__disabled__ || {};
- flags.__leaveLoc__ = flags.__leaveLoc__ || {};
- for (var i = fromIndex; i <= toIndex; ++i) {
- var floorId = core.floorIds[i];
- if (core.status.maps[floorId].deleted) continue;
- delete flags.__visited__[floorId];
- flags.__removed__.push(floorId);
- delete flags.__disabled__[floorId];
- delete flags.__leaveLoc__[floorId];
- (core.status.autoEvents || []).forEach(function (event) {
- if (event.floorId == floorId && event.currentFloor) {
- core.autoEventExecuting(event.symbol, false);
- core.autoEventExecuted(event.symbol, false);
- }
+ // 绘制每个灯光效果
+ ctx.globalCompositeOperation = 'destination-out';
+ lights.forEach(function (light) {
+ // 坐标,半径,中心不透明度
+ var x = light[0],
+ y = light[1],
+ r = light[2];
+ // 计算衰减距离
+ var decDistance = parseInt(r * lightDec);
+ // 正方形区域的直径和左上角坐标
+ var grd = ctx.createRadialGradient(x, y, decDistance, x, y, r);
+ grd.addColorStop(0, "rgba(0,0,0,1)");
+ grd.addColorStop(1, "rgba(0,0,0,0)");
+ ctx.beginPath();
+ ctx.fillStyle = grd;
+ ctx.arc(x, y, r, 0, 2 * Math.PI);
+ ctx.fill();
});
- core.status.maps[floorId].deleted = true;
- core.status.maps[floorId].canFlyTo = false;
- core.status.maps[floorId].canFlyFrom = false;
- core.status.maps[floorId].cannotViewMap = true;
+ ctx.globalCompositeOperation = 'source-over';
+ // 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
}
- }
+ },
+ "shop": function () {
+ // 【全局商店】相关的功能
+ //
+ // 打开一个全局商店
+ // shopId:要打开的商店id;noRoute:是否不计入录像
+ this.openShop = function (shopId, noRoute) {
+ var shop = core.status.shops[shopId];
+ // Step 1: 检查能否打开此商店
+ if (!this.canOpenShop(shopId)) {
+ core.drawTip("该商店尚未开启");
+ return false;
+ }
- // 恢复楼层
- // core.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层
- // core.resumeMaps("MT10") 只恢复MT10层
- this.resumeMaps = function (fromId, toId) {
- toId = toId || fromId;
- var fromIndex = core.floorIds.indexOf(fromId),
- toIndex = core.floorIds.indexOf(toId);
- if (toIndex < 0) toIndex = core.floorIds.length - 1;
- flags.__removed__ = flags.__removed__ || [];
- for (var i = fromIndex; i <= toIndex; ++i) {
- var floorId = core.floorIds[i];
- if (!core.status.maps[floorId].deleted) continue;
- flags.__removed__ = flags.__removed__.filter(function (f) { return f != floorId; });
- core.status.maps[floorId] = core.loadFloor(floorId);
+ // Step 2: (如有必要)记录打开商店的脚本事件
+ if (!noRoute) {
+ core.status.route.push("shop:" + shopId);
+ }
+
+ // Step 3: 检查道具商店 or 公共事件
+ if (shop.item) {
+ if (core.openItemShop) {
+ core.openItemShop(shopId);
+ } else {
+ core.playSound('操作失败');
+ core.insertAction("道具商店插件不存在!请检查是否存在该插件!");
+ }
+ return;
+ }
+ if (shop.commonEvent) {
+ core.insertCommonEvent(shop.commonEvent, shop.args);
+ return;
+ }
+
+ _shouldProcessKeyUp = true;
+
+ // Step 4: 执行标准公共商店
+ core.insertAction(this._convertShop(shop));
+ return true;
}
- }
- // 分区砍层相关
- var inAnyPartition = function (floorId) {
- var inPartition = false;
- (core.floorPartitions || []).forEach(function (floor) {
- var fromIndex = core.floorIds.indexOf(floor[0]);
- var toIndex = core.floorIds.indexOf(floor[1]);
- var index = core.floorIds.indexOf(floorId);
- if (fromIndex < 0 || index < 0) return;
- if (toIndex < 0) toIndex = core.floorIds.length - 1;
- if (index >= fromIndex && index <= toIndex) inPartition = true;
- });
- return inPartition;
- }
+ ////// 将一个全局商店转变成可预览的公共事件 //////
+ this._convertShop = function (shop) {
+ return [
+ { "type": "function", "function": "function() {core.addFlag('@temp@shop', 1);}" },
+ {
+ "type": "while",
+ "condition": "true",
+ "data": [
+ // 检测能否访问该商店
+ {
+ "type": "if",
+ "condition": "core.isShopVisited('" + shop.id + "')",
+ "true": [
+ // 可以访问,直接插入执行效果
+ { "type": "function", "function": "function() { core.plugin._convertShop_replaceChoices('" + shop.id + "', false) }" },
+ ],
+ "false": [
+ // 不能访问的情况下:检测能否预览
+ {
+ "type": "if",
+ "condition": shop.disablePreview,
+ "true": [
+ // 不可预览,提示并退出
+ { "type": "playSound", "name": "操作失败" },
+ "当前无法访问该商店!",
+ { "type": "break" },
+ ],
+ "false": [
+ // 可以预览:将商店全部内容进行替换
+ { "type": "tip", "text": "当前处于预览模式,不可购买" },
+ { "type": "function", "function": "function() { core.plugin._convertShop_replaceChoices('" + shop.id + "', true) }" },
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ { "type": "function", "function": "function() {core.addFlag('@temp@shop', -1);}" }
+ ];
+ }
- // 分区砍层
- this.autoRemoveMaps = function (floorId) {
- if (main.mode != 'play' || !inAnyPartition(floorId)) return;
- // 根据分区信息自动砍层与恢复
- (core.floorPartitions || []).forEach(function (floor) {
- var fromIndex = core.floorIds.indexOf(floor[0]);
- var toIndex = core.floorIds.indexOf(floor[1]);
- var index = core.floorIds.indexOf(floorId);
- if (fromIndex < 0 || index < 0) return;
+ this._convertShop_replaceChoices = function (shopId, previewMode) {
+ var shop = core.status.shops[shopId];
+ var choices = (shop.choices || []).filter(function (choice) {
+ if (choice.condition == null || choice.condition == '') return true;
+ try { return core.calValue(choice.condition); } catch (e) { return true; }
+ }).map(function (choice) {
+ var ableToBuy = core.calValue(choice.need);
+ return {
+ "text": choice.text,
+ "icon": choice.icon,
+ "color": ableToBuy && !previewMode ? choice.color : [153, 153, 153, 1],
+ "action": ableToBuy && !previewMode ? [{ "type": "playSound", "name": "商店" }].concat(choice.action) : [
+ { "type": "playSound", "name": "操作失败" },
+ { "type": "tip", "text": previewMode ? "预览模式下不可购买" : "购买条件不足" }
+ ]
+ };
+ }).concat({ "text": "离开", "action": [{ "type": "playSound", "name": "取消" }, { "type": "break" }] });
+ core.insertAction({ "type": "choices", "text": shop.text, "choices": choices });
+ }
+
+ /// 是否访问过某个快捷商店
+ this.isShopVisited = function (id) {
+ if (!core.hasFlag("__shops__")) core.setFlag("__shops__", {});
+ var shops = core.getFlag("__shops__");
+ if (!shops[id]) shops[id] = {};
+ return shops[id].visited;
+ }
+
+ /// 当前应当显示的快捷商店列表
+ this.listShopIds = function () {
+ return Object.keys(core.status.shops).filter(function (id) {
+ return core.isShopVisited(id) || !core.status.shops[id].mustEnable;
+ });
+ }
+
+ /// 是否能够打开某个商店
+ this.canOpenShop = function (id) {
+ if (this.isShopVisited(id)) return true;
+ var shop = core.status.shops[id];
+ if (shop.item || shop.commonEvent || shop.mustEnable) return false;
+ return true;
+ }
+
+ /// 启用或禁用某个快捷商店
+ this.setShopVisited = function (id, visited) {
+ if (!core.hasFlag("__shops__")) core.setFlag("__shops__", {});
+ var shops = core.getFlag("__shops__");
+ if (!shops[id]) shops[id] = {};
+ if (visited) shops[id].visited = true;
+ else delete shops[id].visited;
+ }
+
+ /// 能否使用快捷商店
+ this.canUseQuickShop = function (id) {
+ // 如果返回一个字符串,表示不能,字符串为不能使用的提示
+ // 返回null代表可以使用
+
+ // 检查当前楼层的canUseQuickShop选项是否为false
+ if (core.status.thisMap.canUseQuickShop === false)
+ return '当前楼层不能使用快捷商店。';
+ return null;
+ }
+
+ var _shouldProcessKeyUp = true;
+
+ /// 允许商店X键退出
+ core.registerAction('keyUp', 'shops', function (keycode) {
+ if (!core.status.lockControl || core.status.event.id != 'action') return false;
+ if ((keycode == 13 || keycode == 32) && !_shouldProcessKeyUp) {
+ _shouldProcessKeyUp = true;
+ return true;
+ }
+
+ if (!core.hasFlag("@temp@shop") || core.status.event.data.type != 'choices') return false;
+ var data = core.status.event.data.current;
+ var choices = data.choices;
+ var topIndex = core.actions._getChoicesTopIndex(choices.length);
+ if (keycode == 88 || keycode == 27) { // X, ESC
+ core.actions._clickAction(core.actions.HSIZE, topIndex + choices.length - 1);
+ return true;
+ }
+ return false;
+ }, 60);
+
+ /// 允许长按空格或回车连续执行操作
+ core.registerAction('keyDown', 'shops', function (keycode) {
+ if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false;
+ if (core.status.event.data.type != 'choices') return false;
+ var data = core.status.event.data.current;
+ var choices = data.choices;
+ var topIndex = core.actions._getChoicesTopIndex(choices.length);
+ if (keycode == 13 || keycode == 32) { // Space, Enter
+ core.actions._clickAction(core.actions.HSIZE, topIndex + core.status.event.selection);
+ _shouldProcessKeyUp = false;
+ return true;
+ }
+ return false;
+ }, 60);
+
+ // 允许长按屏幕连续执行操作
+ core.registerAction('longClick', 'shops', function (x, y, px, py) {
+ if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false;
+ if (core.status.event.data.type != 'choices') return false;
+ var data = core.status.event.data.current;
+ var choices = data.choices;
+ var topIndex = core.actions._getChoicesTopIndex(choices.length);
+ if (x >= core.actions.CHOICES_LEFT && x <= core.actions.CHOICES_RIGHT && y >= topIndex && y < topIndex + choices.length) {
+ core.actions._clickAction(x, y);
+ return true;
+ }
+ return false;
+ }, 60);
+ },
+ "removeMap": function () {
+ // 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。
+ // 推荐用法:
+ // 对于超高层或分区域塔,当在1区时将2区以后的地图删除;1区结束时恢复2区,进二区时删除1区地图,以此类推
+ // 这样可以大幅减少存档空间,以及加快存读档速度
+
+ // 删除楼层
+ // core.removeMaps("MT1", "MT300") 删除MT1~MT300之间的全部层
+ // core.removeMaps("MT10") 只删除MT10层
+ this.removeMaps = function (fromId, toId) {
+ toId = toId || fromId;
+ var fromIndex = core.floorIds.indexOf(fromId),
+ toIndex = core.floorIds.indexOf(toId);
if (toIndex < 0) toIndex = core.floorIds.length - 1;
- if (index >= fromIndex && index <= toIndex) {
- core.resumeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
+ flags.__visited__ = flags.__visited__ || {};
+ flags.__removed__ = flags.__removed__ || [];
+ flags.__disabled__ = flags.__disabled__ || {};
+ flags.__leaveLoc__ = flags.__leaveLoc__ || {};
+ for (var i = fromIndex; i <= toIndex; ++i) {
+ var floorId = core.floorIds[i];
+ if (core.status.maps[floorId].deleted) continue;
+ delete flags.__visited__[floorId];
+ flags.__removed__.push(floorId);
+ delete flags.__disabled__[floorId];
+ delete flags.__leaveLoc__[floorId];
+ (core.status.autoEvents || []).forEach(function (event) {
+ if (event.floorId == floorId && event.currentFloor) {
+ core.autoEventExecuting(event.symbol, false);
+ core.autoEventExecuted(event.symbol, false);
+ }
+ });
+ core.status.maps[floorId].deleted = true;
+ core.status.maps[floorId].canFlyTo = false;
+ core.status.maps[floorId].canFlyFrom = false;
+ core.status.maps[floorId].cannotViewMap = true;
+ }
+ }
+
+ // 恢复楼层
+ // core.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层
+ // core.resumeMaps("MT10") 只恢复MT10层
+ this.resumeMaps = function (fromId, toId) {
+ toId = toId || fromId;
+ var fromIndex = core.floorIds.indexOf(fromId),
+ toIndex = core.floorIds.indexOf(toId);
+ if (toIndex < 0) toIndex = core.floorIds.length - 1;
+ flags.__removed__ = flags.__removed__ || [];
+ for (var i = fromIndex; i <= toIndex; ++i) {
+ var floorId = core.floorIds[i];
+ if (!core.status.maps[floorId].deleted) continue;
+ flags.__removed__ = flags.__removed__.filter(function (f) { return f != floorId; });
+ core.status.maps[floorId] = core.loadFloor(floorId);
+ }
+ }
+
+ // 分区砍层相关
+ var inAnyPartition = function (floorId) {
+ var inPartition = false;
+ (core.floorPartitions || []).forEach(function (floor) {
+ var fromIndex = core.floorIds.indexOf(floor[0]);
+ var toIndex = core.floorIds.indexOf(floor[1]);
+ var index = core.floorIds.indexOf(floorId);
+ if (fromIndex < 0 || index < 0) return;
+ if (toIndex < 0) toIndex = core.floorIds.length - 1;
+ if (index >= fromIndex && index <= toIndex) inPartition = true;
+ });
+ return inPartition;
+ }
+
+ // 分区砍层
+ this.autoRemoveMaps = function (floorId) {
+ if (main.mode != 'play' || !inAnyPartition(floorId)) return;
+ // 根据分区信息自动砍层与恢复
+ (core.floorPartitions || []).forEach(function (floor) {
+ var fromIndex = core.floorIds.indexOf(floor[0]);
+ var toIndex = core.floorIds.indexOf(floor[1]);
+ var index = core.floorIds.indexOf(floorId);
+ if (fromIndex < 0 || index < 0) return;
+ if (toIndex < 0) toIndex = core.floorIds.length - 1;
+ if (index >= fromIndex && index <= toIndex) {
+ core.resumeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
+ } else {
+ core.removeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
+ }
+ });
+ }
+ },
+ "fiveLayers": function () {
+ // 是否启用五图层(增加背景2层和前景2层) 将__enable置为true即会启用;启用后请保存后刷新编辑器
+ // 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层
+ // 另外 请注意加入两个新图层 会让大地图的性能降低一些
+ // 插件作者:ad
+ var __enable = false;
+ if (!__enable) return;
+
+ // 创建新图层
+ function createCanvas (name, zIndex) {
+ if (!name) return;
+ var canvas = document.createElement('canvas');
+ canvas.id = name;
+ canvas.className = 'gameCanvas';
+ // 编辑器模式下设置zIndex会导致加入的图层覆盖优先级过高
+ if (main.mode != "editor") canvas.style.zIndex = zIndex || 0;
+ // 将图层插入进游戏内容
+ document.getElementById('gameDraw').appendChild(canvas);
+ var ctx = canvas.getContext('2d');
+ core.canvas[name] = ctx;
+ canvas.width = core.__PIXELS__;
+ canvas.height = core.__PIXELS__;
+ return canvas;
+ }
+
+ var bg2Canvas = createCanvas('bg2', 20);
+ var fg2Canvas = createCanvas('fg2', 63);
+ // 大地图适配
+ core.bigmap.canvas = ["bg2", "fg2", "bg", "event", "event2", "fg", "damage"];
+ core.initStatus.bg2maps = {};
+ core.initStatus.fg2maps = {};
+
+ if (main.mode == 'editor') {
+ /*插入编辑器的图层 不做此步新增图层无法在编辑器显示*/
+ // 编辑器图层覆盖优先级 eui > efg > fg(前景层) > event2(48*32图块的事件层) > event(事件层) > bg(背景层)
+ // 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
+ document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event'));
+ // 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后)
+ document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm'));
+ // 原本有三个图层 从4开始添加
+ var num = 4;
+ // 新增图层存入editor.dom中
+ editor.dom.bg2c = core.canvas.bg2.canvas;
+ editor.dom.bg2Ctx = core.canvas.bg2;
+ editor.dom.fg2c = core.canvas.fg2.canvas;
+ editor.dom.fg2Ctx = core.canvas.fg2;
+ editor.dom.maps.push('bg2map', 'fg2map');
+ editor.dom.canvas.push('bg2', 'fg2');
+
+ // 创建编辑器上的按钮
+ var createCanvasBtn = function (name) {
+ // 电脑端创建按钮
+ var input = document.createElement('input');
+ // layerMod4/layerMod5
+ var id = 'layerMod' + num++;
+ // bg2map/fg2map
+ var value = name + 'map';
+ input.type = 'radio';
+ input.name = 'layerMod';
+ input.id = id;
+ input.value = value;
+ editor.dom[id] = input;
+ input.onchange = function () {
+ editor.uifunctions.setLayerMod(value);
+ }
+ return input;
+ };
+
+ var createCanvasBtn_mobile = function (name) {
+ // 手机端往选择列表中添加子选项
+ var input = document.createElement('option');
+ var id = 'layerMod' + num++;
+ var value = name + 'map';
+ input.name = 'layerMod';
+ input.value = value;
+ editor.dom[id] = input;
+ return input;
+ };
+ if (!editor.isMobile) {
+ var input = createCanvasBtn('bg2');
+ var input2 = createCanvasBtn('fg2');
+ // 获取事件层及其父节点
+ var child = document.getElementById('layerMod'),
+ parent = child.parentNode;
+ // 背景层2插入事件层前
+ parent.insertBefore(input, child);
+ // 不能直接更改背景层2的innerText 所以创建文本节点
+ var txt = document.createTextNode('bg2');
+ // 插入事件层前(即新插入的背景层2前)
+ parent.insertBefore(txt, child);
+ // 向最后插入前景层2(即插入前景层后)
+ parent.appendChild(input2);
+ var txt2 = document.createTextNode('fg2');
+ parent.appendChild(txt2);
+ parent.childNodes[2].replaceWith("bg");
+ parent.childNodes[6].replaceWith("事件");
+ parent.childNodes[8].replaceWith("fg");
} else {
- core.removeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]);
+ var input = createCanvasBtn_mobile('bg2');
+ var input2 = createCanvasBtn_mobile('fg2');
+ // 手机端因为是选项 所以可以直接改innerText
+ input.innerText = '背景层2';
+ input2.innerText = '前景层2';
+ var parent = document.getElementById('layerMod');
+ parent.insertBefore(input, parent.children[1]);
+ parent.appendChild(input2);
}
- });
- }
-},
- "fiveLayers": function () {
- // 是否启用五图层(增加背景2层和前景2层) 将__enable置为true即会启用;启用后请保存后刷新编辑器
- // 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层
- // 另外 请注意加入两个新图层 会让大地图的性能降低一些
- // 插件作者:ad
- var __enable = false;
- if (!__enable) return;
+ }
- // 创建新图层
- function createCanvas(name, zIndex) {
- if (!name) return;
- var canvas = document.createElement('canvas');
- canvas.id = name;
- canvas.className = 'gameCanvas';
- // 编辑器模式下设置zIndex会导致加入的图层覆盖优先级过高
- if (main.mode != "editor") canvas.style.zIndex = zIndex || 0;
- // 将图层插入进游戏内容
- document.getElementById('gameDraw').appendChild(canvas);
- var ctx = canvas.getContext('2d');
- core.canvas[name] = ctx;
- canvas.width = core.__PIXELS__;
- canvas.height = core.__PIXELS__;
- return canvas;
- }
-
- var bg2Canvas = createCanvas('bg2', 20);
- var fg2Canvas = createCanvas('fg2', 63);
- // 大地图适配
- core.bigmap.canvas = ["bg2", "fg2", "bg", "event", "event2", "fg", "damage"];
- core.initStatus.bg2maps = {};
- core.initStatus.fg2maps = {};
-
- if (main.mode == 'editor') {
- /*插入编辑器的图层 不做此步新增图层无法在编辑器显示*/
- // 编辑器图层覆盖优先级 eui > efg > fg(前景层) > event2(48*32图块的事件层) > event(事件层) > bg(背景层)
- // 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
- document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event'));
- // 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后)
- document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm'));
- // 原本有三个图层 从4开始添加
- var num = 4;
- // 新增图层存入editor.dom中
- editor.dom.bg2c = core.canvas.bg2.canvas;
- editor.dom.bg2Ctx = core.canvas.bg2;
- editor.dom.fg2c = core.canvas.fg2.canvas;
- editor.dom.fg2Ctx = core.canvas.fg2;
- editor.dom.maps.push('bg2map', 'fg2map');
- editor.dom.canvas.push('bg2', 'fg2');
-
- // 创建编辑器上的按钮
- var createCanvasBtn = function (name) {
- // 电脑端创建按钮
- var input = document.createElement('input');
- // layerMod4/layerMod5
- var id = 'layerMod' + num++;
- // bg2map/fg2map
- var value = name + 'map';
- input.type = 'radio';
- input.name = 'layerMod';
- input.id = id;
- input.value = value;
- editor.dom[id] = input;
- input.onchange = function () {
- editor.uifunctions.setLayerMod(value);
+ var _loadFloor_doNotCopy = core.maps._loadFloor_doNotCopy;
+ core.maps._loadFloor_doNotCopy = function () {
+ return ["bg2map", "fg2map"].concat(_loadFloor_doNotCopy());
+ }
+ ////// 绘制背景和前景层 //////
+ core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
+ config.ctx = cacheCtx;
+ core.maps._drawBg_drawBackground(floorId, config);
+ // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
+ core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap);
+ core.maps._drawBgFgMap(floorId, 'bg', config);
+ if (config.onMap) {
+ core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
+ core.clearMap('bg2');
+ core.clearMap(cacheCtx);
}
- return input;
- };
-
- var createCanvasBtn_mobile = function (name) {
- // 手机端往选择列表中添加子选项
- var input = document.createElement('option');
- var id = 'layerMod' + num++;
- var value = name + 'map';
- input.name = 'layerMod';
- input.value = value;
- editor.dom[id] = input;
- return input;
- };
- if (!editor.isMobile) {
- var input = createCanvasBtn('bg2');
- var input2 = createCanvasBtn('fg2');
- // 获取事件层及其父节点
- var child = document.getElementById('layerMod'),
- parent = child.parentNode;
- // 背景层2插入事件层前
- parent.insertBefore(input, child);
- // 不能直接更改背景层2的innerText 所以创建文本节点
- var txt = document.createTextNode('bg2');
- // 插入事件层前(即新插入的背景层2前)
- parent.insertBefore(txt, child);
- // 向最后插入前景层2(即插入前景层后)
- parent.appendChild(input2);
- var txt2 = document.createTextNode('fg2');
- parent.appendChild(txt2);
- parent.childNodes[2].replaceWith("bg");
- parent.childNodes[6].replaceWith("事件");
- parent.childNodes[8].replaceWith("fg");
- } else {
- var input = createCanvasBtn_mobile('bg2');
- var input2 = createCanvasBtn_mobile('fg2');
- // 手机端因为是选项 所以可以直接改innerText
- input.innerText = '背景层2';
- input2.innerText = '前景层2';
- var parent = document.getElementById('layerMod');
- parent.insertBefore(input, parent.children[1]);
- parent.appendChild(input2);
+ core.maps._drawBgFgMap(floorId, 'bg2', config);
+ if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
+ config.ctx = toDrawCtx;
}
- }
-
- var _loadFloor_doNotCopy = core.maps._loadFloor_doNotCopy;
- core.maps._loadFloor_doNotCopy = function () {
- return ["bg2map", "fg2map"].concat(_loadFloor_doNotCopy());
- }
- ////// 绘制背景和前景层 //////
- core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
- config.ctx = cacheCtx;
- core.maps._drawBg_drawBackground(floorId, config);
- // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
- core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap);
- core.maps._drawBgFgMap(floorId, 'bg', config);
- if (config.onMap) {
- core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
- core.clearMap('bg2');
- core.clearMap(cacheCtx);
- }
- core.maps._drawBgFgMap(floorId, 'bg2', config);
- if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
- config.ctx = toDrawCtx;
- }
- core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
- config.ctx = cacheCtx;
- // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
- core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap);
- core.maps._drawBgFgMap(floorId, 'fg', config);
- if (config.onMap) {
- core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
- core.clearMap('fg2');
- core.clearMap(cacheCtx);
- }
- core.maps._drawBgFgMap(floorId, 'fg2', config);
- if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
- config.ctx = toDrawCtx;
- }
- ////// 移动判定 //////
- core.maps._generateMovableArray_arrays = function (floorId) {
- return {
- bgArray: this.getBgMapArray(floorId),
- fgArray: this.getFgMapArray(floorId),
- eventArray: this.getMapArray(floorId),
- bg2Array: this._getBgFgMapArray('bg2', floorId),
- fg2Array: this._getBgFgMapArray('fg2', floorId)
- };
- }
-},
- "itemShop": function () {
- // 道具商店相关的插件
- // 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找)
-
- var shopId = null; // 当前商店ID
- var type = 0; // 当前正在选中的类型,0买入1卖出
- var selectItem = 0; // 当前正在选中的道具
- var selectCount = 0; // 当前已经选中的数量
- var page = 0;
- var totalPage = 0;
- var totalMoney = 0;
- var list = [];
- var shopInfo = null; // 商店信息
- var choices = []; // 商店选项
- var use = 'money';
- var useText = '金币';
-
- var bigFont = core.ui._buildFont(20, false),
- middleFont = core.ui._buildFont(18, false);
-
- this._drawItemShop = function () {
- // 绘制道具商店
-
- // Step 1: 背景和固定的几个文字
- core.ui._createUIEvent();
- core.clearMap('uievent');
- core.ui.clearUIEventSelector();
- core.setTextAlign('uievent', 'left');
- core.setTextBaseline('uievent', 'top');
- core.fillRect('uievent', 0, 0, 416, 416, 'black');
- core.drawWindowSkin('winskin.png', 'uievent', 0, 0, 416, 56);
- core.drawWindowSkin('winskin.png', 'uievent', 0, 56, 312, 56);
- core.drawWindowSkin('winskin.png', 'uievent', 0, 112, 312, 304);
- core.drawWindowSkin('winskin.png', 'uievent', 312, 56, 104, 56);
- core.drawWindowSkin('winskin.png', 'uievent', 312, 112, 104, 304);
- core.setFillStyle('uievent', 'white');
- core.setStrokeStyle('uievent', 'white');
- core.fillText("uievent", "购买", 32, 74, 'white', bigFont);
- core.fillText("uievent", "卖出", 132, 74);
- core.fillText("uievent", "离开", 232, 74);
- core.fillText("uievent", "当前" + useText, 324, 66, null, middleFont);
- core.setTextAlign("uievent", "right");
- core.fillText("uievent", core.formatBigNumber(core.status.hero[use]), 405, 89);
- core.setTextAlign("uievent", "left");
- core.ui.drawUIEventSelector(1, "winskin.png", 22 + 100 * type, 66, 60, 33);
- if (selectItem != null) {
- core.setTextAlign('uievent', 'center');
- core.fillText("uievent", type == 0 ? "买入个数" : "卖出个数", 364, 320, null, bigFont);
- core.fillText("uievent", "< " + selectCount + " >", 364, 350);
- core.fillText("uievent", "确定", 364, 380);
- }
-
- // Step 2:获得列表并展示
- list = choices.filter(function (one) {
- if (one.condition != null && one.condition != '') {
- try { if (!core.calValue(one.condition)) return false; } catch (e) {}
+ core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
+ config.ctx = cacheCtx;
+ // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
+ core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap);
+ core.maps._drawBgFgMap(floorId, 'fg', config);
+ if (config.onMap) {
+ core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
+ core.clearMap('fg2');
+ core.clearMap(cacheCtx);
}
- return (type == 0 && one.money != null) || (type == 1 && one.sell != null);
- });
- var per_page = 6;
- totalPage = Math.ceil(list.length / per_page);
- page = Math.floor((selectItem || 0) / per_page) + 1;
-
- // 绘制分页
- if (totalPage > 1) {
- var half = 156;
- core.setTextAlign('uievent', 'center');
- core.fillText('uievent', page + " / " + totalPage, half, 388, null, middleFont);
- if (page > 1) core.fillText('uievent', '上一页', half - 80, 388);
- if (page < totalPage) core.fillText('uievent', '下一页', half + 80, 388);
+ core.maps._drawBgFgMap(floorId, 'fg2', config);
+ if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0);
+ config.ctx = toDrawCtx;
}
- core.setTextAlign('uievent', 'left');
+ ////// 移动判定 //////
+ core.maps._generateMovableArray_arrays = function (floorId) {
+ return {
+ bgArray: this.getBgMapArray(floorId),
+ fgArray: this.getFgMapArray(floorId),
+ eventArray: this.getMapArray(floorId),
+ bg2Array: this._getBgFgMapArray('bg2', floorId),
+ fg2Array: this._getBgFgMapArray('fg2', floorId)
+ };
+ }
+ },
+ "itemShop": function () {
+ // 道具商店相关的插件
+ // 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找)
- // 绘制每一项
- var start = (page - 1) * per_page;
- for (var i = 0; i < per_page; ++i) {
- var curr = start + i;
- if (curr >= list.length) break;
- var item = list[curr];
- core.drawIcon('uievent', item.id, 10, 125 + i * 40);
+ var shopId = null; // 当前商店ID
+ var type = 0; // 当前正在选中的类型,0买入1卖出
+ var selectItem = 0; // 当前正在选中的道具
+ var selectCount = 0; // 当前已经选中的数量
+ var page = 0;
+ var totalPage = 0;
+ var totalMoney = 0;
+ var list = [];
+ var shopInfo = null; // 商店信息
+ var choices = []; // 商店选项
+ var use = 'money';
+ var useText = '金币';
+
+ var bigFont = core.ui._buildFont(20, false),
+ middleFont = core.ui._buildFont(18, false);
+
+ this._drawItemShop = function () {
+ // 绘制道具商店
+
+ // Step 1: 背景和固定的几个文字
+ core.ui._createUIEvent();
+ core.clearMap('uievent');
+ core.ui.clearUIEventSelector();
core.setTextAlign('uievent', 'left');
- core.fillText('uievent', core.material.items[item.id].name, 50, 132 + i * 40, null, bigFont);
- core.setTextAlign('uievent', 'right');
- core.fillText('uievent', (type == 0 ? core.calValue(item.money) : core.calValue(item.sell)) + useText + "/个", 300, 133 + i * 40, null, middleFont);
+ core.setTextBaseline('uievent', 'top');
+ core.fillRect('uievent', 0, 0, 416, 416, 'black');
+ core.drawWindowSkin('winskin.png', 'uievent', 0, 0, 416, 56);
+ core.drawWindowSkin('winskin.png', 'uievent', 0, 56, 312, 56);
+ core.drawWindowSkin('winskin.png', 'uievent', 0, 112, 312, 304);
+ core.drawWindowSkin('winskin.png', 'uievent', 312, 56, 104, 56);
+ core.drawWindowSkin('winskin.png', 'uievent', 312, 112, 104, 304);
+ core.setFillStyle('uievent', 'white');
+ core.setStrokeStyle('uievent', 'white');
+ core.fillText("uievent", "购买", 32, 74, 'white', bigFont);
+ core.fillText("uievent", "卖出", 132, 74);
+ core.fillText("uievent", "离开", 232, 74);
+ core.fillText("uievent", "当前" + useText, 324, 66, null, middleFont);
+ core.setTextAlign("uievent", "right");
+ core.fillText("uievent", core.formatBigNumber(core.status.hero[use]), 405, 89);
core.setTextAlign("uievent", "left");
- if (curr == selectItem) {
- // 绘制描述,文字自动放缩
- var text = core.material.items[item.id].text || "该道具暂无描述";
- 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);
- if (height <= 50) {
- config.top = (56 - height) / 2;
- core.drawTextContent("uievent", text, config);
+ core.ui.drawUIEventSelector(1, "winskin.png", 22 + 100 * type, 66, 60, 33);
+ if (selectItem != null) {
+ core.setTextAlign('uievent', 'center');
+ core.fillText("uievent", type == 0 ? "买入个数" : "卖出个数", 364, 320, null, bigFont);
+ core.fillText("uievent", "< " + selectCount + " >", 364, 350);
+ core.fillText("uievent", "确定", 364, 380);
+ }
+
+ // Step 2:获得列表并展示
+ list = choices.filter(function (one) {
+ if (one.condition != null && one.condition != '') {
+ try { if (!core.calValue(one.condition)) return false; } catch (e) { }
+ }
+ return (type == 0 && one.money != null) || (type == 1 && one.sell != null);
+ });
+ var per_page = 6;
+ totalPage = Math.ceil(list.length / per_page);
+ page = Math.floor((selectItem || 0) / per_page) + 1;
+
+ // 绘制分页
+ if (totalPage > 1) {
+ var half = 156;
+ core.setTextAlign('uievent', 'center');
+ core.fillText('uievent', page + " / " + totalPage, half, 388, null, middleFont);
+ if (page > 1) core.fillText('uievent', '上一页', half - 80, 388);
+ if (page < totalPage) core.fillText('uievent', '下一页', half + 80, 388);
+ }
+ core.setTextAlign('uievent', 'left');
+
+ // 绘制每一项
+ var start = (page - 1) * per_page;
+ for (var i = 0; i < per_page; ++i) {
+ var curr = start + i;
+ if (curr >= list.length) break;
+ var item = list[curr];
+ core.drawIcon('uievent', item.id, 10, 125 + i * 40);
+ core.setTextAlign('uievent', 'left');
+ core.fillText('uievent', core.material.items[item.id].name, 50, 132 + i * 40, null, bigFont);
+ core.setTextAlign('uievent', 'right');
+ core.fillText('uievent', (type == 0 ? core.calValue(item.money) : core.calValue(item.sell)) + useText + "/个", 300, 133 + i * 40, null, middleFont);
+ core.setTextAlign("uievent", "left");
+ if (curr == selectItem) {
+ // 绘制描述,文字自动放缩
+ var text = core.material.items[item.id].text || "该道具暂无描述";
+ 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);
+ if (height <= 50) {
+ config.top = (56 - height) / 2;
+ core.drawTextContent("uievent", text, config);
+ break;
+ }
+ }
+ core.ui.drawUIEventSelector(2, "winskin.png", 8, 120 + i * 40, 295, 40);
+ if (type == 0 && item.number != null) {
+ core.fillText("uievent", "存货", 324, 132, null, bigFont);
+ core.setTextAlign("uievent", "right");
+ core.fillText("uievent", item.number, 406, 132, null, null, 40);
+ } else if (type == 1) {
+ core.fillText("uievent", "数量", 324, 132, null, bigFont);
+ core.setTextAlign("uievent", "right");
+ core.fillText("uievent", core.itemCount(item.id), 406, 132, null, null, 40);
+ }
+ core.setTextAlign("uievent", "left");
+ core.fillText("uievent", "预计" + useText, 324, 250);
+ core.setTextAlign("uievent", "right");
+ totalMoney = selectCount * (type == 0 ? core.calValue(item.money) : core.calValue(item.sell));
+ core.fillText("uievent", core.formatBigNumber(totalMoney), 405, 280);
+
+ core.setTextAlign("uievent", "left");
+ core.fillText("uievent", type == 0 ? "已购次数" : "已卖次数", 324, 170);
+ core.setTextAlign("uievent", "right");
+ core.fillText("uievent", (type == 0 ? item.money_count : item.sell_count) || 0, 405, 200);
+ }
+ }
+
+ core.setTextAlign('uievent', 'left');
+ core.setTextBaseline('uievent', 'alphabetic');
+ }
+
+ var _add = function (item, delta) {
+ if (item == null) return;
+ selectCount = core.clamp(
+ selectCount + delta, 0,
+ Math.min(type == 0 ? Math.floor(core.status.hero[use] / core.calValue(item.money)) : core.itemCount(item.id),
+ type == 0 && item.number != null ? item.number : Number.MAX_SAFE_INTEGER)
+ );
+ }
+
+ var _confirm = function (item) {
+ if (item == null || selectCount == 0) return;
+ if (type == 0) {
+ core.status.hero[use] -= totalMoney;
+ core.getItem(item.id, selectCount);
+ core.stopSound();
+ core.playSound('确定');
+ if (item.number != null) item.number -= selectCount;
+ item.money_count = (item.money_count || 0) + selectCount;
+ } else {
+ core.status.hero[use] += totalMoney;
+ core.removeItem(item.id, selectCount);
+ core.playSound('确定');
+ core.drawTip("成功卖出" + selectCount + "个" + core.material.items[item.id].name, item.id);
+ if (item.number != null) item.number += selectCount;
+ item.sell_count = (item.sell_count || 0) + selectCount;
+ }
+ selectCount = 0;
+ }
+
+ this._performItemShopKeyBoard = function (keycode) {
+ var item = list[selectItem] || null;
+ // 键盘操作
+ switch (keycode) {
+ case 38: // up
+ if (selectItem == null) break;
+ if (selectItem == 0) selectItem = null;
+ else selectItem--;
+ selectCount = 0;
+ break;
+ case 37: // left
+ if (selectItem == null) {
+ if (type > 0) type--;
break;
}
- }
- core.ui.drawUIEventSelector(2, "winskin.png", 8, 120 + i * 40, 295, 40);
- if (type == 0 && item.number != null) {
- core.fillText("uievent", "存货", 324, 132, null, bigFont);
- core.setTextAlign("uievent", "right");
- core.fillText("uievent", item.number, 406, 132, null, null, 40);
- } else if (type == 1) {
- core.fillText("uievent", "数量", 324, 132, null, bigFont);
- core.setTextAlign("uievent", "right");
- core.fillText("uievent", core.itemCount(item.id), 406, 132, null, null, 40);
- }
- core.setTextAlign("uievent", "left");
- core.fillText("uievent", "预计" + useText, 324, 250);
- core.setTextAlign("uievent", "right");
- totalMoney = selectCount * (type == 0 ? core.calValue(item.money) : core.calValue(item.sell));
- core.fillText("uievent", core.formatBigNumber(totalMoney), 405, 280);
-
- core.setTextAlign("uievent", "left");
- core.fillText("uievent", type == 0 ? "已购次数" : "已卖次数", 324, 170);
- core.setTextAlign("uievent", "right");
- core.fillText("uievent", (type == 0 ? item.money_count : item.sell_count) || 0, 405, 200);
+ _add(item, -1);
+ break;
+ case 39: // right
+ if (selectItem == null) {
+ if (type < 2) type++;
+ break;
+ }
+ _add(item, 1);
+ break;
+ case 40: // down
+ if (selectItem == null) {
+ if (list.length > 0) selectItem = 0;
+ break;
+ }
+ if (list.length == 0) break;
+ selectItem = Math.min(selectItem + 1, list.length - 1);
+ selectCount = 0;
+ break;
+ case 13:
+ case 32: // Enter/Space
+ if (selectItem == null) {
+ if (type == 2)
+ core.insertAction({ "type": "break" });
+ else if (list.length > 0)
+ selectItem = 0;
+ break;
+ }
+ _confirm(item);
+ break;
+ case 27: // ESC
+ if (selectItem == null) {
+ core.insertAction({ "type": "break" });
+ break;
+ }
+ selectItem = null;
+ break;
}
}
- core.setTextAlign('uievent', 'left');
- core.setTextBaseline('uievent', 'alphabetic');
- }
+ this._performItemShopClick = function (px, py) {
+ var item = list[selectItem] || null;
+ // 鼠标操作
+ if (px >= 22 && px <= 82 && py >= 71 && py <= 102) {
+ // 买
+ if (type != 0) {
+ type = 0;
+ selectItem = null;
+ selectCount = 0;
+ }
+ return;
+ }
+ if (px >= 122 && px <= 182 && py >= 71 && py <= 102) {
+ // 卖
+ if (type != 1) {
+ type = 1;
+ selectItem = null;
+ selectCount = 0;
+ }
+ return;
+ }
+ if (px >= 222 && px <= 282 && py >= 71 && py <= 102) // 离开
+ return core.insertAction({ "type": "break" });
+ // < >
+ if (px >= 318 && px <= 341 && py >= 348 && py <= 376)
+ return _add(item, -1);
+ if (px >= 388 && px <= 416 && py >= 348 && py <= 376)
+ return _add(item, 1);
+ // 确定
+ if (px >= 341 && px <= 387 && py >= 380 && py <= 407)
+ return _confirm(item);
- var _add = function (item, delta) {
- if (item == null) return;
- selectCount = core.clamp(
- selectCount + delta, 0,
- Math.min(type == 0 ? Math.floor(core.status.hero[use] / core.calValue(item.money)) : core.itemCount(item.id),
- type == 0 && item.number != null ? item.number : Number.MAX_SAFE_INTEGER)
- );
- }
+ // 上一页/下一页
+ if (px >= 45 && px <= 105 && py >= 388) {
+ if (page > 1) {
+ selectItem -= 6;
+ selectCount = 0;
+ }
+ return;
+ }
+ if (px >= 208 && px <= 268 && py >= 388) {
+ if (page < totalPage) {
+ selectItem = Math.min(selectItem + 6, list.length - 1);
+ selectCount = 0;
+ }
+ return;
+ }
- var _confirm = function (item) {
- if (item == null || selectCount == 0) return;
- if (type == 0) {
- core.status.hero[use] -= totalMoney;
- core.getItem(item.id, selectCount);
- core.stopSound();
- core.playSound('确定');
- if (item.number != null) item.number -= selectCount;
- item.money_count = (item.money_count || 0) + selectCount;
- } else {
- core.status.hero[use] += totalMoney;
- core.removeItem(item.id, selectCount);
- core.playSound('确定');
- core.drawTip("成功卖出" + selectCount + "个" + core.material.items[item.id].name, item.id);
- if (item.number != null) item.number += selectCount;
- item.sell_count = (item.sell_count || 0) + selectCount;
+ // 实际区域
+ if (px >= 9 && px <= 300 && py >= 120 && py < 360) {
+ if (list.length == 0) return;
+ var index = parseInt((py - 120) / 40);
+ var newItem = 6 * (page - 1) + index;
+ if (newItem >= list.length) newItem = list.length - 1;
+ if (newItem != selectItem) {
+ selectItem = newItem;
+ selectCount = 0;
+ }
+ return;
+ }
}
- selectCount = 0;
- }
- this._performItemShopKeyBoard = function (keycode) {
- var item = list[selectItem] || null;
- // 键盘操作
- switch (keycode) {
- case 38: // up
- if (selectItem == null) break;
- if (selectItem == 0) selectItem = null;
- else selectItem--;
- selectCount = 0;
- break;
- case 37: // left
- if (selectItem == null) {
- if (type > 0) type--;
- break;
- }
- _add(item, -1);
- break;
- case 39: // right
- if (selectItem == null) {
- if (type < 2) type++;
- break;
- }
- _add(item, 1);
- break;
- case 40: // down
- if (selectItem == null) {
- if (list.length > 0) selectItem = 0;
- break;
- }
- if (list.length == 0) break;
- selectItem = Math.min(selectItem + 1, list.length - 1);
- selectCount = 0;
- break;
- case 13:
- case 32: // Enter/Space
- if (selectItem == null) {
- if (type == 2)
- core.insertAction({ "type": "break" });
- else if (list.length > 0)
- selectItem = 0;
- break;
- }
- _confirm(item);
- break;
- case 27: // ESC
- if (selectItem == null) {
- core.insertAction({ "type": "break" });
- break;
- }
+ this._performItemShopAction = function () {
+ if (flags.type == 0) return this._performItemShopKeyBoard(flags.keycode);
+ else return this._performItemShopClick(flags.px, flags.py);
+ }
+
+ this.openItemShop = function (itemShopId) {
+ shopId = itemShopId;
+ type = 0;
+ page = 0;
selectItem = null;
- break;
- }
- }
+ selectCount = 0;
+ core.isShopVisited(itemShopId);
+ shopInfo = flags.__shops__[shopId];
+ if (shopInfo.choices == null) shopInfo.choices = core.clone(core.status.shops[shopId].choices);
+ choices = shopInfo.choices;
+ use = core.status.shops[shopId].use;
+ if (use != 'exp') use = 'money';
+ useText = use == 'money' ? '金币' : '经验';
- this._performItemShopClick = function (px, py) {
- var item = list[selectItem] || null;
- // 鼠标操作
- if (px >= 22 && px <= 82 && py >= 71 && py <= 102) {
- // 买
- if (type != 0) {
- type = 0;
- selectItem = null;
- selectCount = 0;
- }
- return;
- }
- if (px >= 122 && px <= 182 && py >= 71 && py <= 102) {
- // 卖
- if (type != 1) {
- type = 1;
- selectItem = null;
- selectCount = 0;
- }
- return;
- }
- if (px >= 222 && px <= 282 && py >= 71 && py <= 102) // 离开
- return core.insertAction({ "type": "break" });
- // < >
- if (px >= 318 && px <= 341 && py >= 348 && py <= 376)
- return _add(item, -1);
- if (px >= 388 && px <= 416 && py >= 348 && py <= 376)
- return _add(item, 1);
- // 确定
- if (px >= 341 && px <= 387 && py >= 380 && py <= 407)
- return _confirm(item);
-
- // 上一页/下一页
- if (px >= 45 && px <= 105 && py >= 388) {
- if (page > 1) {
- selectItem -= 6;
- selectCount = 0;
- }
- return;
- }
- if (px >= 208 && px <= 268 && py >= 388) {
- if (page < totalPage) {
- selectItem = Math.min(selectItem + 6, list.length - 1);
- selectCount = 0;
- }
- return;
- }
-
- // 实际区域
- if (px >= 9 && px <= 300 && py >= 120 && py < 360) {
- if (list.length == 0) return;
- var index = parseInt((py - 120) / 40);
- var newItem = 6 * (page - 1) + index;
- if (newItem >= list.length) newItem = list.length - 1;
- if (newItem != selectItem) {
- selectItem = newItem;
- selectCount = 0;
- }
- return;
- }
- }
-
- this._performItemShopAction = function () {
- if (flags.type == 0) return this._performItemShopKeyBoard(flags.keycode);
- else return this._performItemShopClick(flags.px, flags.py);
- }
-
- this.openItemShop = function (itemShopId) {
- shopId = itemShopId;
- type = 0;
- page = 0;
- selectItem = null;
- selectCount = 0;
- core.isShopVisited(itemShopId);
- shopInfo = flags.__shops__[shopId];
- if (shopInfo.choices == null) shopInfo.choices = core.clone(core.status.shops[shopId].choices);
- choices = shopInfo.choices;
- use = core.status.shops[shopId].use;
- if (use != 'exp') use = 'money';
- useText = use == 'money' ? '金币' : '经验';
-
- core.insertAction([{
+ core.insertAction([{
"type": "while",
"condition": "true",
"data": [
@@ -816,551 +817,551 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
"type": "function",
"function": "function () { core.deleteCanvas('uievent'); core.ui.clearUIEventSelector(); }"
}
- ]);
- }
+ ]);
+ }
-},
- "enemyLevel": function () {
- // 此插件将提供怪物手册中的怪物境界显示
- // 使用此插件需要先给每个怪物定义境界,方法如下:
- // 点击怪物的【配置表格】,找到“【怪物】相关的表格配置”,然后在【名称】仿照增加境界定义:
- /*
- "level": {
- "_leaf": true,
- "_type": "textarea",
- "_string": true,
- "_data": "境界"
- },
- */
- // 然后保存刷新,可以看到怪物的属性定义中出现了【境界】。再开启本插件即可。
+ },
+ "enemyLevel": function () {
+ // 此插件将提供怪物手册中的怪物境界显示
+ // 使用此插件需要先给每个怪物定义境界,方法如下:
+ // 点击怪物的【配置表格】,找到“【怪物】相关的表格配置”,然后在【名称】仿照增加境界定义:
+ /*
+ "level": {
+ "_leaf": true,
+ "_type": "textarea",
+ "_string": true,
+ "_data": "境界"
+ },
+ */
+ // 然后保存刷新,可以看到怪物的属性定义中出现了【境界】。再开启本插件即可。
- // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
- var __enable = false;
- if (!__enable) return;
+ // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
+ var __enable = false;
+ if (!__enable) return;
- // 这里定义每个境界的显示颜色;可以写'red', '#RRGGBB' 或者[r,g,b,a]四元数组
- var levelToColors = {
- "萌新一阶": "red",
- "萌新二阶": "#FF0000",
- "萌新三阶": [255, 0, 0, 1],
- };
+ // 这里定义每个境界的显示颜色;可以写'red', '#RRGGBB' 或者[r,g,b,a]四元数组
+ var levelToColors = {
+ "萌新一阶": "red",
+ "萌新二阶": "#FF0000",
+ "萌新三阶": [255, 0, 0, 1],
+ };
- // 复写 _drawBook_drawName
- var originDrawBook = core.ui._drawBook_drawName;
- core.ui._drawBook_drawName = function (index, enemy, top, left, width) {
- // 如果没有境界,则直接调用原始代码绘制
- if (!enemy.level) return originDrawBook.call(core.ui, index, enemy, top, left, width);
- // 存在境界,则额外进行绘制
- core.setTextAlign('ui', 'center');
- if (enemy.specialText.length == 0) {
- core.fillText('ui', enemy.name, left + width / 2,
- top + 27, '#DDDDDD', this._buildFont(17, true));
- core.fillText('ui', enemy.level, left + width / 2,
- top + 51, core.arrayToRGBA(levelToColors[enemy.level] || '#DDDDDD'), this._buildFont(14, true));
- } else {
- core.fillText('ui', enemy.name, left + width / 2,
- top + 20, '#DDDDDD', this._buildFont(17, true), width);
- switch (enemy.specialText.length) {
- case 1:
- core.fillText('ui', enemy.specialText[0], left + width / 2,
- top + 38, core.arrayToRGBA((enemy.specialColor || [])[0] || '#FF6A6A'),
- this._buildFont(14, true), width);
- break;
- case 2:
- // Step 1: 计算字体
- var text = enemy.specialText[0] + " " + enemy.specialText[1];
- core.setFontForMaxWidth('ui', text, width, this._buildFont(14, true));
- // Step 2: 计算总宽度
- var totalWidth = core.calWidth('ui', text);
- var leftWidth = core.calWidth('ui', enemy.specialText[0]);
- var rightWidth = core.calWidth('ui', enemy.specialText[1]);
- // Step 3: 绘制
- core.fillText('ui', enemy.specialText[0], left + (width + leftWidth - totalWidth) / 2,
- top + 38, core.arrayToRGBA((enemy.specialColor || [])[0] || '#FF6A6A'));
- core.fillText('ui', enemy.specialText[1], left + (width + totalWidth - rightWidth) / 2,
- top + 38, core.arrayToRGBA((enemy.specialColor || [])[1] || '#FF6A6A'));
- break;
- default:
- core.fillText('ui', '多属性...', left + width / 2,
- top + 38, '#FF6A6A', this._buildFont(14, true), width);
+ // 复写 _drawBook_drawName
+ var originDrawBook = core.ui._drawBook_drawName;
+ core.ui._drawBook_drawName = function (index, enemy, top, left, width) {
+ // 如果没有境界,则直接调用原始代码绘制
+ if (!enemy.level) return originDrawBook.call(core.ui, index, enemy, top, left, width);
+ // 存在境界,则额外进行绘制
+ core.setTextAlign('ui', 'center');
+ if (enemy.specialText.length == 0) {
+ core.fillText('ui', enemy.name, left + width / 2,
+ top + 27, '#DDDDDD', this._buildFont(17, true));
+ core.fillText('ui', enemy.level, left + width / 2,
+ top + 51, core.arrayToRGBA(levelToColors[enemy.level] || '#DDDDDD'), this._buildFont(14, true));
+ } else {
+ core.fillText('ui', enemy.name, left + width / 2,
+ top + 20, '#DDDDDD', this._buildFont(17, true), width);
+ switch (enemy.specialText.length) {
+ case 1:
+ core.fillText('ui', enemy.specialText[0], left + width / 2,
+ top + 38, core.arrayToRGBA((enemy.specialColor || [])[0] || '#FF6A6A'),
+ this._buildFont(14, true), width);
+ break;
+ case 2:
+ // Step 1: 计算字体
+ var text = enemy.specialText[0] + " " + enemy.specialText[1];
+ core.setFontForMaxWidth('ui', text, width, this._buildFont(14, true));
+ // Step 2: 计算总宽度
+ var totalWidth = core.calWidth('ui', text);
+ var leftWidth = core.calWidth('ui', enemy.specialText[0]);
+ var rightWidth = core.calWidth('ui', enemy.specialText[1]);
+ // Step 3: 绘制
+ core.fillText('ui', enemy.specialText[0], left + (width + leftWidth - totalWidth) / 2,
+ top + 38, core.arrayToRGBA((enemy.specialColor || [])[0] || '#FF6A6A'));
+ core.fillText('ui', enemy.specialText[1], left + (width + totalWidth - rightWidth) / 2,
+ top + 38, core.arrayToRGBA((enemy.specialColor || [])[1] || '#FF6A6A'));
+ break;
+ default:
+ core.fillText('ui', '多属性...', left + width / 2,
+ top + 38, '#FF6A6A', this._buildFont(14, true), width);
+ }
+ core.fillText('ui', enemy.level, left + width / 2,
+ top + 56, core.arrayToRGBA(levelToColors[enemy.level] || '#DDDDDD'), this._buildFont(14, true));
}
- core.fillText('ui', enemy.level, left + width / 2,
- top + 56, core.arrayToRGBA(levelToColors[enemy.level] || '#DDDDDD'), this._buildFont(14, true));
}
- }
- // 也可以复写其他的属性颜色如怪物攻防等,具体参见下面的例子的注释部分
- core.ui._drawBook_drawRow1 = function (index, enemy, top, left, width, position) {
- // 绘制第一行
- core.setTextAlign('ui', 'left');
- var b13 = this._buildFont(13, true),
- f13 = this._buildFont(13, false);
- var col1 = left,
- col2 = left + width * 9 / 25,
- col3 = left + width * 17 / 25;
- core.fillText('ui', '生命', col1, position, '#DDDDDD', f13);
- core.fillText('ui', core.formatBigNumber(enemy.hp || 0), col1 + 30, position, /*'red' */ null, b13);
- core.fillText('ui', '攻击', col2, position, null, f13);
- core.fillText('ui', core.formatBigNumber(enemy.atk || 0), col2 + 30, position, /* '#FF0000' */ null, b13);
- core.fillText('ui', '防御', col3, position, null, f13);
- core.fillText('ui', core.formatBigNumber(enemy.def || 0), col3 + 30, position, /* [255, 0, 0, 1] */ null, b13);
- }
-
-
-},
- "dynamicHp": function () {
- // 此插件允许人物血量动态进行变化
- // 原作:Fux2(老黄鸡)
-
- // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
- var __enable = false;
- if (!__enable) return;
-
- var speed = 0.05; // 动态血量变化速度,越大越快。
-
- var _currentHp = null;
- var _lastStatus = null;
- var _check = function () {
- if (_lastStatus != core.status.hero) {
- _lastStatus = core.status.hero;
- _currentHp = core.status.hero.hp;
+ // 也可以复写其他的属性颜色如怪物攻防等,具体参见下面的例子的注释部分
+ core.ui._drawBook_drawRow1 = function (index, enemy, top, left, width, position) {
+ // 绘制第一行
+ core.setTextAlign('ui', 'left');
+ var b13 = this._buildFont(13, true),
+ f13 = this._buildFont(13, false);
+ var col1 = left,
+ col2 = left + width * 9 / 25,
+ col3 = left + width * 17 / 25;
+ core.fillText('ui', '生命', col1, position, '#DDDDDD', f13);
+ core.fillText('ui', core.formatBigNumber(enemy.hp || 0), col1 + 30, position, /*'red' */ null, b13);
+ core.fillText('ui', '攻击', col2, position, null, f13);
+ core.fillText('ui', core.formatBigNumber(enemy.atk || 0), col2 + 30, position, /* '#FF0000' */ null, b13);
+ core.fillText('ui', '防御', col3, position, null, f13);
+ core.fillText('ui', core.formatBigNumber(enemy.def || 0), col3 + 30, position, /* [255, 0, 0, 1] */ null, b13);
}
- }
- core.registerAnimationFrame('dynamicHp', true, function () {
- _check();
- if (core.status.hero.hp != _currentHp) {
- var dis = (_currentHp - core.status.hero.hp) * speed;
- if (Math.abs(dis) < 2) {
+
+ },
+ "dynamicHp": function () {
+ // 此插件允许人物血量动态进行变化
+ // 原作:Fux2(老黄鸡)
+
+ // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
+ var __enable = false;
+ if (!__enable) return;
+
+ var speed = 0.05; // 动态血量变化速度,越大越快。
+
+ var _currentHp = null;
+ var _lastStatus = null;
+ var _check = function () {
+ if (_lastStatus != core.status.hero) {
+ _lastStatus = core.status.hero;
_currentHp = core.status.hero.hp;
- } else {
- _currentHp -= dis;
- }
- core.setStatusBarInnerHTML('hp', _currentHp);
- }
- });
-},
- "multiHeros": function () {
- // 多角色插件
- // Step 1: 启用本插件
- // Step 2: 定义每个新的角色各项初始数据(参见下方注释)
- // Step 3: 在游戏中的任何地方都可以调用 `core.changeHero()` 进行切换;也可以 `core.changeHero(1)` 来切换到某个具体的角色上
-
- // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
- var __enable = false;
- if (!__enable) return;
-
- // 在这里定义全部的新角色属性
- // 请注意,在这里定义的内容不会多角色共用,在切换时会进行恢复。
- // 你也可以自行新增或删除,比如不共用金币则可以加上"money"的初始化,不共用道具则可以加上"items"的初始化,
- // 多角色共用hp的话则删除hp,等等。总之,不共用的属性都在这里进行定义就好。
- var hero1 = {
- "floorId": "MT0", // 该角色初始楼层ID;如果共用楼层可以注释此项
- "image": "brave.png", // 角色的行走图名称;此项必填不然会报错
- "name": "1号角色",
- "lv": 1,
- "hp": 10000, // 如果HP共用可注释此项
- "atk": 1000,
- "def": 1000,
- "mdef": 0,
- // "money": 0, // 如果要不共用金币则取消此项注释
- // "exp": 0, // 如果要不共用经验则取消此项注释
- "loc": { "x": 0, "y": 0, "direction": "up" }, // 该角色初始位置;如果共用位置可注释此项
- "items": {
- "tools": {}, // 如果共用消耗道具(含钥匙)则可注释此项
- // "constants": {}, // 如果不共用永久道具(如手册)可取消注释此项
- "equips": {}, // 如果共用在背包的装备可注释此项
- },
- "equipment": [], // 如果共用装备可注释此项;此项和上面的「共用在背包的装备」需要拥有相同状态,不然可能出现问题
- };
- // 也可以类似新增其他角色
- // 新增的角色,各项属性共用与不共用的选择必须和上面完全相同,否则可能出现问题。
- // var hero2 = { ...
-
- var heroCount = 2; // 包含默认角色在内总共多少个角色,该值需手动修改。
-
- this.initHeros = function () {
- core.setFlag("hero1", core.clone(hero1)); // 将属性值存到变量中
- // core.setFlag("hero2", core.clone(hero2)); // 更多的角色也存入变量中;每个定义的角色都需要新增一行
-
- // 检测是否存在装备
- if (hero1.equipment) {
- if (!hero1.items || !hero1.items.equips) {
- alert('多角色插件的equipment和道具中的equips必须拥有相同状态!');
- }
- // 存99号套装为全空
- var saveEquips = core.getFlag("saveEquips", []);
- saveEquips[99] = [];
- core.setFlag("saveEquips", saveEquips);
- } else {
- if (hero1.items && hero1.items.equips) {
- alert('多角色插件的equipment和道具中的equips必须拥有相同状态!');
}
}
- }
- // 在游戏开始注入initHeros
- var _startGame_setHard = core.events._startGame_setHard;
- core.events._startGame_setHard = function () {
- _startGame_setHard.call(core.events);
- core.initHeros();
- }
-
- // 切换角色
- // 可以使用 core.changeHero() 来切换到下一个角色
- // 也可以 core.changeHero(1) 来切换到某个角色(默认角色为0)
- this.changeHero = function (toHeroId) {
- var currHeroId = core.getFlag("heroId", 0); // 获得当前角色ID
- if (toHeroId == null) {
- toHeroId = (currHeroId + 1) % heroCount;
- }
- if (currHeroId == toHeroId) return;
-
- var saveList = Object.keys(hero1);
-
- // 保存当前内容
- var toSave = {};
- // 暂时干掉 drawTip 和 音效,避免切装时的提示
- var _drawTip = core.ui.drawTip;
- core.ui.drawTip = function () {};
- var _playSound = core.control.playSound;
- core.control.playSound = function () {}
- // 记录当前录像,因为可能存在换装问题
- core.clearRouteFolding();
- var routeLength = core.status.route.length;
- // 优先判定装备
- if (hero1.equipment) {
- core.items.quickSaveEquip(100 + currHeroId);
- core.items.quickLoadEquip(99);
- }
-
- saveList.forEach(function (name) {
- if (name == 'floorId') toSave[name] = core.status.floorId; // 楼层单独设置
- else if (name == 'items') {
- toSave.items = core.clone(core.status.hero.items);
- Object.keys(toSave.items).forEach(function (one) {
- if (!hero1.items[one]) delete toSave.items[one];
- });
- } else toSave[name] = core.clone(core.status.hero[name]); // 使用core.clone()来创建新对象
- });
-
- core.setFlag("hero" + currHeroId, toSave); // 将当前角色信息进行保存
- var data = core.getFlag("hero" + toHeroId); // 获得要切换的角色保存内容
-
- // 设置角色的属性值
- saveList.forEach(function (name) {
- if (name == "floorId");
- else if (name == "items") {
- Object.keys(core.status.hero.items).forEach(function (one) {
- if (data.items[one]) core.status.hero.items[one] = core.clone(data.items[one]);
- });
- } else {
- core.status.hero[name] = core.clone(data[name]);
+ core.registerAnimationFrame('dynamicHp', true, function () {
+ _check();
+ if (core.status.hero.hp != _currentHp) {
+ var dis = (_currentHp - core.status.hero.hp) * speed;
+ if (Math.abs(dis) < 2) {
+ _currentHp = core.status.hero.hp;
+ } else {
+ _currentHp -= dis;
+ }
+ core.setStatusBarInnerHTML('hp', _currentHp);
}
});
- // 最后装上装备
- if (hero1.equipment) {
- core.items.quickLoadEquip(100 + toHeroId);
+ },
+ "multiHeros": function () {
+ // 多角色插件
+ // Step 1: 启用本插件
+ // Step 2: 定义每个新的角色各项初始数据(参见下方注释)
+ // Step 3: 在游戏中的任何地方都可以调用 `core.changeHero()` 进行切换;也可以 `core.changeHero(1)` 来切换到某个具体的角色上
+
+ // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
+ var __enable = false;
+ if (!__enable) return;
+
+ // 在这里定义全部的新角色属性
+ // 请注意,在这里定义的内容不会多角色共用,在切换时会进行恢复。
+ // 你也可以自行新增或删除,比如不共用金币则可以加上"money"的初始化,不共用道具则可以加上"items"的初始化,
+ // 多角色共用hp的话则删除hp,等等。总之,不共用的属性都在这里进行定义就好。
+ var hero1 = {
+ "floorId": "MT0", // 该角色初始楼层ID;如果共用楼层可以注释此项
+ "image": "brave.png", // 角色的行走图名称;此项必填不然会报错
+ "name": "1号角色",
+ "lv": 1,
+ "hp": 10000, // 如果HP共用可注释此项
+ "atk": 1000,
+ "def": 1000,
+ "mdef": 0,
+ // "money": 0, // 如果要不共用金币则取消此项注释
+ // "exp": 0, // 如果要不共用经验则取消此项注释
+ "loc": { "x": 0, "y": 0, "direction": "up" }, // 该角色初始位置;如果共用位置可注释此项
+ "items": {
+ "tools": {}, // 如果共用消耗道具(含钥匙)则可注释此项
+ // "constants": {}, // 如果不共用永久道具(如手册)可取消注释此项
+ "equips": {}, // 如果共用在背包的装备可注释此项
+ },
+ "equipment": [], // 如果共用装备可注释此项;此项和上面的「共用在背包的装备」需要拥有相同状态,不然可能出现问题
+ };
+ // 也可以类似新增其他角色
+ // 新增的角色,各项属性共用与不共用的选择必须和上面完全相同,否则可能出现问题。
+ // var hero2 = { ...
+
+ var heroCount = 2; // 包含默认角色在内总共多少个角色,该值需手动修改。
+
+ this.initHeros = function () {
+ core.setFlag("hero1", core.clone(hero1)); // 将属性值存到变量中
+ // core.setFlag("hero2", core.clone(hero2)); // 更多的角色也存入变量中;每个定义的角色都需要新增一行
+
+ // 检测是否存在装备
+ if (hero1.equipment) {
+ if (!hero1.items || !hero1.items.equips) {
+ alert('多角色插件的equipment和道具中的equips必须拥有相同状态!');
+ }
+ // 存99号套装为全空
+ var saveEquips = core.getFlag("saveEquips", []);
+ saveEquips[99] = [];
+ core.setFlag("saveEquips", saveEquips);
+ } else {
+ if (hero1.items && hero1.items.equips) {
+ alert('多角色插件的equipment和道具中的equips必须拥有相同状态!');
+ }
+ }
}
- core.ui.drawTip = _drawTip;
- core.control.playSound = _playSound;
- core.status.route = core.status.route.slice(0, routeLength);
- core.control._bindRoutePush();
-
- // 插入事件:改变角色行走图并进行楼层切换
- var toFloorId = data.floorId || core.status.floorId;
- var toLoc = data.loc || core.status.hero.loc;
- core.insertAction([
- { "type": "setHeroIcon", "name": data.image || "hero.png" }, // 改变行走图
- // 同层则用changePos,不同层则用changeFloor;这是为了避免共用楼层造成触发eachArrive
- toFloorId != core.status.floorId ? {
- "type": "changeFloor",
- "floorId": toFloorId,
- "loc": [toLoc.x, toLoc.y],
- "direction": toLoc.direction,
- "time": 0 // 可以在这里设置切换时间
- } : { "type": "changePos", "loc": [toLoc.x, toLoc.y], "direction": toLoc.direction }
- // 你还可以在这里执行其他事件,比如增加或取消跟随效果
- ]);
- core.setFlag("heroId", toHeroId); // 保存切换到的角色ID
- }
-},
- "itemCategory": function () {
- // 物品分类插件。此插件允许你对消耗道具和永久道具进行分类,比如标记「宝物类」「剧情道具」「药品」等等。
- // 使用方法:
- // 1. 启用本插件
- // 2. 在下方数组中定义全部的物品分类类型
- // 3. 点击道具的【配置表格】,找到“【道具】相关的表格配置”,然后在【道具描述】之后仿照增加道具的分类:
- /*
- "category": {
- "_leaf": true,
- "_type": "textarea",
- "_string": true,
- "_data": "道具分类"
- },
- */
- // (你也可以选择使用下拉框的方式定义每个道具的分类,写法参见上面的cls)
- // 然后刷新编辑器,就可以对每个物品进行分类了
-
- // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
- var __enable = false;
- if (!__enable) return;
-
- // 在这里定义所有的道具分类类型,一行一个
- var categories = [
- "宝物类",
- "辅助类",
- "技能类",
- "剧情道具",
- "增益道具",
- ];
- // 当前选中的道具类别
- var currentCategory = null;
-
- // 重写 core.ui._drawToolbox 以绘制分类类别
- var _drawToolbox = core.ui._drawToolbox;
- core.ui._drawToolbox = function (index) {
- _drawToolbox.call(this, index);
- core.setTextAlign('ui', 'left');
- core.fillText('ui', '类别[E]:' + (currentCategory || "全部"), 15, this.PIXEL - 13);
- }
-
- // 获得所有应该在道具栏显示的某个类型道具
- core.ui.getToolboxItems = function (cls) {
- // 检查类别
- return Object.keys(core.status.hero.items[cls])
- .filter(function (id) {
- return !core.material.items[id].hideInToolbox &&
- (currentCategory == null || core.material.items[id].category == currentCategory);
- }).sort();
- }
-
- // 注入道具栏的点击事件(点击类别)
- var _clickToolbox = core.actions._clickToolbox;
- core.actions._clickToolbox = function (x, y) {
- if (x >= 0 && x <= this.HSIZE - 4 && y == this.LAST) {
- drawToolboxCategory();
- return;
+ // 在游戏开始注入initHeros
+ var _startGame_setHard = core.events._startGame_setHard;
+ core.events._startGame_setHard = function () {
+ _startGame_setHard.call(core.events);
+ core.initHeros();
}
- return _clickToolbox.call(core.actions, x, y);
- }
- // 注入道具栏的按键事件(E键)
- var _keyUpToolbox = core.actions._keyUpToolbox;
- core.actions._keyUpToolbox = function (keyCode) {
- if (keyCode == 69) {
- // 按E键则打开分类类别选择
- drawToolboxCategory();
- return;
+ // 切换角色
+ // 可以使用 core.changeHero() 来切换到下一个角色
+ // 也可以 core.changeHero(1) 来切换到某个角色(默认角色为0)
+ this.changeHero = function (toHeroId) {
+ var currHeroId = core.getFlag("heroId", 0); // 获得当前角色ID
+ if (toHeroId == null) {
+ toHeroId = (currHeroId + 1) % heroCount;
+ }
+ if (currHeroId == toHeroId) return;
+
+ var saveList = Object.keys(hero1);
+
+ // 保存当前内容
+ var toSave = {};
+ // 暂时干掉 drawTip 和 音效,避免切装时的提示
+ var _drawTip = core.ui.drawTip;
+ core.ui.drawTip = function () { };
+ var _playSound = core.control.playSound;
+ core.control.playSound = function () { }
+ // 记录当前录像,因为可能存在换装问题
+ core.clearRouteFolding();
+ var routeLength = core.status.route.length;
+ // 优先判定装备
+ if (hero1.equipment) {
+ core.items.quickSaveEquip(100 + currHeroId);
+ core.items.quickLoadEquip(99);
+ }
+
+ saveList.forEach(function (name) {
+ if (name == 'floorId') toSave[name] = core.status.floorId; // 楼层单独设置
+ else if (name == 'items') {
+ toSave.items = core.clone(core.status.hero.items);
+ Object.keys(toSave.items).forEach(function (one) {
+ if (!hero1.items[one]) delete toSave.items[one];
+ });
+ } else toSave[name] = core.clone(core.status.hero[name]); // 使用core.clone()来创建新对象
+ });
+
+ core.setFlag("hero" + currHeroId, toSave); // 将当前角色信息进行保存
+ var data = core.getFlag("hero" + toHeroId); // 获得要切换的角色保存内容
+
+ // 设置角色的属性值
+ saveList.forEach(function (name) {
+ if (name == "floorId");
+ else if (name == "items") {
+ Object.keys(core.status.hero.items).forEach(function (one) {
+ if (data.items[one]) core.status.hero.items[one] = core.clone(data.items[one]);
+ });
+ } else {
+ core.status.hero[name] = core.clone(data[name]);
+ }
+ });
+ // 最后装上装备
+ if (hero1.equipment) {
+ core.items.quickLoadEquip(100 + toHeroId);
+ }
+
+ core.ui.drawTip = _drawTip;
+ core.control.playSound = _playSound;
+ core.status.route = core.status.route.slice(0, routeLength);
+ core.control._bindRoutePush();
+
+ // 插入事件:改变角色行走图并进行楼层切换
+ var toFloorId = data.floorId || core.status.floorId;
+ var toLoc = data.loc || core.status.hero.loc;
+ core.insertAction([
+ { "type": "setHeroIcon", "name": data.image || "hero.png" }, // 改变行走图
+ // 同层则用changePos,不同层则用changeFloor;这是为了避免共用楼层造成触发eachArrive
+ toFloorId != core.status.floorId ? {
+ "type": "changeFloor",
+ "floorId": toFloorId,
+ "loc": [toLoc.x, toLoc.y],
+ "direction": toLoc.direction,
+ "time": 0 // 可以在这里设置切换时间
+ } : { "type": "changePos", "loc": [toLoc.x, toLoc.y], "direction": toLoc.direction }
+ // 你还可以在这里执行其他事件,比如增加或取消跟随效果
+ ]);
+ core.setFlag("heroId", toHeroId); // 保存切换到的角色ID
}
- return _keyUpToolbox.call(core.actions, keyCode);
- }
+ },
+ "itemCategory": function () {
+ // 物品分类插件。此插件允许你对消耗道具和永久道具进行分类,比如标记「宝物类」「剧情道具」「药品」等等。
+ // 使用方法:
+ // 1. 启用本插件
+ // 2. 在下方数组中定义全部的物品分类类型
+ // 3. 点击道具的【配置表格】,找到“【道具】相关的表格配置”,然后在【道具描述】之后仿照增加道具的分类:
+ /*
+ "category": {
+ "_leaf": true,
+ "_type": "textarea",
+ "_string": true,
+ "_data": "道具分类"
+ },
+ */
+ // (你也可以选择使用下拉框的方式定义每个道具的分类,写法参见上面的cls)
+ // 然后刷新编辑器,就可以对每个物品进行分类了
- // ------ 以下为选择道具分类的相关代码 ------ //
+ // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
+ var __enable = false;
+ if (!__enable) return;
- // 关闭窗口时清除分类选择项
- var _closePanel = core.ui.closePanel;
- core.ui.closePanel = function () {
- currentCategory = null;
- _closePanel.call(core.ui);
- }
+ // 在这里定义所有的道具分类类型,一行一个
+ var categories = [
+ "宝物类",
+ "辅助类",
+ "技能类",
+ "剧情道具",
+ "增益道具",
+ ];
+ // 当前选中的道具类别
+ var currentCategory = null;
- // 弹出菜单以选择具体哪个分类
- // 直接使用 core.drawChoices 进行绘制
- var drawToolboxCategory = function () {
- if (core.status.event.id != 'toolbox') return;
- var selection = categories.indexOf(currentCategory) + 1;
- core.ui.closePanel();
- core.status.event.id = 'toolbox-category';
- core.status.event.selection = selection;
- core.lockControl();
- // 给第一项插入「全部」
- core.drawChoices('请选择道具类别', ["全部"].concat(categories));
- }
-
- // 选择某一项
- var _selectCategory = function (index) {
- core.ui.closePanel();
- if (index <= 0 || index > categories.length) currentCategory = null;
- else currentCategory = categories[index - 1];
- core.openToolbox();
- }
-
- var _clickToolBoxCategory = function (x, y) {
- if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
-
- if (x < core.actions.CHOICES_LEFT || x > core.actions.CHOICES_RIGHT) return false;
- var choices = core.status.event.ui.choices;
- var topIndex = core.actions._getChoicesTopIndex(choices.length);
- if (y >= topIndex && y < topIndex + choices.length) {
- _selectCategory(y - topIndex);
+ // 重写 core.ui._drawToolbox 以绘制分类类别
+ var _drawToolbox = core.ui._drawToolbox;
+ core.ui._drawToolbox = function (index) {
+ _drawToolbox.call(this, index);
+ core.setTextAlign('ui', 'left');
+ core.fillText('ui', '类别[E]:' + (currentCategory || "全部"), 15, this.PIXEL - 13);
}
- return true;
- }
- // 注入点击事件
- core.registerAction('onclick', 'toolbox-category', _clickToolBoxCategory, 100);
-
- // 注入光标跟随事件
- core.registerAction('onmove', 'toolbox-category', function (x, y) {
- if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
- core.actions._onMoveChoices(x, y);
- return true;
- }, 100);
-
- // 注入键盘光标事件
- core.registerAction('keyDown', 'toolbox-category', function (keyCode) {
- if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
- core.actions._keyDownChoices(keyCode);
- return true;
- }, 100);
-
- // 注入键盘按键事件
- core.registerAction('keyUp', 'toolbox-category', function (keyCode) {
- if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
- core.actions._selectChoices(core.status.event.ui.choices.length, keyCode, _clickToolBoxCategory);
- return true;
- }, 100);
-
-},
- "heroFourFrames": function () {
- // 样板的勇士/跟随者移动时只使用2、4两帧,观感较差。本插件可以将四帧全用上。
-
- // 是否启用本插件
- var __enable = false;
- if (!__enable) return;
-
- ["up", "down", "left", "right"].forEach(function (one) {
- // 指定中间帧动画
- core.material.icons.hero[one].midFoot = 2;
- });
-
- var heroMoving = function (timestamp) {
- if (core.status.heroMoving <= 0) return;
- if (timestamp - core.animateFrame.moveTime > core.values.moveSpeed) {
- core.animateFrame.leftLeg++;
- core.animateFrame.moveTime = timestamp;
+ // 获得所有应该在道具栏显示的某个类型道具
+ core.ui.getToolboxItems = function (cls) {
+ // 检查类别
+ return Object.keys(core.status.hero.items[cls])
+ .filter(function (id) {
+ return !core.material.items[id].hideInToolbox &&
+ (currentCategory == null || core.material.items[id].category == currentCategory);
+ }).sort();
}
- core.drawHero(['stop', 'leftFoot', 'midFoot', 'rightFoot'][core.animateFrame.leftLeg % 4], 4 * core.status.heroMoving);
- }
- core.registerAnimationFrame('heroMoving', true, heroMoving);
- core.events._eventMoveHero_moving = function (step, moveSteps) {
- var curr = moveSteps[0];
- var direction = curr[0], x = core.getHeroLoc('x'), y = core.getHeroLoc('y');
- // ------ 前进/后退
- var o = direction == 'backward' ? -1 : 1;
- if (direction == 'forward' || direction == 'backward') direction = core.getHeroLoc('direction');
- var faceDirection = direction;
- if (direction == 'leftup' || direction == 'leftdown') faceDirection = 'left';
- if (direction == 'rightup' || direction == 'rightdown') faceDirection = 'right';
- core.setHeroLoc('direction', direction);
- if (curr[1] <= 0) {
- core.setHeroLoc('direction', faceDirection);
- moveSteps.shift();
+ // 注入道具栏的点击事件(点击类别)
+ var _clickToolbox = core.actions._clickToolbox;
+ core.actions._clickToolbox = function (x, y) {
+ if (x >= 0 && x <= this.HSIZE - 4 && y == this.LAST) {
+ drawToolboxCategory();
+ return;
+ }
+ return _clickToolbox.call(core.actions, x, y);
+ }
+
+ // 注入道具栏的按键事件(E键)
+ var _keyUpToolbox = core.actions._keyUpToolbox;
+ core.actions._keyUpToolbox = function (keyCode) {
+ if (keyCode == 69) {
+ // 按E键则打开分类类别选择
+ drawToolboxCategory();
+ return;
+ }
+ return _keyUpToolbox.call(core.actions, keyCode);
+ }
+
+ // ------ 以下为选择道具分类的相关代码 ------ //
+
+ // 关闭窗口时清除分类选择项
+ var _closePanel = core.ui.closePanel;
+ core.ui.closePanel = function () {
+ currentCategory = null;
+ _closePanel.call(core.ui);
+ }
+
+ // 弹出菜单以选择具体哪个分类
+ // 直接使用 core.drawChoices 进行绘制
+ var drawToolboxCategory = function () {
+ if (core.status.event.id != 'toolbox') return;
+ var selection = categories.indexOf(currentCategory) + 1;
+ core.ui.closePanel();
+ core.status.event.id = 'toolbox-category';
+ core.status.event.selection = selection;
+ core.lockControl();
+ // 给第一项插入「全部」
+ core.drawChoices('请选择道具类别', ["全部"].concat(categories));
+ }
+
+ // 选择某一项
+ var _selectCategory = function (index) {
+ core.ui.closePanel();
+ if (index <= 0 || index > categories.length) currentCategory = null;
+ else currentCategory = categories[index - 1];
+ core.openToolbox();
+ }
+
+ var _clickToolBoxCategory = function (x, y) {
+ if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
+
+ if (x < core.actions.CHOICES_LEFT || x > core.actions.CHOICES_RIGHT) return false;
+ var choices = core.status.event.ui.choices;
+ var topIndex = core.actions._getChoicesTopIndex(choices.length);
+ if (y >= topIndex && y < topIndex + choices.length) {
+ _selectCategory(y - topIndex);
+ }
return true;
}
- if (step <= 4) core.drawHero('stop', 4 * o * step);
- else if (step <= 8) core.drawHero('leftFoot', 4 * o * step);
- else if (step <= 12) core.drawHero('midFoot', 4 * o * (step - 8));
- else if (step <= 16) core.drawHero('rightFoot', 4 * o * (step - 8)); // if (step == 8) {
- if (step == 8 || step == 16) {
- core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true);
- core.setHeroLoc('y', y + o * core.utils.scan2[direction].y, true);
- core.updateFollowers();
- curr[1]--;
- if (curr[1] <= 0) moveSteps.shift();
- core.setHeroLoc('direction', faceDirection);
- return step == 16;
- }
- return false;
- }
-},
- "startCanvas": function () {
- // 使用本插件可以将自绘的标题界面居中。仅在【标题开启事件化】后才有效。
- // 由于一些技术性的原因,标题界面事件化无法应用到覆盖状态栏的整个界面。
- // 这是一个较为妥协的插件,会在自绘标题界面时隐藏状态栏、工具栏和边框,并将画布进行居中。
- // 本插件仅在全塔属性的 "startCanvas" 生效;进入 "startText" 时将会离开居中状态,回归正常界面。
- // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
- var __enable = false;
- if (!__enable) return;
+ // 注入点击事件
+ core.registerAction('onclick', 'toolbox-category', _clickToolBoxCategory, 100);
- // 检查【标题开启事件化】是否开启
- if (!core.flags.startUsingCanvas || main.mode != 'play') return;
+ // 注入光标跟随事件
+ core.registerAction('onmove', 'toolbox-category', function (x, y) {
+ if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
+ core.actions._onMoveChoices(x, y);
+ return true;
+ }, 100);
- var _isTitleCanvasEnabled = false;
- var _getClickLoc = core.actions._getClickLoc;
- this._setTitleCanvas = function () {
- if (_isTitleCanvasEnabled) return;
- _isTitleCanvasEnabled = true;
+ // 注入键盘光标事件
+ core.registerAction('keyDown', 'toolbox-category', function (keyCode) {
+ if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
+ core.actions._keyDownChoices(keyCode);
+ return true;
+ }, 100);
- // 禁用窗口resize
- window.onresize = function () {};
- core.resize = function () {}
+ // 注入键盘按键事件
+ core.registerAction('keyUp', 'toolbox-category', function (keyCode) {
+ if (!core.status.lockControl || core.status.event.id != 'toolbox-category') return false;
+ core.actions._selectChoices(core.status.event.ui.choices.length, keyCode, _clickToolBoxCategory);
+ return true;
+ }, 100);
- // 隐藏状态栏
- core.dom.statusBar.style.display = 'none';
- core.dom.statusCanvas.style.display = 'none';
- core.dom.toolBar.style.display = 'none';
- // 居中画布
- if (core.domStyle.isVertical) {
- core.dom.gameDraw.style.top =
- (parseInt(core.dom.gameGroup.style.height) - parseInt(core.dom.gameDraw.style.height)) / 2 + "px";
- } else {
- core.dom.gameDraw.style.right =
- (parseInt(core.dom.gameGroup.style.width) - parseInt(core.dom.gameDraw.style.width)) / 2 + "px";
- }
- core.dom.gameDraw.style.border = '3px transparent solid';
- core.actions._getClickLoc = function (x, y) {
- var left = core.dom.gameGroup.offsetLeft + core.dom.gameDraw.offsetLeft + 3;
- var top = core.dom.gameGroup.offsetTop + core.dom.gameDraw.offsetTop + 3;
- var loc = { 'x': Math.max(x - left, 0), 'y': Math.max(y - top, 0), 'size': 32 * core.domStyle.scale };
- return loc;
- }
- }
+ },
+ "heroFourFrames": function () {
+ // 样板的勇士/跟随者移动时只使用2、4两帧,观感较差。本插件可以将四帧全用上。
- this._resetTitleCanvas = function () {
- if (!_isTitleCanvasEnabled) return;
- _isTitleCanvasEnabled = false;
- window.onresize = function () { try { main.core.resize(); } catch (e) { main.log(e); } }
- core.resize = function () { return core.control.resize(); }
- core.resize();
- core.actions._getClickLoc = _getClickLoc;
- }
+ // 是否启用本插件
+ var __enable = false;
+ if (!__enable) return;
- // 复写“开始游戏”
- core.events._startGame_start = function (hard, seed, route, callback) {
- console.log('开始游戏');
- core.resetGame(core.firstData.hero, hard, null, core.cloneArray(core.initStatus.maps));
- core.setHeroLoc('x', -1);
- core.setHeroLoc('y', -1);
-
- if (seed != null) {
- core.setFlag('__seed__', seed);
- core.setFlag('__rand__', seed);
- } else core.utils.__init_seed();
-
- core.clearStatusBar();
- core.plugin._setTitleCanvas();
-
- var todo = [];
- core.hideStatusBar();
- core.push(todo, core.firstData.startCanvas);
- core.push(todo, { "type": "function", "function": "function() { core.plugin._resetTitleCanvas(); core.events._startGame_setHard(); }" })
- core.push(todo, core.firstData.startText);
- this.insertAction(todo, null, null, function () {
- core.events._startGame_afterStart(callback);
+ ["up", "down", "left", "right"].forEach(function (one) {
+ // 指定中间帧动画
+ core.material.icons.hero[one].midFoot = 2;
});
- if (route != null) core.startReplay(route);
- }
+ var heroMoving = function (timestamp) {
+ if (core.status.heroMoving <= 0) return;
+ if (timestamp - core.animateFrame.moveTime > core.values.moveSpeed) {
+ core.animateFrame.leftLeg++;
+ core.animateFrame.moveTime = timestamp;
+ }
+ core.drawHero(['stop', 'leftFoot', 'midFoot', 'rightFoot'][core.animateFrame.leftLeg % 4], 4 * core.status.heroMoving);
+ }
+ core.registerAnimationFrame('heroMoving', true, heroMoving);
- var _loadData = core.control.loadData;
- core.control.loadData = function (data, callback) {
- core.plugin._resetTitleCanvas();
- _loadData.call(core.control, data, callback);
+ core.events._eventMoveHero_moving = function (step, moveSteps) {
+ var curr = moveSteps[0];
+ var direction = curr[0], x = core.getHeroLoc('x'), y = core.getHeroLoc('y');
+ // ------ 前进/后退
+ var o = direction == 'backward' ? -1 : 1;
+ if (direction == 'forward' || direction == 'backward') direction = core.getHeroLoc('direction');
+ var faceDirection = direction;
+ if (direction == 'leftup' || direction == 'leftdown') faceDirection = 'left';
+ if (direction == 'rightup' || direction == 'rightdown') faceDirection = 'right';
+ core.setHeroLoc('direction', direction);
+ if (curr[1] <= 0) {
+ core.setHeroLoc('direction', faceDirection);
+ moveSteps.shift();
+ return true;
+ }
+ if (step <= 4) core.drawHero('stop', 4 * o * step);
+ else if (step <= 8) core.drawHero('leftFoot', 4 * o * step);
+ else if (step <= 12) core.drawHero('midFoot', 4 * o * (step - 8));
+ else if (step <= 16) core.drawHero('rightFoot', 4 * o * (step - 8)); // if (step == 8) {
+ if (step == 8 || step == 16) {
+ core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true);
+ core.setHeroLoc('y', y + o * core.utils.scan2[direction].y, true);
+ core.updateFollowers();
+ curr[1]--;
+ if (curr[1] <= 0) moveSteps.shift();
+ core.setHeroLoc('direction', faceDirection);
+ return step == 16;
+ }
+ return false;
+ }
+ },
+ "startCanvas": function () {
+ // 使用本插件可以将自绘的标题界面居中。仅在【标题开启事件化】后才有效。
+ // 由于一些技术性的原因,标题界面事件化无法应用到覆盖状态栏的整个界面。
+ // 这是一个较为妥协的插件,会在自绘标题界面时隐藏状态栏、工具栏和边框,并将画布进行居中。
+ // 本插件仅在全塔属性的 "startCanvas" 生效;进入 "startText" 时将会离开居中状态,回归正常界面。
+
+ // 是否开启本插件,默认禁用;将此改成 true 将启用本插件。
+ var __enable = false;
+ if (!__enable) return;
+
+ // 检查【标题开启事件化】是否开启
+ if (!core.flags.startUsingCanvas || main.mode != 'play') return;
+
+ var _isTitleCanvasEnabled = false;
+ var _getClickLoc = core.actions._getClickLoc;
+ this._setTitleCanvas = function () {
+ if (_isTitleCanvasEnabled) return;
+ _isTitleCanvasEnabled = true;
+
+ // 禁用窗口resize
+ window.onresize = function () { };
+ core.resize = function () { }
+
+ // 隐藏状态栏
+ core.dom.statusBar.style.display = 'none';
+ core.dom.statusCanvas.style.display = 'none';
+ core.dom.toolBar.style.display = 'none';
+ // 居中画布
+ if (core.domStyle.isVertical) {
+ core.dom.gameDraw.style.top =
+ (parseInt(core.dom.gameGroup.style.height) - parseInt(core.dom.gameDraw.style.height)) / 2 + "px";
+ } else {
+ core.dom.gameDraw.style.right =
+ (parseInt(core.dom.gameGroup.style.width) - parseInt(core.dom.gameDraw.style.width)) / 2 + "px";
+ }
+ core.dom.gameDraw.style.border = '3px transparent solid';
+ core.actions._getClickLoc = function (x, y) {
+ var left = core.dom.gameGroup.offsetLeft + core.dom.gameDraw.offsetLeft + 3;
+ var top = core.dom.gameGroup.offsetTop + core.dom.gameDraw.offsetTop + 3;
+ var loc = { 'x': Math.max(x - left, 0), 'y': Math.max(y - top, 0), 'size': 32 * core.domStyle.scale };
+ return loc;
+ }
+ }
+
+ this._resetTitleCanvas = function () {
+ if (!_isTitleCanvasEnabled) return;
+ _isTitleCanvasEnabled = false;
+ 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;
+ }
+
+ // 复写“开始游戏”
+ core.events._startGame_start = function (hard, seed, route, callback) {
+ console.log('开始游戏');
+ core.resetGame(core.firstData.hero, hard, null, core.cloneArray(core.initStatus.maps));
+ core.setHeroLoc('x', -1);
+ core.setHeroLoc('y', -1);
+
+ if (seed != null) {
+ core.setFlag('__seed__', seed);
+ core.setFlag('__rand__', seed);
+ } else core.utils.__init_seed();
+
+ core.clearStatusBar();
+ core.plugin._setTitleCanvas();
+
+ var todo = [];
+ core.hideStatusBar();
+ core.push(todo, core.firstData.startCanvas);
+ core.push(todo, { "type": "function", "function": "function() { core.plugin._resetTitleCanvas(); core.events._startGame_setHard(); }" })
+ core.push(todo, core.firstData.startText);
+ this.insertAction(todo, null, null, function () {
+ core.events._startGame_afterStart(callback);
+ });
+
+ if (route != null) core.startReplay(route);
+ }
+
+ var _loadData = core.control.loadData;
+ core.control.loadData = function (data, callback) {
+ core.plugin._resetTitleCanvas();
+ _loadData.call(core.control, data, callback);
+ }
}
-}
}
\ No newline at end of file
diff --git a/runtime.d.ts b/runtime.d.ts
index 313f9da1..28b2e1d8 100644
--- a/runtime.d.ts
+++ b/runtime.d.ts
@@ -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
\ No newline at end of file