源战役客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

189 行
7.4 KiB

MarketVerTabItem = MarketVerTabItem or BaseClass(BaseItem)
local MarketVerTabItem = MarketVerTabItem
function MarketVerTabItem:__init()
self.base_file = "market"
self.layout_file = "MarketVerTabItem"
self.model = MarketModel:GetInstance()
self.view_type = MarketModel.VER_TAB_TYPE.WORLD_TYPE
self:Load()
end
function MarketVerTabItem:Load_callback()
self.nodes = {
"tab_con:obj","sub_con:obj","tab_con/tab_text:tmp","sub_con/sub_text:tmp",
"sub_con/sub_bg:obj","tab_con/arrow","tab_con/tab_bg:img",
}
self:GetChildren(self.nodes)
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
if self.need_refresh_select then
self:SetSelect(self.select_sell_type, self.select_sell_sub_type)
end
end
function MarketVerTabItem:AddEvents( )
function on_click( target )
local delay_fun = function()--一秒内只能点1次
if self._use_delete_method then
return
end
if target == self.tab_con_obj then
if self.view_type == MarketModel.VER_TAB_TYPE.WORLD_TYPE or self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
local data = self.data[1] or self.data[0]
if self.call_back then
self.call_back(data, data.sell_type, nil)--上层就直接传空的回去
end
elseif self.view_type == MarketModel.VER_TAB_TYPE.ATTENTION_TYPE then
local data = self.data[1][1]
if self.call_back then
self.call_back(data, data.sell_category, nil)--上层就直接传空的回去
end
end
elseif target == self.sub_con_obj then
if self.view_type == MarketModel.VER_TAB_TYPE.WORLD_TYPE or self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
if self.call_back then
self.call_back(self.data, self.data.sell_type, self.data.sell_sub_type)
end
elseif self.view_type == MarketModel.VER_TAB_TYPE.ATTENTION_TYPE then
if self.data.is_zero == true then
self.call_back(self.data, self.data.sell_type, self.data.sell_sub_type)
else
local data = self.data[1]
if self.call_back then
self.call_back(data, data.sell_category, data.sell_subcategory)
end
end
end
end
end
TimeManager.GetInstance():StartDalayTime("MarketVerTabItemBtnClick",0.1,delay_fun)
end
AddClickEvent(self.tab_con_obj, on_click)
AddClickEvent(self.sub_con_obj, on_click)
end
function MarketVerTabItem:UpdateView( )
if not self.data then
return
end
if self.data.is_tab then
self.tab_con_obj:SetActive(true)
self.sub_con_obj:SetActive(false)
if self.view_type == MarketModel.VER_TAB_TYPE.WORLD_TYPE or self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
if self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
if TableSize(self.data[1]) == 0 then
self.tab_text_tmp.text = "正在出售"
else
local data = self.data[1] or self.data[0]
self.tab_text_tmp.text = self.model:GetMarketTabNameBuySellType(data.sell_type)
end
else
local data = self.data[1]
self.tab_text_tmp.text = self.model:GetMarketTabNameBuySellType(data.sell_type)
end
elseif self.view_type == MarketModel.VER_TAB_TYPE.ATTENTION_TYPE then
local data = self.data[1]
if TableSize(data) > 0 then
self.tab_text_tmp.text = self.model:GetMarketTabNameBuySellType(data[1].sell_category)
else
self.tab_text_tmp.text = "暂无分类"
end
end
else
self.tab_con_obj:SetActive(false)
self.sub_con_obj:SetActive(true)
if self.view_type == MarketModel.VER_TAB_TYPE.WORLD_TYPE or self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
self.sub_text_tmp.text = Trim(self.data.name)
elseif self.view_type == MarketModel.VER_TAB_TYPE.ATTENTION_TYPE then
if self.data.is_zero then--如果是第一个 就默认是全部
self.sub_text_tmp.text = Trim(self.data.name)
else
local data = self.data[1]
self.sub_text_tmp.text = self.model:GetMarketTabNameBuySellSubType(data.sell_category, data.sell_subcategory)
end
else
end
end
self:SetSelect(self.select_sell_type, self.select_sell_sub_type)
end
function MarketVerTabItem:SetData( data , index, select_sell_type, select_sell_sub_type, view_type)
self.data = data
self.index = index
self.select_sell_type = select_sell_type
self.select_sell_sub_type = select_sell_sub_type
self.view_type = view_type or self.view_type
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function MarketVerTabItem:SetCallBackFunc( call_back )
self.call_back = call_back
end
function MarketVerTabItem:SetSelect( index, sub_index )
self.select_sell_type = index
self.select_sell_sub_type = sub_index
if self.is_loaded then
self.need_refresh_select = false
if self.data.is_tab then
if self.view_type == MarketModel.VER_TAB_TYPE.WORLD_TYPE or self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
local data = self.data[1] or self.data[0]
if data.sell_type == self.select_sell_type then
self.arrow.localRotation = Quaternion.Euler(0,0,0)
lua_resM:setImageSprite(self, self.tab_bg_img, "market_asset", "market_icon5")
self.tab_text_tmp.color = ColorUtil:ConvertHexToRGBColor("ffffff")
SetTMPSharedMaterial(self.tab_text_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab)
else
self.arrow.localRotation = Quaternion.Euler(0,0,180)
lua_resM:setImageSprite(self, self.tab_bg_img, "market_asset", "market_icon4")
self.tab_text_tmp.color = ColorUtil:ConvertHexToRGBColor("7d91ac")
SetTMPSharedMaterial(self.tab_text_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
end
elseif self.view_type == MarketModel.VER_TAB_TYPE.ATTENTION_TYPE then
local data = self.data[1]
if data[1].sell_category == self.select_sell_type then
self.arrow.localRotation = Quaternion.Euler(0,0,0)
lua_resM:setImageSprite(self, self.tab_bg_img, "market_asset", "market_icon5")
self.tab_text_tmp.color = ColorUtil:ConvertHexToRGBColor("ffffff")
SetTMPSharedMaterial(self.tab_text_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab)
else
self.arrow.localRotation = Quaternion.Euler(0,0,180)
lua_resM:setImageSprite(self, self.tab_bg_img, "market_asset", "market_icon4")
self.tab_text_tmp.color = ColorUtil:ConvertHexToRGBColor("7d91ac")
SetTMPSharedMaterial(self.tab_text_tmp, ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
end
end
else
if self.view_type == MarketModel.VER_TAB_TYPE.WORLD_TYPE or self.view_type == MarketModel.VER_TAB_TYPE.GUILD_TYPE then
self.sub_bg_obj:SetActive(self.data.sell_sub_type == self.select_sell_sub_type)
self.sub_text_tmp.color = self.data.sell_sub_type == self.select_sell_sub_type and ColorUtil:ConvertHexToRGBColor("ffffff") or ColorUtil:ConvertHexToRGBColor("7d91ac")
elseif self.view_type == MarketModel.VER_TAB_TYPE.ATTENTION_TYPE then
if self.data.is_zero == true then
self.sub_bg_obj:SetActive(self.data.sell_sub_type == self.select_sell_sub_type)
self.sub_text_tmp.color = self.data.sell_sub_type == self.select_sell_sub_type and ColorUtil:ConvertHexToRGBColor("ffffff") or ColorUtil:ConvertHexToRGBColor("7d91ac")
else
local data = self.data[1]
self.sub_bg_obj:SetActive(data.sell_subcategory == self.select_sell_sub_type)
self.sub_text_tmp.color = data.sell_subcategory == self.select_sell_sub_type and ColorUtil:ConvertHexToRGBColor("ffffff") or ColorUtil:ConvertHexToRGBColor("7d91ac")
end
end
end
else
self.need_refresh_select = true
end
end
function MarketVerTabItem:__delete( )
end