fix drawScrollText

This commit is contained in:
oc 2019-04-20 00:54:20 +08:00
parent 91d7034b78
commit aa63329512
3 changed files with 29 additions and 15 deletions

View File

@ -71,7 +71,7 @@ actions.prototype._init = function () {
* 返回如果func返回true则不会再继续执行其他的交互函数否则会继续执行其他的交互函数
*/
actions.prototype.registerAction = function (action, name, func, priority) {
if (!name || !func || !(func instanceof Function))
if (!name || !func)
return;
priority = priority || 0;
if (!this.actions[action]) {
@ -99,8 +99,14 @@ actions.prototype.doRegisteredAction = function (action) {
var actions = this.actions[action];
if (!actions) return false;
for (var i = 0; i < actions.length; ++i) {
if (core.doFunc.apply(core, [actions[i].func, this].concat(Array.prototype.slice.call(arguments, 1))))
return true;
try {
if (core.doFunc.apply(core, [actions[i].func, this].concat(Array.prototype.slice.call(arguments, 1))))
return true;
}
catch (e) {
main.log(e);
main.log("ERROR in actions["+actions[i].name+"]。");
}
}
return false;
}

View File

@ -928,7 +928,7 @@ events.prototype._action_autoText = function (data, x, y, prefix) {
events.prototype._action_scrollText = function (data, x, y, prefix) {
if (this.__action_checkReplaying()) return;
this.__action_doAsyncFunc(data.async, core.ui.drawScrollText, data.text, data.lineHeight || 1.4, data.time || 5000);
this.__action_doAsyncFunc(data.async, core.drawScrollText, data.text, data.time || 5000, data.lineHeight || 1.4);
}
events.prototype._action_comment = function (data, x, y, prefix) {
@ -1071,20 +1071,20 @@ events.prototype._action_changePos = function (data, x, y, prefix) {
events.prototype._action_showImage = function (data, x, y, prefix) {
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, this.showImage,
this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage,
data.code, data.image, data.sloc, data.loc, data.opacity, data.time);
}
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, this.showImage,
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);
}
events.prototype._action_hideImage = function (data, x, y, prefix) {
if (core.isReplaying()) data.time = 0;
this.__action_doAsyncFunc(data.async || data.time == 0, this.hideImage, data.code, data.time);
this.__action_doAsyncFunc(data.async || data.time == 0, core.hideImage, data.code, data.time);
}
events.prototype._action_showGif = function (data, x, y, prefix) {
@ -1095,7 +1095,7 @@ events.prototype._action_showGif = function (data, x, y, prefix) {
events.prototype._action_moveImage = function (data, x, y, prefix) {
if (this.__action_checkReplaying()) return;
this.__action_doAsyncFunc(data.async, this.moveImage, data.code, data.to, data.opacity, data.time);
this.__action_doAsyncFunc(data.async, core.moveImage, data.code, data.to, data.opacity, data.time);
}
events.prototype._action_setFg = function (data, x, y, prefix) {
@ -1254,7 +1254,7 @@ events.prototype._action_stopSound = function (data, x, y, prefix) {
events.prototype._action_setVolume = function (data, x, y, prefix) {
data.value = core.clamp(parseInt(data.value) / 100, 0, 1);
core.setFlag("__volume__", data.value);
this.__action_doAsyncFunc(data.async, this.setVolume, data.value, data.time || 0);
this.__action_doAsyncFunc(data.async, core.setVolume, data.value, data.time || 0);
}
events.prototype._action_setValue = function (data, x, y, prefix) {
@ -1491,7 +1491,7 @@ events.prototype._action_updateEnemys = function (data, x, y, prefix) {
}
events.prototype._action_vibrate = function (data, x, y, prefix) {
this.__action_doAsyncFunc(data.async, this.vibrate, data.time);
this.__action_doAsyncFunc(data.async, core.vibrate, data.time);
}
events.prototype._action_sleep = function (data, x, y, prefix) {

View File

@ -509,6 +509,14 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
var xoffset = posInfo.xoffset || 0, yoffset = posInfo.yoffset || 0;
var background = core.status.textAttribute.background;
if (this._drawBackground_drawWindowSkin(background, left, top, right, bottom, posInfo.position, px, py))
return true;
if (typeof background == 'string') background = core.initStatus.textAttribute.background;
this._drawBackground_drawColor(background, left, top, right, bottom, posInfo.position, px, py, xoffset, yoffset);
return false;
}
ui.prototype._drawBackground_drawWindowSkin = function (background, left, top, right, bottom, position, px, py) {
if (typeof background == 'string' && core.material.images.images[background]) {
var image = core.material.images.images[background];
if (image.width==192 && image.height==128) {
@ -517,21 +525,22 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
core.setAlpha('ui', 1);
return true;
}
background = core.initStatus.textAttribute.background;
}
return false;
}
ui.prototype._drawBackground_drawColor = function (background, left, top, right, bottom, position, px, py, xoffset, yoffset) {
var alpha = background[3];
core.setAlpha('ui', alpha);
core.setStrokeStyle('ui', core.status.globalAttribute.borderColor);
core.setFillStyle('ui', core.arrayToRGB(background));
core.setLineWidth('ui', 2);
// 绘制
var ctx = core.canvas.ui;
ctx.beginPath();
ctx.moveTo(left, top);
// 上边缘三角
if (posInfo.position == 'down' && px != null && py != null) {
if (position == 'down' && px != null && py != null) {
ctx.lineTo(px + xoffset, top);
ctx.lineTo(px + 16, top - yoffset);
ctx.lineTo(px + 32 - xoffset, top);
@ -539,7 +548,7 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
ctx.lineTo(right, top);
ctx.lineTo(right, bottom);
// 下边缘三角
if (posInfo.position == 'up' && px != null && py != null) {
if (position == 'up' && px != null && py != null) {
ctx.lineTo(px + 32 - xoffset, bottom);
ctx.lineTo(px + 16, bottom + yoffset);
ctx.lineTo(px + xoffset, bottom);
@ -549,7 +558,6 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) {
ctx.fill();
ctx.stroke();
core.setAlpha('ui', 1);
return false;
}
////// 计算有效文本框的宽度