源战役客户端
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

100 linhas
3.1 KiB

DesignToolTips = DesignToolTips or BaseClass(BaseView)
function DesignToolTips:__init()
self.base_file = "common"
self.layout_file = "DesignToolTips"
self.layer_name = "Top"
self.use_background = true
self.hide_maincancas = false
self.click_bg_toClose = true
self.is_set_zdepth = true
self.pos_x = 0
self.pos_y = 0
self.design_cfg = nil
self.model = GoodsModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self.curr_height = 0
self.load_callback = function ()
self:LoadSuccess()
end
self.open_callback = function ()
self:SetData()
end
self.close_callback = function ()
end
self.destroy_callback = function ()
end
end
function DesignToolTips:LoadSuccess()
self.layout = self:GetChild("layout")
self.bg = self:GetChild("layout/bg")
self.icon_con = self:GetChild("layout/icon_con"):GetComponent("Image")
self.nameText = self:GetChild("layout/nameText"):GetComponent("Text")
self.typeText = self:GetChild("layout/typeText"):GetComponent("Text")
self.line1 = self:GetChild("layout/line1")
self.contentText = self:GetChild("layout/contentText")
self.proText = self:GetChild("layout/proText")
self.conditionText = self:GetChild("layout/conditionText")
self.close_btn = self:GetChild("layout/close_btn").gameObject
self:InitEvent()
end
function DesignToolTips:InitEvent()
local function onclick(target)
if target == self.close_btn then
self:Close()
end
end
AddClickEvent(self.close_btn,onclick)
end
function DesignToolTips:Open(design_id, x, y, conditionStr)
self.design_id = design_id
self.design_cfg = Config.Dsgt[design_id]
self.conditionStr = conditionStr
self.pos_x = x
self.pos_y = y
BaseView.Open(self)
end
function DesignToolTips:SetData()
if self.design_cfg == nil then return end
lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetDesignImage(self.design_id),true)
self.nameText.text = self.design_cfg.name
self.typeText.text = "类型:称号"
self.curr_height = 152
self.contentText.localPosition = Vector3(32,-self.curr_height,0)
--描述
local contentStr = Trim(self.design_cfg.description)
self.contentText:GetComponent("Text").text = contentStr
self.curr_height = self.curr_height + self.contentText:GetComponent("Text").preferredHeight
self.curr_height = self.curr_height + 36
--属性
local attr_list = ErlangParser.GetInstance():Parse(self.design_cfg.attr_list)
local attrStr = "激活可加成:\n"
for k,v in ipairs(attr_list) do
attrStr = string.format("%s<color='%s'>%s</color>%s", attrStr, ColorUtil.GREEN,
WordManager:GetPropertyInfo(tonumber(v[1]),tonumber(v[2])), "\n")
end
self.proText:GetComponent("Text").text = attrStr
self.curr_height = self.curr_height + self.proText:GetComponent("Text").preferredHeight
self.curr_height = self.curr_height + 36
if self.conditionStr ~= "" then
self.conditionText.localPosition = Vector3(32,-self.curr_height,0)
self.conditionText:GetComponent("Text").text = self.conditionStr
self.curr_height = self.curr_height + self.conditionText:GetComponent("Text").preferredHeight
else
self.conditionText:GetComponent("Text").text = ""
end
self.curr_height = self.curr_height + 20
self.bg.sizeDelta = Vector2(407,self.curr_height)
end