这篇条目有关 Source引擎。如需详情,点击这里。

game_text

From Valve Developer Community
< Zh
Revision as of 07:19, 12 January 2025 by Yakumo koishi (talk | contribs) (Created page with "{{LanguageBar}} Category:GUI Entities {{CD|CGameText|file1=maprules.cpp}} {{tabs|game_text|goldsrc=1|source=2|main=source}} left|link= {{this is a|point entity|name=game_text|except-multi={{L4d2|4}}}}{{ref|1}} 此实体用于在玩家屏幕上显示文本,并且不像{{ent|env_message}}使用<code>titles.txt</code>文件内预置的文本{{confirm}},此实体的文本内容可以直接在Hammer中定义。在多人游戏中,此实体...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
English (en)中文 (zh)Translate (Translate)
C++ 类层级
CGameText
CRulePointEntity
CRuleEntity
CBaseEntity
C++ maprules.cpp
Game text.png

game_text是一个点实体(en),可在所有的 起源 起源 游戏,除了 求生之路2 求生之路2中使用。[1] 此实体用于在玩家屏幕上显示文本,并且不像env_message使用titles.txt文件内预置的文本[证实],此实体的文本内容可以直接在Hammer中定义。在多人游戏中,此实体通常只会向触发“Display”输出的触发者显示文本。通过勾选“All Players” Flag可以给所有玩家显示文本


Note.png注意:如果你要创建独立模组的话,建议使用env_message实体,该实体使用titles.txt脚本内预置的键值作为文本参数,这样无需重新编译地图即可更改文本。不像game_text实体,其还可以使用双引号与换横符
Tip.png提示:虽然实体注释另有说明,但是game_text在大部分起源游戏都支持使用多语言文本(例如#HL2_Chapter4_Title)
Warning.png警告:在实体键值或IO中使用双引号(")会导致VMF损坏,所以不能将其用于Text Message键值(甚至连反斜杠("\")也不可以)。不过你可以使用两个单引号('')或者中文引号(例如)代替

注意事项

Game_text作为HUD元素的一部分渲染的,更准确的说,是🖿/scripts/HudLayout.txt里的HudMessage元素。

由于历史遗留问题,该实体最初是为低分辨率显示器创建的,所以默认情况下被限制为基于640x480分辨率进行缩放

这会导致分辨率高于1920x1080时出现缩放问题,文本会变得更大,并且一部分文本会被隐藏

该问题还会导致仅适用屏幕的部分区域进行文本绘制,并且长行文本或屏幕边缘附近的文本在宽屏上会被裁剪。这回影响其他适用HudMessage元素渲染的文本,比如经典的“A. I. Disabled”提示

Note.png修复:前往🖿/scripts/HudLayout.txt并找到"HudMessage"部分,修改"wide""tall"的值(默认分别为640和480)为“f0”(显示器的完整尺寸)。这将增加文本出现的不可见VGUI屏幕的最大尺寸,使其扩展到 1920x1080 分辨率以上.[仅在2K、4K和带鱼屏上进行测试,尚不确认是否适用于所有分辨率]

选项

All Players : [1]
如未勾选,则仅向!activator显示文本

键值

Name (目标名称) <target_source>[ Edit ]
这个名称是其他实体通过 输入/输出(en) 或其他 关键值(en)(如 parentnametarget) 来引用该实体时使用的标识符。
该名称也会显示在 Hammer 编辑器的 2D 视图和 实体报告(en) 中。
参见:  所有实体均可使用的 通用键值、输入与输出(en)

Message Text (message) <字符串(en)>
Message to display onscreen. \n signifies a new line in the text.
Icon-Bug.png错误:Hammer will automatically change backslashes to forward slashes, making \n impossible to enter.
PlacementTip.png解决方案:
  • Edit the VMF with a text editor, although this will need to be reapplied after each save
  • Edit the BSP entity lump with a hex editor, although this will need to be reapplied after each compile
  • Use AddOutput to set the message, as outputs are not affected
Tip.png提示:Hammer++ Hammer++ does not do this.
  [todo tested in ?]
X (0 - 1.0 = left to right) (-1 centers) (x) <字符串(en)>
Horizontal position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the far left of the screen and 1 is the far right. -1 centers the text.
Y (0 - 1.0 = top to bottom) (-1 centers) (y) <字符串(en)>
Vertical position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the top of the screen and 1 is the bottom. -1 centers the text.
Text Effect (effect) <choices>
Text scan effect
  • 0: Fade In/Out. The whole text is faded in, and then faded out.
  • 1: Credits
    待完善: Unknown—seems to act like Fade In/Out. Provide description.
  • 2: Scan Out. The text is scanned in letter by letter, and the whole text is then faded out.
Color1 (color) <color255(en)>
The primary color used by all the text effects.
Note.png注意:The color values seem to be added to the background, so either a bright white background or black text will cause the message to be invisible.
Note.png注意:This keyvalue will default to black for entities not created in Hammer.
Color2 (color2) <color255(en)>
The scanning color for the letter being scanned if the Text Effect keyvalue is set to Scan Out—usually a different shade of Color1.
Fade in Time (or character scan time) (fadein) <字符串(en)>
The time it should take for the text to fully fade in.
Fade Out Time (fadeout) <字符串(en)>
The time it should take for the text to fade out, after the hold time has expired.
Hold Time (holdtime) <字符串(en)>
The time the text should stay onscreen, after fading in, before it begins to fade out.
Note.png注意:This value defaults to zero for entities not created in Hammer.
Scan time (scan effect only) (fxtime) <字符串(en)>
If the 'Text Effect' is set to Scan Out, this is the time it should take to scan out all the letters in the text.
Text Channel (channel) <choices>
You can have up to six individual game_text messages onscreen at once, stored in channels. Select which channel this text should be placed in, which will overwrite any active message already in that channel.
  • 0: Channel 0 (may be used by some HUD elements) 不存在于FGD!
  • 1: Channel 1
  • 2: Channel 2 (传送门2 Small text size)
  • 3: Channel 3 (传送门2 Large text size)
  • 4: Channel 4
  • 5: Channel 5 (may be used by some HUD elements) 不存在于FGD!
Warning.png警告:Some HUDs may use Channel 0 and/or Channel 5.
Master (master) <字符串(en)>
Legacy support: The name of a master entity. If the master hasn't been activated, this entity will not activate.

Inputs

Display
Display the message text.
Note.png注意:If the All Players flag is not set, the player must be the !activator of this input in order for the text to be shown.
SetText <字符串(en)> (存在于自 异形丛生 以来)
Set the text to display.
Tip.png提示:AddOutput message can be used to change text at runtime in older games which do not support SetText, although the Display input must be fired again.
SetPosX <浮点型(en)> (存在于自 传送门2 以来)
Set the X position of the text. (0 - 1.0 = left to right) (-1 centers)
SetPosY <浮点型(en)> (存在于自 传送门2 以来)
Set the Y position of the text. (0 - 1.0 = top to bottom) (-1 centers)
SetTextColor <color255(en)> (存在于自 传送门2 以来)
Set color of the front text.
SetTextColor2 <color255(en)> (存在于自 传送门2 以来)
Set color of the transition text.

See also

  • game_text_tf - 军团要塞2 Displays a custom HUD message with icons on a specified team's screen.
  • point_worldtext - 军团要塞2反恐精英:全球攻势 A similar entity that displays a custom message in the world with far more flexibility.
  • training_annotation - 军团要塞2 A similar entity that points to a specified location in the world.
  • env_hudhint - Displays a custom HUD message. Commonly used to show key-binds.
  • env_message - Displays a pre-defined message on the players screen.
  • point_message - A similar entity that displays a small custom message at a specific position in the game world.
  • Customizable triggered HUD-message - How to create a new entity that is similar to game_text but can receive the message string via a triggered input.

References

  1. Left 4 Dead 2, the feature is not functioning. Here is a technical explanation for this issue.