From 42f6841e68f806e506f6df8f098510890e776161 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 18 Aug 2019 15:25:24 +0800 Subject: [PATCH 1/2] Fix bugs --- libs/events.js | 2 +- libs/ui.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/events.js b/libs/events.js index 33315916..4d786341 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1138,7 +1138,7 @@ events.prototype._action_showTextImage = function (data, x, y, prefix) { var loc = this.__action_getLoc(data.loc, 0, 0, prefix); if (core.isReplaying()) data.time = 0; this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage, - data.code, core.ui.textImage(data.text), loc[0], loc[1], 100, 100, data.opacity, data.time); + data.code, core.ui.textImage(data.text), null, loc, data.opacity, data.time); } events.prototype._action_hideImage = function (data, x, y, prefix) { diff --git a/libs/ui.js b/libs/ui.js index 46738a4f..cee68bb8 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -353,7 +353,7 @@ ui.prototype.calWidth = function (name, text, font) { ////// 字符串自动换行的分割 ////// ui.prototype.splitLines = function (name, text, maxWidth, font) { var ctx = this.getContextByName(name); - if (!ctx) return; + if (!ctx) return [text]; if (font) core.setFont(name, font); var contents = []; From a97f9b6f6d8a86726133b861865838e8c8a206dc Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Mon, 19 Aug 2019 10:23:11 +0800 Subject: [PATCH 2/2] resizeCanvas styleOnly --- API列表.txt | 7 +++++-- _docs/api.md | 7 +++++-- libs/ui.js | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/API列表.txt b/API列表.txt index 52e1a2b0..b2013082 100644 --- a/API列表.txt +++ b/API列表.txt @@ -1871,8 +1871,11 @@ core.ui.relocateCanvas(name, x, y) 重新定位一个自定义画布。x和y为画布的左上角坐标。 -core.ui.resizeCanvas(name, width, height) -重新设置一个自定义画布的大小。width和height为新设置的宽高。此操作会清空画布。 +core.ui.resizeCanvas(name, width, height, styleOnly) +重新设置一个自定义画布的大小。width和height为新设置的宽高。 +styleOnly控制是否只修改画布的显示大小(而不修改画布的内部大小)。 +如果styleOnly为true,则只修改其显示大小(即canvas.style.width); +否则,则会同时修改画布的显示大小和内部大小并清空画布内容。 core.ui.deleteCanvas(name) diff --git a/_docs/api.md b/_docs/api.md index 980c3b3a..6424dcf3 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1851,8 +1851,11 @@ core.ui.relocateCanvas(name, x, y) 重新定位一个自定义画布。x和y为画布的左上角坐标。 -core.ui.resizeCanvas(name, width, height) -重新设置一个自定义画布的大小。width和height为新设置的宽高。此操作会清空画布。 +core.ui.resizeCanvas(name, width, height, styleOnly) +重新设置一个自定义画布的大小。width和height为新设置的宽高。 +styleOnly控制是否只修改画布的显示大小(而不修改画布的内部大小)。 +如果styleOnly为true,则只修改其显示大小(即canvas.style.width); +否则,则会同时修改画布的显示大小和内部大小并清空画布内容。 core.ui.deleteCanvas(name) diff --git a/libs/ui.js b/libs/ui.js index cee68bb8..ae81e542 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2919,15 +2919,15 @@ ui.prototype.relocateCanvas = function (name, x, y) { } ////// canvas重置 ////// -ui.prototype.resizeCanvas = function (name, width, height) { +ui.prototype.resizeCanvas = function (name, width, height, styleOnly) { var ctx = core.dymCanvas[name]; if (!core.isset(ctx)) return null; if (core.isset(width)) { - ctx.canvas.width = width; + if (!styleOnly) ctx.canvas.width = width; ctx.canvas.style.width = width * core.domStyle.scale + 'px'; } if (core.isset(height)) { - ctx.canvas.height = height; + if (!styleOnly) ctx.canvas.height = height; ctx.canvas.style.height = height * core.domStyle.scale + 'px'; } return ctx;