From bf4c63a5147f2918ce7a57da81bb0889ee05fe7f Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 31 Aug 2021 20:14:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E4=B8=8D=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 12 +++++++----- _server/MotaActionParser.js | 4 ++-- _server/editor_blockly.js | 2 +- libs/events.js | 10 ++++++++-- libs/ui.js | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 07105cb2..8b824a50 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -968,7 +968,7 @@ return code+',\n'; */; text_1_s - : '标题' EvalString? '图像' EvalString? '对话框效果' EvalString? '起点像素 px' PosString? 'py' PosString? '宽度' PosString? '对话框编号' Int BGNL? Newline EvalString_Multi Newline + : '标题' EvalString? '图像' EvalString? '对话框效果' EvalString? '起点 px' PosString? 'py' PosString? '宽' PosString? '编号' Int '不等待操作' Bool BGNL? Newline EvalString_Multi Newline /* text_1_s @@ -976,7 +976,7 @@ tooltip : text:显示一段文字(剧情),选项较多请右键点击帮 helpUrl : /_docs/#/instruction previewBlock : true allIds : ['EvalString_1'] -default : ["小妖精","fairy","","","","",0,"欢迎使用事件编辑器(双击方块可直接预览)"] +default : ["小妖精","fairy","","","","",0,false,"欢迎使用事件编辑器(双击方块可直接预览)"] var title=''; if (EvalString_0==''){ if (EvalString_1=='' )title=''; @@ -997,10 +997,11 @@ if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.t } EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']'); var code = '"'+title+EvalString_2+EvalString_Multi_0+'"'; -if (block.isCollapsed() || !block.isEnabled() || pos || Int_0) { +if (block.isCollapsed() || !block.isEnabled() || pos || Int_0 || Bool_0) { code = '{"type": "text", "text": '+code; if (pos) code += ', "pos": ' + pos; if (Int_0) code += ', "code": ' + Int_0; + if (Bool_0) code += ', "async": true'; if (block.isCollapsed()) code += ', "_collapsed": true'; if (!block.isEnabled()) code += ', "_disabled": true'; code += '}'; @@ -1009,7 +1010,7 @@ return code+',\n'; */; text_2_s - : '标题' EvalString? '图像' EvalString? '对话框效果' EvalString? '起点像素 px' PosString? 'py' PosString? '宽度' PosString? '对话框编号' Int BGNL? Newline EvalString_Multi BGNL? Newline textDrawingList* Newline + : '标题' EvalString? '图像' EvalString? '对话框效果' EvalString? '起点 px' PosString? 'py' PosString? '宽' PosString? '编号' Int '不等待操作' Bool BGNL? Newline EvalString_Multi BGNL? Newline textDrawingList* Newline /* text_2_s @@ -1038,10 +1039,11 @@ if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.t } EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']'); var code = '"'+title+EvalString_2+textDrawingList_0.replace(/\s/g, '')+EvalString_Multi_0+'"'; -if (block.isCollapsed() || !block.isEnabled() || pos || Int_0) { +if (block.isCollapsed() || !block.isEnabled() || pos || Int_0 || Bool_0) { code = '{"type": "text", "text": '+code; if (pos) code += ', "pos": ' + pos; if (Int_0) code += ', "code": ' + Int_0; + if (Bool_0) code += ', "async": true'; if (block.isCollapsed()) code += ', "_collapsed": true'; if (!block.isEnabled()) code += ', "_disabled": true'; code += '}'; diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 34937f6f..aa2801b5 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -292,12 +292,12 @@ ActionParser.prototype.parseAction = function() { } data.pos = data.pos || []; this.next = MotaActionFunctions.xmlText('text_2_s', [ - info[0], info[1], info[2], data.pos[0], data.pos[1], data.pos[2], data.code||0, info[3], buildTextDrawing(textDrawing), this.next + info[0], info[1], info[2], data.pos[0], data.pos[1], data.pos[2], data.code||0, data.async||false, info[3], buildTextDrawing(textDrawing), this.next ], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed, /*disabled*/ data._disabled); } else if (info[0] || info[1] || info[2] || data.pos || data.code) { data.pos = data.pos || []; this.next = MotaActionFunctions.xmlText('text_1_s',[ - info[0], info[1], info[2], data.pos[0], data.pos[1], data.pos[2], data.code||0, info[3], this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed, /*disabled*/ data._disabled); + info[0], info[1], info[2], data.pos[0], data.pos[1], data.pos[2], data.code||0, data.async||false, info[3], this.next], /* isShadow */false, /*comment*/ null, /*collapsed*/ data._collapsed, /*disabled*/ data._disabled); } else { this.next = MotaActionFunctions.xmlText('text_0_s', [info[3],this.next], diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 7c477ff9..37937512 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -244,7 +244,7 @@ editor_blockly = function () { } } if (one.type == 'previewUI' && this.checkAsync(one.action)) return true; - if (one.async && one.type != 'animate' && one.type != 'function') hasAsync = true; + if (one.async && one.type != 'animate' && one.type != 'function' && one.type != 'text') hasAsync = true; if (one.type == 'waitAsync') hasAsync = false; } return hasAsync; diff --git a/libs/events.js b/libs/events.js index 0cf4023d..7abf9227 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1359,12 +1359,18 @@ events.prototype._action_text = function (data, x, y, prefix) { if (core.getContextByName(ctx) && !data.showAll) { core.ui._animateUI('hide', ctx, function () { core.ui.drawTextBox(data.text, data); - core.ui._animateUI('show', ctx); + core.ui._animateUI('show', ctx, function () { + if (data.async) core.doAction(); + }); }); return; } core.ui.drawTextBox(data.text, data); - if (!data.showAll) core.ui._animateUI('show', ctx); + if (!data.showAll) { + core.ui._animateUI('show', ctx, function () { + if (data.async) core.doAction(); + }); + } } events.prototype._action_moveTextBox = function (data, x, y, prefix) { diff --git a/libs/ui.js b/libs/ui.js index f2886cf5..14439aa7 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1463,7 +1463,7 @@ ui.prototype.drawTextBox = function(content, config) { // Step 5: 绘制正文 var config = this.drawTextContent(config.ctx || 'ui', content, { left: hPos.content_left, top: content_top, maxWidth: hPos.validWidth, - lineHeight: vPos.lineHeight, time: (config.showAll || textAttribute.time<=0 || core.status.event.id!='action')?0:textAttribute.time + lineHeight: vPos.lineHeight, time: (config.showAll || config.async || textAttribute.time<=0 || core.status.event.id!='action')?0:textAttribute.time }); // Step 6: 绘制光标