UITipsView.lua 37 KB

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