Bold in SetText
This commit is contained in:
parent
62f09a6ec0
commit
73188765f5
@ -267,8 +267,8 @@
|
|||||||
|
|
||||||
``` js
|
``` js
|
||||||
"x,y": [ // 实际执行的事件列表
|
"x,y": [ // 实际执行的事件列表
|
||||||
{"type": "setText", "position": "up", "title": [255,0,0], "text": [255,255,0], "background": [0,0,255,0.3]},
|
{"type": "setText", "position": "up", "title": [255,0,0], "text": [255,255,0], "background": [0,0,255,0.3], "bold": true},
|
||||||
"这段话将显示在上方,标题为红色,正文为黄色,背景为透明度0.3的蓝色"
|
"这段话将显示在上方,标题为红色,正文为黄色粗体,背景为透明度0.3的蓝色"
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -280,6 +280,8 @@ text为可选项,如果设置则为一个RGB三元组或RGBA四元组,表示
|
|||||||
|
|
||||||
background为可选项,如果设置则为一个RGB三元组或RGBA四元组,表示背景色。
|
background为可选项,如果设置则为一个RGB三元组或RGBA四元组,表示背景色。
|
||||||
|
|
||||||
|
bold为可选项,如果设置则为true或false,表示正文是否使用粗体。
|
||||||
|
|
||||||
### tip:显示一段提示文字
|
### tip:显示一段提示文字
|
||||||
|
|
||||||
`{"type": "tip"}`可以在左上角显示一段提示文字。
|
`{"type": "tip"}`可以在左上角显示一段提示文字。
|
||||||
|
|||||||
@ -130,6 +130,7 @@ function core() {
|
|||||||
"title": [255,215,0,1],
|
"title": [255,215,0,1],
|
||||||
"background": [0,0,0,0.85],
|
"background": [0,0,0,0.85],
|
||||||
"text": [255,255,255,1],
|
"text": [255,255,255,1],
|
||||||
|
"bold": false,
|
||||||
},
|
},
|
||||||
'curtainColor': null,
|
'curtainColor': null,
|
||||||
'usingCenterFly':false,
|
'usingCenterFly':false,
|
||||||
|
|||||||
@ -313,6 +313,9 @@ events.prototype.doAction = function() {
|
|||||||
core.status.textAttribute[t]=data[t];
|
core.status.textAttribute[t]=data[t];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (core.isset(data.bold)) {
|
||||||
|
core.status.textAttribute.bold=data.bold;
|
||||||
|
}
|
||||||
core.events.doAction();
|
core.events.doAction();
|
||||||
break;
|
break;
|
||||||
case "tip":
|
case "tip":
|
||||||
|
|||||||
@ -120,7 +120,9 @@ ui.prototype.drawTextBox = function(content) {
|
|||||||
if (id=='hero' || core.isset(icon)) content_left=left+63;
|
if (id=='hero' || core.isset(icon)) content_left=left+63;
|
||||||
|
|
||||||
var validWidth = right-(content_left-left)-13;
|
var validWidth = right-(content_left-left)-13;
|
||||||
var contents = core.splitLines("ui", content, validWidth, '16px Verdana');
|
var font = '16px 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)?32-10:0);
|
var height = 20 + 21*(contents.length+1) + (id=='hero'?core.material.icons.hero.height-10:core.isset(name)?32-10:0);
|
||||||
|
|
||||||
@ -229,7 +231,7 @@ ui.prototype.drawTextBox = function(content) {
|
|||||||
core.setFillStyle('ui', core.arrayToRGB(textAttribute.text));
|
core.setFillStyle('ui', core.arrayToRGB(textAttribute.text));
|
||||||
|
|
||||||
for (var i=0;i<contents.length;i++) {
|
for (var i=0;i<contents.length;i++) {
|
||||||
core.fillText('ui', contents[i], content_left, content_top, null, '16px Verdana');
|
core.fillText('ui', contents[i], content_left, content_top, null, font);
|
||||||
content_top+=21;
|
content_top+=21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user