KLUnionCreatePanel.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---@class KLUnionCreatePanel:UIKmlLuaPanelBase
  2. ---@field view KLUnionCreatePanelView
  3. local KLUnionCreatePanel = class(UIKmlLuaPanelBase)
  4. local this =KLUnionCreatePanel
  5. ---创建时调用一次
  6. function this:Init()
  7. self:Hide_log_select()
  8. self.flagIndex=1
  9. GUI:setVisible(self.view.union_log1_select, true)
  10. self:ShowCoin()
  11. GUI:SetMaxTextCount(self.view.input_union_name, 10)
  12. end
  13. function this:ShowCoin()
  14. local coinSplit = string.split(SL:GetConfig('cfg_global',43).value, '#')
  15. local coinId = tonumber(coinSplit[1])
  16. local coinCount = tonumber(coinSplit[2])
  17. GUI:Item_setItemId(self.view.cost_item_id, coinId)
  18. GUI:Text_setString(self.view.cost_item_count, tostring(coinCount))
  19. local haveCount = SL:GetBagItemCount(coinId)
  20. if haveCount < coinCount then
  21. GUI:Text_setTextColor(self.view.cost_item_count, '#ff0000')
  22. else
  23. GUI:Text_setTextColor(self.view.cost_item_count, '#00ff00')
  24. end
  25. end
  26. ---创建或者刷新界面数据时调用
  27. function this:Refresh()
  28. end
  29. ---注册UI事件和服务器消息
  30. function this:RegistEvents()
  31. GUI:AddOnClickEvent(self.view.log_list_bg1, self, self.log_list_bg1)
  32. GUI:AddOnClickEvent(self.view.log_list_bg2, self, self.log_list_bg2)
  33. GUI:AddOnClickEvent(self.view.log_list_bg3, self, self.log_list_bg3)
  34. GUI:AddOnClickEvent(self.view.log_list_bg4, self, self.log_list_bg4)
  35. GUI:AddOnClickEvent(self.view.log_list_bg5, self, self.log_list_bg5)
  36. GUI:AddOnClickEvent(self.view.enter_btn, self, self.enter_btn)
  37. GUI:AddOnClickEvent(self.view.closeBtn, self, self.closeBtn)
  38. GUI:AddOnClickEvent(self.view.cancle_btn, self, self.cancle_btn)
  39. SL:RegisterLuaNetMsg(MessageDef.ResCreateUnionMessage, self.ResCreateUnionMessage, self)
  40. end
  41. function this:ResCreateUnionMessage(_, message)
  42. SL:ScheduleOnce(Time.deltaTime,function()
  43. self:closeBtn()
  44. GUI:UIPanel_Open("dev/ui/Union/Panel/KLUnionToggleList/KLUnionToggleListPanel",nil,nil,{unionId = message.unionInfo.unionId})
  45. end)
  46. end
  47. function this:Hide_log_select()
  48. GUI:setVisible(self.view.union_log1_select, false)
  49. GUI:setVisible(self.view.union_log2_select, false)
  50. GUI:setVisible(self.view.union_log3_select, false)
  51. GUI:setVisible(self.view.union_log4_select, false)
  52. GUI:setVisible(self.view.union_log5_select, false)
  53. end
  54. function this:log_list_bg2()
  55. self:Hide_log_select()
  56. self.flagIndex=2
  57. GUI:setVisible(self.view.union_log2_select, true)
  58. GUI:Image_loadTexture(self.view.union_log, "Texture/log2.png")
  59. end
  60. function this:log_list_bg1()
  61. self:Hide_log_select()
  62. self.flagIndex=1
  63. GUI:setVisible(self.view.union_log1_select, true)
  64. GUI:Image_loadTexture(self.view.union_log, "Texture/log1.png")
  65. end
  66. function this:log_list_bg3()
  67. self:Hide_log_select()
  68. self.flagIndex=3
  69. GUI:setVisible(self.view.union_log3_select, true)
  70. GUI:Image_loadTexture(self.view.union_log, "Texture/log3.png")
  71. end
  72. function this:log_list_bg4()
  73. self:Hide_log_select()
  74. self.flagIndex=4
  75. GUI:setVisible(self.view.union_log4_select, true)
  76. GUI:Image_loadTexture(self.view.union_log, "Texture/log4.png")
  77. end
  78. function this:log_list_bg5()
  79. self:Hide_log_select()
  80. self.flagIndex=5
  81. GUI:setVisible(self.view.union_log5_select, true)
  82. GUI:Image_loadTexture(self.view.union_log, "Texture/log5.png")
  83. end
  84. function this:Close()
  85. end
  86. function this:enter_btn()
  87. if InfoManager.loranSiegeInfo:GetIsOpen() then
  88. SL:TipMessage(SL:GetConfig("cfg_string",16003).text ,1, NoticeType.NoticeMid)
  89. return
  90. end
  91. SL:ReqCreateUnionMessage(GUI:Button_getTitleText(self.view.input_union_name), self.flagIndex)
  92. end
  93. function this:closeBtn()
  94. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionCreate/KLUnionCreatePanel")
  95. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionToggleList/KLUnionToggleListPanel")
  96. end
  97. function this:cancle_btn()
  98. self:closeBtn()
  99. end
  100. return this