2023-07-14 19:35:33 +00:00
|
|
|
|
local ATTR_COLOR = {
|
|
|
|
|
BELOW = XUiHelper.Hexcolor2Color("d11e38ff"),
|
|
|
|
|
EQUAL = XUiHelper.Hexcolor2Color("000000ff"),
|
|
|
|
|
OVER = XUiHelper.Hexcolor2Color("188649ff"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local XUiGridEquipReplaceAttr = XClass(nil, "XUiGridEquipReplaceAttr")
|
|
|
|
|
|
|
|
|
|
function XUiGridEquipReplaceAttr:Ctor(ui, name, doNotChangeColor)
|
|
|
|
|
self.GameObject = ui.gameObject
|
|
|
|
|
self.Transform = ui.transform
|
|
|
|
|
self:InitAutoScript()
|
|
|
|
|
self.TxtName.text = name
|
|
|
|
|
self.DoNotChangeColor = doNotChangeColor
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
|
function XUiGridEquipReplaceAttr:UpdateData(curAttrValue, newattrvalue, notShowSame, attrName)
|
2023-07-14 19:35:33 +00:00
|
|
|
|
if curAttrValue then
|
|
|
|
|
self.CurAttrValue = curAttrValue
|
|
|
|
|
self.TxtCurAttr.text = self.CurAttrValue
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
|
if attrName then
|
|
|
|
|
self.TxtName.text = attrName
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-14 19:35:33 +00:00
|
|
|
|
if not newattrvalue or notShowSame and self.CurAttrValue and newattrvalue == self.CurAttrValue then
|
|
|
|
|
self.TxtSelectAttr.gameObject:SetActive(false)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.Newattrvalue = newattrvalue
|
|
|
|
|
self.TxtSelectAttr.text = self.Newattrvalue
|
|
|
|
|
self.TxtSelectAttr.gameObject:SetActive(true)
|
|
|
|
|
|
|
|
|
|
if not self.DoNotChangeColor then
|
|
|
|
|
if self.CurAttrValue == self.Newattrvalue then
|
|
|
|
|
self.TxtSelectAttr.color = ATTR_COLOR.EQUAL
|
|
|
|
|
elseif self.CurAttrValue < self.Newattrvalue then
|
|
|
|
|
self.TxtSelectAttr.color = ATTR_COLOR.OVER
|
|
|
|
|
elseif self.CurAttrValue > self.Newattrvalue then
|
|
|
|
|
self.TxtSelectAttr.color = ATTR_COLOR.BELOW
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- auto
|
|
|
|
|
-- Automatic generation of code, forbid to edit
|
|
|
|
|
function XUiGridEquipReplaceAttr:InitAutoScript()
|
|
|
|
|
self:AutoInitUi()
|
|
|
|
|
self:AutoAddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridEquipReplaceAttr:AutoInitUi()
|
|
|
|
|
self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text")
|
|
|
|
|
self.TxtCurAttr = self.Transform:Find("TxtCurAttr"):GetComponent("Text")
|
|
|
|
|
self.TxtSelectAttr = self.Transform:Find("TxtSelectAttr"):GetComponent("Text")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridEquipReplaceAttr:RegisterClickEvent(uiNode, func)
|
|
|
|
|
if func == nil then
|
|
|
|
|
XLog.Error("XUiGridEquipReplaceAttr:RegisterClickEvent函数参数错误:参数func不能为空")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if type(func) ~= "function" then
|
|
|
|
|
XLog.Error("XUiGridEquipReplaceAttr:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local listener = function(...)
|
|
|
|
|
func(self, ...)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
CsXUiHelper.RegisterClickEvent(uiNode, listener)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridEquipReplaceAttr:AutoAddListener()
|
|
|
|
|
end
|
|
|
|
|
-- auto
|
|
|
|
|
return XUiGridEquipReplaceAttr
|