From adf6cdb3b18cee732e8ff205e2d76e672a218dc4 Mon Sep 17 00:00:00 2001 From: shrinktofit Date: Fri, 8 Sep 2023 19:17:26 +0800 Subject: [PATCH 1/3] Label component inspector localization --- cocos/2d/components/label.ts | 18 +----- cocos/2d/framework/ui-renderer.ts | 2 - editor/i18n/en/localization.js | 21 +------ editor/i18n/en/modules/ui.js | 96 +++++++++++++++++++++++++++++++ editor/i18n/zh/localization.js | 21 +------ editor/i18n/zh/modules/ui.js | 95 ++++++++++++++++++++++++++++++ 6 files changed, 194 insertions(+), 59 deletions(-) create mode 100644 editor/i18n/en/modules/ui.js create mode 100644 editor/i18n/zh/modules/ui.js diff --git a/cocos/2d/components/label.ts b/cocos/2d/components/label.ts index b22846c7875..dd4a3f27195 100644 --- a/cocos/2d/components/label.ts +++ b/cocos/2d/components/label.ts @@ -23,7 +23,7 @@ THE SOFTWARE. */ -import { ccclass, help, executionOrder, menu, tooltip, displayOrder, visible, multiline, type, serializable, editable } from 'cc.decorator'; +import { ccclass, help, executionOrder, menu, displayOrder, visible, multiline, type, serializable, editable } from 'cc.decorator'; import { BYTEDANCE, EDITOR, JSB } from 'internal:constants'; import { minigame } from 'pal/minigame'; import { BitmapFont, Font, SpriteFrame } from '../assets'; @@ -212,7 +212,6 @@ export class Label extends UIRenderer { * 标签显示的文本内容。 */ @displayOrder(4) - @tooltip('i18n:label.string') @multiline get string (): string { return this._string; @@ -241,7 +240,6 @@ export class Label extends UIRenderer { */ @type(HorizontalTextAlignment) @displayOrder(5) - @tooltip('i18n:label.horizontal_align') get horizontalAlign (): HorizontalTextAlignment { return this._horizontalAlign; } @@ -263,7 +261,6 @@ export class Label extends UIRenderer { */ @type(VerticalTextAlignment) @displayOrder(6) - @tooltip('i18n:label.vertical_align') get verticalAlign (): VerticalTextAlignment { return this._verticalAlign; } @@ -298,7 +295,6 @@ export class Label extends UIRenderer { * 文本字体大小。 */ @displayOrder(7) - @tooltip('i18n:label.font_size') get fontSize (): number { return this._fontSize; } @@ -319,7 +315,6 @@ export class Label extends UIRenderer { * 文本行高。 */ @displayOrder(8) - @tooltip('i18n:label.line_height') get lineHeight (): number { return this._lineHeight; } @@ -343,7 +338,6 @@ export class Label extends UIRenderer { return !this._isSystemFontUsed && this._font instanceof BitmapFont; }) @displayOrder(9) - @tooltip('i18n:label.spacing_x') get spacingX (): number { return this._spacingX; } @@ -365,7 +359,6 @@ export class Label extends UIRenderer { */ @type(Overflow) @displayOrder(10) - @tooltip('i18n:label.overflow') get overflow (): Overflow { return this._overflow; } @@ -386,7 +379,6 @@ export class Label extends UIRenderer { * 是否自动换行。 */ @displayOrder(11) - @tooltip('i18n:label.wrap') get enableWrapText (): boolean { return this._enableWrapText; } @@ -407,7 +399,6 @@ export class Label extends UIRenderer { * 是否使用系统字体。 */ @displayOrder(12) - @tooltip('i18n:label.system_font') get useSystemFont (): boolean { return this._isSystemFontUsed; } @@ -443,7 +434,6 @@ export class Label extends UIRenderer { */ @displayOrder(13) @visible(function (this: Label) { return this._isSystemFontUsed; }) - @tooltip('i18n:label.font_family') get fontFamily (): string { return this._fontFamily; } @@ -466,7 +456,6 @@ export class Label extends UIRenderer { @type(Font) @displayOrder(13) @visible(function (this: Label) { return !this._isSystemFontUsed; }) - @tooltip('i18n:label.font') get font (): Font | null { // return this._N$file; return this._font; @@ -503,7 +492,6 @@ export class Label extends UIRenderer { */ @type(CacheMode) @displayOrder(14) - @tooltip('i18n:label.cache_mode') get cacheMode (): CacheMode { return this._cacheMode; } @@ -531,7 +519,6 @@ export class Label extends UIRenderer { * 字体是否加粗。 */ @displayOrder(15) - @tooltip('i18n:label.font_bold') get isBold (): boolean { return this._isBold; } @@ -552,7 +539,6 @@ export class Label extends UIRenderer { * 字体是否倾斜。 */ @displayOrder(16) - @tooltip('i18n:label.font_italic') get isItalic (): boolean { return this._isItalic; } @@ -573,7 +559,6 @@ export class Label extends UIRenderer { * 字体是否加下划线。 */ @displayOrder(17) - @tooltip('i18n:label.font_underline') get isUnderline (): boolean { return this._isUnderline; } @@ -593,7 +578,6 @@ export class Label extends UIRenderer { @visible(function (this: Label) { return this._isUnderline; }) @editable @displayOrder(18) - @tooltip('i18n:label.underline_height') public get underlineHeight (): number { return this._underlineHeight; } diff --git a/cocos/2d/framework/ui-renderer.ts b/cocos/2d/framework/ui-renderer.ts index d79a81d315f..d6a0e9a957c 100644 --- a/cocos/2d/framework/ui-renderer.ts +++ b/cocos/2d/framework/ui-renderer.ts @@ -168,7 +168,6 @@ export class UIRenderer extends Renderer { */ @type(Material) @displayOrder(0) - @tooltip('i18n:UIRenderer.customMaterial') @displayName('CustomMaterial') @disallowAnimation get customMaterial (): Material | null { @@ -185,7 +184,6 @@ export class UIRenderer extends Renderer { * @zh 渲染颜色,一般情况下会和贴图颜色相乘。 */ @displayOrder(1) - @tooltip('i18n:UIRenderer.color') get color (): Readonly { return this._color; } diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index 236afc74403..610a0be8e76 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -384,30 +384,12 @@ module.exports = link(mixin({ space: 'Space where acceleration calculated', }, label: { - string: 'Text of the Label', - horizontal_align: 'Horizontal alignment', horizontal_align_left: 'Align Left', horizontal_align_center: 'Align Horizontal Center', horizontal_align_right: 'Align Right', - vertical_align: 'Vertical alignment', vertical_align_top: 'Align Top', vertical_align_center: 'Align Vertical Center', vertical_align_bottom: 'Align Bottom', - font_size: 'Font size, in points', - font_family: 'Font family name', - line_height: 'Line height, in points', - overflow: - 'Text layout modes:
1. CLAMP: Text nodes outside the bounding box will be truncated.
2. SHRINK: Automatically shrink text box according to the constraint node.
3. RESIZE: Automatically updates the Node based on heightof the text.', - wrap: 'Wrap text?', - font: 'What font to use', - system_font: 'Whether to use the system default font', - cache_mode: - 'Text cache modes:
1. NONE: No cache,draw once.
2. BITMAP: Text is added as a static image to the dynamic atlas for batch merging, but its content cannot be dynamically modified frequently.
3. CHAR: Split the text into characters and cache the character texture into a character atlas for reuse, which is suitable for text content with repeated character content and frequently updated.', - font_bold: 'Font bold', - font_italic: 'Font italic', - font_underline: 'Font underlined', - spacing_x: 'The spacing between text characters, only available in BMFont', - underline_height: 'The height of underline', }, labelOutline: { color: 'Outline color', @@ -493,8 +475,6 @@ module.exports = link(mixin({ UIRenderer: { srcBlendFactor: 'Source blend factor', dstBlendFactor: 'Destination blend factor', - customMaterial: 'User specified material', - color: 'Render color', }, rotationOvertimeModule: { separateAxes: 'Set rotation of X, Y and Z respectively (not supported now)', @@ -1337,6 +1317,7 @@ module.exports = link(mixin({ }, require('./modules/rendering'), +require('./modules/ui.js'), require('./animation'), )); diff --git a/editor/i18n/en/modules/ui.js b/editor/i18n/en/modules/ui.js new file mode 100644 index 00000000000..587a6f68341 --- /dev/null +++ b/editor/i18n/en/modules/ui.js @@ -0,0 +1,96 @@ +/* eslint-disable quote-props */ + +module.exports = { + classes: { + 'cc': { + 'UIRenderer': { + properties: { + customMaterial: { + displayName: 'Custom Material', + tooltip: 'Use custom material.', + }, + color: { + displayName: 'Color', + tooltip: 'Rendering color.', + }, + }, + }, + 'Label': { + properties: { + __extends__: 'classes.cc.UIRenderer.properties', + 'string': { + displayName: 'string', + tooltip: 'The label text.', + }, + 'horizontalAlign': { + displayName: 'Horizontal Alignment', + tooltip: 'Horizontal alignment mode.', + }, + 'verticalAlign': { + displayName: 'Vertical Alignment', + tooltip: 'Vertical alignment mode.', + }, + 'fontSize': { + displayName: 'Font Size', + tooltip: 'Font size, in points.', + }, + 'lineHeight': { + displayName: 'Line Height', + tooltip: 'Line height, in points.', + }, + 'spacingX': { + displayName: 'Horizontal Spacing', + tooltip: 'The spacing between text characters, only available if bitmap font was used.', + }, + 'overflow': { + displayName: 'Overflow Processing', + tooltip: 'Text layout modes:
' + + '1. CLAMP: Text nodes outside the bounding box will be truncated.
' + + '2. SHRINK: Automatically shrink text box according to the constraint node.
' + + '3. RESIZE: Automatically updates the Node based on height of the text.', + }, + 'enableWrapText': { + displayName: 'Auto Newline', + tooltip: 'Automatic newline.', + }, + 'useSystemFont': { + displayName: 'Use System Fonts', + tooltip: 'Whether to use system default fonts. The referenced font asset would be dereferenced once this option was checked.', + }, + 'fontFamily': { + displayName: 'Font Family', + tooltip: 'Font names.', + }, + 'font': { + displayName: 'Font', + tooltip: 'The font asset to use.', + }, + 'cacheMode': { + displayName: 'Cache Mode', + tooltip: 'Text cache modes:
' + + '1. NONE: No cache,draw once.
' + + '2. BITMAP: Text is added as a static image to the dynamic atlas for batch merging, but its content cannot be dynamically modified frequently.
' + + '3. CHAR: Split the text into characters and cache the character texture into a character atlas for reuse, ' + + 'which is suitable for text content with repeated character content and frequently updated.', + }, + 'isBold': { + displayName: 'Bold', + tooltip: 'Make words bold.', + }, + 'isItalic': { + displayName: 'Italic', + tooltip: 'Make words italic.', + }, + 'isUnderline': { + displayName: 'Underline', + tooltip: 'Underscore the words.', + }, + 'underlineHeight': { + displayName: 'Underline Height', + tooltip: 'The underline\'s height.', + }, + }, + }, + }, + }, +}; diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index 87c24c16973..85244cd7877 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -373,30 +373,12 @@ module.exports = link(mixin({ space: '加速度计算时采用的坐标系', }, label: { - string: 'Label 显示的文本内容字符串', - horizontal_align: '文字水平对齐模式', horizontal_align_left: '左对齐', horizontal_align_center: '水平居中对齐', horizontal_align_right: '右对齐', - vertical_align: '文字垂直对齐模式', vertical_align_top: '顶对齐', vertical_align_center: '垂直居中对齐', vertical_align_bottom: '底对齐', - font_size: '文字尺寸,以 point 为单位', - font_family: '文字字体名字', - line_height: '文字行高,以 point 为单位', - overflow: - '文字排版模式,包括以下三种:
1. CLAMP: 节点约束框之外的文字会被截断
2. SHRINK: 自动根据节点约束框缩小文字
3. RESIZE: 根据文本内容自动更新节点的 height 属性.', - wrap: '是否允许自动换行', - font: 'Label 使用的字体资源', - system_font: '是否使用系统默认字体,选中此项会将 file 属性置空', - cache_mode: - '文本缓存模式,包括以下三种:
1. NONE: 不做任何缓存,文本内容进行一次绘制
2. BITMAP: 将文本作为静态图像加入动态图集进行批次合并,但是不能频繁动态修改文本内容
3. CHAR: 将文本拆分为字符并且把字符纹理缓存到一张字符图集中进行复用,适用于字符内容重复并且频繁更新的文本内容', - font_bold: '字体加粗', - font_italic: '字体倾斜', - font_underline: '字体加下划线', - spacing_x: '文本字符之间的间距。仅在使用 BMFont 位图字体时生效', - underline_height: '下划线高度', }, labelOutline: { color: '描边的颜色', @@ -480,8 +462,6 @@ module.exports = link(mixin({ UIRenderer: { srcBlendFactor: '原始混合因子', dstBlendFactor: '目标混合因子', - customMaterial: '用户指定的材质', - color: '渲染颜色', }, rotationOvertimeModule: { separateAxes: '是否三个轴分开设定旋转(暂不支持)', @@ -1311,6 +1291,7 @@ module.exports = link(mixin({ }, require('./modules/rendering'), +require('./modules/ui.js'), require('./animation'), )); diff --git a/editor/i18n/zh/modules/ui.js b/editor/i18n/zh/modules/ui.js new file mode 100644 index 00000000000..d87b9b6103a --- /dev/null +++ b/editor/i18n/zh/modules/ui.js @@ -0,0 +1,95 @@ +/* eslint-disable quote-props */ + +module.exports = { + classes: { + 'cc': { + 'UIRenderer': { + properties: { + customMaterial: { + displayName: '自定义材质', + tooltip: '使用自定义材质。', + }, + color: { + displayName: '颜色', + tooltip: '渲染颜色。', + }, + }, + }, + 'Label': { + properties: { + __extends__: 'classes.cc.UIRenderer.properties', + 'string': { + displayName: '字符串', + tooltip: '显示的文本内容字符串。', + }, + 'horizontalAlign': { + displayName: '水平对齐', + tooltip: '文字水平对齐模式。', + }, + 'verticalAlign': { + displayName: '竖直对齐', + tooltip: '文字竖直对齐模式。', + }, + 'fontSize': { + displayName: '字体大小', + tooltip: '文字尺寸,以点为单位。', + }, + 'lineHeight': { + displayName: '行高', + tooltip: '文字行高,以点为单位。', + }, + 'spacingX': { + displayName: '水平间距', + tooltip: '文本字符之间的间距。仅在使用位图字体时生效', + }, + 'overflow': { + displayName: '溢出处理', + tooltip: '文字排版模式,包括以下三种:
' + + '1. CLAMP: 节点约束框之外的文字会被截断
' + + '2. SHRINK: 自动根据节点约束框缩小文字
' + + '3. RESIZE: 根据文本内容自动更新节点的 height 属性.', + }, + 'enableWrapText': { + displayName: '自动换行', + tooltip: '自动换行。', + }, + 'useSystemFont': { + displayName: '使用系统字体', + tooltip: '是否使用系统默认字体,选中此项会将引用的字体资产置空。', + }, + 'fontFamily': { + displayName: '字体集', + tooltip: '文字字体名字。', + }, + 'font': { + displayName: '字体', + tooltip: '使用的字体资源。', + }, + 'cacheMode': { + displayName: '缓存模式', + tooltip: '文本缓存模式,包括以下三种:
' + + '1. NONE: 不做任何缓存,文本内容进行一次绘制
' + + '2. BITMAP: 将文本作为静态图像加入动态图集进行批次合并,但是不能频繁动态修改文本内容
' + + '3. CHAR: 将文本拆分为字符并且把字符纹理缓存到一张字符图集中进行复用,适用于字符内容重复并且频繁更新的文本内容', + }, + 'isBold': { + displayName: '粗体', + tooltip: '使字体加粗。', + }, + 'isItalic': { + displayName: '斜体', + tooltip: '使字体倾斜。', + }, + 'isUnderline': { + displayName: '下划线', + tooltip: '为字体加下划线。', + }, + 'underlineHeight': { + displayName: '下划线高度', + tooltip: '下划线高度。', + }, + }, + }, + }, + }, +}; From 7ec127f75dfa6cb29654123de8c63fab2de81550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leslie=20Leigh=20=28=E6=9D=8E=E7=9A=84=E5=BA=8F=29?= Date: Thu, 14 Sep 2023 10:12:45 +0800 Subject: [PATCH 2/3] Update editor/i18n/zh/modules/ui.js --- editor/i18n/zh/modules/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/i18n/zh/modules/ui.js b/editor/i18n/zh/modules/ui.js index d87b9b6103a..07a293b7435 100644 --- a/editor/i18n/zh/modules/ui.js +++ b/editor/i18n/zh/modules/ui.js @@ -58,7 +58,7 @@ module.exports = { tooltip: '是否使用系统默认字体,选中此项会将引用的字体资产置空。', }, 'fontFamily': { - displayName: '字体集', + displayName: '字体族', tooltip: '文字字体名字。', }, 'font': { From 999d36ff18a24bb4c17eb0e4464f0d15e28b61ea Mon Sep 17 00:00:00 2001 From: shrinktofit Date: Wed, 11 Oct 2023 13:56:45 +0800 Subject: [PATCH 3/3] Update --- cocos/2d/components/label.ts | 7 ------- editor/i18n/en/modules/ui.js | 30 +++++++++++++++++++++++++++++- editor/i18n/zh/modules/ui.js | 30 +++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/cocos/2d/components/label.ts b/cocos/2d/components/label.ts index ba0f2999721..6bfde6b7f71 100644 --- a/cocos/2d/components/label.ts +++ b/cocos/2d/components/label.ts @@ -597,7 +597,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return !(this._font instanceof BitmapFont); }) @displayOrder(19) - @tooltip('i18n:label.outline_enable') get enableOutline (): boolean { return this._enableOutline; } @@ -617,7 +616,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); }) @displayOrder(20) - @tooltip('i18n:label.outline_color') get outlineColor (): Color { return this._outlineColor; } @@ -637,7 +635,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); }) @displayOrder(21) - @tooltip('i18n:label.outline_width') get outlineWidth (): number { return this._outlineWidth; } @@ -654,7 +651,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(22) - @tooltip('i18n:label.shadow_enable') get enableShadow (): boolean { return this._enableShadow; } @@ -674,7 +670,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(23) - @tooltip('i18n:label.shadow_color') get shadowColor (): Color { return this._shadowColor; } @@ -694,7 +689,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(24) - @tooltip('i18n:label.shadow_offset') get shadowOffset (): Vec2 { return this._shadowOffset; } @@ -714,7 +708,6 @@ export class Label extends UIRenderer { @editable @visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); }) @displayOrder(25) - @tooltip('i18n:label.shadow_blur') get shadowBlur (): number { return this._shadowBlur; } diff --git a/editor/i18n/en/modules/ui.js b/editor/i18n/en/modules/ui.js index 587a6f68341..51cfde9954b 100644 --- a/editor/i18n/en/modules/ui.js +++ b/editor/i18n/en/modules/ui.js @@ -54,7 +54,7 @@ module.exports = { tooltip: 'Automatic newline.', }, 'useSystemFont': { - displayName: 'Use System Fonts', + displayName: 'System Fonts', tooltip: 'Whether to use system default fonts. The referenced font asset would be dereferenced once this option was checked.', }, 'fontFamily': { @@ -89,6 +89,34 @@ module.exports = { displayName: 'Underline Height', tooltip: 'The underline\'s height.', }, + 'enableOutline': { + displayName: 'Enable Outline', + tooltip: 'Whether outline is enabled.', + }, + 'outlineColor': { + displayName: 'Outline Color', + tooltip: 'The color of outline.', + }, + 'outlineWidth': { + displayName: 'Outline Width', + tooltip: 'The width of outline', + }, + 'enableShadow': { + displayName: 'Enable Shadow', + tooltip: 'Whether shadow is enabled.', + }, + 'shadowColor': { + displayName: 'Enable Outline', + tooltip: 'The color of shadow.', + }, + 'shadowOffset': { + displayName: 'Shadow Offset', + tooltip: 'Offset between font and shadow.', + }, + 'shadowBlur': { + displayName: 'Shadow Blur', + tooltip: 'A non-negative float specifying the level of shadow blur.', + }, }, }, }, diff --git a/editor/i18n/zh/modules/ui.js b/editor/i18n/zh/modules/ui.js index 07a293b7435..fbf429e67fc 100644 --- a/editor/i18n/zh/modules/ui.js +++ b/editor/i18n/zh/modules/ui.js @@ -54,7 +54,7 @@ module.exports = { tooltip: '自动换行。', }, 'useSystemFont': { - displayName: '使用系统字体', + displayName: '系统字体', tooltip: '是否使用系统默认字体,选中此项会将引用的字体资产置空。', }, 'fontFamily': { @@ -88,6 +88,34 @@ module.exports = { displayName: '下划线高度', tooltip: '下划线高度。', }, + 'enableOutline': { + displayName: '启用描边', + tooltip: '是否启用描边。', + }, + 'outlineColor': { + displayName: '描边颜色', + tooltip: '描边颜色。', + }, + 'outlineWidth': { + displayName: '描边宽度', + tooltip: '描边宽度。', + }, + 'enableShadow': { + displayName: '启用阴影', + tooltip: '是否启用阴影。', + }, + 'shadowColor': { + displayName: '阴影颜色', + tooltip: '阴影颜色。', + }, + 'shadowOffset': { + displayName: '阴影偏移', + tooltip: '阴影偏移量。', + }, + 'shadowBlur': { + displayName: '阴影模糊', + tooltip: '阴影模糊程度。', + }, }, }, },