Files

78 lines
5.1 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# name_show —— §8.4 / §8.6 头顶名字「是否显示」1:1CPythonSystem::IsAlwaysShowName /
# SetAlwaysShowNameFlag + game.py::__IsShowName + CPythonTextTail::ShowAllTextTail 的
# 3500 距离裁剪 + ShowCharacterTextTail 的资格判定 + UpdateAllTextTail 的 bNameFlag 强显。
# (与 name_color.gd / text_tail.gd / chat_tail.gd 同一套纯静态镜像套路。)
#
# REF40250 ClientVS22 source/ 为唯一基线):
# UserInterface/PythonSystem.cpp:5 #define DEFAULT_VALUE_ALWAYS_SHOW_NAME true
# UserInterface/PythonSystem.cpp:307 m_Config.bAlwaysShowName = DEFAULT_VALUE_ALWAYS_SHOW_NAME
# UserInterface/PythonSystem.cpp:327 IsAlwaysShowName() -> m_Config.bAlwaysShowName
# UserInterface/PythonSystem.cpp:334 SetAlwaysShowNameFlag(iFlag) -> bAlwaysShowName = (iFlag == 1)
# UserInterface/PythonSystem.cpp:449 config "ALWAYS_VIEW_NAME" -> atoi(value) == 1
# UserInterface/PythonSystem.cpp:535 save "ALWAYS_VIEW_NAME %d"(仅当 != 默认值时落盘)
# UserInterface/PythonSystemModule.cpp:181/214 systemSetAlwaysShowNameFlag / systemIsAlwaysShowName
# root/uigameoption.py:220 __OnClickAlwaysShowNameOnButton -> systemSetting.SetAlwaysShowNameFlag(True) + RefreshAlwaysShowName()
# root/game.py:323 onPressKeyDict[app.DIK_LALT] -> ShowName()
# root/game.py:406 onClickKeyDict[app.DIK_LALT] -> HideName()
# root/game.py:1143 ShowName() -> self.ShowNameFlag = True
# root/game.py:1149 __IsShowName() -> if IsAlwaysShowName(): return True; if ShowNameFlag: return True; return False
# root/game.py:1533 OnRenderchr.Pick() 命中 -> textTail.ShowCharacterTextTail(idx)
# root/game.py:1535 OnRendertargetBoard.GetTargetVID() != 0 -> textTail.ShowCharacterTextTail(vid)
# root/game.py:1550 OnRenderif __IsShowName(): textTail.ShowAllTextTail()
# UserInterface/PythonTextTail.cpp:416 UpdateDistancefDistanceFromPlayer = |(ownerX-centerX, -ownerY-centerY)|
# UserInterface/PythonTextTail.cpp:422 ShowAllTextTailm_CharacterTextTailMap 里 fDistanceFromPlayer < 3500.0f 才 ShowCharacterTextTail
# UserInterface/PythonTextTail.cpp:440 ShowCharacterTextTail:不在图 / 已入列 / !pOwner->isShow() / 无实例 / IsGuildWall() -> returnCanPickInstance() 才入列
# UserInterface/PythonTextTail.cpp:74 UpdateAllTextTailchat 尾标 bNameFlag -> ShowCharacterTextTail(不受 3500 限制)
#
# seam ⑩:参考端「名字显示」是每帧重建 m_CharacterTextTailListPick / target / ShowAll
# 再 Render / Arrange(防重叠)/ Hide 的屏幕空间流程;本移植是 net_world 里每个实体一块
# billboard Label3D,靠本模块谓词逐帧 set .visible。鼠标悬停 chr.Pick() 未接(net_world
# 无悬停拾取)、屏幕空间 ArrangeTextTail 防重叠未做 —— 记为 seam ⑩。
# 另:参考 UpdateDistance 因 owner 在渲染帧(Y 取反)、center 在像素帧才写成
# (ownerX-centerX, -ownerY-centerY);本移植所有坐标统一在 pos_cm 帧,等价于同帧平面距。
extends RefCounted
const ALWAYS_SHOW_NAME_DEFAULT := true # DEFAULT_VALUE_ALWAYS_SHOW_NAME
const SHOW_ALL_DISTANCE := 3500.0 # ShowAllTextTail 的 fDistanceFromPlayer < 3500px==cm
const CFG_KEY := "ALWAYS_VIEW_NAME" # PythonSystem 配置行 / 存盘键
# SetAlwaysShowNameFlag(int iFlag): m_Config.bAlwaysShowName = iFlag == 1
static func always_show_from_flag(flag: int) -> bool:
return flag == 1
# config "ALWAYS_VIEW_NAME" 行:atoi(value) == 1
static func always_show_from_cfg(value: Variant) -> bool:
return int(value) == 1
# __IsShowName() = IsAlwaysShowName() or ShowNameFlagLALT 按住)
static func is_show_name(always_show_name: bool, alt_held: bool) -> bool:
return always_show_name or alt_held
# ShowAllTextTail:只有平面距离 < 3500 的角色尾标才 ShowCharacterTextTail
static func within_show_all(dist_cm: float) -> bool:
return dist_cm < SHOW_ALL_DISTANCE
# UpdateDistance 的平面距。net_world 的 pos_cm 已是统一帧,直接同帧平面距
# (参考端的 -ownerY 是渲染帧 / 像素帧混用的产物,见文件头 seam ⑩ 注)。
static func planar_distance_cm(a_cm: Vector2, b_cm: Vector2) -> float:
return a_cm.distance_to(b_cm)
# ShowCharacterTextTail 的资格判定(把早退条件取反):
# pOwner->isShow()(可见 / 未死透)、!IsGuildWall()、CanPickInstance()
static func eligible_character(is_shown: bool, is_guild_wall: bool, can_pick: bool) -> bool:
return is_shown and not is_guild_wall and can_pick
# 综合:某实体这一帧的头顶名字是否显示。
# forced —— chr.Pick() 命中 / targetBoard VID / chat 尾标 bNameFlag:都走 ShowCharacterTextTail
# 但绕过 ShowAllTextTail 的 3500 裁剪(资格判定仍要过)。
# 非 forced —— 需 __IsShowName() 为真 且 距离 < 3500 且 资格通过。
static func name_visible_for(forced: bool, show_name: bool, dist_cm: float,
is_shown: bool, is_guild_wall: bool, can_pick: bool) -> bool:
if not eligible_character(is_shown, is_guild_wall, can_pick):
return false
if forced:
return true
if not show_name:
return false
return within_show_all(dist_cm)