|
|
- --只显示装备信息的tips, 可与showiconitem搭配使用
- WingInfoTips = WingInfoTips or BaseClass(EquipToolTips)
-
- WingInfoTips.ONLY_SHOW = 0 --只展示信息
- WingInfoTips.COMPOSE_OFF = 1 --显示取出按钮,点击移除合成物品
- WingInfoTips.OFF_AND_REPLACE = 2 --显示取出和替换
-
- function WingInfoTips:__init()
- self.base_file = "common"
- self.layout_file = "EquipToolTips"
- self.layer_name = "Top"
-
- self.use_background = true
- self.click_bg_toClose = true
- self.close_mode = CloseMode.CloseDestroy
- self.destroy_imm = true
-
- self.goods_vo = nil
-
- --self:AddPreLoadList("common_asset",{"star", "com_blackstar"},LuaResManager.RES_TYPE.SPRITE)
-
-
- self.load_callback = function ()
- self:LoadSuccess()
- end
- self.open_callback = function ()
- self:SetData(self.goods_vo)
- end
- self.close_callback = function ()
- end
- self.destroy_callback = function ()
- self:Remove()
- end
- end
-
- --[[
- dynamic: 在外部整合好的物品动态信息table,一般获取背包中的动态信息即可
- 若要实现预览等特殊信息,在外部修改后传入
- type_or_goodsID: 枚举类型,实现某个界面的特殊需求,显示某些按钮,实现特定功能
- ]]
- function WingInfoTips:Open(type_id, x, y, type_or_goodsID, off_callback, replace_callback)
- do return end
- if not Config.Twing[type_id] then
- print("WingInfoTips:Open() 不存在的翅膀类型, type_id = "..type_id)
- self:Close()
- return
- end
-
- self.type_id = type_id
- self.type_or_goodsID = type_or_goodsID
- self.pos_x = x
- self.pos_y = y
- self.off_callback = off_callback
- self.replace_callback = replace_callback
-
- BaseView.Open(self)
- end
-
- function WingInfoTips:LoadSuccess()
- EquipToolTips.LoadSuccess(self)
- self.normal_tra = self:GetChild("layout/normal")
-
- self.replaceBtn = self.strengthBtn
-
- self.replace_btn_text, self.equip_text = self:GetChildTexts({"layout/normal/btn_conta/strengthBtn/Text", "layout/normal/Text2"})
- self.replace_btn_text.text = "替换"
- self.normal_tra.anchoredPosition = Vector2(0,0)
-
- SetSizeDelta(self.transform,ScreenWidth,ScreenHeight)
- self.skill_desc = self:GetChild("layout/normal/ScrollView/Viewport/Content/addStrengthProp"):GetComponent("Text")
- self:GetChild("layout/normal/ScrollView/Viewport/Content/line2/Text"):GetComponent("Text").text = "翅膀描述"
- self.ScrollView:GetComponent("ScrollRect").enabled = false
- end
-
- function WingInfoTips:Remove()
- if self.icon_item then
- self.icon_item:DeleteMe()
- self.icon_item = nil
- end
- if self.modelPreview then
- self.modelPreview:DeleteMe()
- self.modelPreview = nil
- end
- self:DeleteArrowTip()
- if self.addNumComponent then
- if self.change_count_id then
- self.addNumComponent:UnBind(self.change_count_id)
- self.change_count_id = nil
- end
- self.addNumComponent:DeleteMe()
- self.addNumComponent = nil
- end
- end
-
- function WingInfoTips:InitEvent()
- local function onBtnClickHandler(target)
- if target == self.takeBtn then
- if self.off_callback ~= nil then
- local fun = self.off_callback
- setTimeout(fun, 0)
- self:Close()
- end
- elseif target == self.replaceBtn then
- if self.replace_callback ~= nil then
- self:Close()
- self.replace_callback()
- end
- elseif target == self.wearBtn then
- WingModel:getInstance():OutsideRequireWearWing(self.type_or_goodsID)
- self:Close()
- elseif target == self.shelvesUpBtn then
-
- end
- end
- AddClickEvent(self.takeBtn, onBtnClickHandler)
- AddClickEvent(self.strengthBtn, onBtnClickHandler)
- AddClickEvent(self.wearBtn, onBtnClickHandler)
- AddClickEvent(self.shelvesUpBtn, onBtnClickHandler)
- end
-
- function WingInfoTips:SetData()
-
- self.goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
- local wing_vo = Config.Twing[self.type_id]
- local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
- if wing_vo == nil or basic == nil then
- return print("WingInfoTips:SetData() 数据错误, wing_vo = "..tostring(wing_vo)..", basic = "..tostring(basic)..", type_id = "..self.type_id)
- end
-
- -- 名字
- self.nameText.text = "<color="..WordManager.GetGoodsColor(basic.color)..">"..basic.goods_name.."</color>"
-
- local mainVo = RoleManager.Instance.mainRoleInfo
- local color_str
-
- -- 职业
- if wing_vo.career_id == 0 or mainVo.career == wing_vo.career_id then
- color_str = ColorUtil.WHITE
- else
- color_str = ColorUtil.RED
- end
- local career_name = WordManager:GetCareerName(wing_vo.career) or "无"
- self.career.text = "<color="..color_str..">" .. career_name .. "</color>"
-
- -- 等级
- color_str = ColorUtil.WHITE
- if basic.level > mainVo.level then
- color_str = ColorUtil.RED
- end
- self.level.text = "<color="..color_str..">" .. basic.level .. "</color>"
-
- -- 等阶
- local step_str = WordManager:GetWingStepNum(self.type_id)
- self.step_num.text = "<color="..WordManager.GetGoodsColor(basic.color)..">" .. step_str .. "</color>"
-
- self.icon_item:SetData(basic)
-
- lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..basic.color)
-
- if basic then
- local base_pro = ErlangParser:GetInstance():Parse(wing_vo.attr)
- self:SetProperty(base_pro)
- --self.composite_score.text = GetFighting(base_pro)
- self.composite_score.text = wing_vo.power
- end
-
- self:SetBtns()
-
- self:AdjustLayoutPos()
- if Config.ConfigModelPreview[self.type_id] then
- self.modelPreview = ModelPreviewCon.New(self.normal_tra)
- self.modelPreview:SetData(self.type_id,self.bg.sizeDelta.y-29)
- if self.layout.anchoredPosition.x < 400 then
- self.layout.anchoredPosition = Vector2(400, self.layout.anchoredPosition.y)
- end
- end
- end
-
- --按钮显示
- function WingInfoTips:SetBtns()
- for i,v in ipairs(self.btn_list) do
- v:SetActive(false)
- end
-
- local btn_list = nil
- if self.type_or_goodsID == WingInfoTips.COMPOSE_OFF then
- btn_list = {self.takeBtn}
- elseif self.type_or_goodsID == WingInfoTips.OFF_AND_REPLACE then
- btn_list = {self.takeBtn,self.replaceBtn}
- elseif self.type_or_goodsID == WingInfoTips.ONLY_SHOW then
- btn_list = {}
- else
- btn_list = {self.wearBtn,self.shelvesUpBtn}
- end
- for i,v in ipairs(btn_list) do
- v:SetActive(true)
- end
-
- self.btn_conta.sizeDelta = Vector2(self.btn_conta.sizeDelta.x, #btn_list * 60 +10)
- end
-
- --设置基础属性
- function WingInfoTips:SetProperty(base_pro)
-
- self.equip_text.gameObject:SetActive(false)
- self.equip_score.gameObject:SetActive(false)
-
- self.line3.gameObject:SetActive(false)
- self.line4.gameObject:SetActive(false)
- self.line5.gameObject:SetActive(false)
- self.line6.gameObject:SetActive(false)
- self.line7.gameObject:SetActive(false)
- self.line8.gameObject:SetActive(false)
- self.line9.gameObject:SetActive(false)
- self.line10.gameObject:SetActive(false)
-
- self.strengthAdd.gameObject:SetActive(false)
-
- self.addName.gameObject:SetActive(false)
- self.addPro.gameObject:SetActive(false)
-
- self.washName.gameObject:SetActive(false)
- self.washPro.gameObject:SetActive(false)
-
- self.spiritName.gameObject:SetActive(false)
- self.spiritPro.gameObject:SetActive(false)
-
- self.stone_conta.gameObject:SetActive(false)
-
- self.suitNum.gameObject:SetActive(false)
- self.suitName.gameObject:SetActive(false)
- self.suitPro.gameObject:SetActive(false)
- self.suitNameList.gameObject:SetActive(false)
-
- self.wake_baseName.gameObject:SetActive(false)
- self.wake_basePro.gameObject:SetActive(false)
- self.wake_baseAdd.gameObject:SetActive(false)
-
- self.wake_strenName.gameObject:SetActive(false)
- self.wake_strenPro.gameObject:SetActive(false)
- self.wake_strenAdd.gameObject:SetActive(false)
-
- self.wake_suitNum.gameObject:SetActive(false)
- self.wake_suitName.gameObject:SetActive(false)
- self.wake_suitPro.gameObject:SetActive(false)
- self.wake_suitAdd.gameObject:SetActive(false)
-
- self.magic_skillName.gameObject:SetActive(false)
- self.magic_skillLevel.gameObject:SetActive(false)
-
- self.expired_label.gameObject:SetActive(false)
- self.descCon.gameObject:SetActive(false)
-
- local name_str = ""
- local pro_str = ""
- local size = #base_pro
- for i,v in ipairs(base_pro) do
- name_str = name_str .. WordManager:GetProperties(tonumber(v[1]))
- pro_str = pro_str.."+" .. WordManager:GetPropertyValue(tonumber(v[1]),tonumber(v[2]))
-
- if i < size then
- name_str = name_str.."\n"
- pro_str = pro_str.."\n"
- end
- end
- self.baseName.text = name_str
- self.basePro.text = pro_str
- SetSizeDelta(self.baseName.transform, self.baseName.transform.sizeDelta.x, 25 * size)
- SetSizeDelta(self.basePro.transform, self.basePro.transform.sizeDelta.x, 25 * size)
-
- local wing_vo = Config.Twing[self.type_id]
- self.skill_desc.text = "<color=#A4663CFF>"..Trim(wing_vo.description).."</color>"
- local skill_desc_h = 75
- SetAnchoredPosition(self.skill_desc.transform, 25, -25 * size - 100)
- SetSizeDelta(self.skill_desc.transform, 344, skill_desc_h)
- SetAnchoredPosition(self.line2, 0, -25 * size - 52)
-
- SetSizeDelta(self.bg, self.bg.sizeDelta.x, 315 + 25 * size + skill_desc_h)
- self.btn_conta.anchoredPosition = Vector2(self.btn_conta.anchoredPosition.x, -205 - 25 * size)
-
- setTimeout(function ()
- if not self._use_delete_method then
- local skill_desc_h = self.skill_desc.preferredHeight
- SetSizeDelta(self.skill_desc.transform, 344, skill_desc_h)
-
- SetSizeDelta(self.bg, self.bg.sizeDelta.x, 315 + 25 * size + skill_desc_h)
- self.btn_conta.anchoredPosition = Vector2(self.btn_conta.anchoredPosition.x, -205 - 25 * size - skill_desc_h)
- end
- end,0)
- end
-
- function WingInfoTips:AdjustLayoutPos()
- if self.pos_x and self.pos_y then
- local layout_width = self.bg.sizeDelta.x + self.btn_conta.sizeDelta.x
- local layout_height = self.bg.sizeDelta.y
- local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
- local iphone_x_offset = math.max(ClientConfig.iphone_x_offset_left,ClientConfig.iphone_x_offset_right)
- if x + layout_width + 50 + iphone_x_offset * 2 > SrcScreenWidth then
- x = SrcScreenWidth - layout_width - 90 - iphone_x_offset * 2
- end
- if y < layout_height + 50 then
- y = layout_height + 50
- end
- self.layout.anchoredPosition = Vector2(x,y - ScreenHeight)
- end
- end
|