源战役客户端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

178 satır
7.1 KiB

  1. SplitView = SplitView or BaseClass(BaseView)
  2. SplitView.TYPE =
  3. {
  4. SPLIT = 1, --拆分
  5. BAT_USE = 2, --批量使用
  6. BAT_DROP = 3, --批量丢弃
  7. BAT_DECOMPOSE = 4, --批量分解
  8. BAT_SEND_FLOWER = 5, --批量送礼
  9. }
  10. function SplitView:__init()
  11. self.base_file = "bag"
  12. self.layout_file = "BathandleView"
  13. self.layer_name = "Top"
  14. self.use_background = true
  15. self.is_set_zdepth = true
  16. self.type = SplitView.TYPE.SPLIT
  17. self.blur_activity_bg = true
  18. self.use_show_anim = true
  19. self.use_hide_anim = true
  20. self.load_callback = function ()
  21. self:LocalSuccess()
  22. end
  23. self.open_callback = function ()
  24. self:SetData()
  25. end
  26. self.destroy_callback = function ()
  27. self:Remove()
  28. end
  29. end
  30. function SplitView:Remove()
  31. if self.icon_item then
  32. self.icon_item:ReleaseObj()
  33. self.icon_item = nil
  34. end
  35. if self.addNumComponent then
  36. if self.change_count_id then
  37. self.addNumComponent:UnBind(self.change_count_id)
  38. self.change_count_id = nil
  39. end
  40. self.addNumComponent:DeleteMe()
  41. self.addNumComponent = nil
  42. end
  43. end
  44. function SplitView:LocalSuccess()
  45. self.icon_item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self:GetChild("iconItem"))
  46. self.icon_item:ChangeCountVisible(false)
  47. self.bg_raw = self:GetChild("Window"):GetComponent("RawImage")
  48. self.nameText = self:GetChild("nameText"):GetComponent("TextMeshProUGUI")
  49. self.moneyIcon = self:GetChild("moneyIcon"):GetComponent("Image")
  50. self.moneyText = self:GetChild("moneyText"):GetComponent("TextMeshProUGUI")
  51. self.splitBtn = self:GetChild("splitBtn").gameObject
  52. self.btnCancel = self:GetChild("btnCancel").gameObject
  53. self.titleText = self:GetChild("Window/windowTitleCon/windowTitleText"):GetComponent("TextMeshProUGUI")
  54. self.tipsText = self:GetChild("tipsText"):GetComponent("TextMeshProUGUI")
  55. self.splitBtnText = self:GetChild("splitBtn/Text"):GetComponent("TextMeshProUGUI")
  56. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("tips_comm_bg6"), false)
  57. self.addNumComponent = NumberSliderComponent.New(self:GetChild("addNumCon"))
  58. self.addNumComponent:SetComponentWidth(428)
  59. self:InitEvent()
  60. end
  61. function SplitView:InitEvent()
  62. local function onBtnClickHandler(target)
  63. if target == self.splitBtn then
  64. if self.type == SplitView.TYPE.SPLIT then
  65. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15005,self.goods_vo.goods_id, self.goods_vo.type_id,self.addNumComponent:GetCurrCount())
  66. elseif self.type == SplitView.TYPE.BAT_USE then
  67. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15050,self.goods_vo.goods_id, self.goods_vo.type_id,self.addNumComponent:GetCurrCount())
  68. elseif self.type == SplitView.TYPE.BAT_DROP then
  69. local num = self.addNumComponent:GetCurrCount()
  70. local function ok()
  71. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15051, 0 , {[1] ={ goods_id = self.goods_vo.goods_id, type_id = self.goods_vo.type_id, num = num} })
  72. end
  73. local str = string.format("是否丢弃 <color=#ff2e65> %d个 %s</color> ?", num, self.goods_vo.goods_name)
  74. Alert.show(str,Alert.Type.Two,ok)
  75. elseif self.type == SplitView.TYPE.BAT_DECOMPOSE then
  76. local decompose_goods_list = {}
  77. decompose_goods_list[1] = {
  78. goods_id = self.goods_vo.goods_id,
  79. type_id = self.goods_vo.type_id,
  80. goods_num = self.addNumComponent:GetCurrCount(),
  81. }
  82. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15019,decompose_goods_list)
  83. elseif self.type == SplitView.TYPE.BAT_SEND_FLOWER then
  84. if self.extra_param_list and self.extra_param_list.send_role_id then
  85. SocialityModel:getInstance():Fire(SocialityModel.REQUEST_CCMD_EVENT, 22301, self.extra_param_list.send_role_id, self.goods_vo.type_id, self.addNumComponent:GetCurrCount(), 0)
  86. end
  87. end
  88. self:Close()
  89. elseif target == self.btnCancel then
  90. self:Close()
  91. end
  92. end
  93. AddClickEvent(self.splitBtn,onBtnClickHandler)
  94. AddClickEvent(self.btnCancel,onBtnClickHandler)
  95. local function onChangeCountHandler(count)
  96. self:ChangeCount(count)
  97. end
  98. self.change_count_id = self.addNumComponent:Bind(ComponentEvent.AddNumberComponent.CHANGE_COUNT,onChangeCountHandler)
  99. end
  100. function SplitView:Open(goods_vo, type, extra_param_list)
  101. self.goods_vo = goods_vo
  102. self.type = type or SplitView.TYPE.SPLIT
  103. self.extra_param_list = extra_param_list
  104. BaseView.Open(self)
  105. end
  106. function SplitView:SetData()
  107. if self.goods_vo then
  108. self.icon_item:SetData(self.goods_vo.type_id, self.goods_vo.goods_num)
  109. self.icon_item:SetItemSize(78, 78)
  110. self.icon_item:SetLimitState(BagModel:getInstance():GetGoodsLimitState(self.goods_vo))
  111. local min, max, step, cur = 0, self.goods_vo.goods_num-1, 1, 1
  112. self.splitBtnText.text = "确定"
  113. if self.type == SplitView.TYPE.SPLIT then
  114. self.titleText.text = "物品拆分"
  115. self.tipsText.text = "选择要拆分物品的数量"
  116. elseif self.type == SplitView.TYPE.BAT_USE then
  117. self.titleText.text = "批量使用"
  118. self.tipsText.text = "选择要使用物品的数量"
  119. min = 1
  120. max = self.goods_vo.goods_num
  121. cur = self.goods_vo.goods_num
  122. elseif self.type == SplitView.TYPE.BAT_DROP then
  123. self.titleText.text = "批量丢弃"
  124. self.tipsText.text = "选择要丢弃物品的数量"
  125. min = 1
  126. max = self.goods_vo.goods_num
  127. cur = self.goods_vo.goods_num
  128. elseif self.type == SplitView.TYPE.BAT_DECOMPOSE then
  129. self.titleText.text = "批量分解"
  130. self.tipsText.text = "选择要分解物品的数量"
  131. min = 1
  132. max = self.goods_vo.goods_num
  133. cur = self.goods_vo.goods_num
  134. elseif self.type == SplitView.TYPE.BAT_SEND_FLOWER then
  135. self.titleText.text = "批量赠送"
  136. self.tipsText.text = "选择要赠送的物品数量"
  137. min = 1
  138. max = self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num or 1
  139. -- cur = self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num or 1
  140. if self.goods_vo.type_id == 102401 then
  141. cur = self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num <= 5 and self.extra_param_list.gift_have_num or 5
  142. else
  143. cur = 1
  144. end
  145. self.splitBtnText.text = "赠送"
  146. self.icon_item:SetData(self.goods_vo.type_id, self.extra_param_list and self.extra_param_list.gift_have_num and self.extra_param_list.gift_have_num or 1)
  147. self.icon_item:ChangeCountVisible(true,999)
  148. end
  149. self.addNumComponent:InitData(min, max, step, cur)
  150. self:ChangeCount(1)
  151. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id)
  152. local name = Trim(self.goods_vo.goods_name)
  153. if self.goods_vo.type == 11 and (self.goods_vo.subtype == 10 or self.goods_vo.subtype == 11) then
  154. local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(self.goods_vo.type_id, RoleManager.Instance.mainRoleInfo.career, self.goods_vo.color)
  155. name = _name
  156. end
  157. self.nameText.text = HtmlColorTxt(name, WordManager.GetGoodsColor(self.goods_vo.color))
  158. end
  159. end
  160. function SplitView:ChangeCount(count)
  161. end