128 lines
6.6 KiB
GDScript
128 lines
6.6 KiB
GDScript
# text_tail.gd —— 头顶「称号 / 等级 / 公会名」子标签的 1:1 迁移(§8.8)
|
||
#
|
||
# 参考(REF/ = /Users/shenlei/Work/mt/40250/ClientVS22/source/):
|
||
# UserInterface/InstanceBaseEffect.cpp:609 GetTitleColor —— uGrade>=TITLE_NUM 时白,否则 g_akD3DXClrTitle[uGrade]
|
||
# UserInterface/InstanceBaseEffect.cpp:621 AttachTextTail —— fTextTailHeight = IsMountingHorse()?110:10;末尾 if(m_dwLevel) UpdateTextTailLevel
|
||
# UserInterface/InstanceBaseEffect.cpp:654 UpdateTextTailLevel —— s_kLevelColor = D3DXCOLOR(152/255,255/255,51/255,1);"Lv %d"
|
||
# UserInterface/InstanceBaseEffect.cpp:664 RefreshTextTail —— SetCharacterTextTailColor(GetNameColor()) + 按 AlignmentGrade attach/detach 称号
|
||
# UserInterface/InstanceBaseEffect.cpp:1107 RegisterTitleName —— g_TitleNameMap[i] = c_szTitleName
|
||
# UserInterface/InstanceBaseEffect.cpp:1131 RegisterTitleColor —— g_akD3DXClrTitle[u] = __RGBToD3DXColoru(r,g,b)
|
||
# UserInterface/InstanceBase.h:262 TITLE_NUM = 9 / TITLE_NONE = 4
|
||
# UserInterface/InstanceBase.cpp:2053 SetAlignment -> RefreshTextTailTitle -> RefreshTextTail
|
||
# UserInterface/PythonTextTail.cpp:18 c_TextTail_Guild_Name_Color = 0xFFEFD3FF
|
||
# UserInterface/PythonTextTail.cpp:23 bPKTitleEnable = TRUE(EnablePKTitle)
|
||
# UserInterface/PythonTextTail.cpp:509 RegisterCharacterTextTail —— dwGuildID!=0 才建公会名标签;GetGuildName 失败 -> "Noname"
|
||
# UserInterface/PythonTextTail.cpp:890 AttachTitle / :943 AttachLevel —— 均 if(!bPKTitleEnable) return
|
||
# assets/root/introloading.py:287 TITLE_COLOR_DICT(注册序 0..8)
|
||
# assets/root/colorInfo.py:29 TITLE_RGB_GOOD_4 .. TITLE_RGB_EVIL_4
|
||
# assets/root/localeInfo.py:215 TITLE_NAME_LIST = (PVP_LEVEL0..PVP_LEVEL8,)
|
||
# assets/root/constinfo.py:4 PVPMODE_ENABLE = 1;game.py:155 textTail.EnablePKTitle(constInfo.PVPMODE_ENABLE)
|
||
#
|
||
# 纯静态。调用方(net_world.gd)把网络快照 self_e({alignment,level,guild,mount_vnum,...})
|
||
# 传进来,再自己把 title_name_key / 公会名解析成本地化字符串并落到 Label3D 上。
|
||
extends RefCounted
|
||
|
||
const EntityRules = preload("res://entity_rules.gd")
|
||
|
||
# InstanceBase.h 匿名枚举
|
||
const TITLE_NUM := 9
|
||
const TITLE_NONE := 4
|
||
|
||
const _WHITE := Color(1, 1, 1)
|
||
|
||
# UpdateTextTailLevel 的 s_kLevelColor = D3DXCOLOR(152/255, 255/255, 51/255, 1)
|
||
const LEVEL_COLOR := Color(152.0 / 255.0, 255.0 / 255.0, 51.0 / 255.0)
|
||
# PythonTextTail.cpp:18 c_TextTail_Guild_Name_Color = 0xFFEFD3FF(ARGB -> RGB 239,211,255)
|
||
const GUILD_NAME_COLOR := Color(239.0 / 255.0, 211.0 / 255.0, 255.0 / 255.0)
|
||
# CPythonGuild::GetGuildName 失败时的兜底名(PythonTextTail.cpp:551)
|
||
const GUILD_NAME_FALLBACK := "Noname"
|
||
|
||
# g_akD3DXClrTitle:introloading.py TITLE_COLOR_DICT 经 RegisterTitleColor -> __RGBToD3DXColoru
|
||
# 写进的 9 个槽(idx0 GOOD_4 .. idx8 EVIL_4)。Color8(r,g,b) == D3DXCOLOR(r/255,g/255,b/255)。
|
||
static func _title_colors() -> Array:
|
||
return [
|
||
Color8(0, 204, 255), # 0 GOOD_4
|
||
Color8(0, 144, 255), # 1 GOOD_3
|
||
Color8(92, 110, 255), # 2 GOOD_2
|
||
Color8(155, 155, 255), # 3 GOOD_1
|
||
Color8(255, 255, 255), # 4 NORMAL(= TITLE_NONE,实际不会 attach)
|
||
Color8(207, 117, 0), # 5 EVIL_1
|
||
Color8(235, 83, 0), # 6 EVIL_2
|
||
Color8(227, 0, 0), # 7 EVIL_3
|
||
Color8(255, 0, 0), # 8 EVIL_4
|
||
]
|
||
|
||
# --- EnablePKTitle / bPKTitleEnable(PythonTextTail.cpp:23 / :938)--------------
|
||
# game.py:155 起始 EnablePKTitle(constInfo.PVPMODE_ENABLE),constinfo.py:4 PVPMODE_ENABLE = 1。
|
||
static var _pk_title_enabled := true
|
||
|
||
static func set_pk_title_enabled(enabled: bool) -> void:
|
||
_pk_title_enabled = enabled
|
||
|
||
static func is_pk_title_enabled() -> bool:
|
||
return _pk_title_enabled
|
||
|
||
# --- CInstanceBase::GetTitleColor(InstanceBaseEffect.cpp:609)—— 逐行 -----------
|
||
# 入参是 GetAlignmentGrade() 的结果(0..8),越界(>=TITLE_NUM)返回白。
|
||
static func title_color(grade: int) -> Color:
|
||
if grade < 0 or grade >= TITLE_NUM:
|
||
return _WHITE
|
||
return _title_colors()[grade]
|
||
|
||
# introloading.py __RegisterTitleName:chrmgr.RegisterTitleName(i, TITLE_NAME_LIST[i]),
|
||
# TITLE_NAME_LIST[i] == localeInfo.PVP_LEVEL<i>。调用方用它查 Locale 表。
|
||
static func title_name_key(grade: int) -> String:
|
||
return "PVP_LEVEL%d" % grade
|
||
|
||
# UpdateTextTailLevel:sprintf(szText, "Lv %d", level)
|
||
static func level_text(level: int) -> String:
|
||
return "Lv %d" % level
|
||
|
||
# AttachTextTail:fTextTailHeight = IsMountingHorse() ? 110.0f : 10.0f
|
||
static func text_tail_height(mounted: bool) -> float:
|
||
return 110.0 if mounted else 10.0
|
||
|
||
# --- CInstanceBase::RefreshTextTail 的称号分支(InstanceBaseEffect.cpp:664)-------
|
||
# 返回 { show_title, grade, name_key, color }。
|
||
# iAlignmentGrade = GetAlignmentGrade();
|
||
# if (TITLE_NONE == iAlignmentGrade) DetachTitle();
|
||
# else if (g_TitleNameMap.has(grade)) AttachTitle(name, GetTitleColor());
|
||
# AttachTitle/DetachTitle 均 if(!bPKTitleEnable) return —— 关闭时参考端「冻结」上一态;
|
||
# 本移植取「隐藏」(show_title=false),差异见 §8.8 seam ⑦。
|
||
static func refresh_title(alignment: int) -> Dictionary:
|
||
var grade := EntityRules.alignment_grade(alignment)
|
||
var out := {
|
||
"show_title": false,
|
||
"grade": grade,
|
||
"name_key": title_name_key(grade),
|
||
"color": title_color(grade),
|
||
}
|
||
if not _pk_title_enabled:
|
||
return out
|
||
if grade == TITLE_NONE:
|
||
return out
|
||
# g_TitleNameMap 注册了 0..8 全部(introloading.__RegisterTitleName),故只排除 TITLE_NONE。
|
||
if grade < 0 or grade >= TITLE_NUM:
|
||
return out
|
||
out["show_title"] = true
|
||
return out
|
||
|
||
# --- AttachTextTail 的等级分支(InstanceBaseEffect.cpp:621 末 + UpdateTextTailLevel)
|
||
# if (m_dwLevel) UpdateTextTailLevel(m_dwLevel);AttachLevel 亦 if(!bPKTitleEnable) return。
|
||
static func refresh_level(level: int) -> Dictionary:
|
||
var show := _pk_title_enabled and level > 0
|
||
return {
|
||
"show_level": show,
|
||
"text": level_text(level) if show else "",
|
||
"color": LEVEL_COLOR,
|
||
}
|
||
|
||
# --- RegisterCharacterTextTail 的公会名分支(PythonTextTail.cpp:543)--------------
|
||
# dwGuildID != 0 才建公会名标签;CPythonGuild::GetGuildName(dwGuildID) 失败 -> "Noname"。
|
||
# resolved_name 由调用方经 client.get_guild_name(guild_id) 解出(空串 = 解析失败)。
|
||
static func refresh_guild(guild_id: int, resolved_name: String) -> Dictionary:
|
||
if guild_id == 0:
|
||
return {"show_guild": false, "name": "", "color": GUILD_NAME_COLOR}
|
||
var nm := resolved_name if resolved_name != "" else GUILD_NAME_FALLBACK
|
||
return {"show_guild": true, "name": nm, "color": GUILD_NAME_COLOR}
|