源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

112 rivejä
3.3 KiB

DsgtToolTip = DsgtToolTip or BaseClass(BaseView)
function DsgtToolTip:__init()
self.base_file = "common"
self.layout_file = "DsgtToolTips"
self.layer_name = "Top"
self.use_background = true
self.click_bg_toClose = true
self.append_to_ctl_queue = false
self.hide_maincancas = false
self.pos_x = 0
self.pos_y = 0
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 ()
self:Remove()
end
end
function DsgtToolTip:LoadSuccess()
self.bg = self:GetChild("layout/bg")
self.img = self:GetChild("layout/img"):GetComponent("Image")
-- lua_resM:setOutsideImageSprite(self,self.img,GameResPath.GetJpgImage("bg_dsgtTip.jpg"),false)
self.combat = self:GetChild("layout/combat/val"):GetComponent("Text")
self.des_con = self:GetChild("layout/Designation")
self.content_text = self:GetChild("layout/contentText")
self.getway = self:GetChild("layout/getway")
self.layout = self:GetChild("layout")
self.getway_text = self:GetChild("layout/getway/getwayText"):GetComponent("Text")
end
function DsgtToolTip:Open(dsgt_id,x,y)
self.dsgt_id = dsgt_id
self.pos_x = x
self.pos_y = y
BaseView.Open(self)
end
function DsgtToolTip:SetData()
if self.dsgt_id then
if self.dsgt_item == nil then
self.dsgt_item = PerfectLoverDesignationItem.New(self.des_con)
end
end
self.dsgt_item:SetData(self.dsgt_id)
self.cfg = Config.Dsgt[self.dsgt_id]
if self.cfg == nil then return end
if type(self.cfg.attr_list) ~= "table" then
attr_list = ErlangParser:GetInstance():Parse(self.cfg.attr_list)
end
self.combat.text = GetFighting(attr_list)
self.curr_height = 185
self.content_text.localPosition = Vector3(28.3,-self.curr_height,0)
local str = "<color=#835741>称号属性加成:</color>\n"
if #attr_list > 0 then
local attr_name = ""
local attr_value = ""
for i = 1,#attr_list do
local attr_id = attr_list[i].attr_id or tonumber(attr_list[i][1])
local attr_num = attr_list[i].attr_num or tonumber(attr_list[i][2])
attr_name = WordManager:GetProperties(attr_id)
attr_value = WordManager:GetPropertyValue(attr_id,attr_num)
str = str..string.format("<color=#a77755>%s</color><color=%s> + %s</color>\n",attr_name,ColorUtil.GREEN,attr_value)
end
end
self.content_text:GetComponent("Text").text = str
self.curr_height = self.curr_height + self.content_text:GetComponent("Text").preferredHeight + 10
self.getway.localPosition = Vector3(17.4,-self.curr_height,0)
self.getway_text.text = "<color=#60a0ff>"..Trim(self.cfg.description).."</color>"
self.curr_height = self.curr_height + self.getway_text.preferredHeight + 10
self.bg.sizeDelta = Vector2(340.5,self.curr_height + 15)
local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
self.layout.anchoredPosition = Vector3(x + 10,y +self.bg.sizeDelta.y,0)
if self.pos_x and self.pos_y then
local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
if x+340.5 > ScreenWidth then
x = ScreenWidth-340.5-20
elseif x<20 then
x = 20
end
if y < 20 then
y = 20
elseif y+self.bg.sizeDelta.y > ScreenHeight then
y = ScreenHeight-self.bg.sizeDelta.y -20
end
self.layout.anchoredPosition = Vector3(x + 10,y +self.bg.sizeDelta.y,0)
end
end
function DsgtToolTip:Remove()
if self.dsgt_item then
self.dsgt_item:DeleteMe()
self.dsgt_item = nil
end
end