源战役客户端
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.
 
 
 
 
 

124 lines
4.0 KiB

CSMainMilitaryRanksRankView = CSMainMilitaryRanksRankView or BaseClass(BaseItem)
local CSMainMilitaryRanksRankView = CSMainMilitaryRanksRankView
function CSMainMilitaryRanksRankView:__init()
self.base_file = "csMain"
self.layout_file = "CSMainMilitaryRanksRankView"
self.model = CSMainModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self:Load()
end
function CSMainMilitaryRanksRankView:Load_callback()
self.nodes = {
"myCon/myName:tmp", "myCon/militarySmallIcon:img", "myCon/militaryBigIcon:img",
"myCon/myVipCon", "myCon/myRankIcon:obj:img", "myCon/myContrayName:tmp", "myCon/mySex:img",
"ScrollView", "ScrollView/Viewport/Content", "myCon/myRank:tmp",
"empty:obj", "empty/emptyGirl:raw",
}
self:GetChildren(self.nodes)
lua_resM:setOutsideRawImage(self, self.emptyGirl_raw, GameResPath.GetRoleBg("setting_girl"))
self.myVipItem = RoleVipItem.New(self.myVipCon)
self:AddEvents()
if self.need_refreshData then
self:RequesData()
end
end
function CSMainMilitaryRanksRankView:AddEvents( )
local function on_update_rank_view(vo)
self:UpdateRankView(vo)
end
self:BindEvent(self.model, CSMainConst.UPDATE_MILITARY_RANKS_RANK_VIEW, on_update_rank_view)
end
function CSMainMilitaryRanksRankView:UpdateRankView(vo)
local rank_data = vo and vo.ranks or {}
local sort_func = function ( a, b )
return a.rank < b.rank
end
table.sort(rank_data, sort_func)
local final_rank_list = {}
local max_show_ranks = Config.Legionkv["military_max_rank"].value
for i=1,max_show_ranks do
if rank_data[i] then
table.insert(final_rank_list,rank_data[i])
end
end
if not self.item_list_com then
self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
end
local info = {
data_list = final_rank_list,
item_con = self.Content,
item_class = CSMainMilitaryRanksRankItem,
item_width = 905,
item_height = 50,
-- space_x = 0,
-- space_y = 0,
start_x = 1.5,
start_y = -1.5,
scroll_view = self.ScrollView,
create_frequency = 0.01,
on_update_item = function(item, i, v)
item:SetData(v)
end,
}
self.item_list_com:UpdateItems(info)
self.empty_obj:SetActive(#rank_data==0)
self.myVipItem:SetData(self.mainVo.vip_flag,self.mainVo.sup_vip_type)
self.myName_tmp.text = GetCSLongName(self.mainVo.name,self.mainVo.server_num)
local sex_res = self.mainVo.sex == 1 and "com_boy" or "com_girl"
lua_resM:setImageSprite(self, self.mySex_img, "common_asset", sex_res, true)
SetAnchoredPositionX(self.mySex, -228+self.myName_tmp.preferredWidth+20)
if vo.my_rank == 0 then
self.myRankIcon_obj:SetActive(false)
self.myRank_tmp.text = "未上榜"
elseif vo.my_rank >= 1 and vo.my_rank <= 3 then
lua_resM:setImageSprite(self, self.myRankIcon_img, "csMain_asset","cs_main_rank_"..vo.my_rank,true)
self.myRankIcon_obj:SetActive(true)
self.myRank_tmp.text = ""
else
self.myRankIcon_obj:SetActive(false)
self.myRank_tmp.text = vo.my_rank
end
local my_country_id = KfWorldModel:GetInstance():GetMyCountryId() and KfWorldModel:GetInstance():GetMyCountryId() or 1
local my_country_name = KfWorldModel:GetInstance():GetContrayNameById(my_country_id)
self.myContrayName_tmp.text = my_country_name
local my_military_ranks = self.model:GetCSMainMilitaryRanks()
lua_resM:setOutsideImageSprite(self, self.militarySmallIcon_img, GameResPath.GetMilitaryImage("military_ranks_"..my_military_ranks), true)
-- local high_military_ranks = self.model:GetCSMainHighMilitaryRanks(my_military_ranks)
-- lua_resM:setOutsideImageSprite(self, self.militaryBigIcon_img, GameResPath.GetCSMainImage("military_ranks_big_icon_"..high_military_ranks), true)
end
function CSMainMilitaryRanksRankView:RequesData( )
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60313)
end
function CSMainMilitaryRanksRankView:SetData()
if self.is_loaded then
self.need_refreshData = false
self:RequesData()
else
self.need_refreshData = true
end
end
function CSMainMilitaryRanksRankView:__delete( )
if self.myVipItem then
self.myVipItem:DeleteMe()
self.myVipItem = nil
end
end