From ba297813c31376f79038888346e3725e29e4878e Mon Sep 17 00:00:00 2001 From: voderl Date: Mon, 28 Oct 2019 21:08:01 +0800 Subject: [PATCH 1/2] update --- _docs/api.md | 1 + _docs/event.md | 2 ++ _server/MotaAction.g4 | 2 +- libs/ui.js | 6 +++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/_docs/api.md b/_docs/api.md index 6424dcf3..ac18e836 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1757,6 +1757,7 @@ config为绘制的配置项,目前可以包括如下几项: - fontSize:字体大小,如果不设置则使用剧情文本设置中的正文字体大小。 - lineHeight:绘制的行距值,如果不设置则使用fontSize*1.3(即1.3倍行距)。 - time:打字机效果。若不为0,则会逐个字进行绘制,并设置core.status.event.interval定时器。 + - interval:字符间的间距。值表示绘制每个字符之间间隔的距离,默认为0。 core.drawTextBox(content, showAll) diff --git a/_docs/event.md b/_docs/event.md index aaf97b4a..7d1a34a2 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -413,6 +413,8 @@ textfont为可选项,表示正文字体大小(px为单位)。默认值:` time为可选项,表示文字添加的速度。若此项设置为0将直接全部显示,若大于0则会设置为相邻字符依次显示的时间间隔。 默认值:`0` +interval为可选项,表示文字之间的间距。单位为像素值。默认值:`0` + ### tip:显示一段提示文字 `{"type": "tip"}`可以在左上角显示一段提示文字。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index c0a8ad3c..70b9830d 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -462,7 +462,7 @@ setText_s /* setText_s -tooltip : setText:设置剧情文本的属性,颜色为RGB三元组或RGBA四元组,打字间隔为剧情文字添加的时间间隔,为整数或不填 +tooltip : setText:设置剧情文本的属性,颜色为RGB三元组或RGBA四元组,打字间隔为剧情文字添加的时间间隔,为整数或不填,字符间距为字符之间的距离,为整数或不填。 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=settext%EF%BC%9A%E8%AE%BE%E7%BD%AE%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC%E7%9A%84%E5%B1%9E%E6%80%A7 default : [null,"",null,"",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',null,"","","",""] SetTextPosition_List_0 =SetTextPosition_List_0==='null'?'': ', "position": "'+SetTextPosition_List_0+'"'; diff --git a/libs/ui.js b/libs/ui.js index d18a9d1d..79487416 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -875,7 +875,7 @@ ui.prototype.drawTextContent = function (ctx, content, config) { config.fontSize = config.fontSize || textAttribute.textfont; config.lineHeight = config.lineHeight || (config.fontSize * 1.3); config.time = config.time || 0; - config.interval = textAttribute.interval || 0; + config.interval = config.interval == null ? (textAttribute.interval || 0) : config.interval; config.index = 0; config.currcolor = config.color; @@ -1263,7 +1263,7 @@ ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, al } ui.prototype._createTextCanvas = function (content, lineHeight) { - var width = this.PIXEL, height = 30 + this.getTextContentHeight(content, {lineHeight: lineHeight}); + var width = this.PIXEL, height = 30 + this.getTextContentHeight(content, {lineHeight: lineHeight,maxWidth:core.__PIXELS__}); var ctx = document.createElement('canvas').getContext('2d'); ctx.canvas.width = width; ctx.canvas.height = height; @@ -1280,7 +1280,7 @@ ui.prototype.drawScrollText = function (content, time, lineHeight, callback) { var offset = core.status.textAttribute.offset || 15; lineHeight *= core.status.textAttribute.textfont; var ctx = this._createTextCanvas(content, lineHeight); - var obj = { align: core.status.textAttribute.align, lineHeight: lineHeight }; + var obj = { align: core.status.textAttribute.align, lineHeight: lineHeight ,maxWidth: core.__PIXELS__}; if (obj.align == 'right') obj.left = this.PIXEL - offset; else if (obj.align != 'center') obj.left = offset; this.drawTextContent(ctx, content, obj); From 5d962ec91fafbbeb0e655c4ec8b89ba1bb268c19 Mon Sep 17 00:00:00 2001 From: voderl Date: Mon, 28 Oct 2019 21:14:19 +0800 Subject: [PATCH 2/2] delete some wrongs --- libs/ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ui.js b/libs/ui.js index 79487416..6242031e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1263,7 +1263,7 @@ ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, al } ui.prototype._createTextCanvas = function (content, lineHeight) { - var width = this.PIXEL, height = 30 + this.getTextContentHeight(content, {lineHeight: lineHeight,maxWidth:core.__PIXELS__}); + var width = this.PIXEL, height = 30 + this.getTextContentHeight(content, {lineHeight: lineHeight}); var ctx = document.createElement('canvas').getContext('2d'); ctx.canvas.width = width; ctx.canvas.height = height; @@ -1280,7 +1280,7 @@ ui.prototype.drawScrollText = function (content, time, lineHeight, callback) { var offset = core.status.textAttribute.offset || 15; lineHeight *= core.status.textAttribute.textfont; var ctx = this._createTextCanvas(content, lineHeight); - var obj = { align: core.status.textAttribute.align, lineHeight: lineHeight ,maxWidth: core.__PIXELS__}; + var obj = { align: core.status.textAttribute.align, lineHeight: lineHeight }; if (obj.align == 'right') obj.left = this.PIXEL - offset; else if (obj.align != 'center') obj.left = offset; this.drawTextContent(ctx, content, obj);