text font

This commit is contained in:
oc 2018-10-13 20:02:36 +08:00
parent 0dbac3f467
commit ed5966b746
5 changed files with 29 additions and 18 deletions

View File

@ -305,13 +305,13 @@ return code;
*/;
setText_s
: '设置剧情文本的属性' '位置' SetTextPosition_List BGNL? '标题颜色' EvalString? '正文颜色' EvalString? '背景色' EvalString? BGNL? '粗体' B_1_List '打字间隔' EvalString? Newline
: '设置剧情文本的属性' '位置' SetTextPosition_List BGNL? '标题颜色' EvalString? '正文颜色' EvalString? '背景色' EvalString? '粗体' B_1_List BGNL? '标题字体大小' EvalString? '正文字体大小' EvalString? '打字间隔' EvalString? Newline
/* setText_s
tooltip : setText设置剧情文本的属性,颜色为RGB三元组或RGBA四元组,打字间隔为剧情文字添加的时间间隔,为整数或不填
helpUrl : https://ckcz123.github.io/mota-js/#/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,'']
default : [null,"","","",null,"","",'']
SetTextPosition_List_0 =SetTextPosition_List_0==='null'?'': ', "position": "'+SetTextPosition_List_0+'"';
var colorRe = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/;
if (EvalString_0) {
@ -327,11 +327,19 @@ if (EvalString_2) {
EvalString_2 = ', "background": ['+EvalString_2+']';
}
if (EvalString_3) {
if (!/^\d+$/.test(EvalString_3))throw new Error('打字时间间隔必须是整数或不填');
EvalString_3 = ', "time": '+EvalString_3;
if (!/^\d+$/.test(EvalString_3))throw new Error('字体大小必须是整数或不填');
EvalString_3 = ', "titlefont": '+EvalString_3;
}
if (EvalString_4) {
if (!/^\d+$/.test(EvalString_4))throw new Error('字体大小必须是整数或不填');
EvalString_4 = ', "textfont": '+EvalString_4;
}
if (EvalString_5) {
if (!/^\d+$/.test(EvalString_5))throw new Error('打字时间间隔必须是整数或不填');
EvalString_5 = ', "time": '+EvalString_5;
}
B_1_List_0 = ', "bold": '+B_1_List_0;
var code = '{"type": "setText"'+SetTextPosition_List_0+EvalString_0+EvalString_1+EvalString_2+B_1_List_0+EvalString_3+'},\n';
var code = '{"type": "setText"'+SetTextPosition_List_0+EvalString_0+EvalString_1+EvalString_2+EvalString_3+EvalString_4+B_1_List_0+EvalString_5+'},\n';
return code;
*/;
@ -1675,7 +1683,7 @@ ActionParser.prototype.parseAction = function() {
data.text=setTextfunc(data.text);
data.background=setTextfunc(data.background);
this.next = MotaActionBlocks['setText_s'].xmlText([
data.position,data.title,data.text,data.background,data.bold,data.time,this.next]);
data.position,data.title,data.text,data.background,data.bold,data.titlefont,data.textfont,data.time,this.next]);
break;
case "tip":
this.next = MotaActionBlocks['tip_s'].xmlText([

View File

@ -148,6 +148,8 @@ function core() {
"title": [255,215,0,1],
"background": [0,0,0,0.85],
"text": [255,255,255,1],
"titlefont": 22,
"textfont": 16,
"bold": false,
"time": 0,
},

View File

@ -345,18 +345,15 @@ events.prototype.doAction = function() {
if (data.position=='up'||data.position=='down'||data.position=='center') {
core.status.textAttribute.position=data.position;
}
["bold", "titlefont", "textfont", "time"].forEach(function (t) {
if (core.isset(data[t])) core.status.textAttribute[t]=data[t];
});
["background", "title", "text"].forEach(function (t) {
if (core.isset(data[t]) && (data[t] instanceof Array) && data[t].length>=3) {
if (data[t].length==3) data[t].push(1);
core.status.textAttribute[t]=data[t];
}
})
if (core.isset(data.bold)) {
core.status.textAttribute.bold=data.bold;
}
if (core.isset(data.time)) {
core.status.textAttribute.time=data.time;
}
});
core.setFlag('textAttribute', core.status.textAttribute);
core.events.doAction();
break;

View File

@ -371,6 +371,9 @@ ui.prototype.drawTextBox = function(content, showAll) {
var textAttribute = core.status.textAttribute || core.initStatus.textAttribute;
var titlefont = textAttribute.titlefont || 22;
var textfont = textAttribute.textfont || 16;
var position = textAttribute.position, px=null, py=null, ydelta=iconHeight-32;
if (content.indexOf("\b[")==0 || content.indexOf("\\b[")==0) {
var index = content.indexOf("]");
@ -416,11 +419,11 @@ ui.prototype.drawTextBox = function(content, showAll) {
if (id=='hero' || core.isset(icon)) content_left=left+63;
var validWidth = right-(content_left-left)-13;
var font = '16px Verdana';
var font = textfont + 'px Verdana';
if (textAttribute.bold) font = "bold "+font;
var contents = core.splitLines("ui", content, validWidth, font);
var height = 20 + 21*(contents.length+1) + (id=='hero'?core.material.icons.hero.height-10:core.isset(name)?iconHeight-10:0);
var height = 20 + (textfont+5)*(contents.length+1) + (id=='hero'?core.material.icons.hero.height-10:core.isset(name)?iconHeight-10:0);
var xoffset = 6, yoffset = 22;
@ -506,14 +509,14 @@ ui.prototype.drawTextBox = function(content, showAll) {
if (id == 'hero') {
var heroHeight=core.material.icons.hero.height;
core.strokeRect('ui', left + 15 - 1, top + 40 - 1, 34, heroHeight+2, borderColor, 2);
core.fillText('ui', name, content_left, top + 30, null, 'bold 22px Verdana');
core.fillText('ui', name, content_left, top + 30, null, 'bold '+titlefont+'px Verdana');
core.clearMap('ui', left + 15, top + 40, 32, heroHeight);
core.fillRect('ui', left + 15, top + 40, 32, heroHeight, background);
var heroIcon = core.material.icons.hero['down'];
core.canvas.ui.drawImage(core.material.images.hero, heroIcon.stop * 32, heroIcon.loc * heroHeight, 32, heroHeight, left+15, top+40, 32, heroHeight);
}
else {
core.fillText('ui', name, content_left, top + 30, null, 'bold 22px Verdana');
core.fillText('ui', name, content_left, top + 30, null, 'bold '+titlefont+'px Verdana');
if (core.isset(icon)) {
core.strokeRect('ui', left + 15 - 1, top + 40 - 1, 34, iconHeight + 2, borderColor, 2);
@ -543,7 +546,7 @@ ui.prototype.drawTextBox = function(content, showAll) {
var contents = core.splitLines("ui", content, validWidth, font);
for (var i=0;i<contents.length;i++) {
core.fillText('ui', contents[i], content_left, content_top + 21*i, null, font);
core.fillText('ui', contents[i], content_left, content_top + (textfont+5)*i, null, font);
}
}

View File

@ -8,6 +8,7 @@
Autotile注册优化
状态栏可以显示角色名字
双击道具栏图标直接进入装备栏
可以设置剧情文本的字体大小
录像播放可以最高24倍速
1-6键快速设置录像播放速度滚轮加减速
修复大地图的夹击Bug