|
|
-
- GuildWarRankView = GuildWarRankView or BaseClass(BaseView)
- local GuildWarRankView = GuildWarRankView
-
- GuildWarRankView.TAB_ID =
- {
- PERSON = 1,
- GUILD = 2,
- KILL = 3,
- }
-
- GuildWarRankView.TAB_TITLE =
- {
- [1] = { [1] = "排名", [2] = "玩家名称", [3] = "积分", [4] = "奖励", },
- [2] = { [1] = "排名", [2] = "社团名称", [3] = "积分", [4] = "奖励", },
- [3] = { [1] = "排名", [2] = "玩家名称", [3] = "击杀", [4] = "奖励", },
- }
-
- function GuildWarRankView:__init()
- self.base_file = "guild"
- self.layout_file = "GuildWarRankView"
-
- self.layer_name = "UI"
- self.model = GuildModel:getInstance()
- self.destroy_imm = true
- self.use_background = true
- self.hide_clear_role_model = false
- self.change_scene_close = true
- self.append_to_ctl_queue = false
- self.is_set_zdepth = true
- self.rank_data = false
- self.my_rank_data = false
- self.my_rank_item = false
-
- self.blur_activity_bg = true
- self.use_show_anim = true
- self.use_hide_anim = true
-
- self.loop_mgr = LoopScrowViewMgr.New()
-
- self.item_list = {}
- self.title_list = {}
- self.tab_id = nil
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:InitEvent()
- end
- self.open_callback = function ()
- self:InitView()
- end
-
- self.close_callback = function ()
- self:Remove()
- end
- end
-
- function GuildWarRankView:Remove()
- if self.loop_mgr then
- self.loop_mgr:DeleteMe()
- self.loop_mgr = nil
- end
- if self.my_rank_item then
- self.my_rank_item:DeleteMe()
- self.my_rank_item = nil
- end
-
- for i,item in pairs(self.item_list) do
- item:DeleteMe()
- end
- self.item_list = {}
-
- if self.tabWindowComponent then
- self.tabWindowComponent:DeleteMe()
- self.tabWindowComponent = nil
- end
- end
-
- function GuildWarRankView:InitView()
- for k = 1,10 do
- local item = self.item_list[k]
- if item == nil then
- item = GuildWarRankItem.New(self.con,nil,self.maskID)
- self.item_list[k] = item
- end
- end
- self:SwitchTab(GuildWarRankView.TAB_ID.PERSON)
- end
-
- function GuildWarRankView:LoadSuccess()
- local nodes = {
- "contain/tips_1:tmp",
- "contain/close:obj",
- "contain/ScrollView/Viewport/con",
- "contain/ScrollView",
- "contain/bg1:raw",
- "contain/title_text:tmp",
- "contain/my_con",
- }
- self:GetChildren(nodes)
- self.tab_btn = {}
- for i=1,3 do
- self.tab_btn[i] = {}
- self.tab_btn[i].obj = self:GetChild("contain/btn_" .. i).gameObject
- self.tab_btn[i].select = self:GetChild("contain/btn_" .. i.."/select").gameObject
- self.tab_btn[i].text = self:GetChild("contain/btn_" .. i.."/name"):GetComponent("TMPro.TextMeshProUGUI")
- end
-
- self.title_list = {}
- for i=1,4 do
- self.title_list[i] = {}
- self.title_list[i].text = self:GetChild("contain/line/title_" .. i):GetComponent("TMPro.TextMeshProUGUI")
- end
- local closeWin_callback = function()
- self:Close()
- end
-
- self.title_text_tmp.text = "战场排行"
- self.tabWindowComponent = UITabWindow.New(self.transform,{},nil,closeWin_callback,self.background_wnd,self.contain, UITabWindow.SizeSmallNoTab, false,nil,true)
- self.tabWindowComponent:SetTitleText("")
- lua_resM:setOutsideRawImage(self, self.bg1_raw, GameResPath.GetViewBigBg("guild_event_war_bg2"), false)
- end
-
- function GuildWarRankView:InitEvent()
- local function onBtnClickHandler(target)
- if target == self.close_obj then
- self:Close()
- else
- for i=1,3 do
- if target == self.tab_btn[i].obj then
- self:SwitchTab(i)
- break
- end
- end
- end
- end
- AddClickEvent(self.close_obj,onBtnClickHandler)
- for i=1,3 do
- AddClickEvent(self.tab_btn[i].obj, onBtnClickHandler)
- end
-
-
- --更新排行榜
- local function onUpdateRankList( )
- self:UpdateRankList()
- end
- self:BindEvent(self.model, GuildModel.GUILD_WAR_RANK_LIST, onUpdateRankList)
- end
-
-
- function GuildWarRankView:SetMyInfo()
-
- end
-
- function GuildWarRankView:UpdateRankList(is_top)
- self.rank_data, self.my_rank_data = self.model:GetRankData(self.tab_id)
- self.rank_num_list = self.model:GuildWarGetRankNumByType(self.tab_id)
- if is_top then
- self.loop_mgr:Init(self.ScrollView,self.con,1,810,90,function(item,index,realIndex )
- self:OnInitializeItem(item,index,realIndex)
- end, 0, 0,{x =0, y=-5})
- self.loop_mgr:InitChildren(self.item_list, #self.rank_num_list)
- self.loop_mgr:RestToBeginning()
- self.loop_mgr:SetContentSizeData()
- else
- self.loop_mgr:InitChildren(self.item_list, #self.rank_num_list)
- self.loop_mgr:ForceUpdateCurrentItems()
- self.loop_mgr:SetContentSizeData()
- end
- self:UpdateMyInfo()
- end
-
- function GuildWarRankView:OnInitializeItem(item,index,realIndex)
- if item and realIndex > 0 and realIndex <= #self.rank_num_list then
- item:SetData(self.rank_data[realIndex], realIndex, self.tab_id)
- end
- end
-
- function GuildWarRankView:SwitchTab(tab_id)
- if tab_id ~= self.tab_id then
- self.tab_id = tab_id
- for i=1,3 do
- self.tab_btn[i].select:SetActive(i == self.tab_id)
- self.tab_btn[i].select:SetActive(i == self.tab_id)
- end
- self.tab_btn[1].text.text = HtmlColorTxt("个人榜", tab_id == GuildWarRankView.TAB_ID.PERSON and "#ffffff" or "#7d91ac")
- self.tab_btn[2].text.text = HtmlColorTxt("社团榜", tab_id == GuildWarRankView.TAB_ID.GUILD and "#ffffff" or "#7d91ac")
- self.tab_btn[3].text.text = HtmlColorTxt("击杀榜", tab_id == GuildWarRankView.TAB_ID.KILL and "#ffffff" or "#7d91ac")
- SetTMPSharedMaterial(self.tab_btn[1].text, tab_id == GuildWarRankView.TAB_ID.PERSON and ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab or ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
- SetTMPSharedMaterial(self.tab_btn[2].text, tab_id == GuildWarRankView.TAB_ID.GUILD and ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab or ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
- SetTMPSharedMaterial(self.tab_btn[3].text, tab_id == GuildWarRankView.TAB_ID.KILL and ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab or ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
- self:UpdateRankList(true)
- local title_info = GuildWarRankView.TAB_TITLE[self.tab_id]
- for i,v in ipairs(self.title_list) do
- v.text.text = title_info[i]
- end
- end
- end
-
- function GuildWarRankView:UpdateMyInfo()
- local d = self.my_rank_data or {}
- if not self.my_rank_item then
- self.my_rank_item = GuildWarRankItem.New(self.my_con)
- self.my_rank_item:HideBg(true)
- end
- self.my_rank_item:SetData(d, d.my_rank, self.tab_id)
- end
|