源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

298 regels
9.1 KiB

CSMainAppointView = CSMainAppointView or BaseClass(BaseView)
local CSMainAppointView = CSMainAppointView
function CSMainAppointView:__init()
self.base_file = "csMain"
self.layout_file = "CSMainAppointView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true
self.change_scene_close = true
self.hide_maincancas = true --是否隐藏主界面
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.is_set_zdepth = true
self.model = CSMainModel:getInstance()
self.tab_item_list = {}
self.current_index = nil
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:OpenSuccess()
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function CSMainAppointView:Open(index)
self.current_index = index or 1
BaseView.Open(self)
end
function CSMainAppointView:LoadSuccess()
local nodes = {
"bg:raw", "closeBtn:obj",
"tabCon",
"rankCon:obj",
"roleScrollView:obj", "roleScrollView/Viewport/roleContent",
"allRoleScrollView:obj", "allRoleScrollView/Viewport/allRoleContent",
"rankCon/titleCon/Text_3:tmp", "rankCon/titleCon/Text_2:tmp",
"rankCon/rankScrollView", "rankCon/rankScrollView/Viewport/rankContent",
"helpBtn:obj", "des:tmp",
"empty:obj", "empty/emptyGirl:raw",
"rankCon/rankBg:img",
"lastRankBtn:obj", "sandBtn:obj", "csWarBtn:obj",
"rankConBlock:obj",
"rankTitleImg:img",
}
self:GetChildren(nodes)
SetSizeDelta(self.rankConBlock,ScreenWidth, ScreenHeight)
self.rankCon_obj:SetActive(false)
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("cs_main_appoint_bg"))
lua_resM:setOutsideRawImage(self, self.emptyGirl_raw, GameResPath.GetRoleBg("setting_girl"))
lua_resM:setOutsideImageSprite(self, self.rankBg_img, GameResPath.GetCSMainImage("cs_main_last_rank_bg"))
end
function CSMainAppointView:AddEvent()
local on_click = function ( click_obj )
if self.closeBtn_obj == click_obj then
self:Close()
elseif self.helpBtn_obj == click_obj then
EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 60303)
elseif self.lastRankBtn_obj == click_obj then
local is_show = self.rankCon_obj.activeSelf
self.rankCon_obj:SetActive(not is_show)
self.rankConBlock_obj:SetActive(not is_show)
elseif self.rankConBlock_obj == click_obj then
self.rankCon_obj:SetActive(false)
self.rankConBlock_obj:SetActive(false)
elseif self.sandBtn_obj == click_obj then
SandTableModel:getInstance():Fire(SandTableConst.OPEN_MAIN_VIEW)
self:Close()
elseif self.csWarBtn_obj == click_obj then
--本国团战根据开服天数不同,可能会在同的星期里开,所以要判断一下
local jump_wday = 6
for i=1,7 do
local act_list = GuildModel:getInstance():GetGuildEventByWday(i)
for k,v in pairs(act_list) do
if v.module_id == 410 then
jump_wday = i
break
end
end
end
GuildModel:getInstance():Fire(GuildModel.OPEN_GUILD_EVENT_VIEW,410,jump_wday)
self:Close()
end
end
AddClickEvent(self.closeBtn_obj, on_click)
AddClickEvent(self.helpBtn_obj, on_click)
AddClickEvent(self.lastRankBtn_obj, on_click)
AddClickEvent(self.rankConBlock_obj, on_click)
AddClickEvent(self.sandBtn_obj, on_click)
AddClickEvent(self.csWarBtn_obj, on_click)
--上期本国团战排行榜
local function on_update_last_guild_rank_view()
self:UpdateRankCon(1)
end
self:BindEvent(self.model, CSMainConst.UPDATE_LAST_GUILD_WAR_SCORE_RANK_VIEW, on_update_last_guild_rank_view)
--上期军功排行榜
local function on_update_last_military_score_rank_view()
self:UpdateRankCon(2)
end
self:BindEvent(self.model, CSMainConst.UPDATE_LAST_MILITARY_SCORE_RANK_VIEW, on_update_last_military_score_rank_view)
--任命记录
local function on_update_appoint_data_view(opty)
if opty == 1 or opty == 2 then
self:UpdateRoleList(opty)
elseif opty == 0 then
self:UpdateAllRoleList(opty)
end
end
self:BindEvent(self.model, CSMainConst.UPDATE_APPOINT_DATA_VIEW, on_update_appoint_data_view)
end
function CSMainAppointView:OpenSuccess()
self:InitTab()
end
function CSMainAppointView:InitTab( )
local tab_data = {
[1] = {name = "官员一览"},
[2] = {name = "执政官员"},
[3] = {name = "指挥官员"},
}
local function call_back(tab_index)
self:SwitchTab(tab_index)
end
for k,v in pairs(self.tab_item_list) do
v:SetVisible(false)
end
for i,v in ipairs(tab_data) do
local item = self.tab_item_list[i]
if not item then
item = CSMainAppointTab.New(self.tabCon)
self.tab_item_list[i] = item
end
item:SetVisible(true)
item:SetData(v,i,call_back)
item:SetAnchoredPosition(-2, 41-(i-1)*(74-5))
end
for k,v in pairs(self.tab_item_list) do
v:OnClick(self.current_index)
end
end
function CSMainAppointView:UpdateRoleList(opty)
local appoint_data = self.model:GetAppointData(opty)
self.empty_obj:SetActive(#appoint_data == 0)
if not self.item_list_com then
self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
end
self.item_list_com:Reset()
local info = {
data_list = appoint_data,
item_con = self.roleContent,
item_class = CSMainAppointRoleListItem,
item_width = 777,
item_height = 110,
space_y = 31,
start_x = 9,
start_y = -40,
scroll_view = self.roleScrollView,
create_frequency = 0.01,
on_update_item = function(item, i, v)
item:SetData(v,opty)
end,
}
self.item_list_com:UpdateItems(info)
end
function CSMainAppointView:UpdateAllRoleList(opty)
local appoint_data = self.model:GetAppointData(opty)
self.empty_obj:SetActive(#appoint_data == 0)
if not self.all_role_item_list_com then
self.all_role_item_list_com = self:AddUIComponent(UI.ItemListCreator)
end
self.all_role_item_list_com:Reset()
local info = {
data_list = appoint_data,
item_con = self.allRoleContent,
item_class = CSMainAppointAllRoleListItem,
item_width = 777,
item_height = 349,
space_y = 24,
start_x = 9,
start_y = -14,
scroll_view = self.allRoleScrollView,
create_frequency = 0.01,
reuse_item_num = 2,
on_update_item = function(item, i, v)
item:SetData(v)
end,
}
self.all_role_item_list_com:UpdateItems(info)
end
function CSMainAppointView:UpdateRankCon(rank_type)
local rank_data = {}
if rank_type == 1 then--上期团战成绩排行
rank_data = self.model:GetLastGuildWarScoreRankData()
elseif rank_type == 2 then--上期沙盘结算军功排名
rank_data = self.model:GetLastMilitaryScoreRankData()
end
if not self.rank_list_com then
self.rank_list_com = self:AddUIComponent(UI.ItemListCreator)
end
self.rank_list_com:Reset()
local info = {
data_list = rank_data,
item_con = self.rankContent,
item_class = CSMainAppointRankItem,
item_width = 316,
item_height = 45,
-- space_x = 0,
-- space_y = 0,
start_x = 1,
start_y = 0,
scroll_view = self.rankScrollView,
create_frequency = 0.01,
on_update_item = function(item, i, v)
item:SetData(v,rank_type)
end,
}
self.rank_list_com:UpdateItems(info)
end
function CSMainAppointView:SwitchTab( index )
self.current_index = index
if index == 1 then
lua_resM:setOutsideImageSprite(self, self.rankTitleImg_img, GameResPath.GetCSMainImage("cs_main_appoint_slogan_1",true))
self.sandBtn_obj:SetActive(false)
self.csWarBtn_obj:SetActive(false)
self.lastRankBtn_obj:SetActive(false)
self.roleScrollView_obj:SetActive(false)
self.allRoleScrollView_obj:SetActive(true)
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60312,0)--全部
elseif index == 2 then
lua_resM:setOutsideImageSprite(self, self.rankTitleImg_img, GameResPath.GetCSMainImage("cs_main_appoint_slogan_2",true))
self.Text_2_tmp.text = "社团名"
self.Text_3_tmp.text = "上期伤害"
-- self.des_tmp.text = "伤害总量为上期本国团战成绩"
self.sandBtn_obj:SetActive(false)
self.csWarBtn_obj:SetActive(true)
self.lastRankBtn_obj:SetActive(true)
self.roleScrollView_obj:SetActive(true)
self.allRoleScrollView_obj:SetActive(false)
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60312,1)--前三主官
if self.model.has_request_60314 then
self:UpdateRankCon(1)
else
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60314)--打开界面只请求一次
end
elseif index == 3 then
lua_resM:setOutsideImageSprite(self, self.rankTitleImg_img, GameResPath.GetCSMainImage("cs_main_appoint_slogan_3",true))
self.Text_2_tmp.text = "角色名"
self.Text_3_tmp.text = "上期战功"
-- self.des_tmp.text = "战功为上期沙盘结算时累计军功"
self.sandBtn_obj:SetActive(true)
self.csWarBtn_obj:SetActive(false)
self.lastRankBtn_obj:SetActive(true)
self.roleScrollView_obj:SetActive(true)
self.allRoleScrollView_obj:SetActive(false)
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60312,2)--指挥官
if self.model.has_request_60311 then
self:UpdateRankCon(2)
else
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60311)--打开界面只请求一次
end
end
end
function CSMainAppointView:DestroySuccess( )
self.model.has_request_60314 = false
self.model.has_request_60311 = false
for i, v in ipairs(self.tab_item_list) do
v:DeleteMe()
end
self.tab_item_list = {}
end