源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

131 行
3.4 KiB

  1. CSMainMilitaryRanksBaseView = CSMainMilitaryRanksBaseView or BaseClass(BaseView)
  2. local CSMainMilitaryRanksBaseView = CSMainMilitaryRanksBaseView
  3. function CSMainMilitaryRanksBaseView:__init()
  4. self.base_file = "csMain"
  5. self.layout_file = "CSMainMilitaryRanksBaseView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.hide_maincancas = true --是否隐藏主界面
  11. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.is_set_zdepth = true
  14. self.model = CSMainModel:getInstance()
  15. self.tab_item_list = {}
  16. self.current_index = nil
  17. self.load_callback = function ()
  18. self:LoadSuccess()
  19. self:AddEvent()
  20. end
  21. self.open_callback = function ( )
  22. self:OpenSuccess()
  23. end
  24. self.switch_callback = function(index)
  25. self:SwitchTab(index)
  26. end
  27. self.close_win_callback = function ( )
  28. self:Close()
  29. end
  30. self.destroy_callback = function ( )
  31. self:DestroySuccess()
  32. end
  33. end
  34. function CSMainMilitaryRanksBaseView:Open(index)
  35. self.current_index = index or 1
  36. BaseView.Open(self)
  37. end
  38. function CSMainMilitaryRanksBaseView:LoadSuccess()
  39. local nodes = {
  40. "closeBtn:obj", "bg:raw", "tabCon", "subCon",
  41. }
  42. self:GetChildren(nodes)
  43. end
  44. function CSMainMilitaryRanksBaseView:AddEvent()
  45. local on_click = function ( click_obj )
  46. if self.closeBtn_obj == click_obj then
  47. self:Close()
  48. end
  49. end
  50. AddClickEvent(self.closeBtn_obj, on_click)
  51. local function CLICK_GET_WAY_ITEM( )
  52. self:Close()
  53. end
  54. self:BindEvent(GlobalEventSystem, EventName.CLICK_GET_WAY_ITEM, CLICK_GET_WAY_ITEM)
  55. end
  56. function CSMainMilitaryRanksBaseView:OpenSuccess()
  57. -- self:InitTab()
  58. self:SwitchTab(1)
  59. end
  60. function CSMainMilitaryRanksBaseView:InitTab( )
  61. local tab_data = {
  62. [1] = {name = "军衔详情"},
  63. [2] = {name = "军衔排行"},
  64. }
  65. local function call_back(tab_index)
  66. self:SwitchTab(tab_index)
  67. end
  68. for k,v in pairs(self.tab_item_list) do
  69. v:SetVisible(false)
  70. end
  71. for i,v in ipairs(tab_data) do
  72. local item = self.tab_item_list[i]
  73. if not item then
  74. item = CSMainMilitaryRanksTab.New(self.tabCon)
  75. self.tab_item_list[i] = item
  76. end
  77. item:SetVisible(true)
  78. item:SetData(v,i,call_back)
  79. item:SetAnchoredPosition(-2, 41-(i-1)*(74-5))
  80. end
  81. for k,v in pairs(self.tab_item_list) do
  82. v:OnClick(self.current_index)
  83. end
  84. end
  85. function CSMainMilitaryRanksBaseView:SwitchTab( index )
  86. self.current_index = index
  87. if index == 1 then
  88. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_military_ranks_bg_1"))
  89. if self.details_view == nil then
  90. self.details_view = CSMainMilitaryRanksDetailsView.New(self.subCon)
  91. end
  92. self.details_view:SetData()
  93. self:PopUpChild(self.details_view)
  94. elseif index == 2 then
  95. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_military_ranks_bg_2"))
  96. if self.rank_view == nil then
  97. self.rank_view = CSMainMilitaryRanksRankView.New(self.subCon)
  98. end
  99. self.rank_view:SetData()
  100. self:PopUpChild(self.rank_view)
  101. end
  102. end
  103. function CSMainMilitaryRanksBaseView:DestroySuccess( )
  104. for i, v in ipairs(self.tab_item_list) do
  105. v:DeleteMe()
  106. end
  107. self.tab_item_list = {}
  108. if self.details_view then
  109. self.details_view:DeleteMe()
  110. end
  111. self.details_view = nil
  112. if self.rank_view then
  113. self.rank_view:DeleteMe()
  114. end
  115. self.rank_view = nil
  116. end