|
|
- CSGWarRecordView = CSGWarRecordView or BaseClass(BaseView)
- local CSGWarRecordView = CSGWarRecordView
- --[[
- CSGWarRecordView.TabData = {
- [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
- }
- --]]
-
- function CSGWarRecordView:__init()
- self.base_file = "CSGWar"
- self.layout_file = "CSGWarRecordView"
- self.layer_name = "Activity"
- self.destroy_imm = true
- self.use_background = true --全屏界面默认使用这个参数
- self.hide_maincancas = false --全屏界面需要放开隐藏主UI
- self.change_scene_close = true
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
- self.model = CSGWarModel:getInstance()
- self.model:Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60115)
-
- self.load_callback = function ()
- self:LoadSuccess()
- end
- self.open_callback = function ( )
- self:OpenSuccess()
- end
- self.switch_callback = function(index)
- self:SwitchTab(index)
- end
- self.destroy_callback = function ( )
- self:DestroySuccess()
- end
- end
-
- function CSGWarRecordView:Open( )
- --self.data = data
- BaseView.Open(self)
- end
-
- function CSGWarRecordView:LoadSuccess()
- local nodes = {
- "item_scroll", "item_scroll/Viewport/item_con", "bg:raw", "bg2:raw",
- "rename_btn:obj", "overlord_btn:obj", "close_btn:obj", "text2:tmp", "text3:tmp", "text1:tmp", "text4:tmp",
- "empty:obj", "empty/empty_talk_image:raw", "empty/empty_text:tmp",
- -- "empty/girl:raw",
- }
- self:GetChildren(nodes)
- self:AddEvent()
- lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("csgwar_record_bg"),false)
- lua_resM:setOutsideRawImage(self,self.bg2_raw,GameResPath.GetRoleBg("csgwar_406_686"))
- lua_resM:setOutsideRawImage(self, self.empty_talk_image_raw, GameResPath.GetViewBigBg("com_empty_bg1"), false)
- -- lua_resM:setOutsideRawImage(self, self.girl_raw, GameResPath.GetRoleBg("team_empty_bg_267_589"), false) -- 不显示这个妹子了
- self.empty_text_tmp.text = "暂无记录"
- end
-
- function CSGWarRecordView:AddEvent()
- local function on_update_view( )
- self:UpdateView()
- end
- self.on_update_view_id = self.model:BindOne("CSGWar_record_info", on_update_view)
- local function on_click( target )
- if target == self.rename_btn_obj then
- KfWorldModel:GetInstance():Fire(KfWorldConst.OPEN_KfWorld_BASE_VIEW)
- elseif target == self.close_btn_obj then
- self:Close()
- elseif target == self.overlord_btn_obj then
- self:Close()
- self.model:Fire(CSGWarConst.OPEN_CSGWAR_OVERLORD_VIEW)
- end
- end
- AddClickEvent(self.close_btn_obj, on_click)
- AddClickEvent(self.rename_btn_obj, on_click)
- AddClickEvent(self.overlord_btn_obj, on_click)
- end
-
- function CSGWarRecordView:OpenSuccess()
- self:UpdateView()
- end
-
- function CSGWarRecordView:UpdateView()
- local data = self.model:GetCSGWarRecordInfo()
- local function sortfunction( a,b )
- if a.time == b.time then
- return a.room_id < b.room_id
- else
- return a.time > b.time
- end
- end
- table.sort( data, sortfunction )
- if not self.item_list_com then
- self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
- end
- self.empty_obj:SetActive(TableSize(data) == 0)
- local info = {
- data_list = data,
- item_con = self.item_con,
- scroll_view = self.item_scroll,
- item_class = CSGWarRecordItem,
- start_y = 0, start_x = -8,
- create_frequency = 0.02,
- create_num_per_time = 3,
- item_height = 210,
- space_y = 3,
- on_update_item = function(item, i, v)
- item:SetData(i, v)
- end,
- }
- self.item_list_com:UpdateItems(info)
- for i=1,4 do
- self["text"..i.."_tmp"].text = CSGWarConst.OVERLORD_DESC[i]
- end
- end
-
- function CSGWarRecordView:DestroySuccess( )
- if self.on_update_view_id then
- self.model:UnBind(self.on_update_view_id)
- self.on_update_view_id = nil
- end
- end
|