|
|
ChuanWenManager = ChuanWenManager or BaseClass(EventDispatcher)
|
|
|
|
ChuanWenManager.Type = {
|
|
Rolling = 1,--传闻跑马灯飘(屏幕上方)
|
|
SystemNomal = 2,--频道普通消息
|
|
RollingSystemNomal = 3,--传闻跑马灯中部(屏幕中部)
|
|
CSEvent = 4, -- 跨服活动玩法传闻
|
|
}
|
|
|
|
function ChuanWenManager:__init()
|
|
ChuanWenManager.Instance = self
|
|
end
|
|
|
|
function ChuanWenManager:__delete()
|
|
|
|
end
|
|
|
|
function ChuanWenManager:getInstance()
|
|
if ChuanWenManager.Instance==nil then
|
|
ChuanWenManager.New()
|
|
end
|
|
return ChuanWenManager.Instance
|
|
end
|
|
|
|
--获取传闻内容
|
|
function ChuanWenManager:GetChuanWen(scmd)
|
|
local chuanwen_cfg = Config.Languageextra[scmd.module_id .. "@" .. scmd.id]
|
|
|
|
if chuanwen_cfg then
|
|
local array = Split(scmd.content,",")
|
|
local replaceFunc = function (str)
|
|
return array[tonumber(str)] or ""
|
|
end
|
|
local text, num = string.gsub(chuanwen_cfg.content, "{(%d+)}", replaceFunc)
|
|
text = self:FormatColorTag(text)
|
|
local p1, p2, param_str = string.find(text, "%<a@goods3([^%>^/.]-)%>") --goods3特殊解析 -_-||
|
|
if param_str and param_str~="" then
|
|
local temp = Split(param_str, "@")
|
|
if temp and temp[2] then
|
|
local basic = GoodsModel:GetGoodsBasicByTypeId(tonumber(temp[2]))
|
|
if basic and ((basic.type==10 and basic.subtype~=GoodsModel.SHOUHU_EQUIP_TYPE) or basic.type==39) then --装备,而且不是守护类型才这样解析
|
|
local tb = Split(scmd.content, "%[")
|
|
if tb and tb[2] and tb[2]~="" then
|
|
local str = "{"..tb[2]
|
|
str = string.gsub(str, "]", "")
|
|
str = string.format("{%s}", str)
|
|
local list = StrToTable(str)
|
|
local bigList = {}
|
|
local temp2 = {"color","type_id","attr_id","attr_val","plus_interval","plus_unit"}
|
|
for k,v in ipairs(list) do
|
|
local proList = {}
|
|
for m,n in ipairs(v) do
|
|
proList[temp2[m]] = n
|
|
end
|
|
table.insert(bigList, proList)
|
|
end
|
|
str = TableToStr(bigList)
|
|
--那个颜色字段暂时截取不掉,先这样处理
|
|
text = string.gsub(text, "%[{0", str)
|
|
text = string.gsub(text, "%[{1", str)
|
|
text = string.gsub(text, "%[{2", str)
|
|
text = string.gsub(text, "%[{3", str)
|
|
text = string.gsub(text, "%[{4", str)
|
|
text = string.gsub(text, "%[{5", str)
|
|
text = string.gsub(text, "%[{6", str)
|
|
text = string.gsub(text, "%[{7", str)
|
|
text = string.gsub(text, "%[{8", str)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return text, chuanwen_cfg
|
|
else
|
|
print("没有找到传闻配置==:", scmd.module_id, scmd.id)
|
|
end
|
|
return "", nil
|
|
end
|
|
|
|
|
|
|
|
--解析颜色标签,适用于这种格式<color@颜色值>
|
|
function ChuanWenManager:FormatColorTag(text)
|
|
if text == nil or Trim(text) =="" then return text end
|
|
text = Trim(text)
|
|
local function replaceFunc(str)
|
|
local str = string.sub(str,2,-2)
|
|
local arr = Split(str,"@")
|
|
local desc = "<color=" .. WordManager.GetChuanwenColor(tonumber(arr[2])) .. ">"
|
|
return desc
|
|
end
|
|
local result = string.gsub(text, "%<color[^%>^/]+%>", replaceFunc)
|
|
return result
|
|
end
|
|
|
|
--解析颜色标签,适用于这种格式<color@颜色值> 上面主要是主界面的聊天面板的传闻颜色(颜色浅) 下面这个是对于其他使用了这个接口的界面(颜色深)
|
|
function ChuanWenManager:FormatColorTag2(text, is_dark)
|
|
if text == nil or Trim(text) =="" then return text end
|
|
text = Trim(text)
|
|
local function replaceFunc(str)
|
|
local str = string.sub(str,2,-2)
|
|
local arr = Split(str,"@")
|
|
local desc = "<color=" .. WordManager.GetGoodsColor(tonumber(arr[2]), is_dark) .. ">"
|
|
return desc
|
|
end
|
|
local result = string.gsub(text, "%<color[^%>^/]+%>", replaceFunc)
|
|
return result
|
|
end
|
|
|
|
function ChuanWenManager:DeleteSpecialSign(text)
|
|
if text == nil or Trim(text) =="" then return text end
|
|
text = Trim(text)
|
|
local result = text
|
|
result = string.gsub(result, "<a.->", "")
|
|
result = string.gsub(result, "</a>", "")
|
|
return result
|
|
end
|