|
|
-
- FullWindowComponent = FullWindowComponent or BaseClass(BaseComponent)
- local FullWindowComponent = FullWindowComponent
- --title 窗口名字
- --tabbar_list 标签名字数组
- --tabbar_asset 图片的预设资源
- --select_callback 选择的回调函数
- --close_win_callback 关闭窗口的回调函数
- --background_wnd 窗口的background_wnd属性
- --show_anim 标签按钮是否移动显示
- --hide_coin_add 是否隐藏金币栏
-
- --ShowRoleLevelItem方法 显示人物等级
- --HideCoinAddByType方法 是否隐藏某种金币类型
-
- function FullWindowComponent:__init(parent,title,tabbar_asset,tabbar_list,select_callback,close_win_callback,background_wnd,show_anim,hide_coin_add)
- self:InitData(title,tabbar_asset,tabbar_list,select_callback,close_win_callback,background_wnd,show_anim,hide_coin_add)
- self:CreateGameObject(UIType.FullWindowComponent)
- end
-
- function FullWindowComponent:InitData(title,tabbar_asset,tabbar_list,select_callback,close_win_callback,background_wnd,show_anim,hide_coin_add)
- self.curr_tabBtn_index = 0
- self.tabbar_item_list = {}
- self.tabbar_prefab = nil
-
- self.title = title
- self.tabbar_asset = tabbar_asset
- self.tabbar_list = tabbar_list or {}
-
- self.select_callback = select_callback
- self.close_win_callback = close_win_callback
- self.background_wnd = background_wnd
- self.show_anim = show_anim
- self.hide_coin_add = hide_coin_add
- end
-
- --根据类型隐藏金币/红钻/彩钻
- function FullWindowComponent:ShowRoleLevelItem(level,turn,need_lv,alignment_type,add_str,font_color,font_size,front_str)
- if self.RoleLevelItem == nil then
- self.RoleLevelItem = RoleLevelItem.New(self.transform)
- self.RoleLevelItem:SetOrignPos(co.TableXY(-275, 334))
- end
-
- self.RoleLevelItem:SetData(level,turn,need_lv,alignment_type,add_str,font_color,font_size,front_str)
- end
-
-
- --根据类型隐藏金币/红钻/彩钻
- function FullWindowComponent:HideCoinAddByType( type, bool )
- if self.coinAddBar then
- self.coinAddBar:ShowByType(type, bool)
- end
- end
-
- function FullWindowComponent:LoadSuccess()
-
- self.win_transform = self.GetChild("Window")
- self.win_title = self:GetChild("Window/windowTitleCon/windowTitleText"):GetComponent("Text")
- self.subtitle = self:GetChild("Window/subtitle"):GetComponent("Text")
- self.win_close_btn = self:GetChild("Window/windowCloseBtn").gameObject
-
- self.mScroll = self:GetChild("ScrollView")
- self.mContent = self:GetChild("ScrollView/Viewport/Content")
- self.cdn_image = self:GetChild("Window"):GetComponent("Image")
-
- if not self.hide_coin_add then
- self.coinAddBar = CoinAddBar.New(self.transform)
- self.coinAddBar_transform = self.coinAddBar.transform
- end
-
- lua_resM:setOutsideImageSprite(self, self.cdn_image, GameResPath.GetJpgImage("bag_bg.jpg"), false)
-
- self:InitEvent()
- self:LayoutUI()
- self:LoadTabbarPrefab()
- end
-
- --在父窗口调用
- function FullWindowComponent:__delete()
-
- self.tabbar_prefab = nil
- self.curr_tabBtn_index = 0
-
- for i,item in pairs(self.tabbar_item_list) do
- item:DeleteMe()
- end
- self.tabbar_item_list = {}
-
- if self.coinAddBar then
- self.coinAddBar:DeleteMe()
- self.coinAddBar = nil
- end
-
- if self.RoleLevelItem then
- self.RoleLevelItem:DeleteMe()
- self.RoleLevelItem = nil
- end
- end
-
- function FullWindowComponent:SetTitle( name )
- self.title = name
- self.win_title.text = self.title
- end
-
- function FullWindowComponent:SetSubtitle(name)
- self.subtitle.text = name
- end
-
- function FullWindowComponent:LayoutUI()
-
- self.win_title.text = self.title
-
- if self.coinAddBar then
- self.coinAddBar:SetImageBg(false)
- self.coinAddBar_transform.anchoredPosition = Vector3(202,334)
- end
-
- if self.background_wnd then
- local index = self.background_wnd.transform:GetSiblingIndex()
- self.transform:SetSiblingIndex(index + 1)
- else
- self.transform:SetAsFirstSibling()
- end
- end
-
- function FullWindowComponent:LoadTabbarPrefab()
- local name = nil
- local item = nil
-
- local len = #self.tabbar_list
-
- for index,vo in ipairs(self.tabbar_list) do
- item = self.tabbar_item_list[index]
- if item == nil then
- item = FullTabButton.New(self.mContent)
- self.tabbar_item_list[index] = item
- end
- item:SetVisible(true)
- item:SetData(index,self.tabbar_asset,vo,self.select_callback,self.show_anim)
- end
-
- self.mContent.sizeDelta = Vector2(144, len * 100)
-
- for i=#self.tabbar_list + 1,#self.tabbar_item_list do
- self.tabbar_item_list[i]:SetVisible(false)
- end
- end
-
- function FullWindowComponent:InitEvent()
- local function onCloseBtnHandler(target)
- if self.close_win_callback ~= nil then
- self.close_win_callback()
- end
- end
-
- AddClickEvent(self.win_close_btn,onCloseBtnHandler,1)
- end
-
- function FullWindowComponent:SetTabBarIndex(index)
- if self.curr_tabBtn_index == index then return end
-
- ------------这是tabbar按钮样式------------------------
- local tabbar = self.tabbar_item_list[self.curr_tabBtn_index]
- if tabbar then
- tabbar:SetSelect(false)
- end
-
- self.curr_tabBtn_index = index
-
- tabbar = self.tabbar_item_list[self.curr_tabBtn_index]
- if tabbar then
- tabbar:SetSelect(true)
- end
- end
-
- function FullWindowComponent:GetCurrentSelectIndex()
- return self.curr_tabBtn_index
- end
-
- function FullWindowComponent:ShowRedPoint(index,bool)
- local tabbar = self.tabbar_item_list[index]
- if tabbar then
- tabbar:ShowRedPoint(bool)
- end
- end
|