源战役客户端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.6 KiB

  1. CSGWarRecordView = CSGWarRecordView or BaseClass(BaseView)
  2. local CSGWarRecordView = CSGWarRecordView
  3. --[[
  4. CSGWarRecordView.TabData = {
  5. [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
  6. }
  7. --]]
  8. function CSGWarRecordView:__init()
  9. self.base_file = "CSGWar"
  10. self.layout_file = "CSGWarRecordView"
  11. self.layer_name = "Activity"
  12. self.destroy_imm = true
  13. self.use_background = true --全屏界面默认使用这个参数
  14. self.hide_maincancas = false --全屏界面需要放开隐藏主UI
  15. self.change_scene_close = true
  16. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  17. self.need_show_money = false --是否要显示顶部的金钱栏
  18. self.model = CSGWarModel:getInstance()
  19. self.model:Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60115)
  20. self.load_callback = function ()
  21. self:LoadSuccess()
  22. end
  23. self.open_callback = function ( )
  24. self:OpenSuccess()
  25. end
  26. self.switch_callback = function(index)
  27. self:SwitchTab(index)
  28. end
  29. self.destroy_callback = function ( )
  30. self:DestroySuccess()
  31. end
  32. end
  33. function CSGWarRecordView:Open( )
  34. --self.data = data
  35. BaseView.Open(self)
  36. end
  37. function CSGWarRecordView:LoadSuccess()
  38. local nodes = {
  39. "item_scroll", "item_scroll/Viewport/item_con", "bg:raw", "bg2:raw",
  40. "rename_btn:obj", "overlord_btn:obj", "close_btn:obj", "text2:tmp", "text3:tmp", "text1:tmp", "text4:tmp",
  41. "empty:obj", "empty/empty_talk_image:raw", "empty/empty_text:tmp",
  42. -- "empty/girl:raw",
  43. }
  44. self:GetChildren(nodes)
  45. self:AddEvent()
  46. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("csgwar_record_bg"),false)
  47. lua_resM:setOutsideRawImage(self,self.bg2_raw,GameResPath.GetRoleBg("csgwar_406_686"))
  48. lua_resM:setOutsideRawImage(self, self.empty_talk_image_raw, GameResPath.GetViewBigBg("com_empty_bg1"), false)
  49. -- lua_resM:setOutsideRawImage(self, self.girl_raw, GameResPath.GetRoleBg("team_empty_bg_267_589"), false) -- 不显示这个妹子了
  50. self.empty_text_tmp.text = "暂无记录"
  51. end
  52. function CSGWarRecordView:AddEvent()
  53. local function on_update_view( )
  54. self:UpdateView()
  55. end
  56. self.on_update_view_id = self.model:BindOne("CSGWar_record_info", on_update_view)
  57. local function on_click( target )
  58. if target == self.rename_btn_obj then
  59. KfWorldModel:GetInstance():Fire(KfWorldConst.OPEN_KfWorld_BASE_VIEW)
  60. elseif target == self.close_btn_obj then
  61. self:Close()
  62. elseif target == self.overlord_btn_obj then
  63. self:Close()
  64. self.model:Fire(CSGWarConst.OPEN_CSGWAR_OVERLORD_VIEW)
  65. end
  66. end
  67. AddClickEvent(self.close_btn_obj, on_click)
  68. AddClickEvent(self.rename_btn_obj, on_click)
  69. AddClickEvent(self.overlord_btn_obj, on_click)
  70. end
  71. function CSGWarRecordView:OpenSuccess()
  72. self:UpdateView()
  73. end
  74. function CSGWarRecordView:UpdateView()
  75. local data = self.model:GetCSGWarRecordInfo()
  76. local function sortfunction( a,b )
  77. if a.time == b.time then
  78. return a.room_id < b.room_id
  79. else
  80. return a.time > b.time
  81. end
  82. end
  83. table.sort( data, sortfunction )
  84. if not self.item_list_com then
  85. self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
  86. end
  87. self.empty_obj:SetActive(TableSize(data) == 0)
  88. local info = {
  89. data_list = data,
  90. item_con = self.item_con,
  91. scroll_view = self.item_scroll,
  92. item_class = CSGWarRecordItem,
  93. start_y = 0, start_x = -8,
  94. create_frequency = 0.02,
  95. create_num_per_time = 3,
  96. item_height = 210,
  97. space_y = 3,
  98. on_update_item = function(item, i, v)
  99. item:SetData(i, v)
  100. end,
  101. }
  102. self.item_list_com:UpdateItems(info)
  103. for i=1,4 do
  104. self["text"..i.."_tmp"].text = CSGWarConst.OVERLORD_DESC[i]
  105. end
  106. end
  107. function CSGWarRecordView:DestroySuccess( )
  108. if self.on_update_view_id then
  109. self.model:UnBind(self.on_update_view_id)
  110. self.on_update_view_id = nil
  111. end
  112. end