UITipsView.lua 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. local UITipsView = require("UITips/UITipsView_Generate")
  2. local IconItemCtr = require("Common/IconItemCtr")
  3. local ColorExtension = require("ColorExtension")
  4. local TaskJumpCtr = require("Common/TaskJumpCtr")
  5. local cfgId, state, itemCount, chosenCount, targetData, ItemOpenTime
  6. local itemType
  7. function UITipsView:OnAwake(data)
  8. self.controller = require("UITips/UITipsCtr"):new()
  9. self.controller:Init(self)
  10. self.controller:SetData(data)
  11. end
  12. function UITipsView:AddEventListener()
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.COIN_CHANGED, self, self.RefreshMoney)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.DIAMOND_CHANGED, self, self.RefreshMoney)
  15. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.ITEM_CHANGE, self, self.RefreshItem)
  16. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.FASHION_LIST_CHANGE, self, self.RefreshFasionPaperOwnSign)
  17. end
  18. function UITipsView:FillContent(data, uiBase)
  19. self.uiBase = uiBase
  20. local gameObject = self.uiBase:GetRoot()
  21. if gameObject ~= nil then
  22. self.gameObject = gameObject
  23. self.transform = gameObject.transform
  24. end
  25. self:InitGenerate(self.transform, data)
  26. self:Init()
  27. end
  28. function UITipsView:Init()
  29. targetData = self.controller:GetData()
  30. if targetData.tipsType == Enum.UITipsType.Skill then
  31. self:InitSkill()
  32. else
  33. self:InitItem()
  34. end
  35. end
  36. function UITipsView:InitSkill()
  37. local skillId = targetData.cfgId
  38. local skillLevel = targetData.num or 0
  39. local skillCfgData = ManagerContainer.CfgMgr:GetSkillCfgByType(Enum.SkillType.Active, skillId, skillLevel)
  40. local skillLevelCfgId = CommonUtil.GetSkillCfgIdByIdAndLv(skillId, skillLevel)
  41. local skillLevelCfgData = ManagerContainer.CfgMgr:GetSkillLevelCfgById(skillLevelCfgId)
  42. local skillShowData = ManagerContainer.CfgMgr:GetSkillShowCfgById(skillId)
  43. CommonUtil.SetTotalChildrenGray(self.iconItem.icon, false)
  44. self.iconItem.icon.image.sprite = nil
  45. CommonUtil.LoadIcon(self, skillCfgData and skillCfgData.Icon or nil, function (sprite)
  46. self.iconItem.icon.image.sprite = sprite
  47. end, self.iconItem, 'IconIcon')
  48. self.iconItem.frame.image.sprite = nil
  49. CommonUtil.LoadIcon(self, Constant.Quality_White_Frame_Icon, function (sprite)
  50. self.iconItem.frame.image.sprite = sprite
  51. end, self.iconItem, 'IconFrame')
  52. self.iconItem.num.text.text = (I18N.SetLanguageValue('Lv') .. tostring(skillLevel))
  53. self.iconItem.frame.image.material = nil
  54. -- self.iconItem.frameLead:SetActive(false)
  55. self.iconItem.level:SetActive(false)
  56. self.iconItem.job:SetActive(false)
  57. self.iconItem.limited:SetActive(false)
  58. self.iconItem.sexLabel:SetActive(false)
  59. self.iconItem.cardLabel:SetActive(false)
  60. self.iconItem.num:SetActive(true)
  61. self.iconItem.refineLv:SetActive(false)
  62. self.iconItem.qualityFX:SetActive(false)
  63. self.iconItem.repeatSign:SetActive(false)
  64. self.iconItem.conertips:SetActive(false)
  65. self.iconItem.vip:SetActive(false)
  66. self.iconItem.redPoint:SetActive(false)
  67. if skillCfgData then
  68. self.textName.text.text = string.formatbykey(skillCfgData.Name)
  69. else
  70. self.textName.text.text = ''
  71. end
  72. if skillLevelCfgData then
  73. self.type1.text2.text.text = tostring(skillLevelCfgData.CD) .. string.formatbykey('S')
  74. self.type2.text2.text.text = tostring(skillLevelCfgData.Cost) .. string.formatbykey('sp')
  75. local descParam = skillLevelCfgData.DescParam
  76. if descParam then
  77. if type(descParam) == 'table' then
  78. self.desTxt.text.text = string.formatbykey(skillLevelCfgData.Desc, unpack(descParam))
  79. else
  80. self.desTxt.text.text = string.formatbykey(skillLevelCfgData.Desc, descParam)
  81. end
  82. else
  83. self.desTxt.text.text = string.formatbykey(skillLevelCfgData.Desc)
  84. end
  85. else
  86. self.type1.text2.text.text = '-'
  87. self.type2.text2.text.text = '-'
  88. self.desTxt.text.text = ''
  89. end
  90. local tags = nil
  91. local num = 0
  92. if skillShowData then
  93. tags = skillShowData.Label
  94. if tags then
  95. if type(tags[1]) == 'number' then
  96. tags = {tags}
  97. end
  98. num = #tags
  99. end
  100. end
  101. for i = 1, 4 do
  102. local skillTagItem = self['skillTagItem' .. i]
  103. if skillTagItem then
  104. if i <= num then
  105. local tagId = tags[i][1]
  106. local colorId = tags[i][2]
  107. skillTagItem:SetActive(true)
  108. skillTagItem.bgColorID.image.color = ColorExtension.HexStringToColor(I18N.SetLanguageValue('ColorID' .. tostring(colorId)))
  109. skillTagItem.textSkillID.uILocalizeScript:SetContent('SkillTagID' .. tostring(tagId))
  110. else
  111. skillTagItem:SetActive(false)
  112. end
  113. end
  114. end
  115. self.type1:SetActive(true)
  116. self.type2:SetActive(true)
  117. self.type1.text1.uILocalizeScript:SetContent('SkillCD1')
  118. self.type2.text1.uILocalizeScript:SetContent('SkillCost')
  119. self.type3:SetActive(false)
  120. self.type4:SetActive(false)
  121. self.type5:SetActive(false)
  122. self.type6:SetActive(false)
  123. self.skillTag:SetActive(true)
  124. self.baseAttr:SetActive(false)
  125. self.costMaterials:SetActive(false)
  126. self.btnBox:SetActive(false)
  127. end
  128. function UITipsView:RefreshTimer()
  129. if not ItemOpenTime then
  130. self:StopRefreshTimer()
  131. return
  132. end
  133. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(ItemOpenTime)
  134. if remainTime > 0 then
  135. self.box.cD.number.text.text = I18N.SetLanguageValue("CDitemTime",DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  136. else
  137. self.box.cD.number.text.text = I18N.SetLanguageValue("CDitemDesc")
  138. end
  139. if not remainTime or remainTime <= 0 then
  140. self:StopRefreshTimer()
  141. else
  142. if self.refreshTimer then
  143. local validTime = nil
  144. if remainTime >= 86400 then
  145. validTime = remainTime % 3600
  146. if validTime == 0 then validTime = 3600 end
  147. elseif remainTime >= 3600 then
  148. validTime = remainTime % 60
  149. if validTime == 0 then validTime = 60 end
  150. else
  151. validTime = 1
  152. end
  153. if validTime then
  154. self.refreshTimer.duration = validTime
  155. else
  156. self:StopRefreshTimer()
  157. end
  158. end
  159. end
  160. end
  161. function UITipsView:StopRefreshTimer()
  162. if self.refreshTimer then
  163. self.refreshTimer:Stop()
  164. end
  165. end
  166. function UITipsView:DisposeRefreshTimer()
  167. self:StopRefreshTimer()
  168. self.refreshTimer = nil
  169. end
  170. function UITipsView:StartRefreshTimer()
  171. local timer = self.refreshTimer
  172. if not timer then
  173. timer = Timer.New(slot(self.RefreshTimer,self), 1, -1)
  174. self.refreshTimer = timer
  175. end
  176. if not timer.running then
  177. timer:Start()
  178. end
  179. end
  180. function UITipsView:InitItem()
  181. --targetData = {cfgId = 100001, num = 100, state = CommonUtil.Get2Powers(Enum.TipsEnterType.BaseAttr, Enum.TipsEnterType.Cost)}
  182. cfgId = targetData.cfgId
  183. state = targetData.state or 0
  184. itemCount = targetData.num or 0
  185. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  186. if itemCfgData == nil then
  187. LogError("cant find "..cfgId.." in itemcfg");
  188. return
  189. end
  190. local cfgData = self:GetCfgDataAndType(cfgId,itemCfgData.ResType,itemCfgData.ComposeItem)
  191. itemType = itemCfgData.ResType
  192. if cfgData == nil then
  193. cfgData = itemCfgData
  194. end
  195. local data1 = {cfgId = cfgId, num = itemCount, starLv = targetData.starLv}
  196. IconItemCtr:SetData(self, self.iconItem, data1, Enum.ItemIEnterType.Bag)
  197. if itemCfgData.ItemTime and itemCfgData.ItemTime == 7 then --延时开启道具类型
  198. self.box.cD:SetActive(true)
  199. ItemOpenTime = (targetData.timeStamp + itemCfgData.ItemTimeCd) * 1000
  200. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(ItemOpenTime)
  201. if remainTime > 0 then
  202. self.box.cD.number.text.text = I18N.SetLanguageValue("CDitemTime",DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  203. else
  204. self.box.cD.number.text.text = I18N.SetLanguageValue("CDitemDesc")
  205. end
  206. self:StartRefreshTimer()
  207. else
  208. self.box.cD:SetActive(false)
  209. ItemOpenTime = nil
  210. end
  211. self.textName.text.text = I18N.T(itemCfgData.Name)
  212. self.type1.text1.uILocalizeScript:SetContent('Type')
  213. self.type1.text2.text.text = I18N.T("ItemTypeDes_"..itemType)
  214. local dcs = cfgData.Desc or itemCfgData.Describe
  215. self.desTxt.text.text = I18N.T(dcs)
  216. local _type2State = itemType == Enum.ItemType.Equip or itemType == Enum.ItemType.Card or itemType == Enum.ItemType.FashionPaper;
  217. self.type2:SetActive(_type2State)
  218. self.type2.text1.uILocalizeScript:SetContent('Position')
  219. local _type3State = (itemType == Enum.ItemType.Gift or itemType == Enum.ItemType.Income or itemType == Enum.ItemType.OptionalGift)
  220. self.type3:SetActive(_type3State)
  221. local _type4State = itemType == Enum.ItemType.FashionPaper
  222. self.type4:SetActive(_type4State)
  223. local _type5State = (itemType == Enum.ItemType.HeadFrame or (itemCfgData.ItemTime > 0 and itemCfgData.ItemTime ~= Enum.ActivitiesItemType.ForeverItem and itemCfgData.ItemTime ~= Enum.ActivitiesItemType.SeasonForeverItem and itemCfgData.ItemTime ~= Enum.ActivitiesItemType.DelayOpenItem))
  224. self.type5:SetActive(_type5State);
  225. local _type6State = itemType == Enum.ItemType.PetStamp
  226. self.type6:SetActive(_type6State);
  227. if _type5State or itemType == Enum.ItemType.Income then
  228. self.box.btn_Open.text.text = I18N.T("BtnUse");
  229. else
  230. self.box.btn_Open.text.text = I18N.T("BtnOpen");
  231. end
  232. if itemType == Enum.ItemType.Equip then
  233. self.type2.text2.text.text = I18N.T(Enum.EquipTypeName[cfgData.Type])
  234. elseif itemType == Enum.ItemType.Card then
  235. self.type2.text2.text.text = I18N.T(Enum.EquipTypeName[cfgData.CardLocation])
  236. elseif itemType == Enum.ItemType.FashionPaper then
  237. local fashionData = ManagerContainer.CfgMgr:GetFashionById(cfgData.FashionId)
  238. self:RefreshJobOnly(fashionData.FashionUseJob)
  239. self.type2.text2.text.text = I18N.T('FashionSlot_' .. fashionData.FashionLocation)
  240. elseif itemType == Enum.ItemType.Gift or itemType == Enum.ItemType.Compose or itemType == Enum.ItemType.Income or itemType == Enum.ItemType.OptionalGift then
  241. local _enough, _needLevel, _level = self:JudgeItemNeedLevel(itemCfgData)
  242. if _needLevel <= 0 then
  243. self.type3:SetActive(false)
  244. else
  245. self.type3.text2.text.text = tostring(_needLevel);
  246. if not _enough then
  247. CommonUtil.SetTextColor(self.type3.text2.text, Constant.RedColorText)
  248. end
  249. end
  250. elseif itemType == Enum.ItemType.HeadFrame then
  251. local _timeStamp = itemCfgData.ComposeItem
  252. if _timeStamp then
  253. if _timeStamp[1][2] == nil or _timeStamp[1][2] <= 0 then
  254. self.type5.text2.text.text = I18N.T("Forever");
  255. else
  256. local _timeStr = "";
  257. local _timeSecond = _timeStamp[1][2] * 3600;
  258. if _timeSecond >= 60 and _timeSecond < Constant.OneDaySeconds then
  259. _timeStr = DateTimeUtil.convertSeconds2TimeStr1(_timeSecond, true, false, false);
  260. else
  261. _timeStr = DateTimeUtil.convertSeconds2TimeStr1(_timeSecond, false, false, false);
  262. end
  263. self.type5.text2.text.text = _timeStr;
  264. end
  265. end
  266. elseif itemType == Enum.ItemType.PetStamp then
  267. CommonUtil.LoadIcon(self, Constant.Pet_Stamp_Slot_Icons[cfgData.Type], function (sprite)
  268. self.type6.image.image.sprite = sprite
  269. end)
  270. self.type1:SetActive(false)
  271. end
  272. if targetData.isPreview then
  273. self.type5.text2.text.text = I18N.T("TimeShowTips")
  274. else
  275. if itemCfgData.ItemTime > 0 and itemCfgData.ItemTime ~= Enum.ActivitiesItemType.ForeverItem and itemCfgData.ItemTime ~= Enum.ActivitiesItemType.SeasonForeverItem then
  276. if targetData.timeStamp then
  277. if targetData.timeStamp > 0 then
  278. local curTime = ManagerContainer.LuaTimerMgr:GetTimeSecond()
  279. local delta = targetData.timeStamp - curTime
  280. if delta <= 0 then
  281. self.type5.text2.text.text = I18N.T("DscSeasonResult6")
  282. elseif delta <= 60 then
  283. self.type5.text2.text.text = I18N.T("LessOneMinu")
  284. else
  285. local time = DateTimeUtil.convertSeconds2TimeStr1(delta, true, false)
  286. self.type5.text2.text.text = time
  287. end
  288. else
  289. self.type5.text2.text.text = I18N.T("Forever")
  290. end
  291. else
  292. self.type5.text2.text.text = "---"
  293. end
  294. end
  295. end
  296. self.skillTag:SetActive(false)
  297. local needBase = self:BitAnd(state, Enum.TipsEnterType.BaseAttr)
  298. self.baseAttr:SetActive(needBase)
  299. if needBase then
  300. if itemType == Enum.ItemType.Equip then
  301. local baseAttrs = {}
  302. for k,v in pairs(Enum.HeroAttrType) do
  303. if cfgData[k] and cfgData[k] ~= 0 then
  304. table.insert(baseAttrs, {Enum.HeroAttrType[k], cfgData[k]})
  305. end
  306. end
  307. local index = 0
  308. for k, v in pairs(baseAttrs) do
  309. index = index + 1
  310. CommonUtil.BatchCreateItemsLoopWithMould(self, self.attrItem, self.baseAttr.grid.transform, v, index, Enum.ItemIEnterType.Attr)
  311. end
  312. elseif itemType == Enum.ItemType.Card then
  313. local index = 0
  314. for _,v in pairs(CommonUtil.DeserializeCfgItemList(cfgData.Attribute1)) do
  315. index = index + 1
  316. CommonUtil.BatchCreateItemsLoopWithMould(self, self.attrItem, self.baseAttr.grid.transform, v, index, Enum.ItemIEnterType.Attr)
  317. end
  318. elseif itemType == Enum.ItemType.PetStamp then
  319. local petStampData = ManagerContainer.DataMgr.PetDataMgr.petStampData:GetPetStampDataMapById(targetData.id)
  320. local lv = 1
  321. if petStampData then
  322. lv = petStampData.lv
  323. end
  324. local lvCfgData = ManagerContainer.CfgMgr:GetPetEquipExpCfgDataByLvAndCfgId(lv, cfgId)
  325. local index = 0
  326. for _,v in pairs(lvCfgData.Nature) do
  327. index = index + 1
  328. CommonUtil.BatchCreateItemsLoopWithMould(self, self.attrItem, self.baseAttr.grid.transform, v, index, Enum.ItemIEnterType.Attr)
  329. end
  330. self.iconItem.num.text.text = I18N.SetLanguageValue("Lv")..lv
  331. elseif itemType == Enum.ItemType.FashionPaper then
  332. local fashionData = ManagerContainer.CfgMgr:GetFashionById(cfgData.FashionId)
  333. local fashionAttrs = fashionData.FashionAttr
  334. -- 一条属性的时候
  335. if type(fashionAttrs[1]) == 'number' then
  336. fashionAttrs = {fashionAttrs}
  337. end
  338. local index = 0
  339. for _,v in pairs(fashionAttrs) do
  340. index = index + 1
  341. CommonUtil.BatchCreateItemsLoopWithMould(self, self.attrItem, self.baseAttr.grid.transform, v, index, Enum.ItemIEnterType.Attr)
  342. end
  343. elseif itemType == Enum.ItemType.HeadFrame then
  344. local baseAttrs = {}
  345. local _Attrs = cfgData.HeadFrameQuality;
  346. if _Attrs then
  347. for _k, _v in pairs(_Attrs) do
  348. if _v[1] and _v[2] then
  349. table.insert(baseAttrs, {_v[1],_v[2]});
  350. end
  351. end
  352. local index = 0
  353. for k, v in pairs(baseAttrs) do
  354. index = index + 1
  355. CommonUtil.BatchCreateItemsLoopWithMould(self, self.attrItem, self.baseAttr.grid.transform, v, index, Enum.ItemIEnterType.Attr)
  356. end
  357. end
  358. end
  359. end
  360. self:RefreshMakeMaterials()
  361. local boxState = self:BitAnd(state, Enum.TipsEnterType.BtnDecompose)
  362. or self:BitAnd(state, Enum.TipsEnterType.BtnEquip) or self:BitAnd(state, Enum.TipsEnterType.BtnInfo)
  363. or self:BitAnd(state, Enum.TipsEnterType.BtnOK) or self:BitAnd(state, Enum.TipsEnterType.BtnOpen)
  364. or self:BitAnd(state, Enum.TipsEnterType.BtnCompose) or self:BitAnd(state, Enum.TipsEnterType.SliderBox)
  365. or self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition) or self:BitAnd(state, Enum.TipsEnterType.BtnInsertCard)
  366. or self:BitAnd(state, Enum.TipsEnterType.BtnUse) or self:BitAnd(state, Enum.TipsEnterType.BtnGoto)
  367. or self:BitAnd(state, Enum.TipsEnterType.ItemNumber)
  368. self.btnBox:SetActive(targetData.displayBtn and boxState)
  369. self.btn_Decompose:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnDecompose))
  370. local equipState = self:BitAnd(state, Enum.TipsEnterType.BtnEquip)
  371. local equipComposeState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(1)
  372. self.btn_EquipCompose:SetActive(equipState and equipComposeState)
  373. self.btn_Info:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnInfo))
  374. self.btn_OK:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnOK))
  375. self.btn_Open:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnOpen))
  376. self.btn_InsertCard:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnInsertCard))
  377. self.btn_Use:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnUse))
  378. self.btn_Goto:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnGoto))
  379. self:SetBoxState();
  380. self:SetBoxItemNumber()
  381. if self:BitAnd(state, Enum.TipsEnterType.SliderBox) or self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition) then
  382. self:SetBoxSlider();
  383. if self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition) then
  384. self:SetUseItemIcon();
  385. end
  386. end
  387. end
  388. -------------------宝箱相关start----------------------
  389. --设置打开宝箱需要条件的按钮
  390. function UITipsView:SetBoxState()
  391. self.box:SetActive(self:BitAnd(state, Enum.TipsEnterType.SliderBox) or self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition) or self:BitAnd(state, Enum.TipsEnterType.ItemNumber))
  392. local needSliderComs = self:BitAnd(state, Enum.TipsEnterType.SliderComs)
  393. self.btnMinus:SetActive(needSliderComs)
  394. self.btnPlus:SetActive(needSliderComs)
  395. self.boxSliderHande:SetActive(needSliderComs)
  396. self.slider.slider.interactable = needSliderComs
  397. self.box:SetActive(self:BitAnd(state, Enum.TipsEnterType.SliderBox) or self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition))
  398. self.box.btn_Open:SetActive(self:BitAnd(state, Enum.TipsEnterType.SliderBox) and not self:BitAnd(state, Enum.TipsEnterType.BtnBoxCompose))
  399. self.box.btn_Open1:SetActive(self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition))
  400. self.box.btn_Compose:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnBoxCompose))
  401. end
  402. function UITipsView:SetBoxItemNumber()
  403. if not self:BitAnd(state, Enum.TipsEnterType.ItemNumber) then
  404. self.box.itemNumber:SetActive(false)
  405. return
  406. end
  407. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  408. if not itemCfgData or #itemCfgData.ComposeItem <= 0 then
  409. self.box.itemNumber:SetActive(false)
  410. return
  411. end
  412. local composeData = itemCfgData.ComposeItem[1]
  413. if not composeData then
  414. self.box.itemNumber:SetActive(false)
  415. return
  416. end
  417. local itemCfgData1 = ManagerContainer.CfgMgr:GetItemById(composeData[1])
  418. if not itemCfgData1 then
  419. self.box.itemNumber:SetActive(false)
  420. return
  421. end
  422. self.box.itemNumber:SetActive(true)
  423. CommonUtil.LoadIcon(self, itemCfgData1.MiniIcon, function(sprite)
  424. if sprite then
  425. self.box.itemNumber.icon.image.sprite = sprite
  426. self.box.itemNumber.icon.image.enabled = true
  427. end
  428. end)
  429. self.box.itemNumber.number.text.text = ''
  430. end
  431. function UITipsView:RefreshBoxItemNumber()
  432. if not self:BitAnd(state, Enum.TipsEnterType.ItemNumber) then
  433. return
  434. end
  435. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  436. if not itemCfgData or #itemCfgData.ComposeItem <= 0 then
  437. return
  438. end
  439. local composeData = itemCfgData.ComposeItem[1]
  440. if not composeData then
  441. return
  442. end
  443. local itemCfgData1 = ManagerContainer.CfgMgr:GetItemById(composeData[1])
  444. if not itemCfgData1 then
  445. return
  446. end
  447. local num = tonumber(composeData[2]) * chosenCount
  448. if itemCfgData.ResType == Enum.ItemType.Income then
  449. local levelData = ManagerContainer.LuaBattleMgr:GetCurrentLevelData()
  450. if levelData then
  451. if itemCfgData1.ResType == Enum.ItemType.RoleBaseExp then
  452. local _rewardIntervalTime = GlobalConfig.Instance:GetConfigIntValue(47)
  453. num = tonumber(levelData.BaseExpOl) * num / _rewardIntervalTime
  454. elseif itemCfgData1.ResType == Enum.ItemType.ParterExp then
  455. local _rewardIntervalTime = GlobalConfig.Instance:GetConfigIntValue(47)
  456. num = tonumber(levelData.ParterOl) * num / _rewardIntervalTime
  457. elseif itemCfgData1.ResType == Enum.ItemType.Coin then
  458. local _rewardIntervalTime = GlobalConfig.Instance:GetConfigIntValue(47)
  459. num = tonumber(levelData.ZenyOl) * num / _rewardIntervalTime
  460. elseif itemCfgData1.ResType == Enum.ItemType.SkillExp then
  461. local _rewardIntervalTime = GlobalConfig.Instance:GetConfigIntValue(47)
  462. num = tonumber(levelData.CruiseOl) * num / _rewardIntervalTime
  463. end
  464. end
  465. end
  466. self.box.itemNumber.number.text.text = CommonUtil.FormatNumber(num)
  467. end
  468. --判断玩家能选中的宝箱开启的最大个数
  469. function UITipsView:JudgeMaxCount() --判断玩家能选中的最大数量
  470. local _maxCount = itemCount;
  471. if self:BitAnd(state, Enum.TipsEnterType.SliderBoxCondition) then
  472. local _itemData = ManagerContainer.CfgMgr:GetItemById(targetData.cfgId);
  473. local _costItem = _itemData.Costitem;
  474. local _costItemCount = CommonUtil.GetOwnResCountByItemId(_costItem[1][1]);
  475. local _canUseCount = math.floor(_costItemCount / _costItem[1][2]);
  476. if _canUseCount < _maxCount then
  477. _maxCount = _canUseCount;
  478. end
  479. end
  480. return _maxCount;
  481. end
  482. --判断是否要根据当前的滑动条的值改变选中的数量
  483. function UITipsView:JudgeNeedChangeValue()
  484. local _needChange = false;
  485. local _changedValue = chosenCount;
  486. if itemCount > 0 then
  487. local _changedCount = self.slider.slider.value;
  488. if _changedCount == 0 then
  489. _changedCount = 1;
  490. self.slider.slider.value = _changedCount
  491. end
  492. if _changedCount ~= chosenCount then
  493. _needChange = true;
  494. _changedValue = _changedCount;
  495. end
  496. end
  497. return _needChange, _changedValue;
  498. end
  499. --改变选中的数量
  500. function UITipsView:ChangeChosenCount(_up)
  501. if _up then --增加一个
  502. local _newCount = chosenCount + 1;
  503. if _newCount <= itemCount then chosenCount = _newCount; end
  504. else
  505. if chosenCount > 1 then chosenCount = chosenCount - 1; end
  506. end
  507. end
  508. --刷新滑动条和选中的宝箱的数量
  509. function UITipsView:RefreshSliderBoxNum(_needChangeSlider)
  510. self.box.numBox.num.text.text = tostring(chosenCount);-- .. "/" .. tostring(itemCount);
  511. if _needChangeSlider then
  512. self.slider.slider.value = chosenCount;
  513. end
  514. self:RefreshBoxNum();
  515. self:RefreshBoxItemNumber()
  516. end
  517. --刷新宝箱开启按钮,这个是只设置btn_Open1按钮的
  518. function UITipsView:RefreshBoxNum()
  519. --设置btn_Open1下的开启宝箱需要道具的数量的显示
  520. local _itemData = ManagerContainer.CfgMgr:GetItemById(cfgId);
  521. if _itemData and _itemData.Costitem ~= nil and #_itemData.Costitem[1] > 0 then
  522. self.box.btn_Open1.num.text.text = _itemData.Costitem[1][2] * chosenCount;
  523. end
  524. local _canOpenMaxCount = self:JudgeMaxCount();
  525. self.box.btn_Open1.button.interactable = _canOpenMaxCount >= chosenCount;
  526. end
  527. --点击减少按钮
  528. function UITipsView:MinusFun()
  529. self:ChangeChosenCount(false);
  530. self:RefreshSliderBoxNum(true);
  531. end
  532. --点击增加按钮
  533. function UITipsView:PlusFun()
  534. self:ChangeChosenCount(true);
  535. self:RefreshSliderBoxNum(true);
  536. end
  537. --滑动条的数值有改变的时候
  538. function UITipsView:OnSliderValueChanged(slider, value)
  539. local _needChange, _changedValue = self:JudgeNeedChangeValue();
  540. if _needChange then
  541. chosenCount = _changedValue;
  542. end
  543. self:RefreshSliderBoxNum(false);
  544. end
  545. function UITipsView:TransComposeItemCount()
  546. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  547. if not itemCfgData or not itemCfgData.Costitem then return end
  548. local costNum = itemCfgData.Costitem[1][2]
  549. itemCount = math.floor(itemCount / costNum)
  550. end
  551. function UITipsView:SetBoxSlider()
  552. if itemType == Enum.ItemType.Gift
  553. or itemType == Enum.ItemType.HeadFrame
  554. or itemType == Enum.ItemType.Income
  555. or itemType == Enum.ItemType.Compose then
  556. if itemType == Enum.ItemType.Compose then
  557. self:TransComposeItemCount()
  558. end
  559. local _showSlider = itemCount > 1;
  560. self.box.numBox:SetActive(_showSlider);
  561. chosenCount = itemCount; --默认选中最大数量
  562. if _showSlider then
  563. self.uiBase:AddButtonUniqueEventListener(self.btnMinus.button, self, self.MinusFun);
  564. self.uiBase:AddButtonUniqueEventListener(self.btnPlus.button, self, self.PlusFun);
  565. self.uiBase:AddSliderUniqueEventListener(self.slider.slider, self, self.OnSliderValueChanged, nil)
  566. self.slider.slider.maxValue = itemCount;
  567. self:RefreshSliderBoxNum(true);
  568. else
  569. self:RefreshBoxNum();
  570. self:RefreshBoxItemNumber()
  571. end
  572. --elseif itemType == Enum.ItemType.Compose then
  573. -- chosenCount = itemCount
  574. -- self.box.numBox:SetActive(true);
  575. -- local cfgData = ManagerContainer.CfgMgr:GetItemById(targetData.cfgId);
  576. -- self.slider.slider.maxValue = cfgData.Costitem[1][2];
  577. -- self.box.numBox.num.text.text = chosenCount.. "/" .. cfgData.Costitem[1][2];
  578. -- self.slider.slider.value = chosenCount;
  579. end
  580. end
  581. --设置Btn_Open1按钮的用到的item的icon
  582. function UITipsView:SetUseItemIcon()
  583. local _itemData = ManagerContainer.CfgMgr:GetItemById(targetData.cfgId);
  584. local _costItem = ManagerContainer.CfgMgr:GetItemById(_itemData.Costitem[1][1]);
  585. CommonUtil.LoadIcon(self, _costItem.Icon, function (sprite)
  586. self.box.btn_Open1.icon.image.sprite = sprite
  587. end)
  588. end
  589. -------------------宝箱相关end------------------------
  590. function UITipsView:RefreshMoney()
  591. if itemType ~= Enum.ItemType.FashionPaper then
  592. return
  593. end
  594. self:RefreshMakeMaterials()
  595. end
  596. function UITipsView:RefreshItem()
  597. if itemType ~= Enum.ItemType.FashionPaper then
  598. return
  599. end
  600. self:RefreshMakeMaterials()
  601. end
  602. function UITipsView:RefreshMakeMaterials()
  603. local needCost = self:BitAnd(state, Enum.TipsEnterType.Cost)
  604. local enoughCost = true
  605. self.costMaterials:SetActive(needCost)
  606. if needCost then
  607. if itemType == Enum.ItemType.FashionPaper then
  608. local cfgData = ManagerContainer.CfgMgr:GetFashionPaperById(cfgId)
  609. local makeMaterial = clone(cfgData.MakeMaterial)
  610. if type(makeMaterial[1]) == 'number' then
  611. makeMaterial = {makeMaterial}
  612. end
  613. local num = #makeMaterial
  614. local materialCfgId = nil
  615. local materialNum = nil
  616. local moneyCfgId = nil
  617. local moneyNum = nil
  618. for i = num, 1, -1 do
  619. materialCfgId = makeMaterial[i][1]
  620. materialNum = makeMaterial[i][2]
  621. local ownCost = CommonUtil.GetOwnResCountByItemId(materialCfgId)
  622. if ownCost < materialNum then
  623. enoughCost = false
  624. end
  625. local materialItemCfgData = ManagerContainer.CfgMgr:GetItemById(materialCfgId)
  626. if materialItemCfgData.ResType == Enum.ItemType.Coin
  627. or materialItemCfgData.ResType == Enum.ItemType.Diamond then
  628. moneyCfgId = materialCfgId
  629. moneyNum = materialNum
  630. -- 移除一个货币显示到列表,会单独显示
  631. table.remove(makeMaterial, i)
  632. break
  633. end
  634. end
  635. num = #makeMaterial
  636. if num > 4 then num = 4 end
  637. local index = 0
  638. for _,v in pairs(makeMaterial) do
  639. index = index + 1
  640. CommonUtil.BatchCreateItemsLoopWithMould(self, self.attrItem, self.costMaterials.grid.transform, v, index, Enum.ItemIEnterType.CostMat)
  641. end
  642. self:RefreshFasionPaperOwnSign()
  643. return
  644. end
  645. end
  646. self.btn_Compose:SetActive(self:BitAnd(state, Enum.TipsEnterType.BtnCompose))
  647. CommonUtil.SetTotalChildrenGray(self.btn_Compose, not enoughCost)
  648. end
  649. function UITipsView:JudgeItemNeedLevel(_itemCfg)
  650. local _needLevel = _itemCfg.NeedLevel or 0;
  651. local _level = ManagerContainer.DataMgr.UserData:GetRoleLv();
  652. return _needLevel <= _level, _needLevel, _level;
  653. end
  654. function UITipsView:BitAnd(num, lshift)
  655. local shiftNum = Bit.lshift (1, lshift)
  656. return Bit.band(num, shiftNum) == shiftNum
  657. end
  658. function UITipsView:GetCfgDataAndType(cfgId,resType,composeItem)
  659. local cfgData = nil
  660. if resType == Enum.ItemType.Equip then
  661. cfgData = ManagerContainer.CfgMgr:GetEquipById(cfgId)
  662. if cfgData ~= nil then
  663. return cfgData
  664. end
  665. end
  666. if resType == Enum.ItemType.Card then
  667. cfgData = ManagerContainer.CfgMgr:GetCardDataById(cfgId)
  668. if cfgData ~= nil then
  669. return cfgData
  670. end
  671. end
  672. if resType == Enum.ItemType.Parter then
  673. cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(cfgId)
  674. if cfgData ~= nil then
  675. return cfgData
  676. end
  677. end
  678. if resType == Enum.ItemType.FashionPaper then
  679. cfgData = ManagerContainer.CfgMgr:GetFashionPaperById(cfgId)
  680. if cfgData ~= nil then
  681. return cfgData
  682. end
  683. end
  684. if resType == Enum.ItemType.Pet then
  685. cfgData = ManagerContainer.CfgMgr:GetPetDataById(cfgId)
  686. if cfgData ~= nil then
  687. return cfgData
  688. end
  689. end
  690. if resType == Enum.ItemType.PetStamp then
  691. cfgData = ManagerContainer.CfgMgr:GetPetEquipCfgDataById(cfgId)
  692. if cfgData ~= nil then
  693. return cfgData
  694. end
  695. end
  696. if resType == Enum.ItemType.HeadFrame then
  697. if composeItem ~= nil and #composeItem > 0 and #composeItem[1] > 0 then
  698. cfgData = ManagerContainer.CfgMgr:GetHeadFrameById(composeItem[1][1])
  699. return cfgData
  700. end
  701. end
  702. return nil
  703. end
  704. function UITipsView:RemoveEventListener()
  705. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  706. end
  707. function UITipsView:AddUIEventListener()
  708. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  709. self.uiBase:AddButtonUniqueEventListener(self.AnyBtn.button, self, self.OnClickClose)
  710. self.uiBase:AddButtonUniqueEventListener(self.btn_Decompose.button, self, self.OnClickDecomposeBtn)
  711. self.uiBase:AddButtonUniqueEventListener(self.btn_Compose.button, self, self.OnClickComposeBtn)
  712. self.uiBase:AddButtonUniqueEventListener(self.btn_EquipCompose.button, self, self.OnClickEquipBtn)
  713. self.uiBase:AddButtonUniqueEventListener(self.btn_Info.button, self, self.OnClickInfoBtn)
  714. self.uiBase:AddButtonUniqueEventListener(self.btn_OK.button, self, self.OnClickOkBtn)
  715. self.uiBase:AddButtonUniqueEventListener(self.btn_Open.button, self, self.OnClickOpenBtn)
  716. self.uiBase:AddButtonUniqueEventListener(self.box.btn_Open.button, self, self.OnClickBoxOpenBtn)
  717. self.uiBase:AddButtonUniqueEventListener(self.box.btn_Open1.button, self, self.OnClickBoxOpenBtn)
  718. self.uiBase:AddButtonUniqueEventListener(self.btn_InsertCard.button, self, self.OnInsertCardBtn)
  719. self.uiBase:AddButtonUniqueEventListener(self.btn_Goto.button, self, self.OnGotoClick)
  720. self.uiBase:AddButtonUniqueEventListener(self.box.btn_Compose.button, self, self.OnComposeClick)
  721. end
  722. function UITipsView:OnClickClose(button, params)
  723. self:UIClose()
  724. end
  725. function UITipsView:OnInsertCardBtn(button, params)
  726. if self.controller:CanEquipCard() then
  727. self:UIClose()
  728. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UICardEquipList, self.controller:GetCfgId())
  729. else
  730. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("CardWearTips")
  731. return
  732. end
  733. end
  734. function UITipsView:OnClickDecomposeBtn(button, params)
  735. if itemType ~= Enum.ItemType.FashionPaper then
  736. return
  737. end
  738. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  739. local itemName1 = I18N.SetLanguageValue(itemCfgData.Name)
  740. local itemNum1 = CommonUtil.GetOwnResCountByItemId(cfgId)
  741. local fashionPaperCfgData = ManagerContainer.CfgMgr:GetFashionPaperById(cfgId)
  742. local resolveItem = fashionPaperCfgData.ResolveItem
  743. local content = ""
  744. for i = 1, #resolveItem do
  745. local cfgId = resolveItem[i][1]
  746. local num = resolveItem[i][2]
  747. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  748. local quality = itemCfgData.Quality
  749. local name = I18N.SetLanguageValue(itemCfgData.Name)
  750. content = content ..string.format(Constant.ColorTextArray[quality],name.."X"..(itemNum1 * num))
  751. if i < #resolveItem then
  752. content = content .. string.format("<color=#000000>%s</color>", ",")
  753. end
  754. end
  755. local data = {"DecomposeFashionSure", {itemName1, itemNum1, content}, nil, self, self.SureDecomposeFashion}
  756. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  757. end
  758. function UITipsView:RefreshFasionPaperOwnSign()
  759. if itemType ~= Enum.ItemType.FashionPaper then
  760. return
  761. end
  762. local fashionPaperData = ManagerContainer.CfgMgr:GetFashionPaperById(cfgId)
  763. local owned = ManagerContainer.DataMgr.FashionData:Contains(fashionPaperData.FashionId)
  764. self.btn_Compose:SetActive(not owned)
  765. self.btn_Decompose:SetActive(owned)
  766. end
  767. function UITipsView:SureDecomposeFashion()
  768. self.controller:SendDecomposeMsg()
  769. self:UIClose()
  770. end
  771. function UITipsView:RefreshJobOnly(jobIds)
  772. if not jobIds then
  773. self.type4:SetActive(false)
  774. return
  775. end
  776. local len1 = #jobIds
  777. if len1 <= 0 then
  778. self.type4:SetActive(false)
  779. return
  780. end
  781. local len2
  782. if not self.jobBoxIcons then
  783. self.jobBoxIcons = {}
  784. len2 = 0
  785. else
  786. len2 = #self.jobBoxIcons
  787. end
  788. self.type4.jobBox.icon:SetActive(false)
  789. local parent = self.type4.jobBox.icon.transform.parent
  790. for i = 1, len1 do
  791. local jobBoxIcon
  792. if i <= len2 then
  793. jobBoxIcon = self.jobBoxIcons[i]
  794. else
  795. jobBoxIcon = {}
  796. local go = CommonUtil.Instantiate(self.type4.jobBox.icon, parent)
  797. jobBoxIcon.go = go
  798. jobBoxIcon.image = go:GetComponent(Enum.TypeInfo.Image)
  799. self.jobBoxIcons[i] = jobBoxIcon
  800. end
  801. local jobCfgData = ManagerContainer.CfgMgr:GetJobDataById(jobIds[i])
  802. jobBoxIcon.go:SetActive(true)
  803. jobBoxIcon.image.enabled = false
  804. jobBoxIcon.image.sprite = nil
  805. CommonUtil.CloseUIClearAsyncSeqIds(jobBoxIcon)
  806. if jobCfgData then
  807. CommonUtil.LoadIcon(self, jobCfgData.JobIcon, function(sprite)
  808. jobBoxIcon.image.enabled = true
  809. jobBoxIcon.image.sprite = sprite
  810. end, jobBoxIcon, 'JobIcon')
  811. end
  812. end
  813. for i = len1 + 1, len2 do
  814. local jobBoxIcon = self.jobBoxIcons[i]
  815. jobBoxIcon.go:SetActive(false)
  816. jobBoxIcon.image.sprite = nil
  817. end
  818. end
  819. function UITipsView:DisposeJobOnly()
  820. if self.jobBoxIcons then
  821. for _, jobBoxIcon in pairs(self.jobBoxIcons) do
  822. CommonUtil.CloseUIClearAsyncSeqIds(jobBoxIcon)
  823. CommonUtil.DestroyGO(jobBoxIcon.go)
  824. jobBoxIcon.go = nil
  825. jobBoxIcon.image = nil
  826. end
  827. self.jobBoxIcons = nil
  828. end
  829. end
  830. function UITipsView:SureComposeFashion()
  831. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIFashionCompose, {cfgId = cfgId})
  832. self:UIClose()
  833. end
  834. function UITipsView:OnClickComposeBtn(button, params)
  835. if itemType ~= Enum.ItemType.FashionPaper then
  836. return
  837. end
  838. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIFashionCompose, {cfgId = cfgId})
  839. self:UIClose()
  840. end
  841. function UITipsView:OnClickEquipBtn(button, params)
  842. --装备合成
  843. if itemType ~= Enum.ItemType.Equip then
  844. return
  845. end
  846. local forgeType = CommonUtil.GetEquipForgeTypeByCfgId(cfgId)
  847. local data1
  848. if forgeType ~= nil then
  849. data1 = Enum.EquipForgeType[forgeType]
  850. end
  851. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIForge1, data1)
  852. self:UIClose()
  853. end
  854. function UITipsView:OnClickInfoBtn(button, params)
  855. end
  856. function UITipsView:OnClickOkBtn(button, params)
  857. end
  858. function UITipsView:OnClickOpenBtn(button, params)
  859. if self:DelayItemOpenCheck() then
  860. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("CDitemDesc01")
  861. self:UIClose()
  862. return
  863. end
  864. local _itemData = ManagerContainer.CfgMgr:GetItemById(targetData.cfgId)
  865. local _enough, _needLevel, _level = self:JudgeItemNeedLevel(_itemData)
  866. if not _enough then
  867. local _text = I18N.SetLanguageValue("UseLvTips", tostring(_needLevel), _itemData.Name)
  868. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(_text)
  869. return
  870. end
  871. if _itemData.ResType == Enum.ItemType.OptionalGift then
  872. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIOptionalGift, {targetData.extData._id, targetData.cfgId, 1})
  873. end
  874. if _itemData.ResType == Enum.ItemType.VipProof or _itemData.ResType == Enum.ItemType.RuneShopExploreUnlock then
  875. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_USE_ITEM_REQ, {
  876. item_id = targetData.id,
  877. item_num = 1,
  878. })
  879. end
  880. if _itemData.ResType == Enum.ItemType.WishBox then
  881. ManagerContainer.DataMgr.BagData:SendWishBoxReq({id = targetData.extData._id})
  882. end
  883. if _itemData.ResType == Enum.ItemType.OptionalWishBox then
  884. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIOptionalWishBox,{targetData.extData._id,targetData.cfgId})
  885. end
  886. self:UIClose()
  887. end
  888. function UITipsView:OnGotoClick(button, params)
  889. local cfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  890. if not cfgData then
  891. return
  892. end
  893. --LogError("=======OnGotoClick================"..Inspect(cfgData))
  894. local num = CommonUtil.GetOwnResCountByItemId(cfgId)
  895. local params
  896. if itemType == Enum.ItemType.TitleMaterial and cfgData.Resolve and #cfgData.Resolve > 0 then
  897. local titleCfg = ManagerContainer.CfgMgr:GetDesignationCfgById(cfgData.Resolve[1])
  898. if titleCfg then
  899. params = titleCfg.Type
  900. local titleData = ManagerContainer.DataMgr.TitleData:GetTitleDataByTypeAndId(titleCfg.Type,titleCfg.ID)
  901. if titleCfg.Time == 0 and titleData.state > 2 then --称号已激活并且不是时限道具 可以进行多余材料分解确认操作
  902. local data = {"TitleDecomposeTips", {cfgData.Name ,num,titleCfg.DecomposeReward * num}, {cfgId,num,titleCfg.DecomposeReward * num}, self, self.DecomposeItemClickSure}
  903. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  904. return
  905. end
  906. end
  907. end
  908. self:UIClose()
  909. TaskJumpCtr:JumpBuyCfgId(cfgData.SkipInterface,params)
  910. end
  911. function UITipsView:DecomposeItemClickSure(data)
  912. local num = data[2]
  913. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_USE_ITEM_REQ, {item_id = targetData.id,item_num = num})
  914. self:UIClose()
  915. end
  916. function UITipsView:OnComposeClick(button, params)
  917. local cfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  918. if not cfgData then
  919. return
  920. end
  921. local count = CommonUtil.GetOwnResCountByItemId(cfgId)
  922. if cfgData.Costitem and count < cfgData.Costitem[1][2] then
  923. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("PetCardcompound")
  924. return
  925. end
  926. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_USE_ITEM_REQ, {
  927. item_id = targetData.id,
  928. item_num = chosenCount,
  929. })
  930. self:UIClose()
  931. end
  932. function UITipsView:DelayItemOpenCheck()
  933. if ItemOpenTime then
  934. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(ItemOpenTime)
  935. if remainTime > 0 then
  936. return true
  937. else
  938. return false
  939. end
  940. else
  941. return false
  942. end
  943. end
  944. function UITipsView:OnClickBoxOpenBtn(button, params)
  945. if chosenCount == nil or chosenCount == 0 then
  946. return
  947. end
  948. if self:DelayItemOpenCheck() then
  949. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("CDitemDesc01")
  950. self:UIClose()
  951. return
  952. end
  953. local _itemData = ManagerContainer.CfgMgr:GetItemById(targetData.cfgId)
  954. if _itemData.ResType == Enum.ItemType.HeadFrame then
  955. local headFrameId = 0
  956. if _itemData.ComposeItem ~= nil and #_itemData.ComposeItem > 0 and #_itemData.ComposeItem[1] > 0 then
  957. headFrameId = _itemData.ComposeItem[1][1]
  958. end
  959. ManagerContainer.DataMgr.HeadFrameDataMgr:UseHeadFrameItem(targetData.extData._id,headFrameId,chosenCount)
  960. else
  961. local _enough, _needLevel, _level = self:JudgeItemNeedLevel(_itemData)
  962. if not _enough then
  963. local _text = I18N.SetLanguageValue("UseLvTips", tostring(_needLevel), _itemData.Name);
  964. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(_text);
  965. else
  966. --开启宝箱
  967. if _itemData.ItemTime and _itemData.ItemTime == 7 then
  968. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_USE_ITEM_REQ, {
  969. item_id = targetData.extData._id,
  970. item_num = chosenCount,
  971. force_item_id = true
  972. })
  973. else
  974. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_USE_ITEM_REQ, {
  975. item_id = targetData.extData._id,
  976. item_num = chosenCount,
  977. })
  978. end
  979. end
  980. end
  981. self:UIClose();
  982. end
  983. function UITipsView:OnHide()
  984. end
  985. function UITipsView:OnShow(data)
  986. self.controller:SetData(data)
  987. self:Init()
  988. end
  989. function UITipsView:OnClose()
  990. end
  991. function UITipsView:OnDispose()
  992. ItemOpenTime = nil
  993. self:DisposeRefreshTimer()
  994. self:DisposeJobOnly()
  995. end
  996. return UITipsView