KLUIMonthCardPanel.lua 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. ---@class KLUIMonthCardPanel:UIKmlLuaPanelBase
  2. ---@field view KLUIMonthCardPanelView
  3. local KLUIMonthCardPanel = class(UIKmlLuaPanelBase)
  4. local this = KLUIMonthCardPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. local data = {
  8. width = "500",
  9. height = "500",
  10. itemid = 30030306,
  11. noclip = "1",
  12. z = -500,
  13. y = 50,
  14. mscale = "160,160,160",
  15. bgtype = "0",
  16. mfixsize = "500,500",
  17. itemcount = nil,
  18. selfrotation = "4,50,1",
  19. }
  20. self.item = GUI:Item_Create(self.view.item_model, data)
  21. self.reTime = 0
  22. end
  23. ---创建或者刷新界面数据时调用
  24. function this:Refresh()
  25. self.BuyCount = 1
  26. self.MonthCardTbl = InfoManager.monthCardInfo:GetMonthCardTblData()
  27. self.DailyCardTbl = InfoManager.monthCardInfo:GetDailyCardTblData()
  28. if InfoManager.monthCardInfo.DailyCardBuyCount < self.DailyCardTbl.limitCount then
  29. GUI:Text_setString(self.view.daliyCardBuy_btn, self.DailyCardTbl.price .. "元日卡")
  30. GUI:SetActive(self.view.text2, true)
  31. local text2 = ""
  32. if self.DailyCardTbl.limitType == 1 then
  33. text2 = "永久限购:"
  34. end
  35. if self.DailyCardTbl.limitType == 2 then
  36. text2 = "每月限购:"
  37. end
  38. if self.DailyCardTbl.limitType == 3 then
  39. text2 = "每周限购:"
  40. end
  41. if self.DailyCardTbl.limitType == 4 then
  42. text2 = "每日限购:"
  43. end
  44. GUI:Text_setString(self.view.text2, text2)
  45. GUI:Text_setString(self.view.LimitCount, tostring(InfoManager.monthCardInfo.DailyCardBuyCount .. "/" .. self.DailyCardTbl.limitCount))
  46. else
  47. GUI:Text_setString(self.view.daliyCardBuy_btn, "兑换特权")
  48. GUI:Text_setString(self.view.LimitCount, "")
  49. GUI:SetActive(self.view.text2, false)
  50. end
  51. GUI:Text_setString(self.view.inputText, tostring(self.BuyCount))
  52. GUI:Text_setString(self.view.monthCardBuy_Btn, "¥" .. self.BuyCount * self.MonthCardTbl.price)
  53. GUI:SetActive(self.view.chat_Btn, InfoManager.monthCardInfo:IsNeedShowPanel("chat"))
  54. GUI:SetActive(self.view.tradeLine_Btn, InfoManager.monthCardInfo:IsNeedShowPanel("stall"))
  55. GUI:SetActive(self.view.TripleEarningsBtn, InfoManager.monthCardInfo:IsNeedShowPanel("inCome"))
  56. GUI:SetActive(self.view.auto_pickUpBtn, InfoManager.monthCardInfo:IsNeedShowPanel("pickUp"))
  57. GUI:SetActive(self.view.auto_recyBtn, InfoManager.monthCardInfo:IsNeedShowPanel("recovery"))
  58. GUI:SetActive(self.view.ex_privilegeBtn, InfoManager.monthCardInfo:IsNeedShowPanel("privilege"))
  59. self.reTime = InfoManager.monthCardInfo.MonthCardTimeTotal - SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME)
  60. if self.reTime > 0 then
  61. GUI:Text_setString(self.view.TimeText, "剩余时间:" .. GUIUtil.FormatTimeDHM(self.reTime // 1000))
  62. GUI:Button_setGrey(self.view.GoTripleEarningBtn, false)
  63. else
  64. self.reTime = 0
  65. GUI:Text_setString(self.view.TimeText, "")
  66. GUI:Button_setGrey(self.view.GoTripleEarningBtn, true)
  67. end
  68. GUI:SetInputEnable(self.view.inputText, false)
  69. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_TRADE_INFO)
  70. end
  71. ---注册UI事件和服务器消息
  72. function this:RegistEvents()
  73. GUI:AddOnClickEvent(self.view.Help_Btn, self, self.Help_BtnOnClick)
  74. GUI:AddOnClickEvent(self.view.chat_Btn, self, self.chat_BtnOnClick)
  75. GUI:AddOnClickEvent(self.view.tradeLine_Btn, self, self.tradeLine_BtnOnClick)
  76. GUI:AddOnClickEvent(self.view.TripleEarningsBtn, self, self.TripleEarningsBtnOnClick)
  77. GUI:AddOnClickEvent(self.view.auto_pickUpBtn, self, self.auto_pickUpBtnOnClick)
  78. GUI:AddOnClickEvent(self.view.auto_recyBtn, self, self.auto_recyBtnOnClick)
  79. GUI:AddOnClickEvent(self.view.ex_privilegeBtn, self, self.ex_privilegeBtnOnClick)
  80. GUI:Input_SetOnEndEdit(self.view.inputText, self, self.InputFieldLevelOnEndEdit)
  81. GUI:AddOnClickEvent(self.view.Reduce_btn, self, self.Reduce_btnOnClick)
  82. GUI:AddOnClickEvent(self.view.Add_Btn, self, self.Add_BtnOnClick)
  83. GUI:AddOnClickEvent(self.view.monthCardBuy_Btn, self, self.monthCardBuy_BtnOnClick)
  84. GUI:AddOnClickEvent(self.view.daliyCardBuy_btn, self, self.daliyCardBuy_btnOnClick)
  85. GUI:AddOnClickEvent(self.view.CloseBtn, self, self.CloseBtn)
  86. GUI:AddOnClickEvent(self.view.GoTripleEarningBtn, self, self.GoTripleEarningBtn)
  87. --SL:RegisterLUAEvent(LUA_EVENT_GET_MONTH_CARD_INFO, self.LUA_EVENT_GET_MONTH_CARD_INFO, self)
  88. SL:RegisterLUAEvent(LUA_EVENT_GET_MONTH_CARD_CHANGE, self.LUA_EVENT_GET_MONTH_CARD_CHANGE, self)
  89. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_TRADE_INFO,self.OnGetRechargeTradeInfo,self)
  90. end
  91. --[[function this:LUA_EVENT_GET_MONTH_CARD_INFO(_, message)
  92. if message then
  93. end
  94. end]]
  95. ---@param message recharge
  96. function this:OnGetRechargeTradeInfo(_,message)
  97. if not message then
  98. return
  99. end
  100. --GUI:SetActive(self.view.img_cost_tips,true)
  101. if message.quit then
  102. local text = "当前额度:<color=#ff2323>%d</color>\n再充值<color=#1add1f>%d</color>元,即可恢复到<color=#1add1f>%d</color>额度上限!"
  103. ---@type cfg_lines_column
  104. local curLines = SL:GetConfig("cfg_lines",message.gearPosition)
  105. local recoveredCount = message.totalRecharge + curLines.activationRecharge
  106. local curLimit = self:GetQuotaLimit(recoveredCount)
  107. GUI:Text_setString(self.view.text_cost_tips, string.format(text, message.upperLimit,curLines.activationRecharge,curLimit))
  108. else
  109. local text = "当前额度:<color=#1add1f>%d</color>\n再充值<color=#1add1f>%d</color>元,即可提高<color=#1add1f>%d</color>奇迹币额度上限!"
  110. ---@type cfg_lines_column
  111. local curLines = SL:GetConfig("cfg_lines",message.gearPosition)
  112. GUI:Text_setString(self.view.text_cost_tips, string.format(text, message.upperLimit,curLines.each,curLines.quotaLimit))
  113. end
  114. end
  115. function this:GetQuotaLimit(count)
  116. ---@type cfg_lines_column[]
  117. local tbls = SL:GetConfigTable("cfg_lines")
  118. local result = 0
  119. for _, v in pairs(tbls) do
  120. local min = v.interval[1]
  121. local max = v.interval[2]
  122. if count < min then
  123. break
  124. end
  125. local curCount
  126. if count >= max then
  127. curCount = max - min + 1
  128. else
  129. curCount = count - min + 1
  130. end
  131. result = result + curCount // v.each * v.quotaLimit
  132. end
  133. return result
  134. end
  135. function this:LUA_EVENT_GET_MONTH_CARD_CHANGE(_, message)
  136. if message then
  137. self:Refresh()
  138. end
  139. end
  140. function this:GoTripleEarningBtn()
  141. if not InfoManager.monthCardInfo:IsHaveMonthCardRights("inCome") then
  142. return
  143. end
  144. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  145. GUI:UIPanel_Open("dev/outui/ThreeEarnings/Panel/KLEarnings/KLEarningsPanel")
  146. end
  147. function this:CloseBtn()
  148. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  149. end
  150. function this:daliyCardBuy_btnOnClick()
  151. --local emptyGrid = RoleManager.meData.bagInfo:GetRemainTileCount()
  152. if InfoManager.monthCardInfo.DailyCardBuyCount < self.DailyCardTbl.limitCount then
  153. local DailyCardTbl = InfoManager.monthCardInfo:GetMonthCardTblData()
  154. if not SL:CanPutToBag(DailyCardTbl.id, 1) then
  155. ---背包满
  156. --local desc = "您的背包已满,月卡购买后将直接使用为月卡点数,是否继续购买?"
  157. SL:CommonTipsMessage({ stringTblID = 202, ui = self,
  158. callback = self.BuyDailyCard, callbackData = nil })
  159. return
  160. end
  161. --local desc = "日卡无法上架宝石、翅膀材料、时装材料等道具是否花费<color=#5CE366FF>"..self.DailyCardTbl.price.."元</color>购买日卡?\n\n当前月卡剩余时间:".. GUIUtil.FormatTimeDHM(self.reTime // 1000)
  162. SL:CommonTipsMessage({ stringTblID = 203, stringTblFormat = { tostring(self.DailyCardTbl.price), tostring(GUIUtil.FormatTimeDHM(self.reTime // 1000)) }, ui = self,
  163. callback = self.BuyDailyCard, callbackData = nil })
  164. else
  165. if self.reTime <= 0 then
  166. SL:TipMessage( SL:GetConfig('cfg_string', 442).text, 1, NoticeType.NoticeMid )
  167. return
  168. end
  169. GUI:UIPanel_Open("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel", _, _, { type = "privilege" })
  170. end
  171. end
  172. function this:monthCardBuy_BtnOnClick()
  173. --local emptyGrid = RoleManager.meData.bagInfo:GetRemainTileCount()
  174. local MonthCardTbl = InfoManager.monthCardInfo:GetMonthCardTblData()
  175. if not SL:CanPutToBag(MonthCardTbl.id, 1) then
  176. ---背包满
  177. SL:CommonTipsMessage({ stringTblID = 202,
  178. callback = self.BuyMonthCard, callbackData = { count = self.BuyCount }, ui = self })
  179. return
  180. end
  181. if InfoManager.monthCardInfo.IsFirstBuyMonthCard then
  182. SL:CommonTipsMessage({ stringTblID = 204, stringTblFormat = { tostring(self.MonthCardTbl.price * self.BuyCount), tostring(GUIUtil.FormatTimeDHM(self.reTime // 1000)) },
  183. callback = self.BuyMonthCard, callbackData = { count = self.BuyCount }, ui = self })
  184. else
  185. SL:CommonTipsMessage({ stringTblID = 205, stringTblFormat = { tostring(self.MonthCardTbl.price * self.BuyCount), tostring(GUIUtil.FormatTimeDHM(self.reTime // 1000)) },
  186. callback = self.BuyMonthCard, callbackData = { count = self.BuyCount }, ui = self })
  187. end
  188. end
  189. function this:BuyMonthCard()
  190. ---@type cfg_recharge_column
  191. local rechargeTbl = InfoManager.monthCardInfo:GetRechargeMonthCard(EMonthType.MonthCard)
  192. GUIUtil.SDKPay(rechargeTbl,self.callbackData.count)
  193. end
  194. function this:BuyDailyCard()
  195. local rechargeTbl = InfoManager.monthCardInfo:GetRechargeMonthCard(EMonthType.DailyCard)
  196. GUIUtil.SDKPay(rechargeTbl,1)
  197. end
  198. function this:Add_BtnOnClick()
  199. if self.BuyCount + 1 < self.MonthCardTbl.maxCount + 1 then
  200. self.BuyCount = self.BuyCount + 1
  201. GUI:Text_setString(self.view.inputText, tostring(self.BuyCount))
  202. GUI:Text_setString(self.view.monthCardBuy_Btn, "¥" .. self.BuyCount * self.MonthCardTbl.price)
  203. end
  204. end
  205. function this:Reduce_btnOnClick()
  206. if self.BuyCount - 1 > 0 then
  207. self.BuyCount = self.BuyCount - 1
  208. GUI:Text_setString(self.view.inputText, tostring(self.BuyCount))
  209. GUI:Text_setString(self.view.monthCardBuy_Btn, "¥" .. self.BuyCount * self.MonthCardTbl.price)
  210. end
  211. end
  212. function this:InputFieldLevelOnEndEdit(_, _, eventData)
  213. self.BuyCount = tonumber(eventData[1])
  214. if self.BuyCount < 1 then
  215. self.BuyCount = 1
  216. end
  217. if self.BuyCount > self.MonthCardTbl.maxCount then
  218. self.BuyCount = self.MonthCardTbl.maxCount
  219. end
  220. GUI:Text_setString(self.view.inputText, tostring(self.BuyCount))
  221. GUI:Text_setString(self.view.monthCardBuy_Btn, "¥" .. self.BuyCount * self.MonthCardTbl.price)
  222. end
  223. function this:ex_privilegeBtnOnClick()
  224. if not InfoManager.monthCardInfo:IsHaveMonthCardRights("privilege") then
  225. SL:TipMessage( SL:GetConfig('cfg_string', 274).text, 1, NoticeType.NoticeMid )--"开通月卡后显示",
  226. return
  227. end
  228. local TitleText = "兑换特权"
  229. local Content = "1.可以消耗月卡时间兑换<color=#5CE366FF>黄金特权</color>或<color=#5CE366FF>钻石特权</color>获取超额收益。\n2.黄金特权激活后可以开启<color=#5CE366FF>黄金分线、开启自动回收、开启自动买药、开启随身商店功能</color>。\n3.钻石特权激活后<color=#5CE366FF>装备掉率增加100%、怪物经验增加100%、奇迹币回收价增加30%、开启自动拾取、开启远程仓库、增加交易行寄售格子5格</color>。"
  230. local GoBtnBack = function()
  231. --logError("打开" .. TitleText .. "界面")
  232. --GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  233. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel")
  234. GUI:UIPanel_Open("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel", _, _, { type = "privilege" })
  235. end
  236. self:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  237. end
  238. function this:auto_recyBtnOnClick()
  239. local TitleText = "自动回收"
  240. local Content = "1.购买并使用<color=#5CE366FF>月卡</color>,解锁<color=#5CE366FF>自动回收功能</color>。\n2.解锁<color=#5CE366FF>自动回收功能</color>后,可以在背包数量不足时自动回收背包中的普通装备和卓越装备。"
  241. local GoBtnBack = function()
  242. --logError("打开" .. TitleText .. "界面")
  243. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel")
  244. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  245. GUI:UIPanel_Open("dev/ui/Bag/Panel/KLUIBag/KLUIBagPanel", _, _, { JumpType = 1 })
  246. end
  247. self:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  248. end
  249. function this:auto_pickUpBtnOnClick()
  250. local TitleText = "自动拾取"
  251. local Content = "1.购买并使用<color=#5CE366FF>月卡</color>,解锁<color=#5CE366FF>自动拾取功能</color>。\n2.解锁<color=#5CE366FF>自动拾取功能</color>后,可以让您快速拾取掉落道具。"
  252. local GoBtnBack = function()
  253. --logError("打开" .. TitleText .. "界面")
  254. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel")
  255. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  256. GUI:UIPanel_Open("dev/outui/ChallengeBoss/Panel/KLChallengeBoss/KLChallengeBossPanel")
  257. end
  258. self:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  259. end
  260. function this:TripleEarningsBtnOnClick()
  261. local TitleText = "三倍收益"
  262. local Content = "1.购买并使用<color=#5CE366FF>月卡</color>,解锁<color=#5CE366FF>三倍收益功能</color>,您可在<color=#5CE366FF>三倍收益界面</color>开启三倍收益时间,获得<color=#5CE366FF>经验、掉落加成</color>。\n2.在三倍收益界面<color=#5CE366FF>点击领取</color>即可领取三倍收益时间。\n3.首次拥有日卡后,立即获得<color=#5CE366FF>4小时</color>三倍收益时间,之后每天可以获得<color=#5CE366FF>8小时</color>的三倍收益时间,可以自由控制三倍收益时间开启的时间。\n4.第一次购买月卡时将会立即增加<color=#5CE366FF>20小时</color>三倍收益时间。\n5.每天剩余的三倍收益时间能够<color=#5CE366FF>继承</color>到下一天继续使用,<color=#5CE366FF>最多可以继承56小时</color>三倍收益时间。\n6.月卡剩余时间大于等于<color=#5CE366FF>24小时</color>时三倍收益时间将在<color=#5CE366FF>每天24:00</color>更新。如果今日没有更新三倍收益时间那么三倍收益时间将在您的月卡剩余时间大于等于<color=#5CE366FF>24小时</color>后发放。"
  263. local GoBtnBack = function()
  264. --logError("打开" .. TitleText .. "界面")
  265. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel")
  266. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  267. GUI:UIPanel_Open("dev/outui/ThreeEarnings/Panel/KLEarnings/KLEarningsPanel")
  268. end
  269. self:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  270. end
  271. function this:tradeLine_BtnOnClick()
  272. local TitleText = "交易行"
  273. local Content = "1.购买并使用<color=#5CE366FF>月卡</color>,解锁<color=#5CE366FF>交易行功能</color>,可以在交易行界面进行<color=#5CE366FF>装备、道具、材料</color>之间的交易,是快速获取<color=#5CE366FF>装备、货币</color>的渠道。\n2.没有月卡时间后,可以在交易行使用<color=#5CE366FF>奇迹币</color>购买其他玩家上架的<color=#5CE366FF>月卡道具</color>。\n3.有<color=#5CE366FF>公示期</color>限制的道具上架后,公示期期间内玩家可以对物品进行预约购买,公示期结束后将从所有预约该物品的玩家中<color=#5CE366FF>随机抽选</color>一人出售该道具\n4.公示期结束后玩家可对物品进行直接购买操作。\n5.您可以自行对物品进行上架、下架、定价操作。"
  274. local GoBtnBack = function()
  275. --logError("打开" .. TitleText .. "界面")
  276. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel")
  277. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  278. GUI:UIPanel_Open("dev/outui/Trade/Panel/KLTradeMain/KLTradeMainPanel")
  279. end
  280. self:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  281. end
  282. function this:chat_BtnOnClick()
  283. local TitleText = "聊天功能"
  284. local Content = "1.购买并使用<color=#5CE366FF>月卡</color>,解锁<color=#5CE366FF>聊天功能</color>,您可以在聊天界面与其他玩家交流游戏心得,沟通任务进度。\n2.解锁<color=#5CE366FF>聊天功能</color>后,您可以<color=#5CE366FF>快速发送位置信息</color>,也可以点击聊天框中的位置信息前往标记的位置。\n3.解锁<color=#5CE366FF>聊天功能</color>后,您可以<color=#5CE366FF>发送</color>背包中的<color=#5CE366FF>道具或已穿戴的装备信息</color>到聊天框中。"
  285. local GoBtnBack = function()
  286. --logError("打开"..TitleText.."界面")
  287. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel")
  288. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
  289. SL:OpenChatUI()
  290. end
  291. self:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  292. end
  293. function this:Help_BtnOnClick()
  294. SL:CommonStrTipsMessage({ title = "提示", str = SL:GetConfig("cfg_rule_text", 12).location, ui = self })
  295. --[[ local content = "1.购买使用月卡后激活<color=#5CE366FF>30天</color>的月卡特权(掉落<color=#5CE366FF>非绑定道具</color>,正常获取回收收益,激活<color=#5CE366FF>交易行上架</color>功能,解锁<color=#5CE366FF>聊天</color>功能,可选择激活<color=#5CE366FF>黄金特权</color>或<color=#5CE366FF>钻石特权</color>获取超额收益)\n2.月卡到期后可以在<color=#5CE366FF>交易行</color>或<color=#5CE366FF>月卡活动</color>界面购买月卡。"
  296. GUI:UIPanel_Open("dev/outui/MonthCard/Panel/KLUIMonthCardDescTips/KLUIMonthCardDescTipsPanel", nil, nil, { Content = content })]]
  297. end
  298. function this:OpenMonthCardCommonPanel(TitleText, Content, GoBtnBack)
  299. GUI:UIPanel_Open("dev/outui/MonthCard/Panel/KLUIMonthCardCommon/KLUIMonthCardCommonPanel", nil, nil, { TitleText = TitleText, Content = Content, GoBtnBack = GoBtnBack })
  300. end
  301. function this:Close()
  302. GUI:SetInputEnable(self.view.inputText, true)
  303. GUI:UIPanel_Close("dev/outui/MonthCard/Panel/KLUIMonthCardDescTips/KLUIMonthCardDescTipsPanel")
  304. end
  305. return this