kill main.log
This commit is contained in:
parent
f7f3e66cd6
commit
1ad1e12df6
@ -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"), "<mark>$&</mark>");
|
||||
if (input != "") text = text.replace(new RegExp("^" + input, "i"), "<mark>$&</mark>");
|
||||
li.innerHTML = text;
|
||||
if (info) {
|
||||
var height = (info.height || 32), width = 32;
|
||||
@ -907,10 +913,10 @@ editor_blockly = function () {
|
||||
value = value.substring(0, index);
|
||||
// cal prefix
|
||||
awesomplete.prefix = value;
|
||||
for (var i = index - 1; i>=0; i--) {
|
||||
for (var i = index - 1; i >= 0; i--) {
|
||||
var c = value.charAt(i);
|
||||
if (!/^[a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]$/.test(c)) {
|
||||
awesomplete.prefix = value.substring(i+1);
|
||||
awesomplete.prefix = value.substring(i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -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 = '';
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
@ -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 =
|
||||
'<option value="thumbnail" selected>缩略图</option>' +
|
||||
'<option value="#000000">黑色</option>' +
|
||||
uievent.elements.select.innerHTML =
|
||||
'<option value="thumbnail" selected>缩略图</option>' +
|
||||
'<option value="#000000">黑色</option>' +
|
||||
'<option value="#FFFFFF">白色</option>';
|
||||
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 += "<input type='radio' name='uievent_selectFloor' onchange='editor.uievent.values.floorId=\""+one+"\"'" + (checked ? ' checked' : '') + ">";
|
||||
html += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\""+one+"\"' style='cursor: default'>"
|
||||
if (!one.includes(value) && !(floor.title || "").includes(value) && !(floor.name || "").includes(value)) return;
|
||||
html += "<input type='radio' name='uievent_selectFloor' onchange='editor.uievent.values.floorId=\"" + one + "\"'" + (checked ? ' checked' : '') + ">";
|
||||
html += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\"" + one + "\"' style='cursor: default'>"
|
||||
+ one + '(' + floor.title + ')' + "</span>";
|
||||
html += "<button onclick='editor.uievent._selectFloor_preview(this)' style='margin-left: 10px'>预览</button>";
|
||||
html += "<span style='display:none;' key='"+one+"'></span>";
|
||||
html += "<span style='display:none;' key='" + one + "'></span>";
|
||||
html += '<br/>';
|
||||
});
|
||||
floorList.innerHTML = html;
|
||||
@ -522,7 +522,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
}
|
||||
span.appendChild(uievent.values.dom);
|
||||
core.clearMap(uievent.values.ctx);
|
||||
core.drawThumbnail(floorId, null, {ctx: uievent.values.ctx, all: true});
|
||||
core.drawThumbnail(floorId, null, { ctx: uievent.values.ctx, all: true });
|
||||
} else {
|
||||
button.innerText = '预览';
|
||||
span.style.display = 'none';
|
||||
@ -545,7 +545,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
return;
|
||||
}
|
||||
value = value || [];
|
||||
data = (transform ? data.map(transform) : data).filter(function (one) {return one;}).sort();
|
||||
data = (transform ? data.map(transform) : data).filter(function (one) { return one; }).sort();
|
||||
var data2 = Object.keys(appendedImages);
|
||||
data2 = (transform ? data2.map(transform) : data2).filter(function (one) {
|
||||
return one && data.indexOf(one) < 0;
|
||||
@ -567,7 +567,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
uievent.elements.yes.onclick = function () {
|
||||
var list = Array.from(document.getElementsByClassName('materialCheckbox')).filter(function (one) {
|
||||
return one.checked;
|
||||
}).map(function (one) {return one.getAttribute('key'); });
|
||||
}).map(function (one) { return one.getAttribute('key'); });
|
||||
uievent.close();
|
||||
if (callback) callback(list);
|
||||
}
|
||||
@ -576,44 +576,44 @@ editor_uievent_wrapper = function (editor) {
|
||||
|
||||
// 显示每一项内容
|
||||
var html = "<p style='margin-left: 10px; line-height: 25px'>";
|
||||
html += "<button onclick='editor.uievent._selectAllMaterial(true)'>全选</button>"+
|
||||
"<button style='margin-left: 10px' onclick='editor.uievent._selectAllMaterial(false)'>全不选</button><br/>";
|
||||
html += "<button onclick='editor.uievent._selectAllMaterial(true)'>全选</button>" +
|
||||
"<button style='margin-left: 10px' onclick='editor.uievent._selectAllMaterial(false)'>全不选</button><br/>";
|
||||
if (_isTileset) {
|
||||
html += "<b style='margin-top: 5px;'>警告!额外素材一旦注册成功将不可删除,否则可能会导致素材错位风险!如果你不再想用某个额外素材,"
|
||||
+"但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。</b><br/>"
|
||||
+ "但又不想让它出现在素材区,可以考虑使用空气墙同名替换该额外素材文件。</b><br/>"
|
||||
}
|
||||
data.forEach(function (one) {
|
||||
var checked = value.indexOf(one) >= 0? 'checked' : '';
|
||||
var checked = value.indexOf(one) >= 0 ? 'checked' : '';
|
||||
var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : ''
|
||||
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
|
||||
// 预览图片
|
||||
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) {
|
||||
html += "<button onclick='editor.uievent._previewMaterialImage(this)' style='margin-left: 10px'>预览</button>";
|
||||
html += '<br style="display:none"/><img key="'+directory+one+'" style="display:none; max-width: 100%"/>';
|
||||
html += '<br style="display:none"/><img key="' + directory + one + '" style="display:none; max-width: 100%"/>';
|
||||
}
|
||||
// 试听音频
|
||||
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) {
|
||||
html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>播放</button>"
|
||||
html += "<small> 音调:<input value='100' style='width:28px' onchange='editor.uievent._previewMaterialAudio_onPitchChange(this)'></small>";
|
||||
html += `<small style='display:none; margin-left: 15px'>0:00 / 0:00</small><br style="display:none"/>
|
||||
<audio preload="none" src="${directory+one}" ontimeupdate="editor.uievent._previewMaterialAudio_onTimeUpdate(this)"></audio>
|
||||
<audio preload="none" src="${directory + one}" ontimeupdate="editor.uievent._previewMaterialAudio_onTimeUpdate(this)"></audio>
|
||||
<progress value="0" max="1" style="display:none; width:100%" onclick="editor.uievent._previewMaterialAudio_seek(this, event)"></progress>`;
|
||||
}
|
||||
// 预览动画
|
||||
if (directory.indexOf('animates') >= 0) {
|
||||
html += "<button onclick='editor.uievent._previewMaterialAnimate(this)' style='margin-left: 10px'>预览</button>";
|
||||
html += "<span style='display:none; margin-left: 10px' key='"+directory+one+".animate'></span>";
|
||||
html += "<span style='display:none; margin-left: 10px' key='" + directory + one + ".animate'></span>";
|
||||
}
|
||||
html += '<br/>';
|
||||
});
|
||||
data2.forEach(function (one) {
|
||||
var checked = value.indexOf(one) >= 0? 'checked' : '';
|
||||
var checked = value.indexOf(one) >= 0 ? 'checked' : '';
|
||||
var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : '';
|
||||
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
|
||||
// 预览图片
|
||||
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) {
|
||||
html += "<button onclick='editor.uievent._previewMaterialImage2(this)' style='margin-left: 10px'>预览</button>";
|
||||
html += '<br style="display:none" key="'+one+'"/><br/>';
|
||||
html += '<br style="display:none" key="' + one + '"/><br/>';
|
||||
}
|
||||
})
|
||||
html += "</p>";
|
||||
@ -670,7 +670,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
} else {
|
||||
button.innerText = '播放';
|
||||
br.style.display = 'none';
|
||||
progress.style.display='none';
|
||||
progress.style.display = 'none';
|
||||
span.style.display = 'none';
|
||||
audio.pause();
|
||||
}
|
||||
@ -683,7 +683,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
}
|
||||
|
||||
uievent._previewMaterialAudio_onTimeUpdate = function (audio) {
|
||||
var _format = function (time) { return parseInt(time/60) + ":" + core.setTwoDigits(parseInt(time) % 60); }
|
||||
var _format = function (time) { return parseInt(time / 60) + ":" + core.setTwoDigits(parseInt(time) % 60); }
|
||||
if (audio.duration > 0) {
|
||||
audio.previousElementSibling.previousElementSibling.innerText = _format(audio.currentTime) + " / " + _format(audio.duration);
|
||||
audio.nextElementSibling.setAttribute('value', audio.currentTime / audio.duration);
|
||||
@ -709,7 +709,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = core.__PIXELS__;
|
||||
canvas.style.position = 'absolute';
|
||||
core.drawThumbnail(editor.currentFloorId, null, {ctx: canvas.getContext('2d')});
|
||||
core.drawThumbnail(editor.currentFloorId, null, { ctx: canvas.getContext('2d') });
|
||||
dom.appendChild(canvas);
|
||||
var canvas2 = document.createElement('canvas');
|
||||
canvas2.style.position = 'absolute';
|
||||
@ -738,7 +738,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
|
||||
var _previewMaterialAnimate_buildSounds = function (span, content) {
|
||||
var sounds = content.se || {};
|
||||
if (typeof sounds == 'string') sounds = {1: sounds};
|
||||
if (typeof sounds == 'string') sounds = { 1: sounds };
|
||||
var pitch = content.pitch || {};
|
||||
|
||||
span.appendChild(document.createElement('br'));
|
||||
@ -761,14 +761,14 @@ editor_uievent_wrapper = function (editor) {
|
||||
var html = "";
|
||||
html += "第 <select>";
|
||||
for (var i = 1; i <= frames; ++i) {
|
||||
html += "<option value="+i;
|
||||
html += "<option value=" + i;
|
||||
if (index == i) html += " selected";
|
||||
html += ">"+i+"</option>";
|
||||
html += ">" + i + "</option>";
|
||||
}
|
||||
html += "</select> 帧:";
|
||||
html += '<input type="text" class="_audio" data-list="'+audios+'" data-minchars="1" data-autofirst="true" style="width: 110px" value="'+se+'"/>';
|
||||
html += '<input type="text" class="_audio" data-list="' + audios + '" data-minchars="1" data-autofirst="true" style="width: 110px" value="' + se + '"/>';
|
||||
html += '<button onclick="editor.uievent._previewMaterialAnimate_previewSound(this)" style="margin-left: 10px">试听</button>';
|
||||
html += "<small> 音调:<input value='"+(pitch||100)+"' style='width:28px'></small>";
|
||||
html += "<small> 音调:<input value='" + (pitch || 100) + "' style='width:28px'></small>";
|
||||
html += '<button onclick="editor.uievent._previewMaterialAnimate_deleteSound(this)" style="margin-left: 10px">删除</button>';
|
||||
html += '<br/>';
|
||||
return html;
|
||||
@ -798,7 +798,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
} else {
|
||||
fs.readFile(filename, 'utf-8', function (e, d) {
|
||||
if (e) {
|
||||
alert('无法打开动画文件!'+e); return;
|
||||
alert('无法打开动画文件!' + e); return;
|
||||
}
|
||||
uievent.values.animates[filename] = core.loader._loadAnimate(d);
|
||||
if (uievent.values.animates[filename]) {
|
||||
@ -856,11 +856,11 @@ editor_uievent_wrapper = function (editor) {
|
||||
}
|
||||
}
|
||||
uievent.values.animates[filename].se = se;
|
||||
uievent.values.animates[filename+':raw'].se = se;
|
||||
uievent.values.animates[filename + ':raw'].se = se;
|
||||
uievent.values.animates[filename].pitch = pitch;
|
||||
uievent.values.animates[filename+':raw'].pitch = pitch;
|
||||
fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename+':raw']), 'utf-8', function (e, d) {
|
||||
if (e) alert('无法修改音效文件!'+e);
|
||||
uievent.values.animates[filename + ':raw'].pitch = pitch;
|
||||
fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename + ':raw']), 'utf-8', function (e, d) {
|
||||
if (e) alert('无法修改音效文件!' + e);
|
||||
else {
|
||||
alert('动画音效修改成功!别忘了在全塔属性中注册音效哦!');
|
||||
}
|
||||
@ -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 += '<tr>';
|
||||
}
|
||||
table += `<td class='popCheckboxItem'>${prefixStrings[index]}<input type="checkbox" _type="${typeof one}" key="${one}" class="uieventCheckboxSet" ${value.indexOf(one) >= 0? 'checked' : ''}/></td>`;
|
||||
table += `<td class='popCheckboxItem'>${prefixStrings[index]}<input type="checkbox" _type="${typeof one}" key="${one}" class="uieventCheckboxSet" ${value.indexOf(one) >= 0 ? 'checked' : ''}/></td>`;
|
||||
if (index % 3 == 2) {
|
||||
table += '</tr>';
|
||||
}
|
||||
@ -923,7 +923,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
if (keys.length % 3 != 0) table += '</tr>';
|
||||
table += '</table>';
|
||||
|
||||
uievent.elements.extraBody.innerHTML = "<p>"+table+"</p>";
|
||||
uievent.elements.extraBody.innerHTML = "<p>" + table + "</p>";
|
||||
}
|
||||
|
||||
uievent.previewEditorMulti = function (mode, code) {
|
||||
@ -974,7 +974,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
html += "魔力:<input value='0'> 上限:<input value='-1'> 金币:<input value='0'> 经验:<input value='0'> 等级:<input value='1'> ";
|
||||
html += "<br/>当前道具ID(以逗号分隔):<br/><textarea style='width:300px;height:40px'>yellowKey,yellowKey,blueKey</textarea>";
|
||||
html += "<br/>当前装备ID(以逗号分隔):<br/><textarea style='width:300px;height:40px'>sword1,sheild1</textarea>";
|
||||
html += "<br/>当前变量值(JSON格式):<br/><textarea style='width:300px;height:80px'>"+JSON.stringify(flags)+"</textarea>";
|
||||
html += "<br/>当前变量值(JSON格式):<br/><textarea style='width:300px;height:80px'>" + JSON.stringify(flags) + "</textarea>";
|
||||
html += "</span></p>"
|
||||
uievent.elements.extraBody.innerHTML = html;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
136
libs/actions.js
136
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,
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
40
libs/core.js
40
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
function data() {
|
||||
function data () {
|
||||
this._init();
|
||||
}
|
||||
|
||||
|
||||
@ -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++) {
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -6,7 +6,7 @@ extensions.js:负责拓展插件
|
||||
|
||||
"use strict";
|
||||
|
||||
function extensions() {
|
||||
function extensions () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
805
main.js
805
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
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/// <reference path="../runtime.d.ts" />
|
||||
var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
{
|
||||
"events": {
|
||||
@ -1571,7 +1572,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
try {
|
||||
eval(core.floors[core.status.floorId].parallelDo);
|
||||
} catch (e) {
|
||||
main.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2543
project/plugins.js
2543
project/plugins.js
File diff suppressed because it is too large
Load Diff
7
runtime.d.ts
vendored
7
runtime.d.ts
vendored
@ -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
|
||||
Loading…
Reference in New Issue
Block a user